Skip to content

Commit 2aac0bf

Browse files
Joshua Yeongalexandrebelloni
authored andcommitted
i3c: Add fallback method for GETMXDS CCC
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> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/r/20231114085525.6271-2-joshua.yeong@starfivetech.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 4afd728 commit 2aac0bf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/i3c/master.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,8 +1130,16 @@ static int i3c_master_getmxds_locked(struct i3c_master_controller *master,
11301130

11311131
i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETMXDS, &dest, 1);
11321132
ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
1133-
if (ret)
1134-
goto out;
1133+
if (ret) {
1134+
/*
1135+
* Retry when the device does not support max read turnaround
1136+
* while expecting shorter length from this CCC command.
1137+
*/
1138+
dest->payload.len -= 3;
1139+
ret = i3c_master_send_ccc_cmd_locked(master, &cmd);
1140+
if (ret)
1141+
goto out;
1142+
}
11351143

11361144
if (dest.payload.len != 2 && dest.payload.len != 5) {
11371145
ret = -EIO;

0 commit comments

Comments
 (0)