Skip to content

Commit f91f6cf

Browse files
committed
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: drm/radeon/kms/atom: fix handling of FB scratch indices drm/radeon/kms/DCE4.1: fix Select_CrtcSource EncodeMode setting for DP bridges (v2) drm/radeon/kms/DCE4.1: ss is not supported on the internal pplls drm/radeon/kms/DCE4.1: fix dig encoder to transmitter mapping ttm: Fix error-path using an uninitialized value
2 parents bcd5cff + 5a6e848 commit f91f6cf

5 files changed

Lines changed: 36 additions & 9 deletions

File tree

‎drivers/gpu/drm/radeon/atom.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
277277
case ATOM_ARG_FB:
278278
idx = U8(*ptr);
279279
(*ptr)++;
280-
val = gctx->scratch[((gctx->fb_base + idx) / 4)];
280+
if ((gctx->fb_base + (idx * 4)) > gctx->scratch_size_bytes) {
281+
DRM_ERROR("ATOM: fb read beyond scratch region: %d vs. %d\n",
282+
gctx->fb_base + (idx * 4), gctx->scratch_size_bytes);
283+
val = 0;
284+
} else
285+
val = gctx->scratch[(gctx->fb_base / 4) + idx];
281286
if (print)
282287
DEBUG("FB[0x%02X]", idx);
283288
break;
@@ -531,7 +536,11 @@ static void atom_put_dst(atom_exec_context *ctx, int arg, uint8_t attr,
531536
case ATOM_ARG_FB:
532537
idx = U8(*ptr);
533538
(*ptr)++;
534-
gctx->scratch[((gctx->fb_base + idx) / 4)] = val;
539+
if ((gctx->fb_base + (idx * 4)) > gctx->scratch_size_bytes) {
540+
DRM_ERROR("ATOM: fb write beyond scratch region: %d vs. %d\n",
541+
gctx->fb_base + (idx * 4), gctx->scratch_size_bytes);
542+
} else
543+
gctx->scratch[(gctx->fb_base / 4) + idx] = val;
535544
DEBUG("FB[0x%02X]", idx);
536545
break;
537546
case ATOM_ARG_PLL:
@@ -1370,11 +1379,13 @@ int atom_allocate_fb_scratch(struct atom_context *ctx)
13701379

13711380
usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
13721381
}
1382+
ctx->scratch_size_bytes = 0;
13731383
if (usage_bytes == 0)
13741384
usage_bytes = 20 * 1024;
13751385
/* allocate some scratch memory */
13761386
ctx->scratch = kzalloc(usage_bytes, GFP_KERNEL);
13771387
if (!ctx->scratch)
13781388
return -ENOMEM;
1389+
ctx->scratch_size_bytes = usage_bytes;
13791390
return 0;
13801391
}

‎drivers/gpu/drm/radeon/atom.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ struct atom_context {
137137
int cs_equal, cs_above;
138138
int io_mode;
139139
uint32_t *scratch;
140+
int scratch_size_bytes;
140141
};
141142

142143
extern int atom_debug;

‎drivers/gpu/drm/radeon/atombios_crtc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static void atombios_crtc_program_ss(struct drm_crtc *crtc,
466466
return;
467467
}
468468
args.v2.ucEnable = enable;
469-
if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK))
469+
if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK) || ASIC_IS_DCE41(rdev))
470470
args.v2.ucEnable = ATOM_DISABLE;
471471
} else if (ASIC_IS_DCE3(rdev)) {
472472
args.v1.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage);

‎drivers/gpu/drm/radeon/radeon_encoders.c‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,17 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
16381638
break;
16391639
case 2:
16401640
args.v2.ucCRTC = radeon_crtc->crtc_id;
1641-
args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
1641+
if (radeon_encoder_is_dp_bridge(encoder)) {
1642+
struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1643+
1644+
if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
1645+
args.v2.ucEncodeMode = ATOM_ENCODER_MODE_LVDS;
1646+
else if (connector->connector_type == DRM_MODE_CONNECTOR_VGA)
1647+
args.v2.ucEncodeMode = ATOM_ENCODER_MODE_CRT;
1648+
else
1649+
args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
1650+
} else
1651+
args.v2.ucEncodeMode = atombios_get_encoder_mode(encoder);
16421652
switch (radeon_encoder->encoder_id) {
16431653
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
16441654
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
@@ -1756,10 +1766,15 @@ static int radeon_atom_pick_dig_encoder(struct drm_encoder *encoder)
17561766
if (ASIC_IS_DCE4(rdev)) {
17571767
dig = radeon_encoder->enc_priv;
17581768
if (ASIC_IS_DCE41(rdev)) {
1759-
if (dig->linkb)
1760-
return 1;
1761-
else
1762-
return 0;
1769+
/* ontario follows DCE4 */
1770+
if (rdev->family == CHIP_PALM) {
1771+
if (dig->linkb)
1772+
return 1;
1773+
else
1774+
return 0;
1775+
} else
1776+
/* llano follows DCE3.2 */
1777+
return radeon_crtc->crtc_id;
17631778
} else {
17641779
switch (radeon_encoder->encoder_id) {
17651780
case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:

‎drivers/gpu/drm/ttm/ttm_bo_util.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
321321
struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
322322
struct ttm_tt *ttm = bo->ttm;
323323
struct ttm_mem_reg *old_mem = &bo->mem;
324-
struct ttm_mem_reg old_copy;
324+
struct ttm_mem_reg old_copy = *old_mem;
325325
void *old_iomap;
326326
void *new_iomap;
327327
int ret;

0 commit comments

Comments
 (0)