Re: [PATCH] i2c: cgbc: Fetch the status of a write transfer
From: Thomas Richard
Date: Fri Nov 27 2026 - 06:05:24 EST
On 11/27/26 10:20 AM, Haberlander, Markus wrote:
> Hi Thomas, Andi,
>
> On 11/26/26 9:18 PM, Thomas Richard wrote:
>> If I'm not mistaken, USEC_PER_SEC is only used if master_xfer returns
>> -EGAIN (arbitration loss), else __i2c_transfer() directly returns so no
>> 1s timeout. And we never return -EAGAIN.
>>
>> So why should we wait 1s?
>
> Thanks for looking into this! I think Andi means the one-second loop in
> cgbc_i2c_xfer(). Before my patch, when the controller was still busy
> with a write, the next call returned -EBUSY and that loop simply tried
> again, for up to a second.
>
> My patch now waits only 2 * read_maxtime_us for a write to finish. That
> is enough for the transfer itself. But if a device stretches the clock,
> the controller might stay busy for longer, and the write would fail
> where it used to succeed. That's why USEC_PER_SEC sounds like the safer
> choice to me. I'm happy with either, though - you know this hardware
> much better than I do.
Ah yes clock stretching, makes sense. So it is also valid for read
operation. So we could drop read_maxtime_us. But it's an other story, I
want my series to be merged, I'll send a patch later.
Markus I'll add your patch in my series, and make the USEC_PER_SEC
modification. Thanks for your contribution.
Best Regards,
Thomas Richard