6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wayne Chang [ Upstream commit bbf6b99a57b2479bf51c3c8ad0946f4b8c33ed69 ] CCG4 firmware occasionally fails to respond to I2C read requests, especially when reading cci and intr_reg from the ISR path. In these cases, i2c_transfer() returns -EREMOTEIO. The CCG4 is EOL, and Infineon no longer supports firmware updates, so a software workaround is necessary. Attempt the read up to CCG_READ_MAX_RETRIES (4) times in total when -EREMOTEIO is returned, sleeping ~1 ms via fsleep() between attempts. This allows recovery from transient I2C failures without affecting other error paths. The sleep is safe because ccg_read() is called both from process context and from ccg_irq_handler(), which runs in threaded IRQ context (registered via request_threaded_irq() with a NULL hard-IRQ handler), so sleeping is allowed in both cases. Fixes: 247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") Cc: stable Signed-off-by: Wayne Chang Reviewed-by: Jon Hunter Tested-by: Jon Hunter Reviewed-by: Heikki Krogerus Link: https://patch.msgid.link/20260916061858.1471606-1-waynec@nvidia.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c index 18236d5c30922..55dbe7508ea7f 100644 --- a/drivers/usb/typec/ucsi/ucsi_ccg.c +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c @@ -134,6 +134,8 @@ struct version_format { #define NVIDIA_FTB_DP_OFFSET (2) #define NVIDIA_FTB_DBG_OFFSET (3) +#define CCG_READ_MAX_RETRIES 4 + struct version_info { struct version_format base; struct version_format app; @@ -254,6 +256,7 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) }; u32 rlen, rem_len = len, max_read_len = len; int status; + int retry_count; /* check any max_read_len limitation on i2c adapter */ if (quirks && quirks->max_read_len) @@ -265,7 +268,17 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) rlen = min_t(u16, rem_len, max_read_len); msgs[1].len = rlen; put_unaligned_le16(rab, buf); - status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + + for (retry_count = 0; retry_count < CCG_READ_MAX_RETRIES; retry_count++) { + status = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + + /* Only retry on -EREMOTEIO, and not after the last attempt */ + if (status != -EREMOTEIO || retry_count == CCG_READ_MAX_RETRIES - 1) + break; + + fsleep(1000); + } + if (status < 0) { dev_err(uc->dev, "i2c_transfer failed %d\n", status); pm_runtime_put_sync(uc->dev); -- 2.53.0