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:   Thu, 3 Sep 2020 14:02:48 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Dmitry Osipenko <digetx@...il.com>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Laxman Dewangan <ldewangan@...dia.com>,
        Wolfram Sang <wsa@...-dreams.de>,
        Michał Mirosław <mirq-linux@...e.qmqm.pl>,
        linux-i2c <linux-i2c@...r.kernel.org>,
        linux-tegra@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 01/22] i2c: tegra: Make tegra_i2c_flush_fifos() usable
 in atomic transfer

On Thu, Sep 3, 2020 at 3:53 AM Dmitry Osipenko <digetx@...il.com> wrote:
>
> The tegra_i2c_flush_fifos() shouldn't sleep in atomic transfer and jiffies
> are not updating if interrupts are disabled. Hence let's use proper delay
> functions and use ktime API in order not to hang atomic transfer. Note
> that this patch doesn't fix any known problem because normally FIFO is
> flushed at the time of starting a new transfer.

> +       /*
> +        * ktime_get() may take up to couple milliseconds in a worst case
> +        * and normally FIFOs are flushed, hence let's check the state before
> +        * proceeding to polling.
> +        */

Everything, including above can be done by using macros from iopoll.h. Why not?

> +       if (!(i2c_readl(i2c_dev, offset) & mask))
> +               return 0;
> +
> +       ktime = ktime_get();
> +       ktimeout = ktime_add_ms(ktime, 1000);
> +
>         while (i2c_readl(i2c_dev, offset) & mask) {
> -               if (time_after(jiffies, timeout)) {
> -                       dev_warn(i2c_dev->dev, "timeout waiting for fifo flush\n");
> -                       return -ETIMEDOUT;
> -               }
> -               usleep_range(1000, 2000);
> +               if (ktime_after(ktime, ktimeout))
> +                       goto err_timeout;
> +
> +               if (i2c_dev->is_curr_atomic_xfer)
> +                       mdelay(1);
> +               else
> +                       fsleep(1000);
> +
> +               ktime = ktime_get();
>         }
>         return 0;
> +
> +err_timeout:
> +       dev_err(i2c_dev->dev, "FIFO flushing timed out\n");
> +
> +       return -ETIMEDOUT;
>  }


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ