Skip to contentSkip to conversation

soundwire: qcom: wait for the interrupt thread before gating the clock

PATCH Superseded Oleg Keri 3 participants 4 messages Oct 7 – Nov 2

Subsystems (4)
lore
Share & tools
lore

Oleg Keri

author
#0 lore raw

PATCH 1/1 soundwire: qcom: wait for the interrupt thread before gating the clock

A broadcast write returns as soon as the interrupt thread signals SPECIAL_CMD_ID_FINISHED, while the thread still has to clear and re-read the interrupt status. swrm_runtime_suspend() gates hclk right after the ClockStopNow broadcast, so those accesses race against the clock being removed; on x1e80100 and glymur hclk is the SoundWire clock itself. The next clock-stop exit then fails at random: bus clash, parity errors reported by the peripherals or AUTO_ENUM_FAILED, each leaving one side of the speakers detached until reboot.

Wait for the interrupt thread to finish before gating the clock.

Fixes 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
---
 drivers/soundwire/qcom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/soundwire/qcom.c +1 -0
index 6e0c5fb10efa..76f940f4eb31 100644
@@ -1887,6 +1887,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
 		}
 	}
 
+	synchronize_irq(ctrl->irq);
 	clk_disable_unprepare(ctrl->hclk);
 
 	usleep_range(300, 305);
Signature · 1 line
2.55.0
author
#1 lore raw

PATCH v2 1/1 soundwire: qcom: disable the interrupt before gating the clock

swrm_runtime_suspend() gates hclk straight after the ClockStopNow broadcast, while the interrupt thread that completed it is still clearing the status and CLK_STOP_FINISHED is about to fire. Both touch registers with the clock going away; on x1e80100 and glymur hclk is the SoundWire clock itself. The next clock-stop exit then fails at random (bus clash, parity errors, AUTO_ENUM_FAILED) and one side of the speakers stays detached until reboot.

Disable the interrupt before gating the clock and enable it again once the clock is back.

Fixes 74e79da9fd46 ("soundwire: qcom: add runtime pm support")

---
v2: disable_irq() instead of synchronize_irq(), which left a window for CLK_STOP_FINISHED; about one boot in four still hit it.

 drivers/soundwire/qcom.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/soundwire/qcom.c +2 -0
index 6e0c5fb10efa..147e55b7a600 100644
@@ -1801,6 +1801,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 	}
 
 	clk_prepare_enable(ctrl->hclk);
+	enable_irq(ctrl->irq);
 
 	if (ctrl->clock_stop_not_supported) {
 		reinit_completion(&ctrl->enumeration);
@@ -1887,6 +1888,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
 		}
 	}
 
+	disable_irq(ctrl->irq);
 	clk_disable_unprepare(ctrl->hclk);
 
 	usleep_range(300, 305);
Signature · 1 line
2.55.0
Reviewed-by on v2 1/1
#2 lore raw

Re: [PATCH v2] soundwire: qcom: disable the interrupt before gating the clock

Quoted 11 lines · Oleg Keri

swrm_runtime_suspend() gates hclk straight after the ClockStopNow broadcast, while the interrupt thread that completed it is still clearing the status and CLK_STOP_FINISHED is about to fire. Both touch registers with the clock going away; on x1e80100 and glymur hclk is the SoundWire clock itself. The next clock-stop exit then fails at random (bus clash, parity errors, AUTO_ENUM_FAILED) and one side of the speakers stays detached until reboot.

Disable the interrupt before gating the clock and enable it again once the clock is back.

Quoted 9 lines
Fixes 74e79da9fd46 ("soundwire: qcom: add runtime pm support")

---
v2: disable_irq() instead of synchronize_irq(), which left a window for CLK_STOP_FINISHED; about one boot in four still hit it.

 drivers/soundwire/qcom.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 2 lines
With best wishes
Dmitry
maintainer Applied
#3 lore raw

Re: [PATCH v2] soundwire: qcom: disable the interrupt before gating the clock

In reply to Oleg Keri
Quoted 9 lines · Oleg Keri

swrm_runtime_suspend() gates hclk straight after the ClockStopNow broadcast, while the interrupt thread that completed it is still clearing the status and CLK_STOP_FINISHED is about to fire. Both touch registers with the clock going away; on x1e80100 and glymur hclk is the SoundWire clock itself. The next clock-stop exit then fails at random (bus clash, parity errors, AUTO_ENUM_FAILED) and one side of the speakers stays detached until reboot.

[...]

Applied, thanks!

[1/1] soundwire: qcom: disable the interrupt before gating the clock

      commit: 6c067677192f054bbfa815caf04f536bb8dcdee2

Best regards,

Signature · 1 line
~Vinod