Skip to content

Commit 5e5e3c9

Browse files
nxpfranklialexandrebelloni
authored andcommitted
i3c: master: svc: fix wrong data return when IBI happen during start frame
┌─────┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┏──┐ ┌───── SCL: ┘ └─────┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┛ └──┘ ───┐ ┌─────┐ ┌─────┐ ┌───────────┐ SDA: └───────────────────────┘ └─────┘ └─────┘ └───── xxx╱ ╲╱ ╲╱ ╲╱ ╲╱ ╲ : xxx╲IBI ╱╲ Addr(0x0a) ╱╲ RW ╱╲NACK╱╲ S ╱ If an In-Band Interrupt (IBI) occurs and IBI work thread is not immediately scheduled, when svc_i3c_master_priv_xfers() initiates the I3C transfer and attempts to send address 0x7e, the target interprets it as an IBI handler and returns the target address 0x0a. However, svc_i3c_master_priv_xfers() does not handle this case and proceeds with other transfers, resulting in incorrect data being returned. Add IBIWON check in svc_i3c_master_xfer(). In case this situation occurs, return a failure to the driver. Fixes: dd3c528 ("i3c: master: svc: Add Silvaco I3C master driver") Cc: <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 6bf3fc2 commit 5e5e3c9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/i3c/master/svc-i3c-master.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,9 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
10111011
u32 reg;
10121012
int ret;
10131013

1014+
/* clean SVC_I3C_MINT_IBIWON w1c bits */
1015+
writel(SVC_I3C_MINT_IBIWON, master->regs + SVC_I3C_MSTATUS);
1016+
10141017
writel(SVC_I3C_MCTRL_REQUEST_START_ADDR |
10151018
xfer_type |
10161019
SVC_I3C_MCTRL_IBIRESP_NACK |
@@ -1029,6 +1032,23 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,
10291032
goto emit_stop;
10301033
}
10311034

1035+
/*
1036+
* According to I3C spec ver 1.1.1, 5.1.2.2.3 Consequence of Controller Starting a Frame
1037+
* with I3C Target Address.
1038+
*
1039+
* The I3C Controller normally should start a Frame, the Address may be arbitrated, and so
1040+
* the Controller shall monitor to see whether an In-Band Interrupt request, a Controller
1041+
* Role Request (i.e., Secondary Controller requests to become the Active Controller), or
1042+
* a Hot-Join Request has been made.
1043+
*
1044+
* If missed IBIWON check, the wrong data will be return. When IBIWON happen, return failure
1045+
* and yield the above events handler.
1046+
*/
1047+
if (SVC_I3C_MSTATUS_IBIWON(reg)) {
1048+
ret = -ENXIO;
1049+
goto emit_stop;
1050+
}
1051+
10321052
if (rnw)
10331053
ret = svc_i3c_master_read(master, in, xfer_len);
10341054
else

0 commit comments

Comments
 (0)