Skip to contentSkip to conversation

drm/amd: Clean up kfd node on surprise disconnect

PATCH In review Mario Limonciello (AMD) 2 participants 2 messages Jan 6 – Jan 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Clean up kfd node on surprise disconnect

When an eGPU is unplugged the KFD topology should also be destroyed for that GPU. This never happens because the fini_sw callbacks never get to run. Run them manually at the end of amdgpu_device_fini_hw() when a device is already disconnected.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 021ecc988ff79..4bac0d25547f2 100644
@@ -5263,6 +5263,9 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
 	if (drm_dev_is_unplugged(adev_to_drm(adev)))
 		amdgpu_device_unmap_mmio(adev);
 
+	/* surprise hotplug */
+	if (pci_dev_is_disconnected(adev->pdev))
+		amdgpu_amdkfd_device_fini_sw(adev);
 }
 
 void amdgpu_device_fini_sw(struct amdgpu_device *adev)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

[Public]

Seems like a good start for the issue linked there.

Quoted 37 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Mario Limonciello (AMD)
Sent: Monday, January 5, 2026 11:39 PM
To: [email protected]
Cc: Mario Limonciello (AMD) <[email protected]>
Subject: [PATCH] drm/amd: Clean up kfd node on surprise disconnect

When an eGPU is unplugged the KFD topology should also be destroyed for that GPU. This never happens because the fini_sw callbacks never get to run. Run them manually at the end of amdgpu_device_fini_hw() when a device is already disconnected.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 021ecc988ff79..4bac0d25547f2 100644
@@ -5263,6 +5263,9 @@ void amdgpu_device_fini_hw(struct amdgpu_device
 *adev)
      if (drm_dev_is_unplugged(adev_to_drm(adev)))
              amdgpu_device_unmap_mmio(adev);
 
+     /* surprise hotplug */
+     if (pci_dev_is_disconnected(adev->pdev))
+             amdgpu_amdkfd_device_fini_sw(adev);
 }
 

void amdgpu_device_fini_sw(struct amdgpu_device *adev)
--
2.43.0