From: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Modify wait_for_wq_completion() to check if task is in idle state using
wait_for_completion_state().
This allows for detecting when waitq contexts are in idle state and
propagates it to __scm_smc_do(), which is beneficial when task is idle
and waiting for a kick to accept new requests.
Signed-off-by: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
---
drivers/firmware/qcom/qcom_scm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 0b6efa7c2bdc25a3ba152c25d5451d1154779ddd..38c1c8aff9fa3a90eca9dba700611dd12c4d82a5 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -2320,7 +2320,7 @@ int qcom_scm_wait_for_wq_completion(u32 wq_ctx)
if (IS_ERR(wq))
return PTR_ERR(wq);
- wait_for_completion(wq);
+ wait_for_completion_state(wq, TASK_IDLE);
return 0;
}
--
2.34.1
On Sun, Nov 2, 2025 at 9:19 AM Shivendra Pratap <shivendra.pratap@oss.qualcomm.com> wrote: > > From: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com> > > Modify wait_for_wq_completion() to check if task is in idle state using > wait_for_completion_state(). > This is not what's happening. wait_for_completion_state(comp, TASK_IDLE) puts the waiting task into TASK_IDLE state. It's not checking anything. > This allows for detecting when waitq contexts are in idle state and > propagates it to __scm_smc_do(), which is beneficial when task is idle > and waiting for a kick to accept new requests. > Could you elaborate on what benefit exactly this is giving us? It's not quite clear from this paragraph. Bart
On 11/3/2025 9:21 PM, Bartosz Golaszewski wrote: > On Sun, Nov 2, 2025 at 9:19 AM Shivendra Pratap > <shivendra.pratap@oss.qualcomm.com> wrote: >> >> From: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com> >> >> Modify wait_for_wq_completion() to check if task is in idle state using >> wait_for_completion_state(). >> > > This is not what's happening. wait_for_completion_state(comp, > TASK_IDLE) puts the waiting task into TASK_IDLE state. It's not > checking anything. sure. Will update the commit message. > >> This allows for detecting when waitq contexts are in idle state and >> propagates it to __scm_smc_do(), which is beneficial when task is idle >> and waiting for a kick to accept new requests. >> > > Could you elaborate on what benefit exactly this is giving us? It's > not quite clear from this paragraph. The TASK_IDLE state is introduced to handle scenarios where the kernel makes a Secure Monitor Call and the firmware requests the kernel to wait. During this wait, the thread typically enters an uninterruptible (D) state. If the firmware’s requested wait is long, and a device suspend request occurs during that time, the suspend cannot proceed because the task is stuck in the D state. To avoid blocking device suspend during these extended waits, the patch adds support for TASK_IDLE state. This allows the thread to wait without the device suspend. Will update the commit message. thanks, Shivendra
© 2016 - 2026 Red Hat, Inc.