Skip to contentSkip to conversation

Adreno QoL changes

PATCH Superseded Konrad Dybcio 2 participants 8 messages Jun 19, 2023 – Jun 20, 2023

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Adreno QoL changes

This series brings some niceties in preparation for A7xx introduction.

It should be fully independent of the GMU wrapper series.

---
Changes in v3:
- Pull more definitions from mesa
- Decode CP_PROTECT_CNTL bitfields
- Rebase on next-20230619
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Drop switching to using the GMU_AO counter in timestamp
- Add a definition for REG_A6XX_GMU_AHB_FENCE_STATUS_CLR, may be subbed
with a register sync after mesa MR22901
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Konrad Dybcio (6):
drm/msm/a6xx: Add some missing header definitions drm/msm/a6xx: Use descriptive bitfield names for CP_PROTECT_CNTL drm/msm/a6xx: Skip empty protection ranges entries drm/msm/a6xx: Ensure clean GMU state in a6xx_gmu_fw_start drm/msm/a6xx: Improve GMU force shutdown sequence drm/msm/a6xx: Fix up GMU region reservations

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c     | 21 +++++++++++++++++----
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h |  2 ++
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c     | 14 ++++++++++----
 3 files changed, 29 insertions(+), 8 deletions(-)

---
base-commit: 47045630bc409ce6606d97b790895210dd1d517d
change-id: 20230517-topic-a7xx_prep-787a69c7d0ff

Best regards,

Signature · 1 line
Konrad Dybcio <[email protected]>
#1 lore raw

PATCH v3 1/6 drm/msm/a6xx: Add some missing header definitions

Add a definition of the GMU_AHB_FENCE_STATUS_CLR reg and CP_PROTECT_CNTL bitfields.

This may be substituted with a mesa header sync.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h +2 -0
index 9ab15d91aced..fcd9eb53baf8 100644
@@ -425,6 +425,8 @@ static inline uint32_t A6XX_GMU_GPU_NAP_CTRL_SID(uint32_t val)
 
 #define REG_A6XX_GMU_AHB_FENCE_STATUS				0x00009313
 
+#define REG_A6XX_GMU_AHB_FENCE_STATUS_CLR			0x00009314
+
 #define REG_A6XX_GMU_RBBM_INT_UNMASKED_STATUS			0x00009315
 
 #define REG_A6XX_GMU_AO_SPARE_CNTL				0x00009316
Signature · 1 line
2.41.0
#2 lore raw

PATCH v3 2/6 drm/msm/a6xx: Use descriptive bitfield names for CP_PROTECT_CNTL

In reply to Konrad Dybcio

We have the necessary information, so explain which bit does what.

---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4 -1
index b3ada1e7b598..cd0c9bccdc19 100644
@@ -930,7 +930,10 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
 	 * protect violation and select the last span to protect from the start
 	 * address all the way to the end of the register address space
 	 */
-	gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL, BIT(0) | BIT(1) | BIT(3));
+	gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL,
+		  A6XX_CP_PROTECT_CNTL_ACCESS_PROT_EN |
+		  A6XX_CP_PROTECT_CNTL_ACCESS_FAULT_ON_VIOL_EN |
+		  A6XX_CP_PROTECT_CNTL_LAST_SPAN_INF_RANGE);
 
 	for (i = 0; i < count - 1; i++)
 		gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]);
Signature · 1 line
2.41.0
#3 lore raw

Re: [PATCH v3 2/6] drm/msm/a6xx: Use descriptive bitfield names for CP_PROTECT_CNTL

kernel test robot noticed the following build errors:

Hi Konrad,

kernel test robot noticed the following build errors:

[auto build test ERROR on 47045630bc409ce6606d97b790895210dd1d517d]

url:    https://github.com/intel-lab-lkp/linux/commits/Konrad-Dybcio/drm-msm-a6xx-Add-some-missing-header-definitions/20230620-004639
base:   47045630bc409ce6606d97b790895210dd1d517d
patch link:    https://lore.kernel.org/r/20230517-topic-a7xx_prep-v3-2-a3ce3725385b%40linaro.org
patch subject: [PATCH v3 2/6] drm/msm/a6xx: Use descriptive bitfield names for CP_PROTECT_CNTL
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20230620/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230620/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/msm/adreno/a6xx_gpu.c: In function 'a6xx_set_cp_protect':

>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c:934:19: error: 'A6XX_CP_PROTECT_CNTL_ACCESS_PROT_EN' undeclared (first use in this function)
     934 |                   A6XX_CP_PROTECT_CNTL_ACCESS_PROT_EN |
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/msm/adreno/a6xx_gpu.c:934:19: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c:935:19: error: 'A6XX_CP_PROTECT_CNTL_ACCESS_FAULT_ON_VIOL_EN' undeclared (first use in this function)
     935 |                   A6XX_CP_PROTECT_CNTL_ACCESS_FAULT_ON_VIOL_EN |
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/msm/adreno/a6xx_gpu.c:936:19: error: 'A6XX_CP_PROTECT_CNTL_LAST_SPAN_INF_RANGE' undeclared (first use in this function)
     936 |                   A6XX_CP_PROTECT_CNTL_LAST_SPAN_INF_RANGE);
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SM_GCC_8350
Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n]) Selected by [m]:
- SM_VIDEOCC_8350 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
WARNING: unmet direct dependencies detected for SM_GCC_8450
Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n]) Selected by [m]:
- SM_GPUCC_8450 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
- SM_VIDEOCC_8450 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
WARNING: unmet direct dependencies detected for SM_GCC_8550
Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n]) Selected by [m]:
- SM_GPUCC_8550 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
- SM_VIDEOCC_8550 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]

vim +/A6XX_CP_PROTECT_CNTL_ACCESS_PROT_EN +934 drivers/gpu/drm/msm/adreno/a6xx_gpu.c

899
900 static void a6xx_set_cp_protect(struct msm_gpu *gpu)
901 {
902 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
903 const u32 *regs = a6xx_protect;
904 unsigned i, count, count_max;
905
906 if (adreno_is_a650(adreno_gpu)) {
907 regs = a650_protect;
908 count = ARRAY_SIZE(a650_protect);
909 count_max = 48;
910 BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
911 } else if (adreno_is_a690(adreno_gpu)) {
912 regs = a690_protect;
913 count = ARRAY_SIZE(a690_protect);
914 count_max = 48;
915 BUILD_BUG_ON(ARRAY_SIZE(a690_protect) > 48);
916 } else if (adreno_is_a660_family(adreno_gpu)) {
917 regs = a660_protect;
918 count = ARRAY_SIZE(a660_protect);
919 count_max = 48;
920 BUILD_BUG_ON(ARRAY_SIZE(a660_protect) > 48);
921 } else {
922 regs = a6xx_protect;
923 count = ARRAY_SIZE(a6xx_protect);
924 count_max = 32;
925 BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
926 }
927
928 /*
929 * Enable access protection to privileged registers, fault on an access
930 * protect violation and select the last span to protect from the start
931 * address all the way to the end of the register address space
932 */
933 gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL,

 > 934			  A6XX_CP_PROTECT_CNTL_ACCESS_PROT_EN |
 > 935			  A6XX_CP_PROTECT_CNTL_ACCESS_FAULT_ON_VIOL_EN |
 > 936			  A6XX_CP_PROTECT_CNTL_LAST_SPAN_INF_RANGE);

937
938 for (i = 0; i < count - 1; i++)
939 gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]);
940 /* last CP_PROTECT to have "infinite" length on the last entry */
941 gpu_write(gpu, REG_A6XX_CP_PROTECT(count_max - 1), regs[i]);
942 }
943

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

PATCH v3 3/6 drm/msm/a6xx: Skip empty protection ranges entries

In reply to Konrad Dybcio

Some specific SKUs leave certain protection range registers empty. Allow for that behavior.

---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5 -2
index cd0c9bccdc19..488c69cf08d3 100644
@@ -935,8 +935,11 @@ static void a6xx_set_cp_protect(struct msm_gpu *gpu)
 		  A6XX_CP_PROTECT_CNTL_ACCESS_FAULT_ON_VIOL_EN |
 		  A6XX_CP_PROTECT_CNTL_LAST_SPAN_INF_RANGE);
 
-	for (i = 0; i < count - 1; i++)
-		gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]);
+	for (i = 0; i < count - 1; i++) {
+		/* Intentionally skip writing to some registers */
+		if (regs[i])
+			gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]);
+	}
 	/* last CP_PROTECT to have "infinite" length on the last entry */
 	gpu_write(gpu, REG_A6XX_CP_PROTECT(count_max - 1), regs[i]);
 }
Signature · 1 line
2.41.0
#5 lore raw

PATCH v3 4/6 drm/msm/a6xx: Ensure clean GMU state in a6xx_gmu_fw_start

In reply to Konrad Dybcio

While it's not very well understood, there is some sort of a fault handler implemented in the GMU firmware which triggers when a certain bit is set, resulting in the M3 core not booting up the way we expect it to.

Write a magic value to a magic register to hopefully prevent that from happening.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +6 -0
index 5deb79924897..9929ff187368 100644
@@ -790,6 +790,12 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)
 	gmu_write(gmu, REG_A6XX_GMU_AHB_FENCE_RANGE_0,
 		(1 << 31) | (0xa << 18) | (0xa0));
 
+	/*
+	 * Snapshots toggle the NMI bit which will result in a jump to the NMI
+	 * handler instead of __main. Set the M3 config value to avoid that.
+	 */
+	gmu_write(gmu, REG_A6XX_GMU_CM3_CFG, 0x4052);
+
 	chipid = adreno_gpu->rev.core << 24;
 	chipid |= adreno_gpu->rev.major << 16;
 	chipid |= adreno_gpu->rev.minor << 12;
Signature · 1 line
2.41.0
#6 lore raw

PATCH v3 5/6 drm/msm/a6xx: Improve GMU force shutdown sequence

In reply to Konrad Dybcio

The GMU force shutdown sequence involves some additional register cleanup which was not implemented previously. Do so.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +7 -0
index 9929ff187368..55b12a8066ee 100644
@@ -893,6 +893,13 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)
 	/* Make sure there are no outstanding RPMh votes */
 	a6xx_gmu_rpmh_off(gmu);
 
+	/* Clear the WRITEDROPPED fields and put fence into allow mode */
+	gmu_write(gmu, REG_A6XX_GMU_AHB_FENCE_STATUS_CLR, 0x7);
+	gmu_write(gmu, REG_A6XX_GMU_AO_AHB_FENCE_CTRL, 0);
+
+	/* Make sure the above writes go through */
+	wmb();
+
 	/* Halt the gmu cm3 core */
 	gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 1);
 
Signature · 1 line
2.41.0
#7 lore raw

PATCH v3 6/6 drm/msm/a6xx: Fix up GMU region reservations

In reply to Konrad Dybcio

Change the order of region allocations to make the addresses match downstream. This shouldn't matter very much, but helps eliminate one more difference when comparing register accesses.

Also, make the log region 16K long. That's what it is, unconditionally on A6xx and A7xx.

---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4 -4
index 55b12a8066ee..d682c1ed48db 100644
@@ -1640,13 +1640,13 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
 			goto err_memory;
 	}
 
-	/* Allocate memory for for the HFI queues */
-	ret = a6xx_gmu_memory_alloc(gmu, &gmu->hfi, SZ_16K, 0, "hfi");
+	/* Allocate memory for the GMU log region */
+	ret = a6xx_gmu_memory_alloc(gmu, &gmu->log, SZ_16K, 0, "log");
 	if (ret)
 		goto err_memory;
 
-	/* Allocate memory for the GMU log region */
-	ret = a6xx_gmu_memory_alloc(gmu, &gmu->log, SZ_4K, 0, "log");
+	/* Allocate memory for for the HFI queues */
+	ret = a6xx_gmu_memory_alloc(gmu, &gmu->hfi, SZ_16K, 0, "hfi");
 	if (ret)
 		goto err_memory;
 
Signature · 1 line
2.41.0