mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
i2c: nvidia-gpu: Handle timeout correctly in gpu_i2c_check_status()
commit d944b27df121e2ee854a6c2fad13d6c6300792d4 upstream.
Nvidia card may come with a "phantom" UCSI device, and its driver gets
stuck in probe routine, prevents any system PM operations like suspend.
There's an unaccounted case that the target time can equal to jiffies in
gpu_i2c_check_status(), let's solve that by using readl_poll_timeout()
instead of jiffies comparison functions.
Fixes: c71bcdcb42 ("i2c: add i2c bus driver for NVIDIA GPU")
Suggested-by: Andy Shevchenko <[email protected]>
Signed-off-by: Kai-Heng Feng <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ajay Gupta <[email protected]>
Tested-by: Ajay Gupta <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
6734a326cb
commit
74617178d6
1 changed files with 8 additions and 12 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
|
@ -75,20 +76,15 @@ static void gpu_enable_i2c_bus(struct gpu_i2c_dev *i2cd)
|
|||
|
||||
static int gpu_i2c_check_status(struct gpu_i2c_dev *i2cd)
|
||||
{
|
||||
unsigned long target = jiffies + msecs_to_jiffies(1000);
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
do {
|
||||
val = readl(i2cd->regs + I2C_MST_CNTL);
|
||||
if (!(val & I2C_MST_CNTL_CYCLE_TRIGGER))
|
||||
break;
|
||||
if ((val & I2C_MST_CNTL_STATUS) !=
|
||||
I2C_MST_CNTL_STATUS_BUS_BUSY)
|
||||
break;
|
||||
usleep_range(500, 600);
|
||||
} while (time_is_after_jiffies(target));
|
||||
ret = readl_poll_timeout(i2cd->regs + I2C_MST_CNTL, val,
|
||||
!(val & I2C_MST_CNTL_CYCLE_TRIGGER) ||
|
||||
(val & I2C_MST_CNTL_STATUS) != I2C_MST_CNTL_STATUS_BUS_BUSY,
|
||||
500, 1000 * USEC_PER_MSEC);
|
||||
|
||||
if (time_is_before_jiffies(target)) {
|
||||
if (ret) {
|
||||
dev_err(i2cd->dev, "i2c timeout error %x\n", val);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue