aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>2018-11-29 12:21:53 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-12-03 11:15:08 -0500
commita82400b57abb6aff068bb3b21d1cccd63acbb863 (patch)
tree69a85209edb417f47210e3cccde644d0b88a25a4
parent38cd8a280d725cd4e0be14b0fbc2797c26cd9de5 (diff)
drm/amdgpu: Handle xgmi device removal.
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>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c20
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h1
3 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c75badfa5c4c..bfd286c40631 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1864,6 +1864,9 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
1864{ 1864{
1865 int i, r; 1865 int i, r;
1866 1866
1867 if (adev->gmc.xgmi.num_physical_nodes > 1)
1868 amdgpu_xgmi_remove_device(adev);
1869
1867 amdgpu_amdkfd_device_fini(adev); 1870 amdgpu_amdkfd_device_fini(adev);
1868 1871
1869 amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE); 1872 amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index f8c86d0593dd..1b15ff3266b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -135,3 +135,23 @@ exit:
135 mutex_unlock(&xgmi_mutex); 135 mutex_unlock(&xgmi_mutex);
136 return ret; 136 return ret;
137} 137}
138
139void amdgpu_xgmi_remove_device(struct amdgpu_device *adev)
140{
141 struct amdgpu_hive_info *hive;
142
143 if (!adev->gmc.xgmi.supported)
144 return;
145
146 mutex_lock(&xgmi_mutex);
147
148 hive = amdgpu_get_xgmi_hive(adev);
149 if (!hive)
150 goto exit;
151
152 if (!(hive->number_devices--))
153 mutex_destroy(&hive->hive_lock);
154
155exit:
156 mutex_unlock(&xgmi_mutex);
157}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
index 6335bfdcc51d..6151eb9c8ad3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
@@ -35,5 +35,6 @@ struct amdgpu_hive_info {
35struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev); 35struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev);
36int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev); 36int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev);
37int amdgpu_xgmi_add_device(struct amdgpu_device *adev); 37int amdgpu_xgmi_add_device(struct amdgpu_device *adev);
38void amdgpu_xgmi_remove_device(struct amdgpu_device *adev);
38 39
39#endif 40#endif