* [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove
@ 2026-06-19 8:03 Runyu Xiao
2026-06-19 11:48 ` Mark Brown
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Runyu Xiao @ 2026-06-19 8:03 UTC (permalink / raw)
To: Oder Chiou, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Rander Wang,
Pierre-Louis Bossart, Bard Liao, linux-sound, linux-kernel,
Runyu Xiao
rt700_sdw_remove() drains jack_detect_work and jack_btn_check_work only
when rt700->hw_init is true. That state bit is cleared by
rt700_update_status() when the SoundWire slave becomes UNATTACHED, but a
jack work item can already have been queued by rt700_interrupt_callback()
or rt700_jack_init() while the device was initialized.
Do not use hw_init as the remove-time guard for draining these work
objects. The delayed works are initialized during rt700_init(), so remove
can cancel them unconditionally and pair the object lifetime with the
codec-private data lifetime instead of a mutable hardware state bit.
This issue was found by our static analysis tool and then confirmed by
manual review of the SoundWire status, interrupt and remove paths. The
remove path should drain work based on whether the work object exists, not
on a runtime hardware state bit that can change after the work was queued.
A QEMU PoC queued jack_detect_work, simulated SDW_SLAVE_UNATTACHED, and
then entered remove. DEBUG_OBJECTS reported an active timer/work object
associated with the rt700 jack work path after remove skipped the cancel.
This is sent as an RFC because the practical trigger depends on SoundWire
core remove ordering after an UNATTACHED status update. If remove cannot
run after hw_init has been cleared while jack work is still pending, this
is a defensive lifecycle cleanup rather than a reachable race on current
systems.
Fixes: 737ee8bdf682 ("ASoC: rt700-sdw: use cancel_work_sync() in .remove as well as .suspend")
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
sound/soc/codecs/rt700-sdw.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c
index 44543c0da177..f7bd793e3e67 100644
--- a/sound/soc/codecs/rt700-sdw.c
+++ b/sound/soc/codecs/rt700-sdw.c
@@ -459,10 +459,8 @@ static int rt700_sdw_remove(struct sdw_slave *slave)
{
struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev);
- if (rt700->hw_init) {
- cancel_delayed_work_sync(&rt700->jack_detect_work);
- cancel_delayed_work_sync(&rt700->jack_btn_check_work);
- }
+ cancel_delayed_work_sync(&rt700->jack_detect_work);
+ cancel_delayed_work_sync(&rt700->jack_btn_check_work);
pm_runtime_disable(&slave->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove
2026-06-19 8:03 [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove Runyu Xiao
@ 2026-06-19 11:48 ` Mark Brown
2026-06-19 12:23 ` [RFC PATCH v2] " Runyu Xiao
2026-06-19 13:49 ` [RFC PATCH] " Pierre-Louis Bossart
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-06-19 11:48 UTC (permalink / raw)
To: Runyu Xiao
Cc: Oder Chiou, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Rander Wang, Pierre-Louis Bossart, Bard Liao, linux-sound,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Fri, Jun 19, 2026 at 04:03:34PM +0800, Runyu Xiao wrote:
> rt700_sdw_remove() drains jack_detect_work and jack_btn_check_work only
> when rt700->hw_init is true. That state bit is cleared by
> rt700_update_status() when the SoundWire slave becomes UNATTACHED, but a
> jack work item can already have been queued by rt700_interrupt_callback()
> or rt700_jack_init() while the device was initialized.
This doesn't apply against current code, please check and resend.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2] ASoC: rt700-sdw: always drain jack work on remove
2026-06-19 8:03 [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove Runyu Xiao
2026-06-19 11:48 ` Mark Brown
@ 2026-06-19 12:23 ` Runyu Xiao
2026-06-29 17:47 ` Mark Brown
2026-06-19 13:49 ` [RFC PATCH] " Pierre-Louis Bossart
2 siblings, 1 reply; 5+ messages in thread
From: Runyu Xiao @ 2026-06-19 12:23 UTC (permalink / raw)
To: Oder Chiou, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Pierre-Louis Bossart, Bard Liao, Rander Wang, linux-sound,
linux-kernel, Runyu Xiao
rt700_sdw_remove() drains jack_detect_work and jack_btn_check_work only
when rt700->hw_init is true. That state bit is cleared by
rt700_update_status() when the SoundWire slave becomes UNATTACHED, but a
jack work item can already have been queued by rt700_interrupt_callback()
or rt700_jack_init() while the device was initialized.
Do not use hw_init as the remove-time guard for draining these work
objects. The delayed works are initialized during rt700_init(), so remove
can cancel them unconditionally and pair the object lifetime with the
codec-private data lifetime instead of a mutable hardware state bit.
This issue was found by our static analysis tool and then confirmed by
manual review of the SoundWire status, interrupt and remove paths. The
remove path should drain work based on whether the work object exists, not
on a runtime hardware state bit that can change after the work was queued.
A QEMU PoC queued jack_detect_work, simulated SDW_SLAVE_UNATTACHED, and
then entered remove. DEBUG_OBJECTS reported an active timer/work object
associated with the rt700 jack work path after remove skipped the cancel.
This is sent as an RFC because the practical trigger depends on SoundWire
core remove ordering after an UNATTACHED status update. If remove cannot
run after hw_init has been cleared while jack work is still pending, this
is a defensive lifecycle cleanup rather than a reachable race on current
systems.
Fixes: 737ee8bdf682 ("ASoC: rt700-sdw: use cancel_work_sync() in .remove as well as .suspend")
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
Changes in v2:
- Rebase onto broonie/sound.git for-next, where SoundWire remove()
callbacks now return void.
sound/soc/codecs/rt700-sdw.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c
index 30fcca210f05..3194379c5778 100644
--- a/sound/soc/codecs/rt700-sdw.c
+++ b/sound/soc/codecs/rt700-sdw.c
@@ -459,10 +459,8 @@ static void rt700_sdw_remove(struct sdw_slave *slave)
{
struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev);
- if (rt700->hw_init) {
- cancel_delayed_work_sync(&rt700->jack_detect_work);
- cancel_delayed_work_sync(&rt700->jack_btn_check_work);
- }
+ cancel_delayed_work_sync(&rt700->jack_detect_work);
+ cancel_delayed_work_sync(&rt700->jack_btn_check_work);
pm_runtime_disable(&slave->dev);
}
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove
2026-06-19 8:03 [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove Runyu Xiao
2026-06-19 11:48 ` Mark Brown
2026-06-19 12:23 ` [RFC PATCH v2] " Runyu Xiao
@ 2026-06-19 13:49 ` Pierre-Louis Bossart
2 siblings, 0 replies; 5+ messages in thread
From: Pierre-Louis Bossart @ 2026-06-19 13:49 UTC (permalink / raw)
To: Runyu Xiao, Oder Chiou, Mark Brown
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Rander Wang,
Bard Liao, linux-sound, linux-kernel
On 6/19/26 10:03, Runyu Xiao wrote:
> rt700_sdw_remove() drains jack_detect_work and jack_btn_check_work only
> when rt700->hw_init is true. That state bit is cleared by
> rt700_update_status() when the SoundWire slave becomes UNATTACHED, but a
> jack work item can already have been queued by rt700_interrupt_callback()
> or rt700_jack_init() while the device was initialized.
>
> Do not use hw_init as the remove-time guard for draining these work
> objects. The delayed works are initialized during rt700_init(), so remove
> can cancel them unconditionally and pair the object lifetime with the
> codec-private data lifetime instead of a mutable hardware state bit.
>
> This issue was found by our static analysis tool and then confirmed by
> manual review of the SoundWire status, interrupt and remove paths. The
> remove path should drain work based on whether the work object exists, not
> on a runtime hardware state bit that can change after the work was queued.
>
> A QEMU PoC queued jack_detect_work, simulated SDW_SLAVE_UNATTACHED, and
> then entered remove. DEBUG_OBJECTS reported an active timer/work object
> associated with the rt700 jack work path after remove skipped the cancel.
>
> This is sent as an RFC because the practical trigger depends on SoundWire
> core remove ordering after an UNATTACHED status update. If remove cannot
> run after hw_init has been cleared while jack work is still pending, this
> is a defensive lifecycle cleanup rather than a reachable race on current
> systems.
The SoundWire core doesn't deal well with devices going off the bus anyways, so this feels like an academic improvement IMHO.
In addition this codec isn't used in any production systems to the best of my knowledge, it's likely this driver could be removed without impacts.
> Fixes: 737ee8bdf682 ("ASoC: rt700-sdw: use cancel_work_sync() in .remove as well as .suspend")
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> sound/soc/codecs/rt700-sdw.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c
> index 44543c0da177..f7bd793e3e67 100644
> --- a/sound/soc/codecs/rt700-sdw.c
> +++ b/sound/soc/codecs/rt700-sdw.c
> @@ -459,10 +459,8 @@ static int rt700_sdw_remove(struct sdw_slave *slave)
> {
> struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev);
>
> - if (rt700->hw_init) {
> - cancel_delayed_work_sync(&rt700->jack_detect_work);
> - cancel_delayed_work_sync(&rt700->jack_btn_check_work);
> - }
> + cancel_delayed_work_sync(&rt700->jack_detect_work);
> + cancel_delayed_work_sync(&rt700->jack_btn_check_work);
>
> pm_runtime_disable(&slave->dev);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH v2] ASoC: rt700-sdw: always drain jack work on remove
2026-06-19 12:23 ` [RFC PATCH v2] " Runyu Xiao
@ 2026-06-29 17:47 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-06-29 17:47 UTC (permalink / raw)
To: Oder Chiou, Runyu Xiao
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Pierre-Louis Bossart, Bard Liao, Rander Wang, linux-sound,
linux-kernel
On Fri, 19 Jun 2026 20:23:25 +0800, Runyu Xiao wrote:
> ASoC: rt700-sdw: always drain jack work on remove
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: rt700-sdw: always drain jack work on remove
https://git.kernel.org/broonie/sound/c/612ccf42acd1
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-30 11:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-19 8:03 [RFC PATCH] ASoC: rt700-sdw: always drain jack work on remove Runyu Xiao
2026-06-19 11:48 ` Mark Brown
2026-06-19 12:23 ` [RFC PATCH v2] " Runyu Xiao
2026-06-29 17:47 ` Mark Brown
2026-06-19 13:49 ` [RFC PATCH] " Pierre-Louis Bossart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®