Skip to contentSkip to conversation

Add changes to support 'HW solver' mode in rpmh driver

PATCH Superseded Maulik Shah 2 participants 6 messages Nov 26, 2020 – Jan 7, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add changes to support 'HW solver' mode in rpmh driver

RSC controllers may be in 'HW solver' state, where they could be in autonomous mode executing low power modes for their hardware and as such are not available for sending active votes.

This series adds changes to support the same in rpmh driver by disallowing active requests when in solver mode and allowing the drivers to write cached sleep and wake votes immediately.

Note: The series can land on its own but to avoid conflicts with other change going in rpmh driver i have based changes on top of [1] which hopefully can land soon.

[1] https://patchwork.kernel.org/project/linux-arm-msm/patch/[email protected]

Lina Iyer (1):
drivers: qcom: rpmh: Disallow active requests in solver mode

Maulik Shah (2):
soc: qcom: rpmh: Add rpmh_write_sleep_and_wake() function
soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()

 drivers/soc/qcom/rpmh-internal.h | 10 ++++
 drivers/soc/qcom/rpmh-rsc.c      | 34 ++++++++++++++
 drivers/soc/qcom/rpmh.c          | 98 ++++++++++++++++++++++++++++++++++++++--
 drivers/soc/qcom/trace-rpmh.h    | 20 ++++++++
 include/soc/qcom/rpmh.h          | 10 ++++
 5 files changed, 168 insertions(+), 4 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH 1/3 drivers: qcom: rpmh: Disallow active requests in solver mode

From: Lina Iyer <[email protected]>

Controllers may be in 'solver' state, where they could be in autonomous mode executing low power modes for their hardware and as such are not available for sending active votes. Device driver may notify RPMH that the controller is in solver mode and when in such mode, disallow requests from platform drivers for state change using the RSC.

---
 drivers/soc/qcom/rpmh-internal.h |  5 ++++
 drivers/soc/qcom/rpmh-rsc.c      | 31 ++++++++++++++++++++++
 drivers/soc/qcom/rpmh.c          | 56 ++++++++++++++++++++++++++++++++++++++++
 drivers/soc/qcom/trace-rpmh.h    | 20 ++++++++++++++
 include/soc/qcom/rpmh.h          |  5 ++++
 5 files changed, 117 insertions(+)
drivers/soc/qcom/rpmh-internal.h +5 -0
index 344ba68..79486d6 100644
@@ -77,12 +77,14 @@ struct rpmh_request {
  * @cache: the list of cached requests
  * @cache_lock: synchronize access to the cache data
  * @dirty: was the cache updated since flush
+ * @in_solver_mode: Controller is busy in solver mode
  * @batch_cache: Cache sleep and wake requests sent as batch
  */
 struct rpmh_ctrlr {
 	struct list_head cache;
 	spinlock_t cache_lock;
 	bool dirty;
+	bool in_solver_mode;
 	struct list_head batch_cache;
 };
 
@@ -94,6 +96,7 @@ struct rpmh_ctrlr {
  * @tcs_base:           Start address of the TCS registers in this controller.
  * @id:                 Instance id in the controller (Direct Resource Voter).
  * @num_tcs:            Number of TCSes in this DRV.
+ * @in_solver_mode:     Controller is busy in solver mode
  * @rsc_pm:             CPU PM notifier for controller.
  *                      Used when solver mode is not present.
  * @cpus_in_pm:         Number of CPUs not in idle power collapse.
@@ -116,6 +119,7 @@ struct rsc_drv {
 	void __iomem *tcs_base;
 	int id;
 	int num_tcs;
+	bool in_solver_mode;
 	struct notifier_block rsc_pm;
 	atomic_t cpus_in_pm;
 	struct tcs_group tcs[TCS_TYPE_NR];
@@ -129,6 +133,7 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg);
 int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 			     const struct tcs_request *msg);
 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);
drivers/soc/qcom/rpmh-rsc.c +31 -0
index 37969dc..ffb4ca7 100644
@@ -638,6 +638,12 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
 
 	spin_lock_irqsave(&drv->lock, flags);
 
+	if (drv->in_solver_mode) {
+		/* Controller is busy in 'solver' mode */
+		spin_unlock_irqrestore(&drv->lock, flags);
+		return -EBUSY;
+	}
+
 	/* Wait forever for a free tcs. It better be there eventually! */
 	wait_event_lock_irq(drv->tcs_wait,
 			    (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0,
@@ -859,6 +865,31 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb,
 	return ret;
 }
 
+/**
+ * rpmh_rsc_mode_solver_set() - Enable/disable solver mode.
+ * @drv:     The controller.
+ * @enable:  Boolean state to be set - true/false
+ *
+ * Return:
+ * * 0			- success
+ * * -EBUSY		- AMCs are busy
+ */
+int rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable)
+{
+	int ret = -EBUSY;
+
+	if (spin_trylock(&drv->lock)) {
+		if (!enable || !rpmh_rsc_ctrlr_is_busy(drv)) {
+			drv->in_solver_mode = enable;
+			trace_rpmh_solver_set(drv, enable);
+			ret = 0;
+		}
+		spin_unlock(&drv->lock);
+	}
+
+	return ret;
+}
+
 static int rpmh_probe_tcs_config(struct platform_device *pdev,
 				 struct rsc_drv *drv, void __iomem *base)
 {
drivers/soc/qcom/rpmh.c +56 -0

88 lines not on this page · raw message

drivers/soc/qcom/trace-rpmh.h +20 -0
index feb0cb4..b2b934c 100644
@@ -71,6 +71,26 @@ TRACE_EVENT(rpmh_send_msg,
 		  __entry->addr, __entry->data, __entry->wait)
 );
 
+TRACE_EVENT(rpmh_solver_set,
+
+	TP_PROTO(struct rsc_drv *d, bool set),
+
+	TP_ARGS(d, set),
+
+	TP_STRUCT__entry(
+			 __string(name, d->name)
+			 __field(bool, set)
+	),
+
+	TP_fast_assign(
+		       __assign_str(name, d->name);
+		       __entry->set = set;
+	),
+
+	TP_printk("%s: solver mode set: %d",
+		  __get_str(name), __entry->set)
+);
+
 #endif /* _TRACE_RPMH_H */
 
 #undef TRACE_INCLUDE_PATH
include/soc/qcom/rpmh.h +5 -0
index bdbee1a..fa8bb53 100644
@@ -20,6 +20,8 @@ int rpmh_write_async(const struct device *dev, enum rpmh_state state,
 int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
 		     const struct tcs_cmd *cmd, u32 *n);
 
+int rpmh_mode_solver_set(const struct device *dev, bool enable);
+
 void rpmh_invalidate(const struct device *dev);
 
 #else
@@ -38,6 +40,9 @@ static inline int rpmh_write_batch(const struct device *dev,
 				   const struct tcs_cmd *cmd, u32 *n)
 { return -ENODEV; }
 
+static int rpmh_mode_solver_set(const struct device *dev, bool enable)
+{ return -ENODEV; }
+
 static inline void rpmh_invalidate(const struct device *dev)
 {
 }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH 2/3 soc: qcom: rpmh: Add rpmh_write_sleep_and_wake() function

In reply to Maulik Shah

Let RPMH clients call rpmh_write_sleep_and_wake() to immediately write cached sleep and wake data to the TCSes.

---
 drivers/soc/qcom/rpmh.c | 16 ++++++++++++++++
 include/soc/qcom/rpmh.h |  5 +++++
 2 files changed, 21 insertions(+)
drivers/soc/qcom/rpmh.c +16 -0
index cbe6b96..725b8f0 100644
@@ -515,6 +515,22 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
 }
 
 /**
+ * rpmh_write_sleep_and_wake() - Writes the buffered wake and sleep sets
+ * to TCSes
+ *
+ * @dev: The device making the request
+ *
+ * Return:
+ * * 0          - Success
+ * * Error code - Otherwise
+ */
+int rpmh_write_sleep_and_wake(const struct device *dev)
+{
+	return rpmh_flush(get_rpmh_ctrlr(dev));
+}
+EXPORT_SYMBOL(rpmh_write_sleep_and_wake);
+
+/**
  * rpmh_invalidate: Invalidate sleep and wake sets in batch_cache
  *
  * @dev: The device making the request
include/soc/qcom/rpmh.h +5 -0
index fa8bb53..59b68f8 100644
@@ -22,6 +22,8 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
 
 int rpmh_mode_solver_set(const struct device *dev, bool enable);
 
+int rpmh_write_sleep_and_wake(const struct device *dev);
+
 void rpmh_invalidate(const struct device *dev);
 
 #else
@@ -43,6 +45,9 @@ static inline int rpmh_write_batch(const struct device *dev,
 static int rpmh_mode_solver_set(const struct device *dev, bool enable)
 { return -ENODEV; }
 
+static int rpmh_write_sleep_and_wake(const struct device *dev)
+{ return -ENODEV; }
+
 static inline void rpmh_invalidate(const struct device *dev)
 {
 }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

PATCH 3/3 soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()

In reply to Maulik Shah

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

However for RSCs that support solver mode, drivers can invoke rpmh_write_sleep_and_wake() to immediately write cached sleep and wake sets to TCSes from any CPU. Conditionally check if RSC controller supports 'HW solver' mode then do not check for irqs disabled as such RSCs can write sleepand wake TCSes at any point.

---
 drivers/soc/qcom/rpmh-internal.h |  5 +++++
 drivers/soc/qcom/rpmh-rsc.c      |  3 +++
 drivers/soc/qcom/rpmh.c          | 26 ++++++++++++++++++++++----
 3 files changed, 30 insertions(+), 4 deletions(-)
drivers/soc/qcom/rpmh-internal.h +5 -0
index 79486d6..39fa3c5 100644
@@ -17,6 +17,9 @@
 #define MAX_TCS_NR			(MAX_TCS_PER_TYPE * TCS_TYPE_NR)
 #define MAX_TCS_SLOTS			(MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
 
+/* CTRLR specific flags */
+#define SOLVER_PRESENT			1
+
 struct rsc_drv;
 
 /**
@@ -78,6 +81,7 @@ struct rpmh_request {
  * @cache_lock: synchronize access to the cache data
  * @dirty: was the cache updated since flush
  * @in_solver_mode: Controller is busy in solver mode
+ * @flags: Controller specific flags
  * @batch_cache: Cache sleep and wake requests sent as batch
  */
 struct rpmh_ctrlr {
@@ -85,6 +89,7 @@ struct rpmh_ctrlr {
 	spinlock_t cache_lock;
 	bool dirty;
 	bool in_solver_mode;
+	u32 flags;
 	struct list_head batch_cache;
 };
 
drivers/soc/qcom/rpmh-rsc.c +3 -0
index ffb4ca7..4caaddf 100644
@@ -1031,6 +1031,9 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
 	if (!solver_config) {
 		drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback;
 		cpu_pm_register_notifier(&drv->rsc_pm);
+		drv->client.flags &= ~SOLVER_PRESENT;
+	} else {
+		drv->client.flags |= SOLVER_PRESENT;
 	}
 
 	/* Enable the active TCS to send requests immediately */
drivers/soc/qcom/rpmh.c +22 -4
index 725b8f0..604d511 100644
@@ -83,6 +83,9 @@ static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state)
 	if (state != RPMH_ACTIVE_ONLY_STATE)
 		return ret;
 
+	if (!(ctrlr->flags & SOLVER_PRESENT))
+		return ret;
+
 	/* Do not allow sending active votes when in solver mode */
 	spin_lock(&ctrlr->cache_lock);
 	if (ctrlr->in_solver_mode)
@@ -468,12 +471,24 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
 	struct cache_req *p;
 	int ret = 0;
 
-	lockdep_assert_irqs_disabled();
+	/*
+	 * For RSC that don't have solver mode,
+	 * rpmh_flush() is only called when we think we're running
+	 * on the last CPU with irqs_disabled.
+	 *
+	 * For RSC that have solver mode,
+	 * rpmh_flush() can be invoked with irqs enabled by any CPU.
+	 *
+	 * Conditionally check for irqs_disabled only when solver mode
+	 * is not available.
+	 */
+
+	if (!(ctrlr->flags & SOLVER_PRESENT))
+		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;
@@ -568,6 +583,9 @@ int rpmh_mode_solver_set(const struct device *dev, bool enable)
 	int ret;
 	struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
 
+	if (!(ctrlr->flags & SOLVER_PRESENT))
+		return -EINVAL;
+
 	spin_lock(&ctrlr->cache_lock);
 	ret = rpmh_rsc_mode_solver_set(ctrlr_to_drv(ctrlr), enable);
 	if (!ret)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

Re: [PATCH 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()

Quoting Maulik Shah (2020-11-26 02:18:18)

Quoted 41 lines

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

However for RSCs that support solver mode, drivers can invoke rpmh_write_sleep_and_wake() to immediately write cached sleep and wake sets to TCSes from any CPU. Conditionally check if RSC controller supports 'HW solver' mode then do not check for irqs disabled as such RSCs can write sleepand wake TCSes at any point.

---
 drivers/soc/qcom/rpmh-internal.h |  5 +++++
 drivers/soc/qcom/rpmh-rsc.c      |  3 +++
 drivers/soc/qcom/rpmh.c          | 26 ++++++++++++++++++++++----
 3 files changed, 30 insertions(+), 4 deletions(-)
drivers/soc/qcom/rpmh-internal.h +4 -0
index 79486d6..39fa3c5 100644
@@ -17,6 +17,9 @@
 #define MAX_TCS_NR                     (MAX_TCS_PER_TYPE * TCS_TYPE_NR)
 #define MAX_TCS_SLOTS                  (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
 
+/* CTRLR specific flags */
+#define SOLVER_PRESENT                 1
+
 struct rsc_drv;
 
 /**
@@ -78,6 +81,7 @@ struct rpmh_request {
  * @cache_lock: synchronize access to the cache data
  * @dirty: was the cache updated since flush
  * @in_solver_mode: Controller is busy in solver mode
+ * @flags: Controller specific flags
  * @batch_cache: Cache sleep and wake requests sent as batch
  */
 struct rpmh_ctrlr {

drivers/soc/qcom/rpmh-internal.h struct rpmh_ctrlr { · line 92

Quoted 4 lines
drivers/soc/qcom/rpmh-internal.h +1 -0
@@ -85,6 +89,7 @@ struct rpmh_ctrlr {
        spinlock_t cache_lock;
        bool dirty;
        bool in_solver_mode;
+       u32 flags;

Maybe unsigned long is more appropriate? Do we rely on 32-bits vs. 64-bits?

Quoted 8 lines
drivers/soc/qcom/rpmh-internal.h +0 -0
        struct list_head batch_cache;
 };
 
drivers/soc/qcom/rpmh-rsc.c +0 -0
index ffb4ca7..4caaddf 100644

drivers/soc/qcom/rpmh-rsc.c static int rpmh_rsc_probe(struct platform_device *pdev) · line 1036

Quoted 6 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
@@ -1031,6 +1031,9 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
        if (!solver_config) {
                drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback;
                cpu_pm_register_notifier(&drv->rsc_pm);
+               drv->client.flags &= ~SOLVER_PRESENT;
+       } else {
+               drv->client.flags |= SOLVER_PRESENT;

It looks like this could be tested by checking for drv->rsc_pm.notifier_call being non-NULL?

Quoted 26 lines
drivers/soc/qcom/rpmh-rsc.c +0 -0
        }
 
        /* Enable the active TCS to send requests immediately */
drivers/soc/qcom/rpmh.c +7 -1
index 725b8f0..604d511 100644
@@ -83,6 +83,9 @@ static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state)
        if (state != RPMH_ACTIVE_ONLY_STATE)
                return ret;
 
+       if (!(ctrlr->flags & SOLVER_PRESENT))
+               return ret;
+
        /* Do not allow sending active votes when in solver mode */
        spin_lock(&ctrlr->cache_lock);
        if (ctrlr->in_solver_mode)
@@ -468,12 +471,24 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
        struct cache_req *p;
        int ret = 0;
 
-       lockdep_assert_irqs_disabled();
+       /*
+        * For RSC that don't have solver mode,
+        * rpmh_flush() is only called when we think we're running
+        * on the last CPU with irqs_disabled.

drivers/soc/qcom/rpmh.c int rpmh_flush(struct rpmh_ctrlr *ctrlr) · line 487

Quoted 10 lines
drivers/soc/qcom/rpmh.c +10 -0
+        *
+        * For RSC that have solver mode,
+        * rpmh_flush() can be invoked with irqs enabled by any CPU.
+        *
+        * Conditionally check for irqs_disabled only when solver mode
+        * is not available.
+        */
+
+       if (!(ctrlr->flags & SOLVER_PRESENT))
+               lockdep_assert_irqs_disabled();

Can we have a different function that is called for the case where solver mode is present and where solver mode isn't present? It would be good to clearly show that rpmh_flush() thinks it is being called from the last CPU vs. from some other random place because the code is assuming solver vs. non-solver enabled state. It would be clearer from the call site too.

Quoted 10 lines
drivers/soc/qcom/rpmh.c +2 -3
        /*
-        * 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;
#5 lore raw

Re: [PATCH 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled()

Hi Stephen,

Quoted 32 lines · Stephen Boyd

Quoting Maulik Shah (2020-11-26 02:18:18)

Quoted 31 lines

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

However for RSCs that support solver mode, drivers can invoke rpmh_write_sleep_and_wake() to immediately write cached sleep and wake sets to TCSes from any CPU. Conditionally check if RSC controller supports 'HW solver' mode then do not check for irqs disabled as such RSCs can write sleepand wake TCSes at any point.

---
  drivers/soc/qcom/rpmh-internal.h |  5 +++++
  drivers/soc/qcom/rpmh-rsc.c      |  3 +++
  drivers/soc/qcom/rpmh.c          | 26 ++++++++++++++++++++++----
  3 files changed, 30 insertions(+), 4 deletions(-)
drivers/soc/qcom/rpmh-internal.h +3 -0
index 79486d6..39fa3c5 100644
@@ -17,6 +17,9 @@
  #define MAX_TCS_NR                     (MAX_TCS_PER_TYPE * TCS_TYPE_NR)
  #define MAX_TCS_SLOTS                  (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
 
+/* CTRLR specific flags */
+#define SOLVER_PRESENT                 1
+
  struct rsc_drv;
 
Quoted 16 lines
Quoted 10 lines
drivers/soc/qcom/rpmh-internal.h +1 -0
  /**
@@ -78,6 +81,7 @@ struct rpmh_request {
   * @cache_lock: synchronize access to the cache data
   * @dirty: was the cache updated since flush
   * @in_solver_mode: Controller is busy in solver mode
+ * @flags: Controller specific flags
   * @batch_cache: Cache sleep and wake requests sent as batch
   */
  struct rpmh_ctrlr {

drivers/soc/qcom/rpmh-internal.h struct rpmh_ctrlr { · line 92

Quoted 4 lines
drivers/soc/qcom/rpmh-internal.h +1 -0
@@ -85,6 +89,7 @@ struct rpmh_ctrlr {
         spinlock_t cache_lock;
         bool dirty;
         bool in_solver_mode;
+       u32 flags;

Maybe unsigned long is more appropriate? Do we rely on 32-bits vs. 64-bits?

We don't rely on 32-bits vs. 64-bits, u32 should be fine.

Quoted 4 lines
Quoted 4 lines
drivers/soc/qcom/rpmh-internal.h +0 -0
         struct list_head batch_cache;
  };
 
Quoted 13 lines

drivers/soc/qcom/rpmh-rsc.c static int rpmh_rsc_probe(struct platform_device *pdev) · line 1036

Quoted 11 lines
drivers/soc/qcom/rpmh-rsc.c +3 -0
index ffb4ca7..4caaddf 100644
@@ -1031,6 +1031,9 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
         if (!solver_config) {
                 drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback;
                 cpu_pm_register_notifier(&drv->rsc_pm);
+               drv->client.flags &= ~SOLVER_PRESENT;
+       } else {
+               drv->client.flags |= SOLVER_PRESENT;

It looks like this could be tested by checking for drv->rsc_pm.notifier_call being non-NULL?

It may for now, but going forward we may have different flags to indicate various functions supported by RSC.

Quoted 35 lines
Quoted 35 lines
drivers/soc/qcom/rpmh-rsc.c +0 -0
         }
 
         /* Enable the active TCS to send requests immediately */
drivers/soc/qcom/rpmh.c +15 -1
index 725b8f0..604d511 100644
@@ -83,6 +83,9 @@ static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state)
         if (state != RPMH_ACTIVE_ONLY_STATE)
                 return ret;
 
+       if (!(ctrlr->flags & SOLVER_PRESENT))
+               return ret;
+
         /* Do not allow sending active votes when in solver mode */
         spin_lock(&ctrlr->cache_lock);
         if (ctrlr->in_solver_mode)
@@ -468,12 +471,24 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr)
         struct cache_req *p;
         int ret = 0;
 
-       lockdep_assert_irqs_disabled();
+       /*
+        * For RSC that don't have solver mode,
+        * rpmh_flush() is only called when we think we're running
+        * on the last CPU with irqs_disabled.
+        *
+        * For RSC that have solver mode,
+        * rpmh_flush() can be invoked with irqs enabled by any CPU.
+        *
+        * Conditionally check for irqs_disabled only when solver mode
+        * is not available.
+        */
+
Quoted 8 lines

drivers/soc/qcom/rpmh.c int rpmh_flush(struct rpmh_ctrlr *ctrlr) · line 487

Quoted 2 lines
drivers/soc/qcom/rpmh.c +2 -0
+       if (!(ctrlr->flags & SOLVER_PRESENT))
+               lockdep_assert_irqs_disabled();

Can we have a different function that is called for the case where solver mode is present and where solver mode isn't present? It would be good to clearly show that rpmh_flush() thinks it is being called from the last CPU vs. from some other random place because the code is assuming solver vs. non-solver enabled state. It would be clearer from the call site too.

Hmm, we can. Patch 2 of this series already added different function which will be called where solver is present. Let me modify this to indicate whether called from last cpu or not.

Thanks,
Maulik

Quoted 11 lines
Quoted 11 lines
drivers/soc/qcom/rpmh.c +2 -3
         /*
-        * 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;
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation