Skip to contentSkip to conversation

amdgpu/jpeg: fix deepsleep register for jpeg 5_0_0 and 5_0_2

PATCH Superseded David (Ming Qiang) Wu 2 participants 2 messages Mar 30 – Mar 31

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu/jpeg: fix deepsleep register for jpeg 5_0_0 and 5_0_2

PCTL0__MMHUB_DEEPSLEEP_IB is 0x69004 on MMHUB 4,1,0 and and 0x60804 on MMHUB 4,2,0. 0x62a04 is on MMHUB 1,8,0/1.

If deepsleep is working then the MMHUB clock will run slower while idle but speed up once anything happens, so some operations might take a little longer to get started.

Based on the logic above and tested on RX9070. 1 with 0x69004 set 0x80004000 at start, 0x4000 at end 2 with 0x69004 set 0x4000 always at start and end 3 with 0x62a04 in case 1

results:
- case 1 shows the best startup performance. speed=9.8x
- case 2 shows the worst startup performance. speed=7.5x
- case 3 is a little bit better than case 2 at startup. speed=7.7x
This clearly indicates the case 1 is correct.

---
 drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 28 ++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +26 -2
index 4b4aa9553624..03883b3b5670 100644
@@ -739,7 +739,19 @@ void jpeg_v4_0_3_dec_ring_insert_start(struct amdgpu_ring *ring)
 	if (!amdgpu_sriov_vf(ring->adev)) {
 		amdgpu_ring_write(ring, PACKETJ(regUVD_JRBC_EXTERNAL_REG_INTERNAL_OFFSET,
 			0, 0, PACKETJ_TYPE0));
-		amdgpu_ring_write(ring, 0x62a04); /* PCTL0_MMHUB_DEEPSLEEP_IB */
+
+		/* PCTL0__MMHUB_DEEPSLEEP_IB could be different on different mmhub version */
+		switch (amdgpu_ip_version(ring->adev, MMHUB_HWIP, 0)) {
+		case IP_VERSION(4, 1, 0):
+			amdgpu_ring_write(ring, 0x69004);
+			break;
+		case IP_VERSION(4, 2, 0):
+			amdgpu_ring_write(ring, 0x60804);
+			break;
+		default:
+			amdgpu_ring_write(ring, 0x62a04);
+			break;
+		}
 
 		amdgpu_ring_write(ring,
 				  PACKETJ(JRBC_DEC_EXTERNAL_REG_WRITE_ADDR, 0,
@@ -760,7 +772,19 @@ void jpeg_v4_0_3_dec_ring_insert_end(struct amdgpu_ring *ring)
 	if (!amdgpu_sriov_vf(ring->adev)) {
 		amdgpu_ring_write(ring, PACKETJ(regUVD_JRBC_EXTERNAL_REG_INTERNAL_OFFSET,
 			0, 0, PACKETJ_TYPE0));
-		amdgpu_ring_write(ring, 0x62a04);
+
+		/* PCTL0__MMHUB_DEEPSLEEP_IB could be different on different mmhub version */
+		switch (amdgpu_ip_version(ring->adev, MMHUB_HWIP, 0)) {
+		case IP_VERSION(4, 1, 0):
+			amdgpu_ring_write(ring, 0x69004);
+			break;
+		case IP_VERSION(4, 2, 0):
+			amdgpu_ring_write(ring, 0x60804);
+			break;
+		default:
+			amdgpu_ring_write(ring, 0x62a04);
+			break;
+		}
 
 		amdgpu_ring_write(ring,
 				  PACKETJ(JRBC_DEC_EXTERNAL_REG_WRITE_ADDR, 0,
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · David (Ming Qiang) Wu

PCTL0__MMHUB_DEEPSLEEP_IB is 0x69004 on MMHUB 4,1,0 and and 0x60804 on MMHUB 4,2,0. 0x62a04 is on MMHUB 1,8,0/1.

If deepsleep is working then the MMHUB clock will run slower while idle but speed up once anything happens, so some operations might take a little longer to get started.

Based on the logic above and tested on RX9070. 1 with 0x69004 set 0x80004000 at start, 0x4000 at end 2 with 0x69004 set 0x4000 always at start and end 3 with 0x62a04 in case 1

Quoted 7 lines

results:
- case 1 shows the best startup performance. speed=9.8x
- case 2 shows the worst startup performance. speed=7.5x
- case 3 is a little bit better than case 2 at startup. speed=7.7x
This clearly indicates the case 1 is correct.

Quoted 53 lines
---
 drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c | 28 ++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c +26 -3
index 4b4aa9553624..03883b3b5670 100644
@@ -739,7 +739,19 @@ void jpeg_v4_0_3_dec_ring_insert_start(struct amdgpu_ring *ring)
        if (!amdgpu_sriov_vf(ring->adev)) {
                amdgpu_ring_write(ring, PACKETJ(regUVD_JRBC_EXTERNAL_REG_INTERNAL_OFFSET,
                        0, 0, PACKETJ_TYPE0));
-               amdgpu_ring_write(ring, 0x62a04); /* PCTL0_MMHUB_DEEPSLEEP_IB */
+
+               /* PCTL0__MMHUB_DEEPSLEEP_IB could be different on different mmhub version */
+               switch (amdgpu_ip_version(ring->adev, MMHUB_HWIP, 0)) {
+               case IP_VERSION(4, 1, 0):
+                       amdgpu_ring_write(ring, 0x69004);
+                       break;
+               case IP_VERSION(4, 2, 0):
+                       amdgpu_ring_write(ring, 0x60804);
+                       break;
+               default:
+                       amdgpu_ring_write(ring, 0x62a04);
+                       break;
+               }
 
                amdgpu_ring_write(ring,
                                  PACKETJ(JRBC_DEC_EXTERNAL_REG_WRITE_ADDR, 0,
@@ -760,7 +772,19 @@ void jpeg_v4_0_3_dec_ring_insert_end(struct amdgpu_ring *ring)
        if (!amdgpu_sriov_vf(ring->adev)) {
                amdgpu_ring_write(ring, PACKETJ(regUVD_JRBC_EXTERNAL_REG_INTERNAL_OFFSET,
                        0, 0, PACKETJ_TYPE0));
-               amdgpu_ring_write(ring, 0x62a04);
+
+               /* PCTL0__MMHUB_DEEPSLEEP_IB could be different on different mmhub version */
+               switch (amdgpu_ip_version(ring->adev, MMHUB_HWIP, 0)) {
+               case IP_VERSION(4, 1, 0):
+                       amdgpu_ring_write(ring, 0x69004);
+                       break;
+               case IP_VERSION(4, 2, 0):
+                       amdgpu_ring_write(ring, 0x60804);
+                       break;
+               default:
+                       amdgpu_ring_write(ring, 0x62a04);
+                       break;
+               }
 
                amdgpu_ring_write(ring,
                                  PACKETJ(JRBC_DEC_EXTERNAL_REG_WRITE_ADDR, 0,
--

2.43.0