Skip to contentSkip to conversation

drm/amd/powerplay: add smu message mutex

PATCH In review Xiao, Jack 1 participant 2 messages Jun 3, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Xiao, Jack

author
#0 lore raw

PATCH 1/1 drm/amd/powerplay: add smu message mutex

Add smu message mutex preventing against race condition issue.

---
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 +
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c      | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index 3eb1de9..735233e 100644
@@ -374,6 +374,7 @@ struct smu_context
 	const struct smu_funcs		*funcs;
 	const struct pptable_funcs	*ppt_funcs;
 	struct mutex			mutex;
+	struct mutex			msg_mutex;
 	uint64_t pool_size;
 
 	struct smu_table_context	smu_table;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -1
index d2eeb62..de737a0 100644
@@ -104,6 +104,8 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
 	if (index < 0)
 		return index;
 
+	mutex_lock(&smu->msg_mutex);
+
 	smu_v11_0_wait_for_response(smu);
 
 	WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
@@ -111,11 +113,11 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
 	smu_v11_0_send_msg_without_waiting(smu, (uint16_t)index);
 
 	ret = smu_v11_0_wait_for_response(smu);
-
 	if (ret)
 		pr_err("Failed to send message 0x%x, response 0x%x\n", index,
 		       ret);
 
+	mutex_unlock(&smu->msg_mutex);
 	return ret;
 
 }
@@ -132,6 +134,8 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
 	if (index < 0)
 		return index;
 
+	mutex_lock(&smu->msg_mutex);
+
 	ret = smu_v11_0_wait_for_response(smu);
 	if (ret)
 		pr_err("Failed to send message 0x%x, response 0x%x, param 0x%x\n",
@@ -148,6 +152,7 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
 		pr_err("Failed to send message 0x%x, response 0x%x param 0x%x\n",
 		       index, ret, param);
 
+	mutex_unlock(&smu->msg_mutex);
 	return ret;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
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): 1559542302-17573-1-git-send-email-Jack.Xiao-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

Drop it due to a modification was missing.
A new patch was sent out.

-----Original Message-----
From: Xiao, Jack <[email protected]>
Sent: Monday, June 03, 2019 2:12 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Cc: Xiao, Jack <[email protected]>
Subject: [PATCH] drm/amd/powerplay: add smu message mutex

Add smu message mutex preventing against race condition issue.

---
 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 +
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c      | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index 3eb1de9..735233e 100644
@@ -374,6 +374,7 @@ struct smu_context
 	const struct smu_funcs		*funcs;
 	const struct pptable_funcs	*ppt_funcs;
 	struct mutex			mutex;
+	struct mutex			msg_mutex;
 	uint64_t pool_size;
 
 	struct smu_table_context	smu_table;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +2 -0
index d2eeb62..de737a0 100644
@@ -104,6 +104,8 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
 	if (index < 0)
 		return index;
 
+	mutex_lock(&smu->msg_mutex);
+
 	smu_v11_0_wait_for_response(smu);
 
 	WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0); @@ -111,11 +113,11 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)

smu_v11_0_send_msg_without_waiting(smu, (uint16_t)index);

ret = smu_v11_0_wait_for_response(smu);
-
if (ret)
pr_err("Failed to send message 0x%x, response 0x%x\n", index,
ret);

+ mutex_unlock(&smu->msg_mutex);
return ret;

}
@@ -132,6 +134,8 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg)
if (index < 0)
return index;

+ mutex_lock(&smu->msg_mutex);
+
ret = smu_v11_0_wait_for_response(smu);
if (ret)
pr_err("Failed to send message 0x%x, response 0x%x, param 0x%x\n", @@ -148,6 +152,7 @@ static int smu_v11_0_send_msg(struct smu_context *smu, uint16_t msg) pr_err("Failed to send message 0x%x, response 0x%x param 0x%x\n",
index, ret, param);

+ mutex_unlock(&smu->msg_mutex);
return ret;
}

--
1.9.1

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