Skip to contentSkip to conversation

drm/v3d: Add V3D tech revision to the device information

PATCH In review Maíra Canal 2 participants 3 messages Jul 14, 2024 – Jul 15, 2024

Subsystems (3)
lore
Share & tools
lore

Maíra Canal

author maintainer
#0 lore raw

PATCH 1/2 drm/v3d: Add V3D tech revision to the device information

The V3D tech revision can be a useful information when configuring jobs. Therefore, expose it in the struct v3d_dev with the V3D tech version.

---
 drivers/gpu/drm/v3d/v3d_drv.c | 5 ++++-
 drivers/gpu/drm/v3d/v3d_drv.h | 8 +++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.c +4 -1
index d38628e4fc2f..d7ff1f5fa481 100644
@@ -267,7 +267,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	struct v3d_dev *v3d;
 	int ret;
 	u32 mmu_debug;
-	u32 ident1;
+	u32 ident1, ident3;
 	u64 mask;
 
 	v3d = devm_drm_dev_alloc(dev, &v3d_drm_driver, struct v3d_dev, drm);
@@ -300,6 +300,9 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)
 	v3d->cores = V3D_GET_FIELD(ident1, V3D_HUB_IDENT1_NCORES);
 	WARN_ON(v3d->cores > 1); /* multicore not yet implemented */
 
+	ident3 = V3D_READ(V3D_HUB_IDENT3);
+	v3d->rev = V3D_GET_FIELD(ident3, V3D_HUB_IDENT3_IPREV);
+
 	v3d_perfmon_init(v3d);
 
 	v3d->reset = devm_reset_control_get_exclusive(dev, NULL);
drivers/gpu/drm/v3d/v3d_drv.h +5 -3
index 8524761bc62d..cf4b23369dc4 100644
@@ -98,10 +98,12 @@ struct v3d_perfmon {
 struct v3d_dev {
 	struct drm_device drm;
 
-	/* Short representation (e.g. 33, 41) of the V3D tech version
-	 * and revision.
-	 */
+	/* Short representation (e.g. 33, 41) of the V3D tech version */
 	int ver;
+
+	/* Short representation (e.g. 5, 6) of the V3D tech revision */
+	int rev;
+
 	bool single_irq_line;
 
 	struct v3d_perfmon_info perfmon_info;
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH 2/2 drm/v3d: Fix Indirect Dispatch configuration for V3D 7.1.6 and later

args->cfg[4] is configured in Indirect Dispatch using the number of batches. Currently, for all V3D tech versions, args->cfg[4] equals the number of batches subtracted by 1. But, for V3D 7.1.6 and later, we must not subtract 1 from the number of batches.

Implement the fix by checking the V3D tech version and revision.

Fixes several dEQP-VK.synchronization* CTS tests related to Indirect Dispatch.

Fixes 18b8413b25b7 ("drm/v3d: Create a CPU job extension for a indirect CSD job")
---
 drivers/gpu/drm/v3d/v3d_sched.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/v3d/v3d_sched.c +13 -3
index d193072703f3..cafa3a298c11 100644
@@ -353,7 +353,8 @@ v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)
 	struct v3d_bo *bo = to_v3d_bo(job->base.bo[0]);
 	struct v3d_bo *indirect = to_v3d_bo(indirect_csd->indirect);
 	struct drm_v3d_submit_csd *args = &indirect_csd->job->args;
-	u32 *wg_counts;
+	struct v3d_dev *v3d = job->base.v3d;
+	u32 num_batches, *wg_counts;
 
 	v3d_get_bo_vaddr(bo);
 	v3d_get_bo_vaddr(indirect);
@@ -366,8 +367,17 @@ v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)
 	args->cfg[0] = wg_counts[0] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
 	args->cfg[1] = wg_counts[1] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
 	args->cfg[2] = wg_counts[2] << V3D_CSD_CFG012_WG_COUNT_SHIFT;
-	args->cfg[4] = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
-		       (wg_counts[0] * wg_counts[1] * wg_counts[2]) - 1;
+
+	num_batches = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
+		      (wg_counts[0] * wg_counts[1] * wg_counts[2]);
+
+	/* V3D 7.1.6 and later don't subtract 1 from the number of batches */
+	if (v3d->ver < 71 || (v3d->ver == 71 && v3d->rev < 6))
+		args->cfg[4] = num_batches - 1;
+	else
+		args->cfg[4] = num_batches;
+
+	WARN_ON(args->cfg[4] == ~0);
 
 	for (int i = 0; i < 3; i++) {
 		/* 0xffffffff indicates that the uniform rewrite is not needed */
Signature · 1 line
2.45.2
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/v3d: Fix Indirect Dispatch configuration for V3D 7.1.6 and later

Thanks Maíra, both patches are:

Quoted 62 lines · Maíra Canal

args->cfg[4] is configured in Indirect Dispatch using the number of batches. Currently, for all V3D tech versions, args->cfg[4] equals the
number of batches subtracted by 1. But, for V3D 7.1.6 and later, we must not
subtract 1 from the number of batches.

Implement the fix by checking the V3D tech version and revision.

Fixes several dEQP-VK.synchronization* CTS tests related to Indirect Dispatch.

Fixes 18b8413b25b7 ("drm/v3d: Create a CPU job extension for a

indirect CSD job")

---
 drivers/gpu/drm/v3d/v3d_sched.c | 16 +++++++++++++---

 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/v3d/v3d_sched.c +2 -1
index d193072703f3..cafa3a298c11 100644
@@ -353,7 +353,8 @@
 v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)
  	struct v3d_bo *bo = to_v3d_bo(job->base.bo[0]);
  	struct v3d_bo *indirect = to_v3d_bo(indirect_csd->indirect);
  	struct drm_v3d_submit_csd *args = &indirect_csd->job->args;
-	u32 *wg_counts;
+	struct v3d_dev *v3d = job->base.v3d;
+	u32 num_batches, *wg_counts;


  v3d_get_bo_vaddr(bo);
  v3d_get_bo_vaddr(indirect);

drivers/gpu/drm/v3d/v3d_sched.c +0 -0
@@ -366,8 +367,17 @@
 v3d_rewrite_csd_job_wg_counts_from_indirect(struct v3d_cpu_job *job)

  args->cfg[0] = wg_counts[0] <<
V3D_CSD_CFG012_WG_COUNT_SHIFT;
  args->cfg[1] = wg_counts[1] <<
V3D_CSD_CFG012_WG_COUNT_SHIFT;
  args->cfg[2] = wg_counts[2] <<
V3D_CSD_CFG012_WG_COUNT_SHIFT;

drivers/gpu/drm/v3d/v3d_sched.c +5 -3
-	args->cfg[4] = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
-		       (wg_counts[0] * wg_counts[1] * wg_counts[2])
- 1;
+
+	num_batches = DIV_ROUND_UP(indirect_csd->wg_size, 16) *
+		      (wg_counts[0] * wg_counts[1] * wg_counts[2]);
+
+	/* V3D 7.1.6 and later don't subtract 1 from the number of

batches */

drivers/gpu/drm/v3d/v3d_sched.c +6 -0
+	if (v3d->ver < 71 || (v3d->ver == 71 && v3d->rev < 6))
+		args->cfg[4] = num_batches - 1;
+	else
+		args->cfg[4] = num_batches;
+
+	WARN_ON(args->cfg[4] == ~0);


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