Skip to content

Commit 1a922cc

Browse files
stanleychuysgregkh
authored andcommitted
i3c: master: svc: Prevent incomplete IBI transaction
[ Upstream commit 3a36273 ] If no free IBI slot is available, svc_i3c_master_handle_ibi returns immediately. This causes the STOP condition to be missed because the EmitStop request is sent when the transfer is not complete. To resolve this, svc_i3c_master_handle_ibi must wait for the transfer to complete before returning. Fixes: dd3c528 ("i3c: master: svc: Add Silvaco I3C master driver") Signed-off-by: Stanley Chu <yschu@nuvoton.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://patch.msgid.link/20251027034715.708243-1-yschu@nuvoton.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c36d47f commit 1a922cc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,27 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master,
350350
int ret, val;
351351
u8 *buf;
352352

353-
slot = i3c_generic_ibi_get_free_slot(data->ibi_pool);
354-
if (!slot)
355-
return -ENOSPC;
356-
357-
slot->len = 0;
358-
buf = slot->data;
359-
353+
/*
354+
* Wait for transfer to complete before returning. Otherwise, the EmitStop
355+
* request might be sent when the transfer is not complete.
356+
*/
360357
ret = readl_relaxed_poll_timeout(master->regs + SVC_I3C_MSTATUS, val,
361358
SVC_I3C_MSTATUS_COMPLETE(val), 0, 1000);
362359
if (ret) {
363360
dev_err(master->dev, "Timeout when polling for COMPLETE\n");
364-
i3c_generic_ibi_recycle_slot(data->ibi_pool, slot);
365361
return ret;
366362
}
367363

364+
slot = i3c_generic_ibi_get_free_slot(data->ibi_pool);
365+
if (!slot) {
366+
dev_dbg(master->dev, "No free ibi slot, drop the data\n");
367+
writel(SVC_I3C_MDATACTRL_FLUSHRB, master->regs + SVC_I3C_MDATACTRL);
368+
return -ENOSPC;
369+
}
370+
371+
slot->len = 0;
372+
buf = slot->data;
373+
368374
while (SVC_I3C_MSTATUS_RXPEND(readl(master->regs + SVC_I3C_MSTATUS)) &&
369375
slot->len < SVC_I3C_FIFO_SIZE) {
370376
mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);

0 commit comments

Comments
 (0)