Skip to contentSkip to conversation

drm/msm/a6xx: Fix missing ARRAY_SIZE() check

PATCH In review Rob Clark 2 participants 2 messages Mar 5, 2022 – Mar 7, 2022

Subsystems (4)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm/a6xx: Fix missing ARRAY_SIZE() check

From: Rob Clark <[email protected]>

Fixes f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8 -4
index 02b47977b5c3..83c31b2ad865 100644
@@ -683,19 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
 {
 	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
 	const u32 *regs = a6xx_protect;
-	unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
-
-	BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
-	BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
+	unsigned i, count, count_max;
 
 	if (adreno_is_a650(adreno_gpu)) {
 		regs = a650_protect;
 		count = ARRAY_SIZE(a650_protect);
 		count_max = 48;
+		BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
 	} else if (adreno_is_a660_family(adreno_gpu)) {
 		regs = a660_protect;
 		count = ARRAY_SIZE(a660_protect);
 		count_max = 48;
+		BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
+	} else {
+		regs = a6xx_protect;
+		count = ARRAY_SIZE(a6xx_protect);
+		count_max = 32;
+		BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
 	}
 
 	/*
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Rob Clark

From: Rob Clark <[email protected]>

Fixes f6d62d091cfd ("drm/msm/a6xx: add support for Adreno 660 GPU")
---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++----
  1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -4
index 02b47977b5c3..83c31b2ad865 100644
@@ -683,19 +683,23 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
  {
  	struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
  	const u32 *regs = a6xx_protect;
-	unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
-
-	BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
-	BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
+	unsigned i, count, count_max;
 
  	if (adreno_is_a650(adreno_gpu)) {
  		regs = a650_protect;
  		count = ARRAY_SIZE(a650_protect);
  		count_max = 48;
+		BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
  	} else if (adreno_is_a660_family(adreno_gpu)) {
  		regs = a660_protect;
  		count = ARRAY_SIZE(a660_protect);

drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_set_cp_protect(struct msm_gpu *gpu) · line 705

Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6 -0
  		count_max = 48;
+		BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
+	} else {
+		regs = a6xx_protect;
+		count = ARRAY_SIZE(a6xx_protect);
+		count_max = 32;
+		BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
  	}
 
  	/*

-Akhil.