Skip to content

Commit 8839e46

Browse files
author
Wolfram Sang
committed
Revert "i2c: tegra: Better handle case where CPU0 is busy for a long time"
This reverts commit a900aea because regressions were showing up. Suggested-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/dmaengine/[email protected]/ Signed-off-by: Wolfram Sang <[email protected]>
1 parent deb821f commit 8839e46

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

drivers/i2c/busses/i2c-tegra.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -996,13 +996,14 @@ tegra_i2c_poll_completion_timeout(struct tegra_i2c_dev *i2c_dev,
996996
do {
997997
u32 status = i2c_readl(i2c_dev, I2C_INT_STATUS);
998998

999-
if (status)
999+
if (status) {
10001000
tegra_i2c_isr(i2c_dev->irq, i2c_dev);
10011001

1002-
if (completion_done(complete)) {
1003-
s64 delta = ktime_ms_delta(ktimeout, ktime);
1002+
if (completion_done(complete)) {
1003+
s64 delta = ktime_ms_delta(ktimeout, ktime);
10041004

1005-
return msecs_to_jiffies(delta) ?: 1;
1005+
return msecs_to_jiffies(delta) ?: 1;
1006+
}
10061007
}
10071008

10081009
ktime = ktime_get();
@@ -1029,18 +1030,14 @@ tegra_i2c_wait_completion_timeout(struct tegra_i2c_dev *i2c_dev,
10291030
disable_irq(i2c_dev->irq);
10301031

10311032
/*
1032-
* Under some rare circumstances (like running KASAN +
1033-
* NFS root) CPU, which handles interrupt, may stuck in
1034-
* uninterruptible state for a significant time. In this
1035-
* case we will get timeout if I2C transfer is running on
1036-
* a sibling CPU, despite of IRQ being raised.
1037-
*
1038-
* In order to handle this rare condition, the IRQ status
1039-
* needs to be checked after timeout.
1033+
* There is a chance that completion may happen after IRQ
1034+
* synchronization, which is done by disable_irq().
10401035
*/
1041-
if (ret == 0)
1042-
ret = tegra_i2c_poll_completion_timeout(i2c_dev,
1043-
complete, 0);
1036+
if (ret == 0 && completion_done(complete)) {
1037+
dev_warn(i2c_dev->dev,
1038+
"completion done after timeout\n");
1039+
ret = 1;
1040+
}
10441041
}
10451042

10461043
return ret;

0 commit comments

Comments
 (0)