mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel J Blueman <daniel@quora.org>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Bartosz Golaszewski <brgl@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel J Blueman <daniel@quora.org>
Subject: [PATCH] firmware: qcom: tzmem: use sleepable variant of DO_ONCE()
Date: Sat,  5 Sep 2026 11:04:41 +0800	[thread overview]
Message-ID: <20260905030450.34800-1-daniel@quora.org> (raw)

qcom_tzmem_enable() runs qcom_tzmem_init() using DO_ONCE(), taking
the once_lock spinlock. qcom_tzmem_init() subsequently takes the
qcom_scm_lock mutex, potentially sleeping holding the spinlock,
triggering:

  BUG: sleeping function called from invalid context at drivers/firmware/qcom/qcom_scm.c:334
  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 112, name: kworker/u49:4
  Call trace:
   __might_resched+0x378/0x698
   __might_sleep+0x9c/0x220
   qcom_scm_call+0x3c/0xf0
   __qcom_scm_is_call_available+0xec/0x198
   qcom_scm_shm_bridge_enable+0xc4/0x158
   qcom_tzmem_enable+0x178/0x218
   qcom_scm_probe+0x4d4/0xcb8

Fix this by using DO_ONCE_SLEEPABLE().

Fixes: 9941fe8a04f3 ("firmware: qcom: scm: Fix tzmem state on probe retry")
Signed-off-by: Daniel J Blueman <daniel@quora.org>
---
 drivers/firmware/qcom/qcom_tzmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
index 0fd9581275f1..ebcdee3c5975 100644
--- a/drivers/firmware/qcom/qcom_tzmem.c
+++ b/drivers/firmware/qcom/qcom_tzmem.c
@@ -518,7 +518,7 @@ int qcom_tzmem_enable(struct device *dev)
 	static int result;
 
 	qcom_tzmem_dev = dev;
-	DO_ONCE(qcom_tzmem_do_init, &result);
+	DO_ONCE_SLEEPABLE(qcom_tzmem_do_init, &result);
 	return result;
 }
 EXPORT_SYMBOL_GPL(qcom_tzmem_enable);
-- 
2.53.0


                 reply	other threads:[~2026-09-05  3:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260905030450.34800-1-daniel@quora.org \
    --to=daniel@quora.org \
    --cc=andersson@kernel.org \
    --cc=brgl@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mukesh.ojha@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®