Re: [PATCH v2] i2c: designware: Release slave SCL hold in __i2c_dw_disable()

From: Mika Westerberg

Date: Fri Nov 20 2026 - 07:56:54 EST


On Fri, Nov 20, 2026 at 01:52:02PM +0100, Heikki Krogerus wrote:
> On Thu, Nov 12, 2026 at 02:52:38PM +0000, Atif Ashhar wrote:
> > When an external I2C master initiates a read to the Synopsys DW_apb_i2c
> > adapter in slave mode during kexec teardown, runtime suspend, or driver
> > unbind, the slave hardware stretches SCL low (0V) waiting for TX data,
> > setting DW_IC_STATUS_SLAVE_HOLD_TX_FIFO_EMPTY.
> >
> > In master mode, __i2c_dw_disable() issues DW_IC_ENABLE_ABORT to release
> > the bus. However, according to the Synopsys DW_apb_i2c Databook, the
> > ABORT bit applies only to master transfers and has no effect in slave
> > mode. Because the slave cannot disable while stretching SCL,
> > __i2c_dw_disable() times out, leaving DW_IC_ENABLE_STATUS[0] = 1 across
> > kexec or rebind. Subsequent writes to DW_IC_SAR are write-protected and
> > silently dropped by hardware, wedging the slave and blocking any other
> > devices sharing the physical bus.
> >
> > Fix this by:
> >
> > 1. In __i2c_dw_disable(), if DW_IC_STATUS_SLAVE_HOLD_TX_FIFO_EMPTY is
> > set while disabling, temporarily re-enable the controller so the APB
> > interface accepts data commands without racing with the slave ISR,
> > clear pending RD_REQ/TX_ABRT interrupts, write a dummy 0xff byte to
> > DW_IC_DATA_CMD to release the SCL stretch, and immediately request
> > disable via __i2c_dw_disable_nowait(). Also drain the RX FIFO if RFNE
> > is set during SLAVE_ACTIVITY.
> >
> > 2. In i2c_dw_reg_slave(), replace __i2c_dw_disable_nowait() with
> > __i2c_dw_disable() to ensure the controller is fully disabled before
> > calling i2c_dw_set_mode(), which programs DW_IC_SAR and DW_IC_CON.
> >
> > Fixes: 9f3e065c54b0 ("i2c: designware: add SLAVE mode functions")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Atif Ashhar <atifashhar@xxxxxxxxxx>
>
> I don't have time to test this unfortunately :( But it LGTM. FWIW, if
> it's okay by Mika:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

Yes it's okay, thanks Heikki!

Acked-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>