All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maulik Shah <mkshah@codeaurora.org>
To: bjorn.andersson@linaro.org, agross@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	tkjos@google.com, dianders@chromium.org, ilina@codeaurora.org,
	lsrao@codeaurora.org, Maulik Shah <mkshah@codeaurora.org>
Subject: [PATCH v2 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()
Date: Mon, 25 Jan 2021 11:50:37 +0530	[thread overview]
Message-ID: <1611555637-7688-3-git-send-email-mkshah@codeaurora.org> (raw)
In-Reply-To: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org>

lockdep_assert_irqs_disabled() was added to check rpmh_flush()
can only be invoked when irqs are disabled from last CPU,
this is true for APPS RSC as the last CPU going to deepest low
power mode is writing sleep and wake TCSes.

However platform drivers can invoke rpmh_write_sleep_and_wake()
to immediately write cached sleep and wake sets to TCSes from any
CPU. Conditionally check if rpmh_flush() is invoked from last CPU
then do not check for irqs disabled as such RSCs can write sleep
and wake TCSes at any point.

Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
---
Changes in v2:
- Update rpmh_flush() to show if its called from last CPU or not
- Drop solver client flag as rpmh_flush() able to check if called from
  last CPU or not
---
 drivers/soc/qcom/rpmh-internal.h |  2 +-
 drivers/soc/qcom/rpmh-rsc.c      |  3 ++-
 drivers/soc/qcom/rpmh.c          | 23 +++++++++++++++++------
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 79486d6..f351780 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -136,6 +136,6 @@ void rpmh_rsc_invalidate(struct rsc_drv *drv);
 int rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable);
 
 void rpmh_tx_done(const struct tcs_request *msg, int r);
-int rpmh_flush(struct rpmh_ctrlr *ctrlr);
+int rpmh_flush(struct rpmh_ctrlr *ctrlr, bool from_last_cpu);
 
 #endif /* __RPM_INTERNAL_H__ */
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 1c1f5b0..a67bcd6 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -841,7 +841,8 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb,
 	 * CPU.
 	 */
 	if (spin_trylock(&drv->lock)) {
-		if (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client))
+		if (rpmh_rsc_ctrlr_is_busy(drv) ||
+		    rpmh_flush(&drv->client, true))
 			ret = NOTIFY_BAD;
 		spin_unlock(&drv->lock);
 	} else {
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 725b8f0..682c566 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -458,22 +458,33 @@ static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state,
  * rpmh_flush() - Flushes the buffered sleep and wake sets to TCSes
  *
  * @ctrlr: Controller making request to flush cached data
+ * @from_last_cpu: Set if invoked from last cpu with irqs disabled
  *
  * Return:
  * * 0          - Success
  * * Error code - Otherwise
  */
-int rpmh_flush(struct rpmh_ctrlr *ctrlr)
+int rpmh_flush(struct rpmh_ctrlr *ctrlr, bool from_last_cpu)
 {
 	struct cache_req *p;
 	int ret = 0;
 
-	lockdep_assert_irqs_disabled();
+	/*
+	 * rpmh_flush() can be called when we think we're running
+	 * on the last CPU with irqs_disabled or when RPMH client
+	 * explicitly requests to write sleep and wake data.
+	 * (for e.g. when in solver mode clients can requests to flush)
+	 *
+	 * Conditionally check for irqs_disabled only when called
+	 * from last cpu.
+	 */
+
+	if (from_last_cpu)
+		lockdep_assert_irqs_disabled();
 
 	/*
-	 * Currently rpmh_flush() is only called when we think we're running
-	 * on the last processor.  If the lock is busy it means another
-	 * processor is up and it's better to abort than spin.
+	 * If the lock is busy it means another transaction is on going,
+	 * in such case it's better to abort than spin.
 	 */
 	if (!spin_trylock(&ctrlr->cache_lock))
 		return -EBUSY;
@@ -526,7 +537,7 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
  */
 int rpmh_write_sleep_and_wake(const struct device *dev)
 {
-	return rpmh_flush(get_rpmh_ctrlr(dev));
+	return rpmh_flush(get_rpmh_ctrlr(dev), false);
 }
 EXPORT_SYMBOL(rpmh_write_sleep_and_wake);
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


  parent reply	other threads:[~2021-01-25  6:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  6:20 [PATCH v2 1/3] drivers: qcom: rpmh: Disallow active requests in solver mode Maulik Shah
2021-01-25  6:20 ` [PATCH v2 2/3] soc: qcom: rpmh: Add rpmh_write_sleep_and_wake() function Maulik Shah
2021-02-03 18:36   ` Doug Anderson
2021-01-25  6:20 ` Maulik Shah [this message]
2021-02-03 18:36   ` [PATCH v2 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled() Doug Anderson
2021-02-03 18:35 ` [PATCH v2 1/3] drivers: qcom: rpmh: Disallow active requests in solver mode Doug Anderson

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=1611555637-7688-3-git-send-email-mkshah@codeaurora.org \
    --to=mkshah@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=dianders@chromium.org \
    --cc=ilina@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsrao@codeaurora.org \
    --cc=tkjos@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.