Skip to contentSkip to conversation

drm/msm/adreno: Fix warn splat for devices without revn

PATCH In review Rob Clark 3 participants 7 messages Jul 4, 2023 – Jul 14, 2023

Subsystems (4)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/2 drm/msm/adreno: Fix warn splat for devices without revn

From: Rob Clark <[email protected]>

Recently, a WARN_ON() was introduced to ensure that revn is filled before adreno_is_aXYZ is called. This however doesn't work very well when revn is 0 by design (such as for A635).

Cc Konrad Dybcio <[email protected]>
Fixes cc943f43ece7 ("drm/msm/adreno: warn if chip revn is verified before being set")
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.h +6 -3
index 65379e4824d9..ef1bcb6b624e 100644
@@ -149,7 +149,8 @@ bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2);
 
 static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn)
 {
-	WARN_ON_ONCE(!gpu->revn);
+	/* revn can be zero, but if not is set at same time as info */
+	WARN_ON_ONCE(!gpu->info);
 
 	return gpu->revn == revn;
 }
@@ -161,14 +162,16 @@ static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu)
 
 static inline bool adreno_is_a2xx(const struct adreno_gpu *gpu)
 {
-	WARN_ON_ONCE(!gpu->revn);
+	/* revn can be zero, but if not is set at same time as info */
+	WARN_ON_ONCE(!gpu->info);
 
 	return (gpu->revn < 300);
 }
 
 static inline bool adreno_is_a20x(const struct adreno_gpu *gpu)
 {
-	WARN_ON_ONCE(!gpu->revn);
+	/* revn can be zero, but if not is set at same time as info */
+	WARN_ON_ONCE(!gpu->info);
 
 	return (gpu->revn < 210);
 }
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 2/2 drm/msm/a690: Remove revn and name

From: Rob Clark <[email protected]>

These fields are deprecated. But any userspace new enough to support a690 also knows how to identify the GPU based on chip-id.

---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 2 --
 drivers/gpu/drm/msm/adreno/adreno_gpu.h    | 3 ++-
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +0 -2
index cb94cfd137a8..ce8d0b2475bf 100644
@@ -369,8 +369,6 @@ static const struct adreno_info gpulist[] = {
 		.hwcg = a640_hwcg,
 	}, {
 		.rev = ADRENO_REV(6, 9, 0, ANY_ID),
-		.revn = 690,
-		.name = "A690",
 		.fw = {
 			[ADRENO_FW_SQE] = "a660_sqe.fw",
 			[ADRENO_FW_GMU] = "a690_gmu.bin",
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
index ef1bcb6b624e..cf45007400c8 100644
@@ -310,7 +310,8 @@ static inline int adreno_is_a680(const struct adreno_gpu *gpu)
 
 static inline int adreno_is_a690(const struct adreno_gpu *gpu)
 {
-	return adreno_is_revn(gpu, 690);
+	/* The order of args is important here to handle ANY_ID correctly */
+	return adreno_cmp_rev(ADRENO_REV(6, 9, 0, ANY_ID), gpu->rev);
 };
 /* check for a615, a616, a618, a619 or any derivatives */
 static inline int adreno_is_a615_family(const struct adreno_gpu *gpu)
Signature · 1 line
2.41.0
#3 lore raw
In reply to Rob Clark
Quoted 29 lines · Rob Clark

From: Rob Clark <[email protected]>

Recently, a WARN_ON() was introduced to ensure that revn is filled before adreno_is_aXYZ is called. This however doesn't work very well when revn is 0 by design (such as for A635).

Cc Konrad Dybcio <[email protected]>
Fixes cc943f43ece7 ("drm/msm/adreno: warn if chip revn is verified before being set")
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
index 65379e4824d9..ef1bcb6b624e 100644
@@ -149,7 +149,8 @@ bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2);
 
 static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
        return gpu->revn == revn;
 }

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 168

Quoted 8 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
@@ -161,14 +162,16 @@ static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu)
 
 static inline bool adreno_is_a2xx(const struct adreno_gpu *gpu)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
        return (gpu->revn < 300);

This is then incorrect for a635 / a690 if they have revn at 0.

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 176

Quoted 9 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
 }
 
 static inline bool adreno_is_a20x(const struct adreno_gpu *gpu)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
        return (gpu->revn < 210);

And this too.

Quoted 4 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -1
 }
--

2.41.0

Signature · 2 lines
With best wishes
Dmitry
author
#4 lore raw
Quoted 38 lines · Dmitry Baryshkov
Quoted 36 lines · Rob Clark

From: Rob Clark <[email protected]>

Recently, a WARN_ON() was introduced to ensure that revn is filled before adreno_is_aXYZ is called. This however doesn't work very well when revn is 0 by design (such as for A635).

Cc Konrad Dybcio <[email protected]>
Fixes cc943f43ece7 ("drm/msm/adreno: warn if chip revn is verified before being set")
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.h +4 -2
index 65379e4824d9..ef1bcb6b624e 100644
@@ -149,7 +149,8 @@ bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2);
 
 static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
        return gpu->revn == revn;
 }
@@ -161,14 +162,16 @@ static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu)
 
 static inline bool adreno_is_a2xx(const struct adreno_gpu *gpu)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
Quoted 3 lines

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 168

Quoted 1 line
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -0
        return (gpu->revn < 300);

This is then incorrect for a635 / a690 if they have revn at 0.

Fortunately not any more broken that it has ever been. But as long as sc7280/sc8280 have GPU OPP tables, you'd never hit this. I'm working on a better solution for next merge window.

BR,
-R

Quoted 21 lines

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 176

Quoted 9 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
 }
 
 static inline bool adreno_is_a20x(const struct adreno_gpu *gpu)
 {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
        return (gpu->revn < 210);

And this too.

Quoted 4 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -1
 }
--

2.41.0

--
With best wishes
Dmitry

Reviewed-by
#5 lore raw
Quoted 40 lines · Rob Clark
Quoted 38 lines · Dmitry Baryshkov
Quoted 36 lines · Rob Clark

From: Rob Clark <[email protected]>

Recently, a WARN_ON() was introduced to ensure that revn is filled before adreno_is_aXYZ is called. This however doesn't work very well when revn is 0 by design (such as for A635).

Cc Konrad Dybcio <[email protected]>
Fixes cc943f43ece7 ("drm/msm/adreno: warn if chip revn is verified before being set")
---
  drivers/gpu/drm/msm/adreno/adreno_gpu.h | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.h +4 -2
index 65379e4824d9..ef1bcb6b624e 100644
@@ -149,7 +149,8 @@ bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2);
 
  static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn)
  {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
         return gpu->revn == revn;
  }
@@ -161,14 +162,16 @@ static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu)
 
  static inline bool adreno_is_a2xx(const struct adreno_gpu *gpu)
  {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
Quoted 7 lines
Quoted 3 lines

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 168

Quoted 1 line
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -0
         return (gpu->revn < 300);

This is then incorrect for a635 / a690 if they have revn at 0.

Fortunately not any more broken that it has ever been. But as long as sc7280/sc8280 have GPU OPP tables, you'd never hit this. I'm working on a better solution for next merge window.

Sounds fine with me then.

Quoted 25 lines

BR,
-R

Quoted 21 lines

drivers/gpu/drm/msm/adreno/adreno_gpu.h static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) · line 176

Quoted 9 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
  }
 
  static inline bool adreno_is_a20x(const struct adreno_gpu *gpu)
  {
-       WARN_ON_ONCE(!gpu->revn);
+       /* revn can be zero, but if not is set at same time as info */
+       WARN_ON_ONCE(!gpu->info);
 
         return (gpu->revn < 210);

And this too.

Quoted 4 lines
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -1
  }
--

2.41.0

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/msm/a690: Remove revn and name

In reply to Rob Clark
Quoted 10 lines · Rob Clark

From: Rob Clark <[email protected]>

These fields are deprecated. But any userspace new enough to support a690 also knows how to identify the GPU based on chip-id.

---
  drivers/gpu/drm/msm/adreno/adreno_device.c | 2 --
  drivers/gpu/drm/msm/adreno/adreno_gpu.h    | 3 ++-
  2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 2 lines
With best wishes
Dmitry
Tested-by on v1 1/2
#6 lore raw
In reply to Rob Clark
Quoted 6 lines · Rob Clark

From: Rob Clark <[email protected]>

Recently, a WARN_ON() was introduced to ensure that revn is filled before adreno_is_aXYZ is called. This however doesn't work very well when revn is 0 by design (such as for A635).

Quoted 7 lines
Cc Konrad Dybcio <[email protected]>
Fixes cc943f43ece7 ("drm/msm/adreno: warn if chip revn is verified before being set")
---
  drivers/gpu/drm/msm/adreno/adreno_gpu.h | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)