From: sashiko-bot@kernel.org
To: "Birk Skyum" <birk.skyum@pm.me>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove
Date: Tue, 01 Dec 2026 17:06:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-243787@kernel.org> (raw)
In-Reply-To: <20261201-qcom-soundwire-rebind-fixes-v1-2-6c31d05f15b3@pm.me>
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
prev parent reply other threads:[~2026-12-01 17:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:28 [PATCH 0/2] soundwire: qcom: Fix IRQ trigger and runtime PM teardown on controller rebind Birk Skyum
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
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
2026-12-01 16:28 ` Birk Skyum via B4 Relay
2026-12-01 17:06 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-243787@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=birk.skyum@pm.me \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.