Skip to contentSkip to conversation

drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

PATCH In review Evan Quan 4 participants 7 messages Oct 18, 2021 – Oct 19, 2021

Subsystems (3)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
 .../powerplay/hwmgr/smu7_clockpowergating.c   | 20 +++++++++++++++++--
 .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16 +++++++++++++--
 drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
 3 files changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +18 -2
index f2bda3bcbbde..d2c6fe8fe473 100644
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)
 
 int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
 {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed on suspend
+	 * and make the action here the last one. But that will involve a lot and needs
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev->in_suspend)
 		return smum_send_msg_to_smc(hwmgr,
 				PPSMC_MSG_UVDPowerOFF,
 				NULL);
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)
 
 static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
 {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
 		return smum_send_msg_to_smc(hwmgr,
 				PPSMC_MSG_VCEPowerOFF,
 				NULL);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +14 -2
index b94a77e4e714..09e755980c42 100644
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,
 
 static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
 {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev->in_suspend)
 		return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF, NULL);
 	return 0;
 }
@@ -1301,7 +1307,13 @@ static int  smu8_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr)
 
 static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
 {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev->in_suspend)
 		return smum_send_msg_to_smc(hwmgr,
 					    PPSMC_MSG_VCEPowerOFF,
 					    NULL);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +2 -2
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void *handle, bool gate)
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
 						       AMD_PG_STATE_GATE);
 		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
 			/* power off the UVD block */
 			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerOFF);
 	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void *handle, bool gate)
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
 						       AMD_PG_STATE_GATE);
 		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the VCE block */
 			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF);
 	} else {
 		if (pi->caps_vce_pg) /* power on the VCE block */
Signature · 1 line
2.29.0
#1 lore raw
Quoted 6 lines · Evan Quan

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

The original issue reported by Boris is related to sytem reboot and hw_fini calls (SMU is hw_fini before UVD/VCE). Boris also mentioned that it got solved by reverting the disable DPM calls during hw_fini. So, I'm still not sure how this is related to suspend path.

Thanks,
Lijo

Quoted 103 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
  .../powerplay/hwmgr/smu7_clockpowergating.c   | 20 +++++++++++++++++--
  .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16 +++++++++++++--
  drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
  3 files changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +18 -2
index f2bda3bcbbde..d2c6fe8fe473 100644
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)
 
  int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed on suspend
+	 * and make the action here the last one. But that will involve a lot and needs
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  				PPSMC_MSG_UVDPowerOFF,
  				NULL);
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)
 
  static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  				PPSMC_MSG_VCEPowerOFF,
  				NULL);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +14 -2
index b94a77e4e714..09e755980c42 100644
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,
 
  static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF, NULL);
  	return 0;
  }
@@ -1301,7 +1307,13 @@ static int  smu8_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr)
 
  static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  					    PPSMC_MSG_VCEPowerOFF,
  					    NULL);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +2 -2
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void *handle, bool gate)
  		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
  						       AMD_PG_STATE_GATE);
  		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
  			/* power off the UVD block */
  			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerOFF);
  	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void *handle, bool gate)
  		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
  						       AMD_PG_STATE_GATE);
  		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the VCE block */
  			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF);
  	} else {
  		if (pi->caps_vce_pg) /* power on the VCE block */
author
#2 lore raw

[AMD Official Use Only]

Quoted 18 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 18, 2021 3:58 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

Quoted 6 lines · Evan Quan

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

Quoted 4 lines

The original issue reported by Boris is related to sytem reboot and hw_fini calls (SMU is hw_fini before UVD/VCE). Boris also mentioned that it got solved by reverting the disable DPM calls during hw_fini. So, I'm still not sure how this is related to suspend path.

[Quan, Evan] hw_fini() was not on the path of system reboot as I confirmed. It's different from the issue Andrey found(during driver unload). The call flow for system reboot is: amdgpu_pci_shutdown() -> amdgpu_device_ip_suspend() -> ...

BR
Evan

Quoted 141 lines

Thanks,
Lijo

Quoted 4 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
  .../powerplay/hwmgr/smu7_clockpowergating.c   | 20

+++++++++++++++++--

Quoted 1 line
  .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16

+++++++++++++--

Quoted 8 lines
  drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
  3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c index f2bda3bcbbde..d2c6fe8fe473 100644
---

a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 1 line

+++

b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr · line 65

Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct pp_hwmgr
 *hwmgr, bool bgate)
 
  int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)

Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed on

suspend

Review static int smu7_update_vce_dpm(struct pp_hwmgr · line 69

Quoted 1 line
(quoted diff) +1 -0
+	 * and make the action here the last one. But that will involve a lot

and needs

Review static int smu7_powerup_uvd(struct pp_hwmgr

Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_UVDPowerOFF, NULL);

(quoted diff) +0 -0
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr

*hwmgr)

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)

Quoted 9 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
  static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  				PPSMC_MSG_VCEPowerOFF,
  				NULL);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +0 -0
index b94a77e4e714..09e755980c42 100644

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_force_dpm_level(struct · line 1255

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct
 pp_hwmgr *hwmgr,
 
  static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,

PPSMC_MSG_UVDPowerOFF, NULL);

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_update_vce_dpm(struct · line 1315

Quoted 13 lines
  	return 0;
  }
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
@@ -1301,7 +1307,13 @@ static int  smu8_dpm_update_vce_dpm(struct
 pp_hwmgr *hwmgr)
 
  static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle,

Quoted 13 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_VCEPowerOFF, NULL);

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void *handle,

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle, · line 1683

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
  		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_UVD,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle, bool gate)

Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
  						       AMD_PG_STATE_GATE);
  		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
  			/* power off the UVD block */
  			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_UVDPowerOFF);

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle,

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
  	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void *handle,

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, · line 1710

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
  		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_VCE,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, bool gate)

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
  						       AMD_PG_STATE_GATE);
  		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the

VCE

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, · line 1715

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -0
+block */
  			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_VCEPowerOFF);

Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
  	} else {
  		if (pi->caps_vce_pg) /* power on the VCE block */
#3 lore raw
Quoted 22 lines · Evan

[AMD Official Use Only]

Quoted 18 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 18, 2021 3:58 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

Quoted 6 lines · Evan Quan

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

Quoted 7 lines
Quoted 4 lines

The original issue reported by Boris is related to sytem reboot and hw_fini calls (SMU is hw_fini before UVD/VCE). Boris also mentioned that it got solved by reverting the disable DPM calls during hw_fini. So, I'm still not sure how this is related to suspend path.

[Quan, Evan] hw_fini() was not on the path of system reboot as I confirmed. It's different from the issue Andrey found(during driver unload). The call flow for system reboot is: amdgpu_pci_shutdown() -> amdgpu_device_ip_suspend() -> ...

Sorry then I misunderstood. I confused it with pci_remove and the hw_fini sequence. It was suspend() calling hw_fini() then.

BTW, is this unrelated to the reboot issue then? in_suspend is not set during amdgpu_pci_shutdown(). Wouldn't it be better to skip uvd/vce poweroff when their DPM is disabled?

Thanks,
Lijo

Quoted 143 lines

BR
Evan

Quoted 141 lines

Thanks,
Lijo

Quoted 4 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
   .../powerplay/hwmgr/smu7_clockpowergating.c   | 20

+++++++++++++++++--

Quoted 1 line
   .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16

+++++++++++++--

Quoted 8 lines
   drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
   3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c index f2bda3bcbbde..d2c6fe8fe473 100644
---

a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 1 line

+++

b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr · line 65

Quoted 11 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct pp_hwmgr
 *hwmgr, bool bgate)
 
   int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
   {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)

Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed on

suspend

Review static int smu7_update_vce_dpm(struct pp_hwmgr · line 69

Quoted 1 line
(quoted diff) +1 -0
+	 * and make the action here the last one. But that will involve a lot

and needs

Review static int smu7_powerup_uvd(struct pp_hwmgr

Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev-
 in_suspend)
   		return smum_send_msg_to_smc(hwmgr,
   				PPSMC_MSG_UVDPowerOFF,
   				NULL);
(quoted diff) +0 -0
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr

*hwmgr)

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)

Quoted 9 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
   static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
   {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

Quoted 12 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
   		return smum_send_msg_to_smc(hwmgr,
   				PPSMC_MSG_VCEPowerOFF,
   				NULL);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +0 -0
index b94a77e4e714..09e755980c42 100644

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_force_dpm_level(struct · line 1255

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct
 pp_hwmgr *hwmgr,
 
   static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
   {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,

PPSMC_MSG_UVDPowerOFF, NULL);

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_update_vce_dpm(struct · line 1315

Quoted 13 lines
   	return 0;
   }
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
@@ -1301,7 +1307,13 @@ static int  smu8_dpm_update_vce_dpm(struct
 pp_hwmgr *hwmgr)
 
   static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
   {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle,

Quoted 13 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev-
 in_suspend)
   		return smum_send_msg_to_smc(hwmgr,
   					    PPSMC_MSG_VCEPowerOFF,
   					    NULL);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void *handle,

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle, · line 1683

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_UVD,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle, bool gate)

Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
   						       AMD_PG_STATE_GATE);
   		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
   			/* power off the UVD block */
   			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_UVDPowerOFF);

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle,

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void *handle,

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, · line 1710

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_VCE,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, bool gate)

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
   						       AMD_PG_STATE_GATE);
   		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the

VCE

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, · line 1715

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -0
+block */
   			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_VCEPowerOFF);

Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   	} else {
   		if (pi->caps_vce_pg) /* power on the VCE block */
author
#4 lore raw

[AMD Official Use Only]

Quoted 40 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 18, 2021 6:47 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

Quoted 20 lines · Evan

[AMD Official Use Only]

Quoted 16 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, October 18, 2021 3:58 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix the hang observed on Carrizo due to UVD suspend failure

Quoted 5 lines · Evan Quan

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend

scenario.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

The original issue reported by Boris is related to sytem reboot and hw_fini calls (SMU is hw_fini before UVD/VCE). Boris also mentioned that it got solved by reverting the disable DPM calls during hw_fini. So, I'm still not sure how this is related to suspend path.

[Quan, Evan] hw_fini() was not on the path of system reboot as I

confirmed. It's different from the issue Andrey found(during driver unload).

Quoted 8 lines
Quoted 1 line

The call flow for system reboot is: amdgpu_pci_shutdown() ->

amdgpu_device_ip_suspend() -> ...

Quoted 1 line

Sorry then I misunderstood. I confused it with pci_remove and the hw_fini sequence. It was suspend() calling hw_fini() then.

BTW, is this unrelated to the reboot issue then?

[Quan, Evan] No, this targets the reboot issue.

Quoted 2 lines

in_suspend is not set during
amdgpu_pci_shutdown().

[Quan, Evan] Oops, missed that. I will provide an updated V2.

Quoted 2 lines

Wouldn't it be better to skip uvd/vce poweroff
when their DPM is disabled?

[Quan, Evan] Not quite sure. As the UVD/VCE poweroff + DPM disablement are also used in amdgpu_uvd_idle_work_handler(). And they seem working quite well there. So, it seems the issue is specific to the ->suspend(e.g. uvd_v6_0_suspend) routine. In fact, the patch is aimed to provide a quick solution. As the comment added in the code, a better solution needs MM team's guide.

+        * TODO: a better solution is to reorg the action chains performed on suspend
+        * and make the action here the last one. But that will involve a lot and needs
+        * MM team's help.
+        */

BR
Evan

Quoted 158 lines

Thanks,
Lijo

Quoted 18 lines

BR
Evan

Quoted 16 lines

Thanks,
Lijo

Quoted 4 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
   .../powerplay/hwmgr/smu7_clockpowergating.c   | 20

+++++++++++++++++--

Quoted 1 line
   .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16

+++++++++++++--

Quoted 5 lines
   drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
   3 files changed, 34 insertions(+), 6 deletions(-)

diff --git

a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 1 line
Quoted 1 line
Quoted 1 line

b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

index f2bda3bcbbde..d2c6fe8fe473 100644
---

a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+++

b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c

Quoted 1 line
Quoted 1 line

Review static int smu7_update_vce_dpm(struct

Quoted 1 line
(quoted diff) +0 -0
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct

pp_hwmgr

Quoted 38 lines
Quoted 38 lines

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
 *hwmgr, bool bgate)
 
   int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
   {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -0
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed
+on

suspend

Review static int smu7_update_vce_dpm(struct · line 71

Quoted 2 lines
(quoted diff) +2 -0
+	 * and make the action here the last one. But that will involve a
+lot

and needs

Review static int smu7_powerup_uvd(struct pp_hwmgr

Quoted 8 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev-

in_suspend)
return smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_UVDPowerOFF, NULL);

(quoted diff) +0 -0
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr

*hwmgr)

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)

Quoted 9 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +4 -1
   static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
   {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
   		return smum_send_msg_to_smc(hwmgr,
   				PPSMC_MSG_VCEPowerOFF,
   				NULL);

diff --git

a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c

Quoted 22 lines
Quoted 22 lines
Quoted 5 lines

b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c index b94a77e4e714..09e755980c42 100644

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_force_dpm_level(struct · line 1255

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct
 pp_hwmgr *hwmgr,
 
   static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
   {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path.

Thus

Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,

PPSMC_MSG_UVDPowerOFF, NULL);

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int

Quoted 3 lines
   	return 0;
   }
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +0 -0
@@ -1301,7 +1307,13 @@ static int

smu8_dpm_update_vce_dpm(struct

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c static int smu8_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr)

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +4 -1
 pp_hwmgr *hwmgr)
 
   static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
   {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr-
 adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path.

Thus

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +3 -0
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev-
 in_suspend)

return smum_send_msg_to_smc(hwmgr,

Quoted 8 lines

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void

Quoted 8 lines
   					    PPSMC_MSG_VCEPowerOFF,
   					    NULL);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void

*handle,

Quoted 10 lines
Quoted 10 lines

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void · line 1683

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_UVD,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_uvd(void *handle, bool gate)

Quoted 6 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
   						       AMD_PG_STATE_GATE);
   		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
   			/* power off the UVD block */
   			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_UVDPowerOFF);

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void

*handle,

Quoted 14 lines
Quoted 14 lines

bool gate)

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void · line 1710

Quoted 1 line
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   		amdgpu_device_ip_set_powergating_state(adev,

AMD_IP_BLOCK_TYPE_VCE,

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void *handle, bool gate)

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -1
   						       AMD_PG_STATE_GATE);
   		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the

VCE

drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c static void kv_dpm_powergate_vce(void · line 1715

Quoted 2 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +1 -0
+block */
   			amdgpu_kv_notify_message_to_smu(adev,

PPSMC_MSG_VCEPowerOFF);

Quoted 3 lines
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +0 -0
   	} else {
   		if (pi->caps_vce_pg) /* power on the VCE block */
#5 lore raw
In reply to Evan Quan
Quoted 6 lines · Evan Quan

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

Quoted 7 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
 .../powerplay/hwmgr/smu7_clockpowergating.c   | 20 +++++++++++++++++--
 .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16 +++++++++++++--
 drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
 3 files changed, 34 insertions(+), 6 deletions(-)

Want me to run it?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#6 lore raw
In reply to Evan Quan

Am 18.10.21 um 09:34 schrieb Evan Quan:

Quoted 5 lines

It's confirmed that on some APUs the interaction with SMU(about DPM disablement) will power off the UVD. That will make the succeeding interactions with UVD on the suspend path impossible. And the system will hang due to that. To workaround the issue, we will skip the UVD(or VCE) power off during interaction with SMU for suspend scenario.

Please sync that up with Leo since he is the technical lead for the MM engines.

Apart from that it looks ok to me, but that is really not my field of expertise.

Regards,
Christian.

Quoted 103 lines
Change-Id I7804d3835aadbc7cf4b686da4994e83333461748
---
  .../powerplay/hwmgr/smu7_clockpowergating.c   | 20 +++++++++++++++++--
  .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   | 16 +++++++++++++--
  drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c     |  4 ++--
  3 files changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_clockpowergating.c +18 -2
index f2bda3bcbbde..d2c6fe8fe473 100644
@@ -57,7 +57,17 @@ static int smu7_update_vce_dpm(struct pp_hwmgr *hwmgr, bool bgate)
 
  int smu7_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_uvd_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 *
+	 * TODO: a better solution is to reorg the action chains performed on suspend
+	 * and make the action here the last one. But that will involve a lot and needs
+	 * MM team's help.
+	 */
+	if (phm_cf_want_uvd_power_gating(hwmgr) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  				PPSMC_MSG_UVDPowerOFF,
  				NULL);
@@ -82,7 +92,13 @@ static int smu7_powerup_uvd(struct pp_hwmgr *hwmgr)
 
  static int smu7_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (phm_cf_want_vce_power_gating(hwmgr))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (phm_cf_want_vce_power_gating(hwmgr) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  				PPSMC_MSG_VCEPowerOFF,
  				NULL);
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +14 -2
index b94a77e4e714..09e755980c42 100644
@@ -1247,7 +1247,13 @@ static int smu8_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,
 
  static int smu8_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with UVD are still needed on the suspend path. Thus
+	 * the power off for UVD here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_UVDPowerGating) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr, PPSMC_MSG_UVDPowerOFF, NULL);
  	return 0;
  }
@@ -1301,7 +1307,13 @@ static int  smu8_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr)
 
  static int smu8_dpm_powerdown_vce(struct pp_hwmgr *hwmgr)
  {
-	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating))
+	struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev;
+
+	/*
+	 * Further inactions with VCE are still needed on the suspend path. Thus
+	 * the power off for VCE here should be avoided.
+	 */
+	if (PP_CAP(PHM_PlatformCaps_VCEPowerGating) && !adev->in_suspend)
  		return smum_send_msg_to_smc(hwmgr,
  					    PPSMC_MSG_VCEPowerOFF,
  					    NULL);
drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +2 -2
index bcae42cef374..4e9c9da255a7 100644
@@ -1683,7 +1683,7 @@ static void kv_dpm_powergate_uvd(void *handle, bool gate)
  		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD,
  						       AMD_PG_STATE_GATE);
  		kv_update_uvd_dpm(adev, gate);
-		if (pi->caps_uvd_pg)
+		if (pi->caps_uvd_pg && !adev->in_suspend)
  			/* power off the UVD block */
  			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_UVDPowerOFF);
  	} else {
@@ -1710,7 +1710,7 @@ static void kv_dpm_powergate_vce(void *handle, bool gate)
  		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE,
  						       AMD_PG_STATE_GATE);
  		kv_enable_vce_dpm(adev, false);
-		if (pi->caps_vce_pg) /* power off the VCE block */
+		if (pi->caps_vce_pg && !adev->in_suspend) /* power off the VCE block */
  			amdgpu_kv_notify_message_to_smu(adev, PPSMC_MSG_VCEPowerOFF);
  	} else {
  		if (pi->caps_vce_pg) /* power on the VCE block */