Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Fix GFX hang on SteamDeck when amdgpu is reloaded

When trying to unload amdgpu in the SteamDeck (TTY mode), the following
set of errors happens and the system gets unstable:

[..]
[drm] Initialized amdgpu 3.64.0 for 0000:04:00.0 on minor 0
amdgpu 0000:04:00.0: [drm:amdgpu_ib_ring_tests [amdgpu]] *ERROR* IB test failed on gfx_0.0.0 (-110).
amdgpu 0000:04:00.0: amdgpu: ib ring test failed (-110).
[..]
amdgpu 0000:04:00.0: amdgpu: SMU: I'm not done with your previous command: SMN_C2PMSG_66:0x0000001E SMN_C2PMSG_82:0x00000000
amdgpu 0000:04:00.0: amdgpu: Failed to disable gfxoff!
amdgpu 0000:04:00.0: amdgpu: SMU: I'm not done with your previous command: SMN_C2PMSG_66:0x0000001E SMN_C2PMSG_82:0x00000000
amdgpu 0000:04:00.0: amdgpu: Failed to disable gfxoff!
[..]

When the driver initializes the GPU, the PSP validates all the firmware
loaded, and after that, it is not possible to load any other firmware
unless the device is reset. What is happening in the load/unload
situation is that PSP halts the GC engine because it suspects that
something is amiss. To address this issue, this commit ensures that the
GPU is reset (mode 2 reset) in the unload sequence.

Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Rodrigo Siqueira and committed by
Alex Deucher
34355e61 e12603bf

+14
+14
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 3681 3681 "failed to release exclusive mode on fini\n"); 3682 3682 } 3683 3683 3684 + /* 3685 + * Driver reload on the APU can fail due to firmware validation because 3686 + * the PSP is always running, as it is shared across the whole SoC. 3687 + * This same issue does not occur on dGPU because it has a mechanism 3688 + * that checks whether the PSP is running. A solution for those issues 3689 + * in the APU is to trigger a GPU reset, but this should be done during 3690 + * the unload phase to avoid adding boot latency and screen flicker. 3691 + */ 3692 + if ((adev->flags & AMD_IS_APU) && !adev->gmc.is_app_apu) { 3693 + r = amdgpu_asic_reset(adev); 3694 + if (r) 3695 + dev_err(adev->dev, "asic reset on %s failed\n", __func__); 3696 + } 3697 + 3684 3698 return 0; 3685 3699 } 3686 3700