Skip to contentSkip to conversation

Fix DCN 3.1.4 hangs on s2idle entry

PATCH Superseded Mario Limonciello 5 participants 11 messages May 16, 2023 – May 17, 2023

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Fix DCN 3.1.4 hangs on s2idle entry

It's been observed that with DCN 3.1.4 s2idle entry will hang occasionally on s2idle entry, but only if running Wayland and only when using systemctl suspend, not echo mem | tee /sys/power/state.

This happens because using systemctl suspend will cause the screen to lock right before writing mem into /sys/power/state.

This causes a delayed GFXOFF entry to be scheduled right before s2idle entry. If the workqueue doesn't get processed before the RLC is turned off the system is hung. Even if the workqueue *does* get processed, there is a race between the APU microcontrollers and driver for whether GFX is actually powered off when RLC is turned off.

To avoid this issue, flush the workqueue on s2idle entry and ensure that GFX is really in GFXOFF before any sensitive register accesses occur.

Mario Limonciello (3):
drm/amd: Flush any delayed gfxoff on suspend entry drm/amd: Poll for GFX core to be off
drm/amd: Add safety check to make sure RLC is only turned off while in
GFXOFF

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 +++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c     | 22 ++++++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_shared.h   |  1 +
 3 files changed, 42 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 drm/amd: Flush any delayed gfxoff on suspend entry

DCN 3.1.4 is reported to hang on s2idle entry if graphics activity is happening during entry. This is because GFXOFF was scheduled as delayed but RLC gets disabled in s2idle entry sequence which will hang GFX IP if not already in GFXOFF.

To help this problem, flush any delayed work for GFXOFF early in s2idle entry sequence to ensure that it's off when RLC is changed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index a9d9bbe8586b..059139f1f973 100644
@@ -4316,6 +4316,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 		drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
 
 	cancel_delayed_work_sync(&adev->delayed_init_work);
+	flush_delayed_work(&adev->gfx.gfx_off_delay_work);
 
 	amdgpu_ras_suspend(adev);
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 drm/amd: Poll for GFX core to be off

In reply to Mario Limonciello

If GFXOFF was flushed during suspend entry it may take some time for GFX core to be powered down. Ensure that it's powered off before continuing any operations that may try to utilize related IP. This avoids hangs from stopping RLC as well as problems with fence interrupts timing out during s2idle entry and exit.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 ++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c     | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_shared.h   |  1 +
 3 files changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +18 -2
index 059139f1f973..17fc053405ef 100644
@@ -3055,12 +3055,28 @@ static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work)
 {
 	struct amdgpu_device *adev =
 		container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work);
+	int r, i;
 
 	WARN_ON_ONCE(adev->gfx.gfx_off_state);
 	WARN_ON_ONCE(adev->gfx.gfx_off_req_count);
 
-	if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
-		adev->gfx.gfx_off_state = true;
+	r = amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+	if (r) {
+		DRM_ERROR("failed to enable gfxoff: %d\n", r);
+		return;
+	}
+	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
+		if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_GFX)
+			continue;
+		if (!adev->ip_blocks[i].version->funcs->wait_for_off)
+			continue;
+		r = adev->ip_blocks[i].version->funcs->wait_for_off((void *)adev);
+		if (r) {
+			DRM_ERROR("failed to wait for gfxoff: %d\n", r);
+			return;
+		}
+	}
+	adev->gfx.gfx_off_state = true;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +18 -0
index 4b7224de879e..dcbdb2641086 100644
@@ -4434,6 +4434,23 @@ static int gfx_v11_0_wait_for_idle(void *handle)
 	return -ETIMEDOUT;
 }
 
+
+static int gfx_v11_0_wait_for_off(void *handle)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	u32 tmp;
+	int i;
+
+	for (i = 0; i < adev->usec_timeout; i++) {
+		tmp = RREG32_SOC15(GC, 0, regGFX_IMU_MSG_FLAGS);
+		if (!(tmp & 0x06))
+			return 0;
+		udelay(1);
+	}
+	dev_dbg(adev->dev, "GFX IMU is %x\n", tmp);
+	return -ETIMEDOUT;
+}
+
 static int gfx_v11_0_soft_reset(void *handle)
 {
 	u32 grbm_soft_reset = 0;
@@ -6109,6 +6126,7 @@ static const struct amd_ip_funcs gfx_v11_0_ip_funcs = {
 	.resume = gfx_v11_0_resume,
 	.is_idle = gfx_v11_0_is_idle,
 	.wait_for_idle = gfx_v11_0_wait_for_idle,
+	.wait_for_off = gfx_v11_0_wait_for_off,
 	.soft_reset = gfx_v11_0_soft_reset,
 	.check_soft_reset = gfx_v11_0_check_soft_reset,
 	.post_soft_reset = gfx_v11_0_post_soft_reset,
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
index f175e65b853a..ce2e2b6fd6ff 100644
@@ -298,6 +298,7 @@ struct amd_ip_funcs {
 	int (*resume)(void *handle);
 	bool (*is_idle)(void *handle);
 	int (*wait_for_idle)(void *handle);
+	int (*wait_for_off)(void *handle);
 	bool (*check_soft_reset)(void *handle);
 	int (*pre_soft_reset)(void *handle);
 	int (*soft_reset)(void *handle);
Signature · 1 line
2.34.1
Tested-by Juan Martinez Tested-by Anson Tsao on v1 2/3
#3 lore raw

RE: [PATCH 2/3] drm/amd: Poll for GFX core to be off

[AMD Official Use Only - General]

Is this register GFX_IMU_MSG_FLAGS outside of GFXOFF domain?

Thanks,
Lijo

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Mario Limonciello
Sent: Tuesday, May 16, 2023 11:22 PM
To: [email protected]
Cc: Tsao, Anson <[email protected]>; Huang, Tim <[email protected]>; Martinez, Juan <[email protected]>; Limonciello, Mario <[email protected]>; Gong, Richard <[email protected]>
Subject: [PATCH 2/3] drm/amd: Poll for GFX core to be off

If GFXOFF was flushed during suspend entry it may take some time for GFX core to be powered down. Ensure that it's powered off before continuing any operations that may try to utilize related IP. This avoids hangs from stopping RLC as well as problems with fence interrupts timing out during s2idle entry and exit.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 ++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c     | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_shared.h   |  1 +
 3 files changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +18 -2
index 059139f1f973..17fc053405ef 100644
@@ -3055,12 +3055,28 @@ static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work)  {
 	struct amdgpu_device *adev =
 		container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work);
+	int r, i;
 
 	WARN_ON_ONCE(adev->gfx.gfx_off_state);
 	WARN_ON_ONCE(adev->gfx.gfx_off_req_count);
 
-	if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
-		adev->gfx.gfx_off_state = true;
+	r = amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+	if (r) {
+		DRM_ERROR("failed to enable gfxoff: %d\n", r);
+		return;
+	}
+	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
+		if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_GFX)
+			continue;
+		if (!adev->ip_blocks[i].version->funcs->wait_for_off)
+			continue;
+		r = adev->ip_blocks[i].version->funcs->wait_for_off((void *)adev);
+		if (r) {
+			DRM_ERROR("failed to wait for gfxoff: %d\n", r);
+			return;
+		}
+	}
+	adev->gfx.gfx_off_state = true;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +17 -0
index 4b7224de879e..dcbdb2641086 100644
@@ -4434,6 +4434,23 @@ static int gfx_v11_0_wait_for_idle(void *handle)
 	return -ETIMEDOUT;
 }
 
+
+static int gfx_v11_0_wait_for_off(void *handle) {
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	u32 tmp;
+	int i;
+
+	for (i = 0; i < adev->usec_timeout; i++) {
+		tmp = RREG32_SOC15(GC, 0, regGFX_IMU_MSG_FLAGS);
+		if (!(tmp & 0x06))
+			return 0;
+		udelay(1);
+	}
+	dev_dbg(adev->dev, "GFX IMU is %x\n", tmp);
+	return -ETIMEDOUT;
+}
+
 static int gfx_v11_0_soft_reset(void *handle)  {
 	u32 grbm_soft_reset = 0;
@@ -6109,6 +6126,7 @@ static const struct amd_ip_funcs gfx_v11_0_ip_funcs = {
 	.resume = gfx_v11_0_resume,
 	.is_idle = gfx_v11_0_is_idle,
 	.wait_for_idle = gfx_v11_0_wait_for_idle,
+	.wait_for_off = gfx_v11_0_wait_for_off,
 	.soft_reset = gfx_v11_0_soft_reset,
 	.check_soft_reset = gfx_v11_0_check_soft_reset,
 	.post_soft_reset = gfx_v11_0_post_soft_reset, diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h

index f175e65b853a..ce2e2b6fd6ff 100644

drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -298,6 +298,7 @@ struct amd_ip_funcs {
 	int (*resume)(void *handle);
 	bool (*is_idle)(void *handle);
 	int (*wait_for_idle)(void *handle);
+	int (*wait_for_off)(void *handle);
 	bool (*check_soft_reset)(void *handle);
 	int (*pre_soft_reset)(void *handle);
 	int (*soft_reset)(void *handle);

--
2.34.1

Tested-by Juan Martinez Tested-by Anson Tsao
#4 lore raw

RE: [PATCH 2/3] drm/amd: Poll for GFX core to be off

[AMD Official Use Only - General]

Hi Lijo,

Yes, the GFX_IMU_MSG_FLAGS is outside of GFXOFF domain. It can be accessed when GFXOFF is entry.

Best Regards,
Tim Huang

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, May 17, 2023 10:48 AM
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Tsao, Anson <[email protected]>; Huang, Tim <[email protected]>; Martinez, Juan <[email protected]>; Limonciello, Mario <[email protected]>; Gong, Richard <[email protected]>
Subject: RE: [PATCH 2/3] drm/amd: Poll for GFX core to be off

[AMD Official Use Only - General]

Is this register GFX_IMU_MSG_FLAGS outside of GFXOFF domain?

Thanks,
Lijo

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Mario Limonciello
Sent: Tuesday, May 16, 2023 11:22 PM
To: [email protected]
Cc: Tsao, Anson <[email protected]>; Huang, Tim <[email protected]>; Martinez, Juan <[email protected]>; Limonciello, Mario <[email protected]>; Gong, Richard <[email protected]>
Subject: [PATCH 2/3] drm/amd: Poll for GFX core to be off

If GFXOFF was flushed during suspend entry it may take some time for GFX core to be powered down. Ensure that it's powered off before continuing any operations that may try to utilize related IP. This avoids hangs from stopping RLC as well as problems with fence interrupts timing out during s2idle entry and exit.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 ++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c     | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/include/amd_shared.h   |  1 +
 3 files changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +18 -2
index 059139f1f973..17fc053405ef 100644
@@ -3055,12 +3055,28 @@ static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work)  {
        struct amdgpu_device *adev =
                container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work);
+       int r, i;
 
        WARN_ON_ONCE(adev->gfx.gfx_off_state);
        WARN_ON_ONCE(adev->gfx.gfx_off_req_count);
 
-       if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
-               adev->gfx.gfx_off_state = true;
+       r = amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+       if (r) {
+               DRM_ERROR("failed to enable gfxoff: %d\n", r);
+               return;
+       }
+       for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
+               if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_GFX)
+                       continue;
+               if (!adev->ip_blocks[i].version->funcs->wait_for_off)
+                       continue;
+               r = adev->ip_blocks[i].version->funcs->wait_for_off((void *)adev);
+               if (r) {
+                       DRM_ERROR("failed to wait for gfxoff: %d\n", r);
+                       return;
+               }
+       }
+       adev->gfx.gfx_off_state = true;
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +17 -0
index 4b7224de879e..dcbdb2641086 100644
@@ -4434,6 +4434,23 @@ static int gfx_v11_0_wait_for_idle(void *handle)
        return -ETIMEDOUT;
 }
 
+
+static int gfx_v11_0_wait_for_off(void *handle) {
+       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+       u32 tmp;
+       int i;
+
+       for (i = 0; i < adev->usec_timeout; i++) {
+               tmp = RREG32_SOC15(GC, 0, regGFX_IMU_MSG_FLAGS);
+               if (!(tmp & 0x06))
+                       return 0;
+               udelay(1);
+       }
+       dev_dbg(adev->dev, "GFX IMU is %x\n", tmp);
+       return -ETIMEDOUT;
+}
+
 static int gfx_v11_0_soft_reset(void *handle)  {
        u32 grbm_soft_reset = 0;
@@ -6109,6 +6126,7 @@ static const struct amd_ip_funcs gfx_v11_0_ip_funcs = {
        .resume = gfx_v11_0_resume,
        .is_idle = gfx_v11_0_is_idle,
        .wait_for_idle = gfx_v11_0_wait_for_idle,
+       .wait_for_off = gfx_v11_0_wait_for_off,
        .soft_reset = gfx_v11_0_soft_reset,
        .check_soft_reset = gfx_v11_0_check_soft_reset,
        .post_soft_reset = gfx_v11_0_post_soft_reset, diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h

index f175e65b853a..ce2e2b6fd6ff 100644

drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -298,6 +298,7 @@ struct amd_ip_funcs {
        int (*resume)(void *handle);
        bool (*is_idle)(void *handle);
        int (*wait_for_idle)(void *handle);
+       int (*wait_for_off)(void *handle);
        bool (*check_soft_reset)(void *handle);
        int (*pre_soft_reset)(void *handle);
        int (*soft_reset)(void *handle);

--
2.34.1

#5 lore raw

PATCH 3/3 drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

In reply to Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
index dcbdb2641086..f1f879d9ed8d 100644
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
 {
 	u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+	if (!adev->gfx.gfx_off_state) {
+		dev_err(adev->dev, "GFX is not in GFXOFF\n");
+		return;
+	}
 	tmp = REG_SET_FIELD(tmp, RLC_CNTL, RLC_ENABLE_F32, 0);
 	WREG32_SOC15(GC, 0, regRLC_CNTL, tmp);
 }
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 3/3] drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

Quoted 15 lines · Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index dcbdb2641086..f1f879d9ed8d 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev) · line 1772

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
 {
        u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+       if (!adev->gfx.gfx_off_state) {
+               dev_err(adev->dev, "GFX is not in GFXOFF\n");
+               return;
+       }

This should move up before the RREG above? Also, I think it would be cleaner to just not mess with the RLC in S0i3. Can we just return early in smu_disable_dpms() for the APU case? All of the DPM features are controlled by the SMU so that function is mostly a nop of APUs anyway.

Alex

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -1
        tmp = REG_SET_FIELD(tmp, RLC_CNTL, RLC_ENABLE_F32, 0);
        WREG32_SOC15(GC, 0, regRLC_CNTL, tmp);
 }
--

2.34.1

#7 lore raw

Re: [PATCH 3/3] drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

Quoted 29 lines · Alex Deucher
Quoted 14 lines · Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index dcbdb2641086..f1f879d9ed8d 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev) · line 1772

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
  {
         u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+       if (!adev->gfx.gfx_off_state) {
+               dev_err(adev->dev, "GFX is not in GFXOFF\n");
+               return;
+       }

This should move up before the RREG above? Also, I think it would be cleaner to just not mess with the RLC in S0i3. Can we just return early in smu_disable_dpms() for the APU case? All of the DPM features are controlled by the SMU so that function is mostly a nop of APUs anyway.

Quoted 1 line

Alex

That was what the original attempt did when we first identified this issue. Unfortunately though just skipping RLC (without patches 1 and 2) means that GFXOFF still either doesn't get toggled at suspend entry or isn't fully

off at suspend entry.

This leads to the graphics core behaving erratically upon resume.

So if you're OK with patches 1 and 2, I'll adjust patch 3 to also skip RLC for APU.

#8 lore raw

Re: [PATCH 3/3] drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

Quoted 37 lines · Mario
Quoted 29 lines · Alex Deucher
Quoted 14 lines · Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index dcbdb2641086..f1f879d9ed8d 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev) · line 1772

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
  {
         u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+       if (!adev->gfx.gfx_off_state) {
+               dev_err(adev->dev, "GFX is not in GFXOFF\n");
+               return;
+       }

This should move up before the RREG above? Also, I think it would be cleaner to just not mess with the RLC in S0i3. Can we just return early in smu_disable_dpms() for the APU case? All of the DPM features are controlled by the SMU so that function is mostly a nop of APUs anyway.

Quoted 1 line

Alex

That was what the original attempt did when we first identified this issue. Unfortunately though just skipping RLC (without patches 1 and 2) means that GFXOFF still either doesn't get toggled at suspend entry or isn't fully

Quoted 7 lines

off at suspend entry.

This leads to the graphics core behaving erratically upon resume.

So if you're OK with patches 1 and 2, I'll adjust patch 3 to also skip RLC for
APU.

Sure. I wonder if we need something similar as patch 2 for other APUs?

Thinking out loud here, I wonder if we shouldn't just return early in the top level suspend/resume functions for S0i3.

Alex

#9 lore raw

Re: [PATCH 3/3] drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

Quoted 37 lines · Alex Deucher
Quoted 36 lines · Mario
Quoted 29 lines · Alex Deucher
Quoted 14 lines · Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
   drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
   1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index dcbdb2641086..f1f879d9ed8d 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev) · line 1772

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
   {
          u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+       if (!adev->gfx.gfx_off_state) {
+               dev_err(adev->dev, "GFX is not in GFXOFF\n");
+               return;
+       }

This should move up before the RREG above? Also, I think it would be cleaner to just not mess with the RLC in S0i3. Can we just return early in smu_disable_dpms() for the APU case? All of the DPM features are controlled by the SMU so that function is mostly a nop of APUs anyway.

Quoted 1 line

Alex

That was what the original attempt did when we first identified this issue. Unfortunately though just skipping RLC (without patches 1 and 2) means that GFXOFF still either doesn't get toggled at suspend entry or isn't fully

Quoted 8 lines
Quoted 7 lines

off at suspend entry.

This leads to the graphics core behaving erratically upon resume.

So if you're OK with patches 1 and 2, I'll adjust patch 3 to also skip RLC for
APU.

Sure.

OK, let me double check RLC skip and I'll send out a v2.

Quoted 1 line

I wonder if we need something similar as patch 2 for other APUs?

I expect patch 1 "alone" to help Renoir and Cezanne hitting a similar circumstance. For Rembrandt and Mendocino, they don't have IMU, so what would you poll?

Quoted 3 lines

Thinking out loud here, I wonder if we shouldn't just return early in the top level suspend/resume functions for S0i3.

I think this can make sense for GFX10 and GFX11 maybe, but as it's already bifurcated I think it's probably better to do case by case basis.

#10 lore raw

Re: [PATCH 3/3] drm/amd: Add safety check to make sure RLC is only turned off while in GFXOFF

Quoted 47 lines · Mario
Quoted 44 lines · Alex Deucher
Quoted 43 lines · Mario
Quoted 29 lines · Alex Deucher
Quoted 14 lines · Mario Limonciello

On GFX11 if RLC is stopped when not in GFXOFF the system will hang. Prevent this case from ever happening.

---
   drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++++
   1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0 -0
index dcbdb2641086..f1f879d9ed8d 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev) · line 1772

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -0
@@ -1766,6 +1766,10 @@ static void gfx_v11_0_rlc_stop(struct amdgpu_device *adev)
   {
          u32 tmp = RREG32_SOC15(GC, 0, regRLC_CNTL);
 
+       if (!adev->gfx.gfx_off_state) {
+               dev_err(adev->dev, "GFX is not in GFXOFF\n");
+               return;
+       }

This should move up before the RREG above? Also, I think it would be cleaner to just not mess with the RLC in S0i3. Can we just return early in smu_disable_dpms() for the APU case? All of the DPM features are controlled by the SMU so that function is mostly a nop of APUs anyway.

Quoted 1 line

Alex

That was what the original attempt did when we first identified this issue. Unfortunately though just skipping RLC (without patches 1 and 2) means that GFXOFF still either doesn't get toggled at suspend entry or isn't fully

off at suspend entry.

This leads to the graphics core behaving erratically upon resume.

So if you're OK with patches 1 and 2, I'll adjust patch 3 to also skip RLC for
APU.

Quoted 6 lines
Quoted 1 line

Sure.

OK, let me double check RLC skip and I'll send out a v2.

Quoted 1 line

I wonder if we need something similar as patch 2 for other APUs?

I expect patch 1 "alone" to help Renoir and Cezanne hitting a similar circumstance.
For Rembrandt and Mendocino, they don't have IMU, so what would you poll?

For older chips, mmPWR_MISC_CNTL_STATUS (smu10), mmSMUIO_GFX_MISC_CNTL (smu12). See smu_v12_0_gfx_off_control() and smu10_disable_gfx_off(). It looks like smu_v13_0_gfx_off_control() doesn't wait for gfxoff like the other functions.

Alex

Quoted 7 lines
Quoted 3 lines

Thinking out loud here, I wonder if we shouldn't just return early in the top level suspend/resume functions for S0i3.

I think this can make sense for GFX10 and GFX11 maybe, but as it's already bifurcated I think it's probably better to do case by case basis.