drm/amdgpu: Use rpm_mode flag instead of checking it again for rpm
Subsystems (2)
PATCH 1/2 drm/amdgpu: Use rpm_mode flag instead of checking it again for rpm
Because the rpm_mode flag is already set when the driver is initialized, we use it directly for runtime suspend/resume instead of checking it again
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12 -12
@@ -2666,7 +2666,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) } adev->in_runpm = true; -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/*
@@ -2676,7 +2676,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)* platforms. * TODO: this may be also needed for PX capable platform. */ -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_UNLOAD ; ret =amdgpu_device_prepare (drm_dev);
@@ -2685,15 +2685,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ret =amdgpu_device_suspend (drm_dev, false);if (ret) { adev->in_runpm = false; -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_NONE ;return ret; } -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_NONE ; -if (amdgpu_device_supports_px (drm_dev)) { +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */
@@ -2702,9 +2702,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)pci_ignore_hotplug (pdev);pci_set_power_state (pdev, PCI_D3cold); drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; - }else if (amdgpu_device_supports_boco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* nothing to do */ - }else if (amdgpu_device_supports_baco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) {amdgpu_device_baco_enter (drm_dev); }
@@ -2727,7 +2727,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!pci_device_is_present (adev->pdev)) adev->no_hw_access = true; -if (amdgpu_device_supports_px (drm_dev)) { +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/* Only need to handle PCI state in the driver for ATPX
@@ -2739,22 +2739,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (ret)return ret;pci_set_master (pdev); - }else if (amdgpu_device_supports_boco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */ pci_set_master (pdev); - }else if (amdgpu_device_supports_baco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) {amdgpu_device_baco_exit (drm_dev); } ret =amdgpu_device_resume (drm_dev, false);if (ret) { -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX )pci_disable_device (pdev);return ret; } -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; adev->in_runpm = false;return 0 ;
Signature · 1 line
2.34.1
PATCH 2/2 drm/amgpu: Check return value of amdgpu_device_baco_enter/exit
Check return value of amdgpu_device_baco_enter/exit and print warning message because these errors may cause runtime resume failure
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -2
@@ -2705,7 +2705,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* nothing to do */ }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_enter (drm_dev); + ret =amdgpu_device_baco_enter (drm_dev); +if (ret) +dev_warn (&pdev->dev,"warning: device fails to enter baco. ret=%d\n" , ret); }dev_dbg (&pdev->dev,"asic/device is runtime suspended\n" );
@@ -2745,7 +2747,9 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)*/ pci_set_master (pdev); }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_exit (drm_dev); + ret =amdgpu_device_baco_exit (drm_dev); +if (ret) +dev_warn (&pdev->dev,"warning: device fails to exit from baco. ret=%d\n" , ret); } ret =amdgpu_device_resume (drm_dev, false);if (ret) {
Signature · 1 line
2.34.1
Re: [PATCH 2/2] drm/amgpu: Check return value of amdgpu_device_baco_enter/exit
Quoted 13 lines · Ma Jun
Check return value of amdgpu_device_baco_enter/exit and print warning message because these errors may cause runtime resume failure
Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 2711
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-1@@ -2705,7 +2705,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* nothing to do */ }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_enter (drm_dev); + ret =amdgpu_device_baco_enter (drm_dev); +if (ret) +dev_warn (&pdev->dev,"warning: device fails to enter baco. ret=%d\n" , ret); }
If the intention is to print for any baco entry/exit failure, it's better to put the print inside enter/exit functions itself. Also, since these are triggered through PMFW, any PMFW fail will be printed. So this may not be that useful.
Thanks,
Lijo
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-1dev_dbg (&pdev->dev,"asic/device is runtime suspended\n" );@@ -2745,7 +2747,9 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)*/ pci_set_master (pdev); }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_exit (drm_dev); + ret =amdgpu_device_baco_exit (drm_dev); +if (ret) +dev_warn (&pdev->dev,"warning: device fails to exit from baco. ret=%d\n" , ret); } ret =amdgpu_device_resume (drm_dev, false);if (ret) {
Re: [PATCH 2/2] drm/amgpu: Check return value of amdgpu_device_baco_enter/exit
Quoted 21 lines · Lijo
Quoted 18 lines · Ma Jun
Check return value of amdgpu_device_baco_enter/exit and print warning message because these errors may cause runtime resume failure
Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1@@ -2705,7 +2705,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* nothing to do */ }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_enter (drm_dev); + ret =amdgpu_device_baco_enter (drm_dev);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 2711
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-0+if (ret) +dev_warn (&pdev->dev,"warning: device fails to enter baco. ret=%d\n" , ret); }If the intention is to print for any baco entry/exit failure, it's better to put the print inside enter/exit functions itself. Also, since these are triggered through PMFW, any PMFW fail will be printed. So this may not be that useful.
Thanks, I will move it into enter/exit functions.
This check is mainly used for other error cases not for PMFW failure.
Regards,
Ma Jun
Quoted 16 lines
Thanks,
LijoQuoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3
-1dev_dbg (&pdev->dev,"asic/device is runtime suspended\n" );@@ -2745,7 +2747,9 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)*/ pci_set_master (pdev); }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) { -amdgpu_device_baco_exit (drm_dev); + ret =amdgpu_device_baco_exit (drm_dev); +if (ret) +dev_warn (&pdev->dev,"warning: device fails to exit from baco. ret=%d\n" , ret); } ret =amdgpu_device_resume (drm_dev, false);if (ret) {
Quoted 5 lines · Ma Jun
Because the
rpm_modeflag is already set when the driver is initialized, we use it directly for runtime suspend/resume instead of checking it againSigned-off-by Ma Jun <[email protected]>
Thanks,
Lijo
Quoted 93 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12
-12@@ -2666,7 +2666,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) } adev->in_runpm = true; -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/* @@ -2676,7 +2676,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)* platforms. * TODO: this may be also needed for PX capable platform. */ -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_UNLOAD ; ret =amdgpu_device_prepare (drm_dev);@@ -2685,15 +2685,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ret =amdgpu_device_suspend (drm_dev, false);if (ret) { adev->in_runpm = false; -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_NONE ;return ret; } -if (amdgpu_device_supports_boco (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) adev->mp1_state =PP_MP1_STATE_NONE ; -if (amdgpu_device_supports_px (drm_dev)) { +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */ @@ -2702,9 +2702,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)pci_ignore_hotplug (pdev);pci_set_power_state (pdev, PCI_D3cold); drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ; - }else if (amdgpu_device_supports_boco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* nothing to do */ - }else if (amdgpu_device_supports_baco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) {amdgpu_device_baco_enter (drm_dev); }@@ -2727,7 +2727,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (!pci_device_is_present (adev->pdev)) adev->no_hw_access = true; -if (amdgpu_device_supports_px (drm_dev)) { +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) { drm_dev->switch_power_state =DRM_SWITCH_POWER_CHANGING ;/* Only need to handle PCI state in the driver for ATPX @@ -2739,22 +2739,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)if (ret)return ret;pci_set_master (pdev); - }else if (amdgpu_device_supports_boco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BOCO ) {/* Only need to handle PCI state in the driver for ATPX * PCI core handles it for _PR3. */ pci_set_master (pdev); - }else if (amdgpu_device_supports_baco (drm_dev)) { + }else if (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ) {amdgpu_device_baco_exit (drm_dev); } ret =amdgpu_device_resume (drm_dev, false);if (ret) { -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX )pci_disable_device (pdev);return ret; } -if (amdgpu_device_supports_px (drm_dev)) +if (adev->pm.rpm_mode ==AMDGPU_RUNPM_PX ) drm_dev->switch_power_state =DRM_SWITCH_POWER_ON ; adev->in_runpm = false;return 0 ;