linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc
@ 2021-08-09  8:24 Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 1/4] slimbus: messaging: start transaction ids from 1 instead of zero Srinivas Kandagatla
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2021-08-09  8:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla

Hi Greg,

Am resending this series with proper cover letter and subject-line.

Recently runtime pm testing on slimbus reveled that its
totally broken on SlimBus ngd drivers.

Below are the fixes to get it back working.

- One of the reason begin incorrect device pointer used for
runtime pm and in some places

- Second one (2 patches) was to do with unable to validate
transaction id which resulted in negative runtime pm count.

- Other fix was to do with resetting dma addresses once ngd
controller is power-cycled.

With all these fixed runtime pm is now fully functional on NGD
controllers.

Currently I marked them all with Cc: <stable@vger.kernel.org>
as these all patches are required to fix runtime pm on SlimBus
NGD controller.

Can you please queue them up for next possible 5.14 rc.

thanks for you help,
srini


Srinivas Kandagatla (4):
  slimbus: messaging: start transaction ids from 1 instead of zero
  slimbus: messaging: check for valid transaction id
  slimbus: ngd: set correct device for pm
  slimbus: ngd: reset dma setup during runtime pm

 drivers/slimbus/messaging.c     |  7 ++++---
 drivers/slimbus/qcom-ngd-ctrl.c | 22 +++++++++++++---------
 2 files changed, 17 insertions(+), 12 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RESEND PATCH 1/4] slimbus: messaging: start transaction ids from 1 instead of zero
  2021-08-09  8:24 [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc Srinivas Kandagatla
@ 2021-08-09  8:24 ` Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 2/4] slimbus: messaging: check for valid transaction id Srinivas Kandagatla
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2021-08-09  8:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla, stable

As tid is unsigned its hard to figure out if the tid is valid or
invalid. So Start the transaction ids from 1 instead of zero
so that we could differentiate between a valid tid and invalid tids

This is useful in cases where controller would add a tid for controller
specific transfers.

Fixes: d3062a210930 ("slimbus: messaging: add slim_alloc/free_txn_tid()")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/slimbus/messaging.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c
index f2b5d347d227..6097ddc43a35 100644
--- a/drivers/slimbus/messaging.c
+++ b/drivers/slimbus/messaging.c
@@ -66,7 +66,7 @@ int slim_alloc_txn_tid(struct slim_controller *ctrl, struct slim_msg_txn *txn)
 	int ret = 0;
 
 	spin_lock_irqsave(&ctrl->txn_lock, flags);
-	ret = idr_alloc_cyclic(&ctrl->tid_idr, txn, 0,
+	ret = idr_alloc_cyclic(&ctrl->tid_idr, txn, 1,
 				SLIM_MAX_TIDS, GFP_ATOMIC);
 	if (ret < 0) {
 		spin_unlock_irqrestore(&ctrl->txn_lock, flags);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH 2/4] slimbus: messaging: check for valid transaction id
  2021-08-09  8:24 [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 1/4] slimbus: messaging: start transaction ids from 1 instead of zero Srinivas Kandagatla
@ 2021-08-09  8:24 ` Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 3/4] slimbus: ngd: set correct device for pm Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 4/4] slimbus: ngd: reset dma setup during runtime pm Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2021-08-09  8:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla, stable

In some usecases transaction ids are dynamically allocated inside
the controller driver after sending the messages which have generic
acknowledge responses. So check for this before refcounting pm_runtime.

Without this we would end up imbalancing runtime pm count by
doing pm_runtime_put() in both slim_do_transfer() and slim_msg_response()
for a single  pm_runtime_get() in slim_do_transfer()

Fixes: d3062a210930 ("slimbus: messaging: add slim_alloc/free_txn_tid()")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/slimbus/messaging.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c
index 6097ddc43a35..e5ae26227bdb 100644
--- a/drivers/slimbus/messaging.c
+++ b/drivers/slimbus/messaging.c
@@ -131,7 +131,8 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn)
 			goto slim_xfer_err;
 		}
 	}
-
+	/* Initialize tid to invalid value */
+	txn->tid = 0;
 	need_tid = slim_tid_txn(txn->mt, txn->mc);
 
 	if (need_tid) {
@@ -163,7 +164,7 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn)
 			txn->mt, txn->mc, txn->la, ret);
 
 slim_xfer_err:
-	if (!clk_pause_msg && (!need_tid  || ret == -ETIMEDOUT)) {
+	if (!clk_pause_msg && (txn->tid == 0  || ret == -ETIMEDOUT)) {
 		/*
 		 * remove runtime-pm vote if this was TX only, or
 		 * if there was error during this transaction
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH 3/4] slimbus: ngd: set correct device for pm
  2021-08-09  8:24 [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 1/4] slimbus: messaging: start transaction ids from 1 instead of zero Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 2/4] slimbus: messaging: check for valid transaction id Srinivas Kandagatla
@ 2021-08-09  8:24 ` Srinivas Kandagatla
  2021-08-09  8:24 ` [RESEND PATCH 4/4] slimbus: ngd: reset dma setup during runtime pm Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2021-08-09  8:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla, stable

For some reason we ended up using wrong device in some places for pm_runtime calls.
Fix this so that NGG driver can do runtime pm correctly.

Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index c054e83ab636..f3ee8e036372 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -618,7 +618,7 @@ static void qcom_slim_ngd_rx(struct qcom_slim_ngd_ctrl *ctrl, u8 *buf)
 		(mc == SLIM_USR_MC_GENERIC_ACK &&
 		 mt == SLIM_MSG_MT_SRC_REFERRED_USER)) {
 		slim_msg_response(&ctrl->ctrl, &buf[4], buf[3], len - 4);
-		pm_runtime_mark_last_busy(ctrl->dev);
+		pm_runtime_mark_last_busy(ctrl->ctrl.dev);
 	}
 }
 
@@ -1257,13 +1257,14 @@ static int qcom_slim_ngd_enable(struct qcom_slim_ngd_ctrl *ctrl, bool enable)
 		}
 		/* controller state should be in sync with framework state */
 		complete(&ctrl->qmi.qmi_comp);
-		if (!pm_runtime_enabled(ctrl->dev) ||
-				!pm_runtime_suspended(ctrl->dev))
-			qcom_slim_ngd_runtime_resume(ctrl->dev);
+		if (!pm_runtime_enabled(ctrl->ctrl.dev) ||
+			 !pm_runtime_suspended(ctrl->ctrl.dev))
+			qcom_slim_ngd_runtime_resume(ctrl->ctrl.dev);
 		else
-			pm_runtime_resume(ctrl->dev);
-		pm_runtime_mark_last_busy(ctrl->dev);
-		pm_runtime_put(ctrl->dev);
+			pm_runtime_resume(ctrl->ctrl.dev);
+
+		pm_runtime_mark_last_busy(ctrl->ctrl.dev);
+		pm_runtime_put(ctrl->ctrl.dev);
 
 		ret = slim_register_controller(&ctrl->ctrl);
 		if (ret) {
@@ -1389,7 +1390,7 @@ static int qcom_slim_ngd_ssr_pdr_notify(struct qcom_slim_ngd_ctrl *ctrl,
 		/* Make sure the last dma xfer is finished */
 		mutex_lock(&ctrl->tx_lock);
 		if (ctrl->state != QCOM_SLIM_NGD_CTRL_DOWN) {
-			pm_runtime_get_noresume(ctrl->dev);
+			pm_runtime_get_noresume(ctrl->ctrl.dev);
 			ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;
 			qcom_slim_ngd_down(ctrl);
 			qcom_slim_ngd_exit_dma(ctrl);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH 4/4] slimbus: ngd: reset dma setup during runtime pm
  2021-08-09  8:24 [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc Srinivas Kandagatla
                   ` (2 preceding siblings ...)
  2021-08-09  8:24 ` [RESEND PATCH 3/4] slimbus: ngd: set correct device for pm Srinivas Kandagatla
@ 2021-08-09  8:24 ` Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2021-08-09  8:24 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla, stable

During suspend/resume NGD remote instance is power cycled along
with remotely controlled bam dma engine.
So Reset the dma configuration during this suspend resume path
so that we are not dealing with any stale dma setup.

Without this transactions timeout after first suspend resume path.

Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index f3ee8e036372..7040293c2ee8 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1080,7 +1080,8 @@ static void qcom_slim_ngd_setup(struct qcom_slim_ngd_ctrl *ctrl)
 {
 	u32 cfg = readl_relaxed(ctrl->ngd->base);
 
-	if (ctrl->state == QCOM_SLIM_NGD_CTRL_DOWN)
+	if (ctrl->state == QCOM_SLIM_NGD_CTRL_DOWN ||
+		ctrl->state == QCOM_SLIM_NGD_CTRL_ASLEEP)
 		qcom_slim_ngd_init_dma(ctrl);
 
 	/* By default enable message queues */
@@ -1131,6 +1132,7 @@ static int qcom_slim_ngd_power_up(struct qcom_slim_ngd_ctrl *ctrl)
 			dev_info(ctrl->dev, "Subsys restart: ADSP active framer\n");
 			return 0;
 		}
+		qcom_slim_ngd_setup(ctrl);
 		return 0;
 	}
 
@@ -1618,6 +1620,7 @@ static int __maybe_unused qcom_slim_ngd_runtime_suspend(struct device *dev)
 	struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(dev);
 	int ret = 0;
 
+	qcom_slim_ngd_exit_dma(ctrl);
 	if (!ctrl->qmi.handle)
 		return 0;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-09  8:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  8:24 [RESEND PATCH 0/4] slimbus: fixes for next 5.14 rc Srinivas Kandagatla
2021-08-09  8:24 ` [RESEND PATCH 1/4] slimbus: messaging: start transaction ids from 1 instead of zero Srinivas Kandagatla
2021-08-09  8:24 ` [RESEND PATCH 2/4] slimbus: messaging: check for valid transaction id Srinivas Kandagatla
2021-08-09  8:24 ` [RESEND PATCH 3/4] slimbus: ngd: set correct device for pm Srinivas Kandagatla
2021-08-09  8:24 ` [RESEND PATCH 4/4] slimbus: ngd: reset dma setup during runtime pm Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).