diff options
| author | Jiaming Fan <fan.jiaming@hotmail.com> | 2026-11-10 15:15:26 +0000 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2026-11-18 01:45:37 -0500 |
| commit | be94997dd5558a0e53bee97306d659e9327dcab9 (patch) | |
| tree | d8b0b84d03f1a08c58017d6a3e4b78b60c9a1c81 /tools/perf/scripts/python | |
| parent | 53fc1be11892a8e695937fdbc24db2699d23dabf (diff) | |
drm/amdgpu: unwind module init on failure
amdgpu_init() registers the ATPX handler with vga_switcheroo and
allocates the ACPI XCC/NUMA info before it initializes KFD, but its
error paths do not undo any of that:
- when amdgpu_amdkfd_init() fails, only amdgpu_sync_fini() is called;
- when pci_register_driver() fails, its result is returned as is, so
KFD, the ATPX handler, the ACPI info and the sync slab cache are all
left behind.
A failed module init frees the module, so vga_switcheroo keeps a
pointer to a handler in freed memory and /dev/kfd keeps file operations
that point into it. A later amdgpu load cannot register its own ATPX
handler, and vga_switcheroo_enable() calls into the stale one.
The KFD path is easy to reach since KFD init failures are no longer
ignored: kfd_init() returns -EINVAL for an out of range sched_policy or
max_num_of_queues_per_device module parameter.
Unwind in the reverse order of initialization, starting from the last
step that succeeded, with the same calls and in the same order as
amdgpu_exit().
amdgpu_amdkfd_fini() is a no-op when KFD was not initialized, which
covers the ignored -ENOENT case, and amdgpu_unregister_atpx_handler()
only removes a handler that amdgpu registered itself.
Fixes: 4259a25341ab ("amdkfd: Only ignore -ENOENT for KFD init failuires")
Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c2c34905fb40d3bddae0d2539830975781715e25)
Cc: stable@vger.kernel.org
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
