From 296f9afa639485d84465a0cb2ad2975ec8887cc8 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Wed, 25 May 2022 12:29:13 +0000 Subject: drm/amd: Don't reset dGPUs if the system is going to s2idle From Mario Limonciello 9d3ec4e5bf032f53137e11075846cec9c474ce4b in linux 5.15.y/5.15.42 7123d39dc24dcd21ff23d75f46f926b15269b9da in mainline linux --- sys/dev/pci/drm/amd/amdgpu/amdgpu.h | 2 ++ sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c | 14 ++++++++++++++ sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h index 9920036a7d6..50d729abfe2 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h @@ -1440,9 +1440,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev, #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev); +bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev); bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev); #else static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } +static inline bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev) { return false; } static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; } #endif diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c index bdedf4f781a..970822d1a36 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c @@ -1058,6 +1058,20 @@ bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) (pm_suspend_target_state == PM_SUSPEND_MEM); } +/** + * amdgpu_acpi_should_gpu_reset + * + * @adev: amdgpu_device_pointer + * + * returns true if should reset GPU, false if not + */ +bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev) +{ + if (adev->flags & AMD_IS_APU) + return false; + return pm_suspend_target_state != PM_SUSPEND_TO_IDLE; +} + /** * amdgpu_acpi_is_s0ix_active * diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c index feaa32429d8..03a116fd55a 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c @@ -2263,7 +2263,7 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev) struct drm_device *drm_dev = dev_get_drvdata(dev); struct amdgpu_device *adev = drm_to_adev(drm_dev); - if (!adev->in_s0ix) + if (amdgpu_acpi_should_gpu_reset(adev)) return amdgpu_asic_reset(adev); return 0; -- cgit v1.2.3