lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 24 Mar 2020 21:07:12 +0800
From:   Kai-Heng Feng <kai.heng.feng@...onical.com>
To:     ajayg@...dia.com
Cc:     Kai-Heng Feng <kai.heng.feng@...onical.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Wolfram Sang <wsa@...-dreams.de>,
        linux-i2c@...r.kernel.org (open list:I2C CONTROLLER DRIVER FOR NVIDIA
        GPU), linux-kernel@...r.kernel.org (open list)
Subject: [PATCH v2] i2c: nvidia-gpu: Handle timeout correctly in gpu_i2c_check_status()

Nvidia card may come with a "phantom" UCSI device, and its driver gets
stuck in probe routine, prevents any system PM operations like suspend.

When the target time equals to jiffies, it's not included by
time_is_before_jiffies(). So let's use a boolean to make sure the
operation is done or timeout.

Fixes: c71bcdcb42a7 ("i2c: add i2c bus driver for NVIDIA GPU")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@...onical.com>
---
v2:
- Use a boolean to make sure the operation is timeout or not.

 drivers/i2c/busses/i2c-nvidia-gpu.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nvidia-gpu.c b/drivers/i2c/busses/i2c-nvidia-gpu.c
index 62e18b4db0ed..bdb48600af0e 100644
--- a/drivers/i2c/busses/i2c-nvidia-gpu.c
+++ b/drivers/i2c/busses/i2c-nvidia-gpu.c
@@ -77,18 +77,20 @@ static int gpu_i2c_check_status(struct gpu_i2c_dev *i2cd)
 {
 	unsigned long target = jiffies + msecs_to_jiffies(1000);
 	u32 val;
+	bool done = false;
 
 	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)
+		if (!(val & I2C_MST_CNTL_CYCLE_TRIGGER)
+		    || (val & I2C_MST_CNTL_STATUS) !=
+				I2C_MST_CNTL_STATUS_BUS_BUSY) {
+			done = true;
 			break;
+		}
 		usleep_range(500, 600);
 	} while (time_is_after_jiffies(target));
 
-	if (time_is_before_jiffies(target)) {
+	if (!done) {
 		dev_err(i2cd->dev, "i2c timeout error %x\n", val);
 		return -ETIMEDOUT;
 	}
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ