* [PATCH 0/2] soundwire: qcom: Fix IRQ trigger and runtime PM teardown on controller rebind
@ 2026-12-01 16:28 Birk Skyum via B4 Relay
2026-12-01 16:28 ` [PATCH 1/2] soundwire: qcom: Take controller IRQ trigger type from DT Birk Skyum via B4 Relay
2026-12-01 16:28 ` [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove Birk Skyum via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Birk Skyum via B4 Relay @ 2026-12-01 16:28 UTC (permalink / raw)
To: Srinivas Kandagatla, Vinod Koul, Bard Liao, Pierre-Louis Bossart
Cc: linux-sound, linux-arm-msm, linux-kernel, Birk Skyum
Two fixes for unbinding and rebinding Qualcomm SoundWire controllers
(for example when the audio DSP restarts after crash recovery, driver
reload, or hibernation on Snapdragon X1 laptops):
1. Stop forcing IRQF_TRIGGER_RISING when requesting the controller IRQ
so level-triggered DT interrupts do not fail to remap on rebind.
2. Disable runtime PM and autosuspend in qcom_swrm_remove() and gate
hclk release on runtime PM status so unbind does not double-disable
hclk and rebind does not oops in swrm_runtime_resume().
Tested on a Lenovo Yoga Slim 7x (X1E80100) across ADSP reloads and
five consecutive hibernation cycles.
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
---
Birk Skyum (2):
soundwire: qcom: Take controller IRQ trigger type from DT
soundwire: qcom: Balance runtime PM and hclk in remove
drivers/soundwire/qcom.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
base-commit: ef922b721a5e99348fc1f5801fdeb427ee14ee9f
change-id: 20261201-qcom-soundwire-rebind-fixes-5793ac889fb2
Best regards,
--
Birk Skyum <birk.skyum@pm.me>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] soundwire: qcom: Take controller IRQ trigger type from DT 2026-12-01 16:28 [PATCH 0/2] soundwire: qcom: Fix IRQ trigger and runtime PM teardown on controller rebind Birk Skyum via B4 Relay @ 2026-12-01 16:28 ` Birk Skyum via B4 Relay 2026-12-01 16:28 ` [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove Birk Skyum via B4 Relay 1 sibling, 0 replies; 4+ messages in thread From: Birk Skyum via B4 Relay @ 2026-12-01 16:28 UTC (permalink / raw) To: Srinivas Kandagatla, Vinod Koul, Bard Liao, Pierre-Louis Bossart Cc: linux-sound, linux-arm-msm, linux-kernel, Birk Skyum From: Birk Skyum <birk.skyum@pm.me> The controller interrupt is requested with IRQF_TRIGGER_RISING even though every Qualcomm device tree declares it IRQ_TYPE_LEVEL_HIGH. That request changes the IRQ mapping's trigger type to edge, and it stays that way after the driver unbinds. The next probe asks for the device tree's level type, irq_create_fwspec_mapping() refuses with "type mismatch", of_irq_get() returns 0, and probe fails with -EINVAL, leaving the sound card gone until reboot. On a Lenovo Yoga Slim 7x (X1E80100), this triggers whenever the audio DSP driver reloads (for example after crash recovery or resuming from hibernation), which unbinds and rebinds the LPASS SoundWire controllers. Drop the hardcoded IRQF_TRIGGER_RISING flag so the trigger type comes from firmware. Fixes: 02efb49aa805 ("soundwire: qcom: add support for SoundWire controller") Signed-off-by: Birk Skyum <birk.skyum@pm.me> --- drivers/soundwire/qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 6e0c5fb10..6dde94e42 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -1713,9 +1713,13 @@ static int qcom_swrm_probe(struct platform_device *pdev) ctrl->reg_read(ctrl, SWRM_COMP_HW_VERSION, &ctrl->version); qcom_swrm_set_ee_register_layout(ctrl, data); + /* + * Take the trigger type from the device tree. Forcing a rising edge + * changes the mapping of a level interrupt, and the next probe after + * an unbind then fails to map it ("type mismatch") and gets IRQ 0. + */ ret = devm_request_threaded_irq(dev, ctrl->irq, NULL, qcom_swrm_irq_handler, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, "soundwire", ctrl); if (ret) { -- 2.56.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove 2026-12-01 16:28 [PATCH 0/2] soundwire: qcom: Fix IRQ trigger and runtime PM teardown on controller rebind Birk Skyum via B4 Relay 2026-12-01 16:28 ` [PATCH 1/2] soundwire: qcom: Take controller IRQ trigger type from DT Birk Skyum via B4 Relay @ 2026-12-01 16:28 ` Birk Skyum via B4 Relay 2026-12-01 17:06 ` sashiko-bot 1 sibling, 1 reply; 4+ messages in thread From: Birk Skyum via B4 Relay @ 2026-12-01 16:28 UTC (permalink / raw) To: Srinivas Kandagatla, Vinod Koul, Bard Liao, Pierre-Louis Bossart Cc: linux-sound, linux-arm-msm, linux-kernel, Birk Skyum From: Birk Skyum <birk.skyum@pm.me> qcom_swrm_probe() enables runtime PM and autosuspend at the end of probe, but qcom_swrm_remove() never disables runtime PM and unconditionally disables and unprepares ctrl->hclk even when runtime suspend has already released it. When the controller unbinds and rebinds (on X1E80100 whenever the audio DSP restarts, because the LPASS chain depends on clocks provided by the DSP), the unbind warns that hclk is already disabled/unprepared, and the second probe runs with runtime PM still enabled. sdw_bus_master_add() then triggers swrm_runtime_resume() before the bus is initialized and oopses with a NULL pointer dereference in sdw_bus_exit_clk_stop(). Disable runtime PM and autosuspend in qcom_swrm_remove(), release hclk only if the device is not runtime-suspended, and mark the device suspended. Tested on a Lenovo Yoga Slim 7x (X1E80100) across ADSP reloads and five consecutive hibernation cycles. Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support") Signed-off-by: Birk Skyum <birk.skyum@pm.me> --- drivers/soundwire/qcom.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 6dde94e42..d3fd7ccad 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -1789,9 +1789,22 @@ static int qcom_swrm_probe(struct platform_device *pdev) static void qcom_swrm_remove(struct platform_device *pdev) { struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev); + struct device *dev = &pdev->dev; sdw_bus_master_delete(&ctrl->bus); - clk_disable_unprepare(ctrl->hclk); + + /* + * Balance pm_runtime_enable() in probe. Left enabled, the next probe + * after an unbind (the audio DSP restarting unbinds the LPASS chain) + * runtime-resumes the controller from sdw_bus_master_add() before its + * bus is set up and oopses in sdw_bus_exit_clk_stop(). Runtime suspend + * already released hclk, so release it here only if still active. + */ + pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); + if (!pm_runtime_status_suspended(dev)) + clk_disable_unprepare(ctrl->hclk); + pm_runtime_set_suspended(dev); } static int __maybe_unused swrm_runtime_resume(struct device *dev) -- 2.56.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove 2026-12-01 16:28 ` [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove Birk Skyum via B4 Relay @ 2026-12-01 17:06 ` sashiko-bot 0 siblings, 0 replies; 4+ messages in thread From: sashiko-bot @ 2026-12-01 17:06 UTC (permalink / raw) To: Birk Skyum; +Cc: linux-sound Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] soundwire: qcom: race in qcom_swrm_remove() deleting bus before disabling PM -- commit 03b09ca4bdac9e2ec9ab217ea5ddf60211e3ae7c Author: Birk Skyum <birk.skyum@pm.me> soundwire: qcom: Balance runtime PM and hclk in remove This commit disables runtime PM and autosuspend in qcom_swrm_remove() and disables ctrl->hclk only when the device is not already runtime-suspended. > diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c > index 6dde94e42e895..d3fd7ccad0dab 100644 > --- a/drivers/soundwire/qcom.c > +++ b/drivers/soundwire/qcom.c > @@ -1789,9 +1789,22 @@ static int qcom_swrm_probe(struct platform_device *pdev) > static void qcom_swrm_remove(struct platform_device *pdev) > { > struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev); > + struct device *dev = &pdev->dev; > > sdw_bus_master_delete(&ctrl->bus); > - clk_disable_unprepare(ctrl->hclk); > + > + /* > + * Balance pm_runtime_enable() in probe. Left enabled, the next probe > + * after an unbind (the audio DSP restarting unbinds the LPASS chain) > + * runtime-resumes the controller from sdw_bus_master_add() before its > + * bus is set up and oopses in sdw_bus_exit_clk_stop(). Runtime suspend > + * already released hclk, so release it here only if still active. > + */ > + pm_runtime_disable(dev); > + pm_runtime_dont_use_autosuspend(dev); > + if (!pm_runtime_status_suspended(dev)) > + clk_disable_unprepare(ctrl->hclk); > + pm_runtime_set_suspended(dev); > } [Severity: High] Can swrm_runtime_suspend() run concurrently with sdw_bus_master_delete() because runtime PM is disabled only after deleting the bus? If the controller is active with active children (child_count > 0) and its last_busy timestamp is older than the autosuspend delay when unbind begins, __device_release_driver() leaves dev active with usage_count == 0. Calling sdw_bus_master_delete() while runtime PM is still enabled then drops child_count to 0 and queues an async runtime suspend while the bus is being torn down: CPU0 kworker (pm_wq) qcom_swrm_remove() sdw_bus_master_delete(&ctrl->bus) ... sdw_master_device_del(&ctrl->bus) device_unregister(bus->dev) ... pm_request_idle(dev) /* frees bus->md (bus->dev) */ swrm_runtime_suspend(dev) sdw_bus_prep_clk_stop(&ctrl->bus) sdw_bus_clk_stop(&ctrl->bus) ... dev_err(bus->dev, ...) <-- use-after-free lockdep_unregister_key(&bus->msg_lock_key) swrm_runtime_suspend() accesses ctrl->bus (including msg_lock and the freed bus->dev) and re-enables ctrl->wake_irq during removal. Calling pm_runtime_disable() and pm_runtime_dont_use_autosuspend() before sdw_bus_master_delete() would prevent runtime PM callbacks from running during bus teardown. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201-qcom-soundwire-rebind-fixes-v1-0-6c31d05f15b3@pm.me?part=2 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 17:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 16:28 [PATCH 0/2] soundwire: qcom: Fix IRQ trigger and runtime PM teardown on controller rebind Birk Skyum via B4 Relay 2026-12-01 16:28 ` [PATCH 1/2] soundwire: qcom: Take controller IRQ trigger type from DT Birk Skyum via B4 Relay 2026-12-01 16:28 ` [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove Birk Skyum via B4 Relay 2026-12-01 17:06 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox