Skip to content

Commit 412dbc6

Browse files
committed
Merge tag 'drm-misc-next-fixes-2024-07-19' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-next
Two fixes for v3d to fix an array indexing on newer V3D revisions. Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20240719-emerald-newt-of-skill-89b54a@houat
2 parents 78e6e46 + 1fe1c66 commit 412dbc6

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

drivers/gpu/drm/v3d/v3d_drv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
265265
struct v3d_dev *v3d;
266266
int ret;
267267
u32 mmu_debug;
268-
u32 ident1;
268+
u32 ident1, ident3;
269269
u64 mask;
270270

271271
v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
@@ -298,6 +298,9 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
298298
v3d->cores = V3D_GET_FIELD(ident1, V3D_HUB_IDENT1_NCORES);
299299
WARN_ON(v3d->cores > 1); /* multicore not yet implemented */
300300

301+
ident3 = V3D_READ(V3D_HUB_IDENT3);
302+
v3d->rev = V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPREV);
303+
301304
if (v3d->ver >= 71)
302305
v3d->max_counters = V3D_V71_NUM_PERFCOUNTERS;
303306
else if (v3d->ver >= 42)

drivers/gpu/drm/v3d/v3d_drv.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ struct v3d_perfmon {
9898
struct v3d_dev {
9999
struct drm_device drm;
100100

101-
/* Short representation (e.g. 33, 41) of the V3D tech version
102-
* and revision.
103-
*/
101+
/* Short representation (e.g. 33, 41) of the V3D tech version */
104102
int ver;
103+
104+
/* Short representation (e.g. 5, 6) of the V3D tech revision */
105+
int rev;
106+
105107
bool single_irq_line;
106108

107109
/* Different revisions of V3D have different total number of performance

drivers/gpu/drm/v3d/v3d_sched.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)
331331
struct v3d_bo *bo = to_v3d_bo(job->base.bo[0]);
332332
struct v3d_bo *indirect = to_v3d_bo(indirect_csd->indirect);
333333
struct drm_v3d_submit_csd *args = &indirect_csd->job->args;
334-
u32 *wg_counts;
334+
struct v3d_dev *v3d = job->base.v3d;
335+
u32 num_batches, *wg_counts;
335336

336337
v3d_get_bo_vaddr(bo);
337338
v3d_get_bo_vaddr(indirect);
@@ -344,8 +345,17 @@ v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)
344345
args->cfg[0] = wg_counts[0] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
345346
args->cfg[1] = wg_counts[1] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
346347
args->cfg[2] = wg_counts[2] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
347-
args->cfg[4] = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
348-
(wg_counts[0] * wg_counts[1] * wg_counts[2]) - 1;
348+
349+
num_batches = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
350+
(wg_counts[0] * wg_counts[1] * wg_counts[2]);
351+
352+
/* V3D 7.1.6 and later don't subtract 1 from the number of batches */
353+
if (v3d->ver < 71 || (v3d->ver == 71 && v3d->rev < 6))
354+
args->cfg[4] = num_batches - 1;
355+
else
356+
args->cfg[4] = num_batches;
357+
358+
WARN_ON(args->cfg[4] == ~0);
349359

350360
for (int i = 0; i < 3; i++) {
351361
/* 0xffffffff indicates that the uniform rewrite is not needed */

0 commit comments

Comments
 (0)