* [PATCH] ASoC: codecs: wcd-common: bound interrupt status retries
@ 2026-11-22 6:25 Jizhou Tong
2026-11-22 6:30 ` sashiko-bot
0 siblings, 1 reply; 2+ 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] 2+ 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
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2026-11-22 6:30 UTC | newest]
Thread overview: 2+ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox