Re: [PATCH v2 1/2] i2c: ocores: increase poll timeout to total transfer timeout
From: Matthias Schiffer
Date: Thu Oct 09 2025 - 09:27:16 EST
On Thu, 2025-10-09 at 15:20 +0200, Andrew Lunn wrote:
> On Thu, Oct 09, 2025 at 11:19:49AM +0200, Matthias Schiffer wrote:
> > When a target makes use of clock stretching, a timeout of 1ms may not be
> > enough. One extreme example is the NXP PTN3460 eDP to LVDS bridge, which
> > takes ~320ms to send its ACK after a flash command has been
> > submitted.
> >
> > The behavior in the regular case is unchanged, spinning for up to 1ms,
> > but the open-coded poll loop is replaced with read_poll_timeout_atomic()
> > as suggested by Andrew Lunn. In cases where 1ms is not sufficient,
> > read_poll_timeout() is used, allowing a total transfer time up to the
> > timeout set in struct i2c_adapter (defaulting to 1s, configurable through
> > the I2C_TIMEOUT ioctl).
>
> Thanks
>
> Did you test with CONFIG_DEBUG_ATOMIC_SLEEP enabled? I don't think it
> is an issue, but the old code could be used in atomic context because
> it never slept.
I did not, but there is only one call chain ocores_xfer_core ->
ocores_process_polling -> ocores_poll_wait -> ocores_wait, which is definitely
not used in atomic context (in IRQ mode, ocores_xfer_core calls
wait_event_timeout, which might_sleep()).
Best,
Matthias
>
> Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
>
> Andrew
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/