Skip to content

Commit 94fa83c

Browse files
committed
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "As per your -rc2 announce, this is small and urgent only, The radeon one is for a regression in 3.4 so we need this one in your tree so we can send the stable one out, code in 3.4 broke some old userspaces. The max props increase fixes spew being seen on a few machines. And a ttm regression to fix some accounting issues that affect vmwgfx." * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: drm/ttm: Fix buffer object metadata accounting regression v2 drm: increase DRM_OBJECT_MAX_PROPERTY to 24 drm/radeon: fix tiling and command stream checking on evergreen v3
2 parents 266ae4e + a393c73 commit 94fa83c

4 files changed

Lines changed: 51 additions & 16 deletions

File tree

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

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct evergreen_cs_track {
5252
u32 cb_color_view[12];
5353
u32 cb_color_pitch[12];
5454
u32 cb_color_slice[12];
55+
u32 cb_color_slice_idx[12];
5556
u32 cb_color_attrib[12];
5657
u32 cb_color_cmask_slice[8];/* unused */
5758
u32 cb_color_fmask_slice[8];/* unused */
@@ -127,12 +128,14 @@ static void evergreen_cs_track_init(struct evergreen_cs_track *track)
127128
track->cb_color_info[i] = 0;
128129
track->cb_color_view[i] = 0xFFFFFFFF;
129130
track->cb_color_pitch[i] = 0;
130-
track->cb_color_slice[i] = 0;
131+
track->cb_color_slice[i] = 0xfffffff;
132+
track->cb_color_slice_idx[i] = 0;
131133
}
132134
track->cb_target_mask = 0xFFFFFFFF;
133135
track->cb_shader_mask = 0xFFFFFFFF;
134136
track->cb_dirty = true;
135137

138+
track->db_depth_slice = 0xffffffff;
136139
track->db_depth_view = 0xFFFFC000;
137140
track->db_depth_size = 0xFFFFFFFF;
138141
track->db_depth_control = 0xFFFFFFFF;
@@ -250,10 +253,9 @@ static int evergreen_surface_check_2d(struct radeon_cs_parser *p,
250253
{
251254
struct evergreen_cs_track *track = p->track;
252255
unsigned palign, halign, tileb, slice_pt;
256+
unsigned mtile_pr, mtile_ps, mtileb;
253257

254258
tileb = 64 * surf->bpe * surf->nsamples;
255-
palign = track->group_size / (8 * surf->bpe * surf->nsamples);
256-
palign = MAX(8, palign);
257259
slice_pt = 1;
258260
if (tileb > surf->tsplit) {
259261
slice_pt = tileb / surf->tsplit;
@@ -262,7 +264,10 @@ static int evergreen_surface_check_2d(struct radeon_cs_parser *p,
262264
/* macro tile width & height */
263265
palign = (8 * surf->bankw * track->npipes) * surf->mtilea;
264266
halign = (8 * surf->bankh * surf->nbanks) / surf->mtilea;
265-
surf->layer_size = surf->nbx * surf->nby * surf->bpe * slice_pt;
267+
mtileb = (palign / 8) * (halign / 8) * tileb;;
268+
mtile_pr = surf->nbx / palign;
269+
mtile_ps = (mtile_pr * surf->nby) / halign;
270+
surf->layer_size = mtile_ps * mtileb * slice_pt;
266271
surf->base_align = (palign / 8) * (halign / 8) * tileb;
267272
surf->palign = palign;
268273
surf->halign = halign;
@@ -434,6 +439,39 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned i
434439

435440
offset += surf.layer_size * mslice;
436441
if (offset > radeon_bo_size(track->cb_color_bo[id])) {
442+
/* old ddx are broken they allocate bo with w*h*bpp but
443+
* program slice with ALIGN(h, 8), catch this and patch
444+
* command stream.
445+
*/
446+
if (!surf.mode) {
447+
volatile u32 *ib = p->ib.ptr;
448+
unsigned long tmp, nby, bsize, size, min = 0;
449+
450+
/* find the height the ddx wants */
451+
if (surf.nby > 8) {
452+
min = surf.nby - 8;
453+
}
454+
bsize = radeon_bo_size(track->cb_color_bo[id]);
455+
tmp = track->cb_color_bo_offset[id] << 8;
456+
for (nby = surf.nby; nby > min; nby--) {
457+
size = nby * surf.nbx * surf.bpe * surf.nsamples;
458+
if ((tmp + size * mslice) <= bsize) {
459+
break;
460+
}
461+
}
462+
if (nby > min) {
463+
surf.nby = nby;
464+
slice = ((nby * surf.nbx) / 64) - 1;
465+
if (!evergreen_surface_check(p, &surf, "cb")) {
466+
/* check if this one works */
467+
tmp += surf.layer_size * mslice;
468+
if (tmp <= bsize) {
469+
ib[track->cb_color_slice_idx[id]] = slice;
470+
goto old_ddx_ok;
471+
}
472+
}
473+
}
474+
}
437475
dev_warn(p->dev, "%s:%d cb[%d] bo too small (layer size %d, "
438476
"offset %d, max layer %d, bo size %ld, slice %d)\n",
439477
__func__, __LINE__, id, surf.layer_size,
@@ -446,6 +484,7 @@ static int evergreen_cs_track_validate_cb(struct radeon_cs_parser *p, unsigned i
446484
surf.tsplit, surf.mtilea);
447485
return -EINVAL;
448486
}
487+
old_ddx_ok:
449488

450489
return 0;
451490
}
@@ -1532,6 +1571,7 @@ static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
15321571
case CB_COLOR7_SLICE:
15331572
tmp = (reg - CB_COLOR0_SLICE) / 0x3c;
15341573
track->cb_color_slice[tmp] = radeon_get_ib_value(p, idx);
1574+
track->cb_color_slice_idx[tmp] = idx;
15351575
track->cb_dirty = true;
15361576
break;
15371577
case CB_COLOR8_SLICE:
@@ -1540,6 +1580,7 @@ static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
15401580
case CB_COLOR11_SLICE:
15411581
tmp = ((reg - CB_COLOR8_SLICE) / 0x1c) + 8;
15421582
track->cb_color_slice[tmp] = radeon_get_ib_value(p, idx);
1583+
track->cb_color_slice_idx[tmp] = idx;
15431584
track->cb_dirty = true;
15441585
break;
15451586
case CB_COLOR0_ATTRIB:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757
* 2.13.0 - virtual memory support, streamout
5858
* 2.14.0 - add evergreen tiling informations
5959
* 2.15.0 - add max_pipes query
60+
* 2.16.0 - fix evergreen 2D tiled surface calculation
6061
*/
6162
#define KMS_DRIVER_MAJOR 2
62-
#define KMS_DRIVER_MINOR 15
63+
#define KMS_DRIVER_MINOR 16
6364
#define KMS_DRIVER_PATCHLEVEL 0
6465
int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
6566
int radeon_driver_unload_kms(struct drm_device *dev);

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
12041204
(*destroy)(bo);
12051205
else
12061206
kfree(bo);
1207+
ttm_mem_global_free(mem_glob, acc_size);
12071208
return -EINVAL;
12081209
}
12091210
bo->destroy = destroy;
@@ -1307,22 +1308,14 @@ int ttm_bo_create(struct ttm_bo_device *bdev,
13071308
struct ttm_buffer_object **p_bo)
13081309
{
13091310
struct ttm_buffer_object *bo;
1310-
struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
13111311
size_t acc_size;
13121312
int ret;
13131313

1314-
acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct ttm_buffer_object));
1315-
ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
1316-
if (unlikely(ret != 0))
1317-
return ret;
1318-
13191314
bo = kzalloc(sizeof(*bo), GFP_KERNEL);
1320-
1321-
if (unlikely(bo == NULL)) {
1322-
ttm_mem_global_free(mem_glob, acc_size);
1315+
if (unlikely(bo == NULL))
13231316
return -ENOMEM;
1324-
}
13251317

1318+
acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct ttm_buffer_object));
13261319
ret = ttm_bo_init(bdev, bo, size, type, placement, page_alignment,
13271320
buffer_start, interruptible,
13281321
persistent_swap_storage, acc_size, NULL, NULL);

‎include/drm/drm_crtc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct drm_mode_object {
5454
struct drm_object_properties *properties;
5555
};
5656

57-
#define DRM_OBJECT_MAX_PROPERTY 16
57+
#define DRM_OBJECT_MAX_PROPERTY 24
5858
struct drm_object_properties {
5959
int count;
6060
uint32_t ids[DRM_OBJECT_MAX_PROPERTY];

0 commit comments

Comments
 (0)