linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR
@ 2022-09-28 13:20 Krzysztof Kozlowski
  2022-09-28 13:20 ` [PATCH 2/2] slimbus: qcom-ngd-ctrl: drop PM runtime counter on transfer error paths Krzysztof Kozlowski
  2022-10-31 18:29 ` [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR Srinivas Kandagatla
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-28 13:20 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla,
	linux-arm-msm, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski, Chandana Kishori Chiluveru

Slimbus core interrupt is getting fired after suspend. At this point
ADSP slimbus hardware is off with gated clocks which is leading to an
unclocked access when HLOS slimbus tried to read the interrupt
status register in the ISR.

Co-developed-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index cec11aa106bf..ba36eb5c0de3 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -763,7 +763,14 @@ static irqreturn_t qcom_slim_ngd_interrupt(int irq, void *d)
 {
 	struct qcom_slim_ngd_ctrl *ctrl = d;
 	void __iomem *base = ctrl->ngd->base;
-	u32 stat = readl(base + NGD_INT_STAT);
+	u32 stat;
+
+	if (pm_runtime_suspended(ctrl->ctrl.dev)) {
+		dev_warn_once(ctrl->dev, "Interrupt received while suspended\n");
+		return IRQ_NONE;
+	}
+
+	stat = readl(base + NGD_INT_STAT);
 
 	if ((stat & NGD_INT_MSG_BUF_CONTE) ||
 		(stat & NGD_INT_MSG_TX_INVAL) || (stat & NGD_INT_DEV_ERR) ||
-- 
2.34.1


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

* [PATCH 2/2] slimbus: qcom-ngd-ctrl: drop PM runtime counter on transfer error paths
  2022-09-28 13:20 [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR Krzysztof Kozlowski
@ 2022-09-28 13:20 ` Krzysztof Kozlowski
  2022-10-31 18:29 ` [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-28 13:20 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla,
	linux-arm-msm, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

If transfer in qcom_slim_ngd_xfer_msg_sync() fails, we need to drop the
PM runtime usage counter to have it balanced.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index ba36eb5c0de3..ac84fdc2822f 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -919,21 +919,29 @@ static int qcom_slim_ngd_xfer_msg_sync(struct slim_controller *ctrl,
 	DECLARE_COMPLETION_ONSTACK(done);
 	int ret, timeout;
 
-	pm_runtime_get_sync(ctrl->dev);
+	ret = pm_runtime_get_sync(ctrl->dev);
+	if (ret < 0)
+		goto pm_put;
 
 	txn->comp = &done;
 
 	ret = qcom_slim_ngd_xfer_msg(ctrl, txn);
 	if (ret)
-		return ret;
+		goto pm_put;
 
 	timeout = wait_for_completion_timeout(&done, HZ);
 	if (!timeout) {
 		dev_err(ctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", txn->mc,
 				txn->mt);
-		return -ETIMEDOUT;
+		ret = -ETIMEDOUT;
+		goto pm_put;
 	}
 	return 0;
+
+pm_put:
+	pm_runtime_put(ctrl->dev);
+
+	return ret;
 }
 
 static int qcom_slim_ngd_enable_stream(struct slim_stream_runtime *rt)
-- 
2.34.1


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

* Re: [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR
  2022-09-28 13:20 [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR Krzysztof Kozlowski
  2022-09-28 13:20 ` [PATCH 2/2] slimbus: qcom-ngd-ctrl: drop PM runtime counter on transfer error paths Krzysztof Kozlowski
@ 2022-10-31 18:29 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2022-10-31 18:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Andy Gross, Bjorn Andersson, Konrad Dybcio,
	linux-arm-msm, alsa-devel, linux-kernel
  Cc: Chandana Kishori Chiluveru



On 28/09/2022 14:20, Krzysztof Kozlowski wrote:
> Slimbus core interrupt is getting fired after suspend. At this point
> ADSP slimbus hardware is off with gated clocks which is leading to an
> unclocked access when HLOS slimbus tried to read the interrupt
> status register in the ISR.
> 
> Co-developed-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
> Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---

Applied both,

--srini
>   drivers/slimbus/qcom-ngd-ctrl.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
> index cec11aa106bf..ba36eb5c0de3 100644
> --- a/drivers/slimbus/qcom-ngd-ctrl.c
> +++ b/drivers/slimbus/qcom-ngd-ctrl.c
> @@ -763,7 +763,14 @@ static irqreturn_t qcom_slim_ngd_interrupt(int irq, void *d)
>   {
>   	struct qcom_slim_ngd_ctrl *ctrl = d;
>   	void __iomem *base = ctrl->ngd->base;
> -	u32 stat = readl(base + NGD_INT_STAT);
> +	u32 stat;
> +
> +	if (pm_runtime_suspended(ctrl->ctrl.dev)) {
> +		dev_warn_once(ctrl->dev, "Interrupt received while suspended\n");
> +		return IRQ_NONE;
> +	}
> +
> +	stat = readl(base + NGD_INT_STAT);
>   
>   	if ((stat & NGD_INT_MSG_BUF_CONTE) ||
>   		(stat & NGD_INT_MSG_TX_INVAL) || (stat & NGD_INT_DEV_ERR) ||

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

end of thread, other threads:[~2022-10-31 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 13:20 [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR Krzysztof Kozlowski
2022-09-28 13:20 ` [PATCH 2/2] slimbus: qcom-ngd-ctrl: drop PM runtime counter on transfer error paths Krzysztof Kozlowski
2022-10-31 18:29 ` [PATCH 1/2] slimbus: qcom-ngd-ctrl: check for device runtime PM status during ISR 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).