lkml.org 
[lkml]   [2020]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [RFC PATCH v2 14/18] gpu: host1x: mipi: Split tegra_mipi_calibrate and tegra_mipi_wait
    From
    Date
    17.06.2020 04:41, Sowjanya Komatineni пишет:
    ...
    > -static int tegra_mipi_wait(struct tegra_mipi *mipi)
    > +int tegra_mipi_wait(struct tegra_mipi_device *device)
    > {
    > + struct tegra_mipi *mipi = device->mipi;
    > unsigned long timeout = jiffies + msecs_to_jiffies(250);
    > u32 value;
    > + int err;
    > +
    > + err = clk_enable(device->mipi->clk);
    > + if (err < 0)
    > + return err;
    > +
    > + mutex_lock(&device->mipi->lock);

    The timeout variable should be assigned *after* taking the lock.

    It will be better if you could use the read_poll_timeout() or
    readl_relaxed_poll_timeout() here.

    > while (time_before(jiffies, timeout)) {
    > value = tegra_mipi_readl(mipi, MIPI_CAL_STATUS);
    > if ((value & MIPI_CAL_STATUS_ACTIVE) == 0 &&
    > (value & MIPI_CAL_STATUS_DONE) != 0)
    > - return 0;
    > + goto done;
    >
    > usleep_range(10, 50);
    > }
    >
    > - return -ETIMEDOUT;
    > + err = -ETIMEDOUT;
    > +done:
    > + mutex_unlock(&device->mipi->lock);
    > + clk_disable(device->mipi->clk);
    > + return err;
    > }
    > +EXPORT_SYMBOL(tegra_mipi_wait);

    \
     
     \ /
      Last update: 2020-06-18 02:36    [W:3.654 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site