mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 15:18:15 +00:00
i2c: tegra: Make tegra_i2c_flush_fifos() usable in atomic transfer
The tegra_i2c_flush_fifos() shouldn't sleep in atomic transfer and jiffies are not updating if interrupts are disabled. Let's switch to use iopoll API helpers for register-polling. The iopoll API provides helpers for both atomic and non-atomic cases. Note that this patch doesn't fix any known problem because normally FIFO is flushed at the time of starting a new transfer. Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Tested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
35baff672f
commit
900aed24d3
1 changed files with 16 additions and 9 deletions
|
@ -470,9 +470,9 @@ err_out:
|
||||||
|
|
||||||
static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev)
|
static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev)
|
||||||
{
|
{
|
||||||
unsigned long timeout = jiffies + HZ;
|
u32 mask, val, offset, reg_offset;
|
||||||
unsigned int offset;
|
void __iomem *addr;
|
||||||
u32 mask, val;
|
int err;
|
||||||
|
|
||||||
if (i2c_dev->hw->has_mst_fifo) {
|
if (i2c_dev->hw->has_mst_fifo) {
|
||||||
mask = I2C_MST_FIFO_CONTROL_TX_FLUSH |
|
mask = I2C_MST_FIFO_CONTROL_TX_FLUSH |
|
||||||
|
@ -488,12 +488,19 @@ static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev)
|
||||||
val |= mask;
|
val |= mask;
|
||||||
i2c_writel(i2c_dev, val, offset);
|
i2c_writel(i2c_dev, val, offset);
|
||||||
|
|
||||||
while (i2c_readl(i2c_dev, offset) & mask) {
|
reg_offset = tegra_i2c_reg_addr(i2c_dev, offset);
|
||||||
if (time_after(jiffies, timeout)) {
|
addr = i2c_dev->base + reg_offset;
|
||||||
dev_warn(i2c_dev->dev, "timeout waiting for fifo flush\n");
|
|
||||||
return -ETIMEDOUT;
|
if (i2c_dev->is_curr_atomic_xfer)
|
||||||
}
|
err = readl_relaxed_poll_timeout_atomic(addr, val, !(val & mask),
|
||||||
usleep_range(1000, 2000);
|
1000, 1000000);
|
||||||
|
else
|
||||||
|
err = readl_relaxed_poll_timeout(addr, val, !(val & mask),
|
||||||
|
1000, 1000000);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
dev_err(i2c_dev->dev, "failed to flush FIFO\n");
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue