Skip to contentSkip to conversation

drm/amdgpu: unlock mutex on error

PATCH In review Dennis Li 2 participants 2 messages Aug 6, 2020

Subsystems (3)
lore
Share & tools
lore

Dennis Li

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: unlock mutex on error

Make sure to unlock the mutex when error happen

v2:
1. correct syntax error in the commit comment
2. remove change-Id

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -2
index a0ea663ecdbc..5e5369abc6fa 100644
@@ -632,13 +632,14 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
 	}
 
 	ret = amdgpu_ib_schedule(ring, 1, ib, job, &f);
+
+	up_read(&adev->reset_sem);
+
 	if (ret) {
 		DRM_ERROR("amdgpu: failed to schedule IB.\n");
 		goto err_ib_sched;
 	}
 
-	up_read(&adev->reset_sem);
-
 	ret = dma_fence_wait(f, false);
 
 err_ib_sched:
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +3 -3
index 4e017f379eb6..67a756f4337b 100644
@@ -545,7 +545,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 			}
 			ret = amdgpu_xgmi_update_topology(hive, tmp_adev);
 			if (ret)
-				goto exit;
+				goto exit_unlock;
 		}
 
 		/* get latest topology info for each device from psp */
@@ -558,7 +558,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 					tmp_adev->gmc.xgmi.node_id,
 					tmp_adev->gmc.xgmi.hive_id, ret);
 				/* To do : continue with some node failed or disable the whole hive */
-				goto exit;
+				goto exit_unlock;
 			}
 		}
 	}
@@ -566,7 +566,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 	if (!ret)
 		ret = amdgpu_xgmi_sysfs_add_dev_info(adev, hive);
 
-
+exit_unlock:
 	mutex_unlock(&hive->hive_lock);
 exit:
 	if (!ret)
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v2 1/1
#1 lore raw

Yes, that's fine. Thanks for fix.

Quoted 54 lines · Dennis Li

Make sure to unlock the mutex when error happen

v2:
1. correct syntax error in the commit comment
2. remove change-Id

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -2
index a0ea663ecdbc..5e5369abc6fa 100644
@@ -632,13 +632,14 @@ int amdgpu_amdkfd_submit_ib(struct kgd_dev *kgd, enum kgd_engine_type engine,
 	}
 
 	ret = amdgpu_ib_schedule(ring, 1, ib, job, &f);
+
+	up_read(&adev->reset_sem);
+
 	if (ret) {
 		DRM_ERROR("amdgpu: failed to schedule IB.\n");
 		goto err_ib_sched;
 	}
 
-	up_read(&adev->reset_sem);
-
 	ret = dma_fence_wait(f, false);
 
 err_ib_sched:
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +2 -2
index 4e017f379eb6..67a756f4337b 100644
@@ -545,7 +545,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 			}
 			ret = amdgpu_xgmi_update_topology(hive, tmp_adev);
 			if (ret)
-				goto exit;
+				goto exit_unlock;
 		}
 
 		/* get latest topology info for each device from psp */
@@ -558,7 +558,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 					tmp_adev->gmc.xgmi.node_id,
 					tmp_adev->gmc.xgmi.hive_id, ret);
 				/* To do : continue with some node failed or disable the whole hive */
-				goto exit;
+				goto exit_unlock;
 			}
 		}
 	}

drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c int amdgpu_xgmi_add_device(struct amdgpu_device *adev) · line 572

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +1 -1
@@ -566,7 +566,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
 	if (!ret)
 		ret = amdgpu_xgmi_sysfs_add_dev_info(adev, hive);
 
-
+exit_unlock:
 	mutex_unlock(&hive->hive_lock);
 exit:
 	if (!ret)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx