diff mbox series

[v3,1/1] i3c: Add fallback method for GETMXDS CCC

Message ID 20231114085525.6271-2-joshua.yeong@starfivetech.com (mailing list archive)
State Accepted
Headers show
Series Fallback mechanism for GETMXDS CCC | expand

Commit Message

Joshua Yeong Nov. 14, 2023, 8:55 a.m. UTC
Some I3C hardware will report error when an incorrect length is received from
device. GETMXDS CCC are available in 2 formats: without turnaround time (format
1) and with turnaround time (format 2). There is no mechanics to determine which
format is supported by device. So in case sending GETMXDS CCC format 2 resulted
in a failure, try sending GETMXDS CCC format 1 instead.

Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
---
 drivers/i3c/master.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Miquel Raynal Nov. 14, 2023, 8:57 a.m. UTC | #1
Hi Joshua,

joshua.yeong@starfivetech.com wrote on Tue, 14 Nov 2023 16:55:25 +0800:

> Some I3C hardware will report error when an incorrect length is received from
> device. GETMXDS CCC are available in 2 formats: without turnaround time (format
> 1) and with turnaround time (format 2). There is no mechanics to determine which
> format is supported by device. So in case sending GETMXDS CCC format 2 resulted
> in a failure, try sending GETMXDS CCC format 1 instead.
> 

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

> Signed-off-by: Joshua Yeong <joshua.yeong@starfivetech.com>
> ---

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 95caa162706f..718b643cb54d 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -1130,8 +1130,16 @@  static int i3c_master_getmxds_locked(struct i3c_master_controller *master,
 
 	i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETMXDS, &dest, 1);
 	ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
-	if (ret)
-		goto out;
+	if (ret) {
+		/*
+		 * Retry when the device does not support max read turnaround
+		 * while expecting shorter length from this CCC command.
+		 */
+		dest->payload.len -= 3;
+		ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
+		if (ret)
+			goto out;
+	}
 
 	if (dest.payload.len != 2 && dest.payload.len != 5) {
 		ret = -EIO;