Re: [PATCH v3 7/7] i2c: designware: Support of controller with IC_EMPTYFIFO_HOLD_MASTER disabled

From: Benoît Monin
Date: Tue Nov 25 2025 - 05:46:50 EST


Hi Andy,

Thanks for the reviews.
(ack on other comments)

On Wednesday, 19 November 2025 at 21:15:16 CET, Andy Shevchenko wrote:
> On Wed, Nov 19, 2025 at 04:05:36PM +0100, Benoît Monin wrote:
[...]

> > i2c_dw_msg_is_valid(struct dw_i2c_dev *dev, const struct i2c_msg *msgs, size_t i
>
> > + /*
> > + * Make sure we don't need explicit RESTART between two messages
> > + * in the same direction for controllers that cannot emit them.
> > + */
> > + if (dev->flags & NO_EMPTYFIFO_HOLD_MASTER &&
> > + (msgs[idx - 1].flags & I2C_M_RD) == (msgs[idx].flags & I2C_M_RD)) {
> > + dev_err(dev->dev, "cannot emit RESTART\n");
> > + return false;
> > + }
>
> Ah, Now I see the point of checking the idx first, but can we rather call it
> with idx >= 1 to begin with?
>
We would still have to check it when calling i2c_dw_msg_is_valid(), as the
first message after a STOP don't have any limitation. It is not just for
protecting against an out-of-bound access to msgs. The validity of a
message is in relation to the previous message in the same transaction.

I will change the comment to make this clearer.

> > return true;
> > }
[...]

> > { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
> > + { .compatible = "mobileye,eyeq6lplus-i2c", .data = (void *)NO_EMPTYFIFO_HOLD_MASTER },
>
> Are you expecting more with this? I would rather use a compatible matching
> instead of the flag,
>
The IC_EMPTYFIFO_HOLD_MASTER_EN parameter is part of the DesignWare IP, it
is not specific to Mobileye. Given that typical i2c accesses (single read,
single write, write-then-read) work on non-PREMPT_RT without this patch, I
suspect there are other controllers that lack the ability to hold the clock
when the FIFO is empty that could benefit from this flag.

> > { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
> > { .compatible = "snps,designware-i2c" },
>
>

Best regards,
--
Benoît Monin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com