Commit 86e14a73 authored by Ma Jun's avatar Ma Jun Committed by Alex Deucher

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
Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f317c5e5
...@@ -2693,7 +2693,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ...@@ -2693,7 +2693,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
} }
adev->in_runpm = true; 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; drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
/* /*
...@@ -2703,7 +2703,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ...@@ -2703,7 +2703,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
* platforms. * platforms.
* TODO: this may be also needed for PX capable platform. * 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; adev->mp1_state = PP_MP1_STATE_UNLOAD;
ret = amdgpu_device_prepare(drm_dev); ret = amdgpu_device_prepare(drm_dev);
...@@ -2712,15 +2712,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ...@@ -2712,15 +2712,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
ret = amdgpu_device_suspend(drm_dev, false); ret = amdgpu_device_suspend(drm_dev, false);
if (ret) { if (ret) {
adev->in_runpm = false; 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; adev->mp1_state = PP_MP1_STATE_NONE;
return ret; return ret;
} }
if (amdgpu_device_supports_boco(drm_dev)) if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
adev->mp1_state = PP_MP1_STATE_NONE; 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 /* Only need to handle PCI state in the driver for ATPX
* PCI core handles it for _PR3. * PCI core handles it for _PR3.
*/ */
...@@ -2729,9 +2729,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) ...@@ -2729,9 +2729,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
pci_ignore_hotplug(pdev); pci_ignore_hotplug(pdev);
pci_set_power_state(pdev, PCI_D3cold); pci_set_power_state(pdev, PCI_D3cold);
drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF; 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 */ /* 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); amdgpu_device_baco_enter(drm_dev);
} }
...@@ -2754,7 +2754,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) ...@@ -2754,7 +2754,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
if (!pci_device_is_present(adev->pdev)) if (!pci_device_is_present(adev->pdev))
adev->no_hw_access = true; 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; drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
/* Only need to handle PCI state in the driver for ATPX /* Only need to handle PCI state in the driver for ATPX
...@@ -2766,22 +2766,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev) ...@@ -2766,22 +2766,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
if (ret) if (ret)
return ret; return ret;
pci_set_master(pdev); 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 /* Only need to handle PCI state in the driver for ATPX
* PCI core handles it for _PR3. * PCI core handles it for _PR3.
*/ */
pci_set_master(pdev); 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); amdgpu_device_baco_exit(drm_dev);
} }
ret = amdgpu_device_resume(drm_dev, false); ret = amdgpu_device_resume(drm_dev, false);
if (ret) { if (ret) {
if (amdgpu_device_supports_px(drm_dev)) if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
pci_disable_device(pdev); pci_disable_device(pdev);
return ret; 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; drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
adev->in_runpm = false; adev->in_runpm = false;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment