soundwire: qcom: wait for the interrupt thread before gating the clock
Subsystems (4)
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.
--- drivers/soundwire/qcom.c | 1 + 1 file changed, 1 insertion(+)
drivers/soundwire/qcom.c +1 -0
@@ -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
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.
---
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
@@ -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
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 andCLK_STOP_FINISHEDis 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")Signed-off-by Oleg Keri <[email protected]>---
v2:disable_irq()instead ofsynchronize_irq(), which left a window forCLK_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
Re: [PATCH v2] soundwire: qcom: disable the interrupt before gating the clock
In reply to Oleg KeriQuoted 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 andCLK_STOP_FINISHEDis 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