add missing mutex lock to amdgpu_get_xgmi_hive()
Subsystems (2)
PATCH 1/1 add missing mutex lock to amdgpu_get_xgmi_hive()
Signed-off-by Tom St Denis <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +11 -2
@@ -47,13 +47,20 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)if (!adev->gmc.xgmi.hive_id)return NULL ; + +mutex_lock (&xgmi_mutex); +for (i =0 ; i < hive_count; ++i) { tmp = &xgmi_hives[i]; -if (tmp->hive_id == adev->gmc.xgmi.hive_id) +if (tmp->hive_id == adev->gmc.xgmi.hive_id) { +mutex_unlock (&xgmi_mutex);return tmp; + } } -if (i >=AMDGPU_MAX_XGMI_HIVE ) +if (i >=AMDGPU_MAX_XGMI_HIVE ) { +mutex_unlock (&xgmi_mutex);return NULL ; + }/* initialize new hive if not exist */ tmp = &xgmi_hives[hive_count++];
@@ -61,6 +68,8 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)INIT_LIST_HEAD (&tmp->device_list);mutex_init (&tmp->hive_lock); +mutex_unlock (&xgmi_mutex); +return tmp; }
Signature · 6 lines
2.17.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Self NAK this ... calling functions take the same lock....
We should remove the locks from the callers so this function is thread safe on its own...
Tom
Quoted 34 lines · Tom
Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +9
-2@@ -47,13 +47,20 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)if (!adev->gmc.xgmi.hive_id)return NULL ; + +mutex_lock (&xgmi_mutex); +for (i =0 ; i < hive_count; ++i) { tmp = &xgmi_hives[i]; -if (tmp->hive_id == adev->gmc.xgmi.hive_id) +if (tmp->hive_id == adev->gmc.xgmi.hive_id) { +mutex_unlock (&xgmi_mutex);return tmp; + } } -if (i >=AMDGPU_MAX_XGMI_HIVE ) +if (i >=AMDGPU_MAX_XGMI_HIVE ) { +mutex_unlock (&xgmi_mutex);return NULL ; + }/* initialize new hive if not exist */ tmp = &xgmi_hives[hive_count++];
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) · line 75
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2
-0@@ -61,6 +68,8 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)INIT_LIST_HEAD (&tmp->device_list);mutex_init (&tmp->hive_lock); +mutex_unlock (&xgmi_mutex); +return tmp; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx