diff options
| author | Ville Syrjala <[email protected]> | 2012-03-15 17:11:05 +0000 |
|---|---|---|
| committer | Jean Delvare <[email protected]> | 2012-03-15 17:11:05 +0000 |
| commit | 8ee161ce5e0cfc689eb677f227a6248191165fac (patch) | |
| tree | e1c6aa2b4788eec7e9e552b90be10cd4ae5333ef /drivers/i2c/algos/i2c-algo-bit.c | |
| parent | i2c-core: Comment says "transmitted" but means "received" (diff) | |
| download | kernel-8ee161ce5e0cfc689eb677f227a6248191165fac.tar.gz kernel-8ee161ce5e0cfc689eb677f227a6248191165fac.zip | |
i2c-algo-bit: Fix spurious SCL timeouts under heavy load
When the system is under heavy load, there can be a significant delay
between the getscl() and time_after() calls inside sclhi(). That delay
may cause the time_after() check to trigger after SCL has gone high,
causing sclhi() to return -ETIMEDOUT.
To fix the problem, double check that SCL is still low after the
timeout has been reached, before deciding to return -ETIMEDOUT.
Signed-off-by: Ville Syrjala <[email protected]>
Cc: [email protected]
Signed-off-by: Jean Delvare <[email protected]>
Diffstat (limited to 'drivers/i2c/algos/i2c-algo-bit.c')
| -rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 525c7345fa0b..24f94f4ae395 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -103,8 +103,14 @@ static int sclhi(struct i2c_algo_bit_data *adap) * chips may hold it low ("clock stretching") while they * are processing data internally. */ - if (time_after(jiffies, start + adap->timeout)) + if (time_after(jiffies, start + adap->timeout)) { + /* Test one last time, as we may have been preempted + * between last check and timeout test. + */ + if (getscl(adap)) + break; return -ETIMEDOUT; + } cond_resched(); } #ifdef DEBUG |
