diff mbox series

[v2] firmware: qcom_scm: Mark get_wq_ctx() as atomic call

Message ID 20240814223244.40081-1-quic_uchalich@quicinc.com (mailing list archive)
State Accepted
Headers show
Series [v2] firmware: qcom_scm: Mark get_wq_ctx() as atomic call | expand

Commit Message

Unnathi Chalicheemala Aug. 14, 2024, 10:32 p.m. UTC
From: Murali Nalajala <quic_mnalajal@quicinc.com>

Currently get_wq_ctx() is wrongly configured as a standard call. When two
SMC calls are in sleep and one SMC wakes up, it calls get_wq_ctx() to
resume the corresponding sleeping thread. But if get_wq_ctx() is
interrupted, goes to sleep and another SMC call is waiting to be allocated
a waitq context, it leads to a deadlock.

To avoid this get_wq_ctx() must be an atomic call and can't be a standard
SMC call. Hence mark get_wq_ctx() as a fast call.

Fixes: 6bf325992236 ("firmware: qcom: scm: Add wait-queue handling logic")
Cc: stable@vger.kernel.org
Signed-off-by: Murali Nalajala <quic_mnalajal@quicinc.com>
Signed-off-by: Unnathi Chalicheemala <quic_uchalich@quicinc.com>
Reviewed-by: Elliot Berman <quic_eberman@quicinc.com>
---
Changes in v2:
- Made commit message more clear.
- R-b tag from Elliot.
- Link to v1: https://lore.kernel.org/all/20240611-get_wq_ctx_atomic-v1-1-9189a0a7d1ba@quicinc.com/

 drivers/firmware/qcom/qcom_scm-smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bjorn Andersson Aug. 15, 2024, 8:40 p.m. UTC | #1
On Wed, 14 Aug 2024 15:32:44 -0700, Unnathi Chalicheemala wrote:
> Currently get_wq_ctx() is wrongly configured as a standard call. When two
> SMC calls are in sleep and one SMC wakes up, it calls get_wq_ctx() to
> resume the corresponding sleeping thread. But if get_wq_ctx() is
> interrupted, goes to sleep and another SMC call is waiting to be allocated
> a waitq context, it leads to a deadlock.
> 
> To avoid this get_wq_ctx() must be an atomic call and can't be a standard
> SMC call. Hence mark get_wq_ctx() as a fast call.
> 
> [...]

Applied, thanks!

[1/1] firmware: qcom_scm: Mark get_wq_ctx() as atomic call
      commit: 9960085a3a82c58d3323c1c20b991db6045063b0

Best regards,
diff mbox series

Patch

diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c
index dca5f3f1883b..2b4c2826f572 100644
--- a/drivers/firmware/qcom/qcom_scm-smc.c
+++ b/drivers/firmware/qcom/qcom_scm-smc.c
@@ -73,7 +73,7 @@  int scm_get_wq_ctx(u32 *wq_ctx, u32 *flags, u32 *more_pending)
 	struct arm_smccc_res get_wq_res;
 	struct arm_smccc_args get_wq_ctx = {0};
 
-	get_wq_ctx.args[0] = ARM_SMCCC_CALL_VAL(ARM_SMCCC_STD_CALL,
+	get_wq_ctx.args[0] = ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,
 				ARM_SMCCC_SMC_64, ARM_SMCCC_OWNER_SIP,
 				SCM_SMC_FNID(QCOM_SCM_SVC_WAITQ, QCOM_SCM_WAITQ_GET_WQ_CTX));