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>
void amdgpu_coredump_init(struct amdgpu_device *adev)
{
}
+void amdgpu_coredump_fini(struct amdgpu_device *adev)
+{
+}
#else
#define AMDGPU_CORE_DUMP_SIZE_MAX (256 * 1024 * 1024)
{
INIT_WORK(&adev->coredump_work, amdgpu_devcoredump_deferred_work);
}
+
+void amdgpu_coredump_fini(struct amdgpu_device *adev)
+{
+ /* Finish deferred coredump formatting before HW/IP teardown. */
+ flush_work(&adev->coredump_work);
+}
#endif
void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
bool vram_lost, struct amdgpu_job *job);
void amdgpu_coredump_init(struct amdgpu_device *adev);
+void amdgpu_coredump_fini(struct amdgpu_device *adev);
#endif
if (pci_dev_is_disconnected(adev->pdev))
amdgpu_amdkfd_device_fini_sw(adev);
+ amdgpu_coredump_fini(adev);
amdgpu_device_ip_fini_early(adev);
amdgpu_irq_fini_hw(adev);