summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/powerplay/smumgr
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2020-03-27 11:20:29 +0800
committerAlex Deucher <alexander.deucher@amd.com>2020-04-01 14:44:45 -0400
commit6b6706cdaca344a9279fe124bf87da040f5711fb (patch)
treee8c1ae27bdad8db082f5454af5cb323748f1b9cd /drivers/gpu/drm/amd/powerplay/smumgr
parenta0ec225633d9f681e393a1827f29f02c837deb84 (diff)
downloadlwn-6b6706cdaca344a9279fe124bf87da040f5711fb.tar.gz
lwn-6b6706cdaca344a9279fe124bf87da040f5711fb.zip
drm/amd/powerplay: added mutex protection on msg issuing
This could avoid the possible race condition. Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/powerplay/smumgr')
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index 3bb0392994ec..b6fb48066841 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -136,13 +136,19 @@ int smum_send_msg_to_smc(struct pp_hwmgr *hwmgr, uint16_t msg, uint32_t *resp)
(resp && !hwmgr->smumgr_funcs->get_argument))
return -EINVAL;
+ mutex_lock(&hwmgr->msg_lock);
+
ret = hwmgr->smumgr_funcs->send_msg_to_smc(hwmgr, msg);
- if (ret)
+ if (ret) {
+ mutex_unlock(&hwmgr->msg_lock);
return ret;
+ }
if (resp)
*resp = hwmgr->smumgr_funcs->get_argument(hwmgr);
+ mutex_unlock(&hwmgr->msg_lock);
+
return ret;
}
@@ -158,14 +164,20 @@ int smum_send_msg_to_smc_with_parameter(struct pp_hwmgr *hwmgr,
(resp && !hwmgr->smumgr_funcs->get_argument))
return -EINVAL;
+ mutex_lock(&hwmgr->msg_lock);
+
ret = hwmgr->smumgr_funcs->send_msg_to_smc_with_parameter(
hwmgr, msg, parameter);
- if (ret)
+ if (ret) {
+ mutex_unlock(&hwmgr->msg_lock);
return ret;
+ }
if (resp)
*resp = hwmgr->smumgr_funcs->get_argument(hwmgr);
+ mutex_unlock(&hwmgr->msg_lock);
+
return ret;
}