DCN 3.1.4 s2idle entry will hang occasionally on s2idle entry, but only if running Wayland and only when using `systemctl suspend`, not `echo mem | tee /sys/power/state`. This happens because using `systemctl suspend` will cause the screen to lock right before writing mem into /sys/power/state. Userspace calls an IOCTL that leads to gpu_clock_counter(). This causes a delayed GFXOFF entry to be scheduled right before s2idle entry. If the workqueue doesn't get processed before the RLC is turned off the system is hung. Even if the workqueue *does* get processed, there is a race between the APU microcontrollers and driver for whether GFX is actually powered off when RLC is turned off. To avoid this issue, flush the workqueue on s2idle entry and ensure that GFX is really in GFXOFF before any sensitive register accesses occur. NOTE: This main trigger for this issue (IOCTL reading GPU clocks at suspend) is solved in amd-staging-drm-next via these commits: 5591a051b86b ("drm/amdgpu: refine get gpu clock counter method") ea27ee2bea6b ("drm/amdgpu/gfx11: update gpu_clock_counter logic") As GFXOFF can still be triggered in other ways, this series helps to improve the robustness. It was tested both with and without those commits present. v2->v3: * Remove dead code * Apply the logic to wait for matching GFXOFF state to more ASICs * Move code for IMU enabled ASICs to other files Mario Limonciello (4): drm/amd: Flush any delayed gfxoff on suspend entry drm/amd: Validate gfxoff state for smu10 drm/amd: Validate gfxoff state for smu12 drm/amd: Validate gfxoff state for smu13 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 9 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_imu.h | 1 + drivers/gpu/drm/amd/amdgpu/imu_v11_0.c | 10 ++++ .../drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c | 57 +++++++++---------- .../gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c | 26 +++++---- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 42 ++++++++++---- 7 files changed, 88 insertions(+), 58 deletions(-) -- 2.34.1