Skip to contentSkip to conversation

usb: typec: ucsi_ccg: Don't probe GPUs without a CCGx controller

PATCH New Hex Lindqvist 2 participants 2 messages Nov 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: ucsi_ccg: Don't probe GPUs without a CCGx controller

The NVIDIA GPU I2C driver adds a ccgx-ucsi client on every GPU, but GPUs without a USB Type-C port, such as the GTX 1660 Ti, have no CCGx controller, and every probe fails with:

ucsi_ccg 4-0008: i2c_transfer failed -110
ucsi_ccg 4-0008: ucsi_ccg_init failed - -110
ucsi_ccg 4-0008: probe with driver ucsi_ccg failed with error -110

Fix this by reading DEVICE_MODE first for clients created by the GPU driver, and returning -ENODEV if the read times out. Controllers described by firmware are not affected.

Tested on an ASUS TUF Gaming A17 (FA706IU, GTX 1660 Ti): the three errors are gone, probe takes the same time (one timed-out transfer, as before), and the platform's own UCSI port and suspend/resume are not affected.

Assisted by LLM.

---
The nvidia-gpu timeout line is fixed by a separate patch to linux-i2c.

Not tested on a GPU with a CCGx controller; there this adds one DEVICE_MODE read before ucsi_ccg_init().

 drivers/usb/typec/ucsi/ucsi_ccg.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +30 -0
index 3f12db95c7f4..0f082952272e 100644
@@ -357,6 +357,31 @@ static int ccg_op_region_update(struct ucsi_ccg *uc, u32 cci)
 	return 0;
 }
 
+/* GPUs without a USB Type-C port have no CCGx; transfers to it time out. */
+static bool ccg_is_present(struct ucsi_ccg *uc)
+{
+	struct i2c_client *client = uc->client;
+	unsigned char buf[2];
+	u8 data;
+	struct i2c_msg msgs[] = {
+		{
+			.addr	= client->addr,
+			.len	= sizeof(buf),
+			.buf	= buf,
+		},
+		{
+			.addr	= client->addr,
+			.flags	= I2C_M_RD,
+			.len	= sizeof(data),
+			.buf	= &data,
+		},
+	};
+
+	put_unaligned_le16(CCGX_RAB_DEVICE_MODE, buf);
+
+	return i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)) != -ETIMEDOUT;
+}
+
 static int ucsi_ccg_init(struct ucsi_ccg *uc)
 {
 	unsigned int count = 10;
@@ -1488,6 +1513,11 @@ static int ucsi_ccg_probe(struct i2c_client *client)
 			dev_err(uc->dev, "failed to get FW build information\n");
 	}
 
+	if (uc->fw_build == CCG_FW_BUILD_NVIDIA && !ccg_is_present(uc)) {
+		dev_dbg(dev, "no CCGx controller on this GPU\n");
+		return -ENODEV;
+	}
+
 	/* reset ccg device and initialize ucsi */
 	status = ucsi_ccg_init(uc);
 	if (status < 0) {

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.56.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines

The NVIDIA GPU I2C driver adds a ccgx-ucsi client on every GPU, but GPUs without a USB Type-C port, such as the GTX 1660 Ti, have no CCGx controller, and every probe fails with:

ucsi_ccg 4-0008: i2c_transfer failed -110
ucsi_ccg 4-0008: ucsi_ccg_init failed - -110
ucsi_ccg 4-0008: probe with driver ucsi_ccg failed with error -110

Fix this by reading DEVICE_MODE first for clients created by the GPU driver, and returning -ENODEV if the read times out. Controllers described by firmware are not affected.

Tested on an ASUS TUF Gaming A17 (FA706IU, GTX 1660 Ti): the three errors are gone, probe takes the same time (one timed-out transfer, as before), and the platform's own UCSI port and suspend/resume are not affected.

Quoted 5 lines

Assisted by LLM.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1