* [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries
@ 2026-11-22 6:25 Jizhou Tong
2026-11-22 6:30 ` sashiko-bot
2026-11-30 18:16 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Jizhou Tong @ 2026-11-22 6:25 UTC (permalink / raw)
To: Mark Brown
Cc: srini, lgirdwood, tiwai, perex, linux-sound, linux-arm-msm,
linux-kernel
wcd_interrupt_callback() reads three status registers after dispatching
the codec interrupt. It ignores read errors, so the loop condition can
use an uninitialized value or a value from the previous pass. A status
bit that stays set can also keep the callback looping while SoundWire
holds sdw_dev_lock.
Return on the first failed read. Allow up to ten dispatches for status
to clear, matching the SoundWire alert handler's retry budget. If a bit
remains set, log a rate-limited error and return -ETIMEDOUT.
Signed-off-by: Jizhou Tong <fqwqf@fqwqf.xyz>
---
Built wcd-common.o with ARCH=arm64 W=1 on the base below. A userspace
test of the callback covered injected regmap read errors, status
clearing on the final pass, and each register remaining pending.
sound/soc/codecs/wcd-common.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/wcd-common.c b/sound/soc/codecs/wcd-common.c
index 9016e97458..7c2d96ace0 100644
--- a/sound/soc/codecs/wcd-common.c
+++ b/sound/soc/codecs/wcd-common.c
@@ -15,6 +15,8 @@
#include "wcd-common.h"
+#define WCD_IRQ_MAX_RETRIES 10
+
#define WCD_MIN_MICBIAS_MV 1000
#define WCD_DEF_MICBIAS_MV 1800
#define WCD_MAX_MICBIAS_MV 2850
@@ -127,16 +129,27 @@ int wcd_interrupt_callback(struct sdw_slave *slave, struct irq_domain *slave_irq
{
struct regmap *regmap = dev_get_regmap(&slave->dev, NULL);
u32 sts1, sts2, sts3;
+ int ret, i;
- do {
+ /* A failed read or a stuck status must not hold sdw_dev_lock forever. */
+ for (i = 0; i < WCD_IRQ_MAX_RETRIES; i++) {
handle_nested_irq(irq_find_mapping(slave_irq, 0));
- regmap_read(regmap, wcd_intr_status0, &sts1);
- regmap_read(regmap, wcd_intr_status1, &sts2);
- regmap_read(regmap, wcd_intr_status2, &sts3);
+ ret = regmap_read(regmap, wcd_intr_status0, &sts1);
+ if (ret)
+ return ret;
+ ret = regmap_read(regmap, wcd_intr_status1, &sts2);
+ if (ret)
+ return ret;
+ ret = regmap_read(regmap, wcd_intr_status2, &sts3);
+ if (ret)
+ return ret;
- } while (sts1 || sts2 || sts3);
+ if (!(sts1 || sts2 || sts3))
+ return IRQ_HANDLED;
+ }
- return IRQ_HANDLED;
+ dev_err_ratelimited(&slave->dev, "interrupt status did not clear\n");
+ return -ETIMEDOUT;
}
EXPORT_SYMBOL_GPL(wcd_interrupt_callback);
base-commit: 7884221ca9857a317bf4bd81ac3bf5528f266feb
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries
2026-11-22 6:25 [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries Jizhou Tong
@ 2026-11-22 6:30 ` sashiko-bot
2026-11-30 18:16 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-22 6:30 UTC (permalink / raw)
To: Jizhou Tong; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ASoC: wcd-common: missing Fixes: trailer for
wcd_interrupt_callback() fix
--
commit 138bed245490e607222eb10428e4dada43820030
Author: Jizhou Tong <fqwqf@fqwqf.xyz>
> ASoC: codecs: wcd-common: bound interrupt status retries
>
> wcd_interrupt_callback() reads three status registers after dispatching
> the codec interrupt. It ignores read errors, so the loop condition can
> use an uninitialized value or a value from the previous pass. A status
> bit that stays set can also keep the callback looping while SoundWire
> holds sdw_dev_lock.
>
> Return on the first failed read. Allow up to ten dispatches for status
> to clear, matching the SoundWire alert handler's retry budget. If a bit
> remains set, log a rate-limited error and return -ETIMEDOUT.
>
> Signed-off-by: Jizhou Tong <fqwqf@fqwqf.xyz>
[Severity: Low]
This fixes the unchecked regmap_read() calls and unbounded retry loop in
wcd_interrupt_callback(). Should it include:
Fixes: 59aebbbb0b47 ("ASoC: codecs: wcd-common: move status_update callback to common")
--
Sashiko AI review · https://sashiko.dev/#/patchset/010601a201ee018c-30715d0f-712e-4181-9dea-d1b82b234831-000000@ap-northeast-1.amazonses.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries
2026-11-22 6:25 [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries Jizhou Tong
2026-11-22 6:30 ` sashiko-bot
@ 2026-11-30 18:16 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-11-30 18:16 UTC (permalink / raw)
To: Jizhou Tong
Cc: srini, lgirdwood, tiwai, perex, linux-sound, linux-arm-msm,
linux-kernel
On Sun, 22 Nov 2026 06:25:04 +0000, Jizhou Tong wrote:
> ASoC: codecs: wcd-common: bound interrupt status retries
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/1] ASoC: codecs: wcd-common: bound interrupt status retries
https://git.kernel.org/broonie/sound/c/eedf01508d86
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] 3+ messages in thread
end of thread, other threads:[~2026-12-01 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 6:25 [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries Jizhou Tong
2026-11-22 6:30 ` sashiko-bot
2026-11-30 18:16 ` Mark Brown
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.