lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Mar 2022 15:34:14 +0000
From:   <tanureal@...nsource.cirrus.com>
To:     Michal Simek <michal.simek@...inx.com>,
        Michal Simek <michal.simek@...inx.com>,
        Shubhrajyoti Datta <shubhrajyoti.datta@...inx.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-i2c@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <patches@...nsource.cirrus.com>
Subject: Re: [PATCH] i2c: cadence: Increase timeout per message if necessary

On 3/21/22 3:57 PM, Michal Simek <michal.simek@...inx.com> wrote:
> +Shubhrajyoti
> 
> On 3/9/22 10:31, Lucas Tanure wrote:
> > Timeout as 1 second sets a upper limit on the length of
> > the transfer executed, but there is no maximum length of
> > a write or read message set in i2c_adapter_quirks for this
> > controller.
> 
> nit: I would expect that you have run any test and you reached an issue.
> Would be good to describe what exactly you have tried on which 
> configuration to make it super clear.
> 
> >
> > To remove that limitation calculate the minimal time
> > necessary, plus some wiggle room, for every message
> > and use it instead of the default one second, if
> > more than one second.
> >
> > Signed-off-by: Lucas Tanure <tanureal@...nsource.cirrus.com>
> > ---
> >   drivers/i2c/busses/i2c-cadence.c | 12 ++++++++++--
> >   1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-cadence.c 
> > b/drivers/i2c/busses/i2c-cadence.c
> > index 805c77143a0f..b4c1ad19cdae 100644
> > --- a/drivers/i2c/busses/i2c-cadence.c
> > +++ b/drivers/i2c/busses/i2c-cadence.c
> > @@ -760,7 +760,7 @@ static void cdns_i2c_master_reset(struct 
> > i2c_adapter *adap)
> >   static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg 
> > *msg,
> >           struct i2c_adapter *adap)
> >   {
> > -    unsigned long time_left;
> > +    unsigned long time_left, msg_timeout;
> >       u32 reg;
> >       id->p_msg = msg;
> > @@ -785,8 +785,16 @@ static int cdns_i2c_process_msg(struct cdns_i2c 
> > *id, struct i2c_msg *msg,
> >       else
> >           cdns_i2c_msend(id);
> > +    /* Minimal time to execute this message */
> > +    msg_timeout = msecs_to_jiffies((1000 * msg->len * BITS_PER_BYTE) 
> > / id->i2c_clk);
> > +    /* Plus some wiggle room */
> > +    msg_timeout += msecs_to_jiffies(500);
> > +
> > +    if (msg_timeout < adap->timeout)
> > +        msg_timeout = adap->timeout;
> > +
> >       /* Wait for the signal of completion */
> > -    time_left = wait_for_completion_timeout(&id->xfer_done, 
> > adap->timeout);
> > +    time_left = wait_for_completion_timeout(&id->xfer_done, 
> > msg_timeout);
> >       if (time_left == 0) {
> >           cdns_i2c_master_reset(adap);
> >           dev_err(id->adap.dev.parent,
> 
> 
> If my assumption is right and there is any actual issue you had please 
> send v2 and feel free to add there my:
> Acked-by: Michal Simek <michal.simek@...inx.com>
> 
> Thanks,
> Michal
> 
> 
> 
The issue happens for I2C devices that have firmware, which will send a big I2C message, but the I2C controller will timeout on it.
That happened for CS35L41 DSP firmware tests, so no particular configuration, just a driver sending firmware blob over I2C.

Thanks,
Lucas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ