[PATCH 6/7] drm/amdgpu: clean up S0ix logic
Alex Deucher
alexander.deucher at amd.com
Tue Mar 9 04:10:11 UTC 2021
We only need special handling for the S0ix suspend and resume
cases, legacy S3/S4/shutdown/reboot/reset should use the
standard code pathes. This should fix systems with S0ix
plus legacy S4.
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ------
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 22 ++++++++++++----------
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ----
3 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 4ddc5cc983c7..bf9359ccf3da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1040,12 +1040,6 @@ struct amdgpu_device {
enum amdgpu_pmops_state pmops_state;
bool in_suspend;
- /*
- * The combination flag in_poweroff_reboot_com used to identify the poweroff
- * and reboot opt in the s0i3 system-wide suspend.
- */
- bool in_poweroff_reboot_com;
-
atomic_t in_gpu_reset;
enum pp_mp1_state mp1_state;
struct rw_semaphore reset_sem;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index ac5f7837285b..2b6e483259f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2680,9 +2680,10 @@ static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work)
static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
{
int i, r;
+ bool s0ix_suspend = amdgpu_acpi_is_s0ix_supported(adev) &&
+ (adev->pmops_state == AMDGPU_PMOPS_SUSPEND);
- if (adev->in_poweroff_reboot_com ||
- !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
+ if (!s0ix_suspend) {
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
}
@@ -3672,13 +3673,13 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
*/
int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
{
- struct amdgpu_device *adev;
+ struct amdgpu_device *adev = drm_to_adev(dev);
struct drm_crtc *crtc;
struct drm_connector *connector;
struct drm_connector_list_iter iter;
int r;
-
- adev = drm_to_adev(dev);
+ bool s0ix_suspend = amdgpu_acpi_is_s0ix_supported(adev) &&
+ (adev->pmops_state == AMDGPU_PMOPS_SUSPEND);
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
@@ -3741,11 +3742,10 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
amdgpu_fence_driver_suspend(adev);
- if (adev->in_poweroff_reboot_com ||
- !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
- r = amdgpu_device_ip_suspend_phase2(adev);
- else
+ if (s0ix_suspend)
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
+ else
+ r = amdgpu_device_ip_suspend_phase2(adev);
/* evict remaining vram memory
* This second call to evict vram is to evict the gart page table
* using the CPU.
@@ -3772,11 +3772,13 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
struct amdgpu_device *adev = drm_to_adev(dev);
struct drm_crtc *crtc;
int r = 0;
+ bool s0ix_resume = amdgpu_acpi_is_s0ix_supported(adev) &&
+ (adev->pmops_state == AMDGPU_PMOPS_RESUME);
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
- if (amdgpu_acpi_is_s0ix_supported(adev))
+ if (s0ix_resume)
amdgpu_gfx_state_change_set(adev, sGpuChangeState_D0Entry);
/* post card */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 0312c52bd39d..dd6d24305b16 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1288,9 +1288,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
*/
if (!amdgpu_passthrough(adev))
adev->mp1_state = PP_MP1_STATE_UNLOAD;
- adev->in_poweroff_reboot_com = true;
amdgpu_device_ip_suspend(adev);
- adev->in_poweroff_reboot_com = false;
adev->mp1_state = PP_MP1_STATE_NONE;
}
@@ -1380,9 +1378,7 @@ static int amdgpu_pmops_poweroff(struct device *dev)
int r;
adev->pmops_state = AMDGPU_PMOPS_POWEROFF;
- adev->in_poweroff_reboot_com = true;
r = amdgpu_device_suspend(drm_dev, true);
- adev->in_poweroff_reboot_com = false;
adev->pmops_state = AMDGPU_PMOPS_NONE;
return r;
}
--
2.29.2
More information about the amd-gfx
mailing list