Skip to contentSkip to conversation

drm/amd/powerplay: fix a couple locking issues

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 3, 2017

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

PATCH 2/2 drm/amd/powerplay: fix a couple locking issues

We should return unlock on the error path in pp_dpm_dispatch_tasks() and there is a double lock bug in pp_dpm_set_sclk_od().

Fixes 2a5071056e6a ("drm/amd/powerplay: add global PowerPlay mutex.")
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +5 -3
index 260b732be7c3..e59b5627d543 100644
@@ -493,8 +493,10 @@ static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_event event_id,
 	{
 		enum amd_pm_state_type  ps;
 
-		if (input == NULL)
-			return -EINVAL;
+		if (input == NULL) {
+			ret = -EINVAL;
+			break;
+		}
 		ps = *(unsigned long *)input;
 
 		data.requested_ui_label = power_state_convert(ps);
@@ -897,7 +899,7 @@ static int pp_dpm_set_sclk_od(void *handle, uint32_t value)
 
 	mutex_lock(&pp_handle->pp_lock);
 	ret = hwmgr->hwmgr_func->set_sclk_od(hwmgr, value);
-	mutex_lock(&pp_handle->pp_lock);
+	mutex_unlock(&pp_handle->pp_lock);
 	return ret;
 }
 
Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

We should return unlock on the error path in pp_dpm_dispatch_tasks() and there is a double lock bug in pp_dpm_set_sclk_od().

Fixes 2a5071056e6a ("drm/amd/powerplay: add global PowerPlay mutex.")

Applied. thanks!

Alex

Quoted 27 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +5 -3
index 260b732be7c3..e59b5627d543 100644
@@ -493,8 +493,10 @@ static int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_event event_id,
        {
                enum amd_pm_state_type  ps;
 
-               if (input == NULL)
-                       return -EINVAL;
+               if (input == NULL) {
+                       ret = -EINVAL;
+                       break;
+               }
                ps = *(unsigned long *)input;
 
                data.requested_ui_label = power_state_convert(ps);
@@ -897,7 +899,7 @@ static int pp_dpm_set_sclk_od(void *handle, uint32_t value)
 
        mutex_lock(&pp_handle->pp_lock);
        ret = hwmgr->hwmgr_func->set_sclk_od(hwmgr, value);
-       mutex_lock(&pp_handle->pp_lock);
+       mutex_unlock(&pp_handle->pp_lock);
        return ret;
 }
 
Quoted 4 lines

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

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