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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: flush coredump work before HW teardown

In amdgpu_device_fini_hw(), deferred coredump formatting work may still
be pending when hardware and IP components are being torn down. Since
the work may access device registers and memory that will be freed or
powered off, it must be completed before proceeding.

Add a flush_work() call for adev->coredump_work, guarded by
CONFIG_DEV_COREDUMP, to ensure any pending coredump work finishes
before the device enters the early IP fini stage.

This avoids potential use-after-free or accessing hardware resources
that are no longer available.

Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Suggested-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Jesse Zhang <jesse.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Jesse Zhang and committed by
Alex Deucher
bf890910 557fa5a4

+11
+9
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
··· 35 35 void amdgpu_coredump_init(struct amdgpu_device *adev) 36 36 { 37 37 } 38 + void amdgpu_coredump_fini(struct amdgpu_device *adev) 39 + { 40 + } 38 41 #else 39 42 40 43 #define AMDGPU_CORE_DUMP_SIZE_MAX (256 * 1024 * 1024) ··· 442 439 void amdgpu_coredump_init(struct amdgpu_device *adev) 443 440 { 444 441 INIT_WORK(&adev->coredump_work, amdgpu_devcoredump_deferred_work); 442 + } 443 + 444 + void amdgpu_coredump_fini(struct amdgpu_device *adev) 445 + { 446 + /* Finish deferred coredump formatting before HW/IP teardown. */ 447 + flush_work(&adev->coredump_work); 445 448 } 446 449 #endif
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
··· 50 50 void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check, 51 51 bool vram_lost, struct amdgpu_job *job); 52 52 void amdgpu_coredump_init(struct amdgpu_device *adev); 53 + void amdgpu_coredump_fini(struct amdgpu_device *adev); 53 54 #endif
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 4225 4225 if (pci_dev_is_disconnected(adev->pdev)) 4226 4226 amdgpu_amdkfd_device_fini_sw(adev); 4227 4227 4228 + amdgpu_coredump_fini(adev); 4228 4229 amdgpu_device_ip_fini_early(adev); 4229 4230 4230 4231 amdgpu_irq_fini_hw(adev);