drm/amdgpu: Handle xgmi device removal.
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Thu, 29 Nov 2018 17:21:53 +0000 (12:21 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 3 Dec 2018 16:15:08 +0000 (11:15 -0500)
XGMI hive has some resources allocted on device init which
needs to be deallocated when the device is unregistered.

v2: Remove creation of dedicated wq for XGMI hive reset.
v3: Use the gmc.xgmi.supported flag

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h

index c75badfa5c4c6d752ec0e51e82186ef6f381cea5..bfd286c406317ea5df91311031b7748b93100661 100644 (file)
@@ -1864,6 +1864,9 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 {
        int i, r;
 
+       if (adev->gmc.xgmi.num_physical_nodes > 1)
+               amdgpu_xgmi_remove_device(adev);
+
        amdgpu_amdkfd_device_fini(adev);
 
        amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
index f8c86d0593dd6845f8c49e6289bdc2fbf21d9a72..1b15ff3266b18901e9ddb5bf3ac58ea5f0b20efc 100644 (file)
@@ -135,3 +135,23 @@ exit:
        mutex_unlock(&xgmi_mutex);
        return ret;
 }
+
+void amdgpu_xgmi_remove_device(struct amdgpu_device *adev)
+{
+       struct amdgpu_hive_info *hive;
+
+       if (!adev->gmc.xgmi.supported)
+               return;
+
+       mutex_lock(&xgmi_mutex);
+
+       hive = amdgpu_get_xgmi_hive(adev);
+       if (!hive)
+               goto exit;
+
+       if (!(hive->number_devices--))
+               mutex_destroy(&hive->hive_lock);
+
+exit:
+       mutex_unlock(&xgmi_mutex);
+}
index 6335bfdcc51dc6ec4b5fa02dda48b2068e0d3318..6151eb9c8ad30bbcaf54eacbcd67b649a7b4fa5a 100644 (file)
@@ -35,5 +35,6 @@ struct amdgpu_hive_info {
 struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev);
 int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev);
 int amdgpu_xgmi_add_device(struct amdgpu_device *adev);
+void amdgpu_xgmi_remove_device(struct amdgpu_device *adev);
 
 #endif