* [PATCH v2] iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failure
@ 2026-05-18 18:11 Stepan Ionichev
2026-07-03 22:59 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Stepan Ionichev @ 2026-05-18 18:11 UTC (permalink / raw)
To: jic23
Cc: dlechner, daniel.lezcano, nuno.sa, andy, gregkh, hcazarim,
linux-iio, linux-kernel, sozdayvek
nxp_sar_adc_isr_buffer() bails on the first channel-read failure
without calling iio_trigger_notify_done(), so the trigger use_count
is left incremented and iio_trigger_poll_chained() drops subsequent
dispatches until the device is rebound.
Reaching this path means a state machine has gone wrong (driver bug
or the SAR ADC in an unexpected state) rather than a transient bus
issue, so this is hardening rather than a bug fix. If the underlying
condition persists the device is wedged and needs an unbind anyway.
Call iio_trigger_notify_done() on the error exit too, matching the
success path. The nxp_sar_adc_read_notify() duplication is intentional
and avoids a goto label for a two-line bail-out, as suggested by David.
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
v2:
- Drop Fixes: and Cc: stable@; this is a state-machine hardening, not
a user-visible bug fix (Jonathan)
- Reframe the commit message and explain why the failure is not a bus
issue
- Inline the iio_trigger_notify_done() in the error exit instead of a
goto label, accepting the small nxp_sar_adc_read_notify() duplication
(David)
v1: https://lore.kernel.org/all/20260517162346.189-1-sozdayvek@gmail.com/
drivers/iio/adc/nxp-sar-adc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iio/adc/nxp-sar-adc.c b/drivers/iio/adc/nxp-sar-adc.c
index 9d9f2c76b..1fc839a15 100644
--- a/drivers/iio/adc/nxp-sar-adc.c
+++ b/drivers/iio/adc/nxp-sar-adc.c
@@ -341,6 +341,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
ret = nxp_sar_adc_read_data(info, info->buffered_chan[i]);
if (ret < 0) {
nxp_sar_adc_read_notify(info);
+ iio_trigger_notify_done(indio_dev->trig);
return;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failure
2026-05-18 18:11 [PATCH v2] iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failure Stepan Ionichev
@ 2026-07-03 22:59 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-07-03 22:59 UTC (permalink / raw)
To: Stepan Ionichev
Cc: dlechner, daniel.lezcano, nuno.sa, andy, gregkh, hcazarim,
linux-iio, linux-kernel
On Mon, 18 May 2026 23:11:38 +0500
Stepan Ionichev <sozdayvek@gmail.com> wrote:
> nxp_sar_adc_isr_buffer() bails on the first channel-read failure
> without calling iio_trigger_notify_done(), so the trigger use_count
> is left incremented and iio_trigger_poll_chained() drops subsequent
> dispatches until the device is rebound.
>
> Reaching this path means a state machine has gone wrong (driver bug
> or the SAR ADC in an unexpected state) rather than a transient bus
> issue, so this is hardening rather than a bug fix. If the underlying
> condition persists the device is wedged and needs an unbind anyway.
>
> Call iio_trigger_notify_done() on the error exit too, matching the
> success path. The nxp_sar_adc_read_notify() duplication is intentional
> and avoids a goto label for a two-line bail-out, as suggested by David.
>
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Huh. Seems I picked this up a while ago but neither replied to this thread
nor marked it so in patchwork.
Anyhow, long applied.
Thanks,
Jonathan
> ---
> v2:
> - Drop Fixes: and Cc: stable@; this is a state-machine hardening, not
> a user-visible bug fix (Jonathan)
> - Reframe the commit message and explain why the failure is not a bus
> issue
> - Inline the iio_trigger_notify_done() in the error exit instead of a
> goto label, accepting the small nxp_sar_adc_read_notify() duplication
> (David)
>
> v1: https://lore.kernel.org/all/20260517162346.189-1-sozdayvek@gmail.com/
>
> drivers/iio/adc/nxp-sar-adc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/adc/nxp-sar-adc.c b/drivers/iio/adc/nxp-sar-adc.c
> index 9d9f2c76b..1fc839a15 100644
> --- a/drivers/iio/adc/nxp-sar-adc.c
> +++ b/drivers/iio/adc/nxp-sar-adc.c
> @@ -341,6 +341,7 @@ static void nxp_sar_adc_isr_buffer(struct iio_dev *indio_dev)
> ret = nxp_sar_adc_read_data(info, info->buffered_chan[i]);
> if (ret < 0) {
> nxp_sar_adc_read_notify(info);
> + iio_trigger_notify_done(indio_dev->trig);
> return;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-03 22:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18 18:11 [PATCH v2] iio: adc: nxp-sar-adc: harden buffer ISR against per-channel read failure Stepan Ionichev
2026-07-03 22:59 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox