From: kettenis Date: Fri, 16 Aug 2024 10:26:20 +0000 (+0000) Subject: drm/amd: Stop evicting resources on APUs in suspend X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8571a5a71f50506094a484ba40500378c39e27e8;p=openbsd drm/amd: Stop evicting resources on APUs in suspend From Mario Limonciello 3a9626c816db901def438dc2513622e281186d39 in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h index 38a424f16fb..92ad570c233 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu.h @@ -1487,9 +1487,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_is_s0ix_active(struct amdgpu_device *adev); +void amdgpu_choose_low_power_state(struct amdgpu_device *adev); #else static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; } static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; } +static inline void amdgpu_choose_low_power_state(struct amdgpu_device *adev) { } #endif #if defined(CONFIG_DRM_AMD_DC) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c index f2124826dc5..e13a31e63a4 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_acpi.c @@ -1541,4 +1541,19 @@ bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) #endif /* CONFIG_AMD_PMC */ } +/** + * amdgpu_choose_low_power_state + * + * @adev: amdgpu_device_pointer + * + * Choose the target low power state for the GPU + */ +void amdgpu_choose_low_power_state(struct amdgpu_device *adev) +{ + if (amdgpu_acpi_is_s0ix_active(adev)) + adev->in_s0ix = true; + else if (amdgpu_acpi_is_s3_active(adev)) + adev->in_s3 = true; +} + #endif /* CONFIG_SUSPEND */ diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c index 948b0fe0765..2c2bb603522 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c @@ -4221,13 +4221,15 @@ int amdgpu_device_prepare(struct drm_device *dev) struct amdgpu_device *adev = drm_to_adev(dev); int i, r; + amdgpu_choose_low_power_state(adev); + if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) return 0; /* Evict the majority of BOs before starting suspend sequence */ r = amdgpu_device_evict_resources(adev); if (r) - return r; + goto unprepare; flush_delayed_work(&adev->gfx.gfx_off_delay_work); @@ -4238,10 +4240,15 @@ int amdgpu_device_prepare(struct drm_device *dev) continue; r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev); if (r) - return r; + goto unprepare; } return 0; + +unprepare: + adev->in_s0ix = adev->in_s3 = false; + + return r; } /**