lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1611555637-7688-3-git-send-email-mkshah@codeaurora.org>
Date:   Mon, 25 Jan 2021 11:50:37 +0530
From:   Maulik Shah <mkshah@...eaurora.org>
To:     bjorn.andersson@...aro.org, agross@...nel.org
Cc:     linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        tkjos@...gle.com, dianders@...omium.org, ilina@...eaurora.org,
        lsrao@...eaurora.org, Maulik Shah <mkshah@...eaurora.org>
Subject: [PATCH v2 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()

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@...eaurora.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ