From 75619d91a6f99f76a1de5f892ff68911166a2de9 Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Wed, 27 Sep 2023 12:09:19 +0530 Subject: [PATCH 1/2] soc: qcom: rpmh-rsc: Add delay during waiting for TCS complete The RSC channel switch in certain cases may take more time to complete at RPMH end. Add delay of maximum 100usec. Change-Id: I65862ad80fbb698e6b66e2038a7692c4b78c2ce9 Signed-off-by: Maulik Shah --- drivers/soc/qcom/rpmh-rsc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 71a5a5452a6e..05775e056952 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -1218,6 +1218,13 @@ int rpmh_rsc_is_tcs_completed(struct rsc_drv *drv, int ch) sts &= CH1_WAKE_TCS_STATUS; retry--; + /* + * Wait till all the WAKE votes of the new channel are + * applied during channel switch. + * Maximum delay of 100 usec. + */ + if (!sts) + udelay(10); } while (!sts && retry); if (!retry) { From d051a7c61f161482abcf28b14e9461fb10be3d80 Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Wed, 18 Oct 2023 12:47:45 +0530 Subject: [PATCH 2/2] soc: qcom: rpmh: Do not use spin_trylock() rpmh_flush() is called for APPS RSC only from last CPU entering power down. spin_trylock() was used to abort flushing as it would mean another CPU is already up. However rpmh_flush() may get invoked by other RSCes too and may fail if another CPU is holding lock. Fix by removing spin_trylock(). Change-Id: Ic94f6bcb9a762e02ccfb98c79f6181f20ee67915 Signed-off-by: Maulik Shah --- drivers/soc/qcom/rpmh.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 9c5d87a27872..d1494d7033af 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -445,6 +445,7 @@ int _rpmh_flush(struct rpmh_ctrlr *ctrlr, int ch) */ int rpmh_flush(struct rpmh_ctrlr *ctrlr, int ch) { + unsigned long flags; int ret; if (rpmh_standalone) @@ -464,14 +465,9 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr, int ch) if (!(ctrlr->flags & SOLVER_PRESENT)) lockdep_assert_irqs_disabled(); - /* - * 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; + spin_lock_irqsave(&ctrlr->cache_lock, flags); ret = _rpmh_flush(ctrlr, ch); - spin_unlock(&ctrlr->cache_lock); + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); return ret; }