Skip to contentSkip to conversation

Some fixes for Silvaco I3C controller driver

PATCH Applied Stanley Chu 3 participants 8 messages Mar 18, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Some fixes for Silvaco I3C controller driver

This patchset adds some fixes for the Silvaco I3C controller driver.

Stanley Chu (3):
i3c: master: svc: Fix missing the IBI rules
i3c: master: svc: Use readsb helper for reading MDB
i3c: master: svc: Fix missing STOP for master request

 drivers/i3c/master/svc-i3c-master.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 i3c: master: svc: Fix missing the IBI rules

From: Stanley Chu <[email protected]>

The code does not add IBI rules for devices with controller capability. However, the secondary controller has the controller capability and works at target mode when the device is probed. Therefore, add IBI rules for such devices.

Fixes dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver")
---
 drivers/i3c/master/svc-i3c-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -1
index 1d1f351b9a85..a72ba5a7edd4 100644
@@ -1106,7 +1106,7 @@ static int svc_i3c_update_ibirules(struct svc_i3c_master *master)
 
 	/* Create the IBIRULES register for both cases */
 	i3c_bus_for_each_i3cdev(&master->base.bus, dev) {
-		if (I3C_BCR_DEVICE_ROLE(dev->info.bcr) == I3C_BCR_I3C_MASTER)
+		if (!(dev->info.bcr & I3C_BCR_IBI_REQ_CAP))
 			continue;
 
 		if (dev->info.bcr & I3C_BCR_IBI_PAYLOAD) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] i3c: master: svc: Fix missing the IBI rules

Quoted 9 lines · Stanley Chu

From: Stanley Chu <[email protected]>

The code does not add IBI rules for devices with controller capability. However, the secondary controller has the controller capability and works at target mode when the device is probed. Therefore, add IBI rules for such devices.

Fixes dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver")
Quoted 20 lines
---
 drivers/i3c/master/svc-i3c-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -2
index 1d1f351b9a85..a72ba5a7edd4 100644
@@ -1106,7 +1106,7 @@ static int svc_i3c_update_ibirules(struct svc_i3c_master *master)
 
 	/* Create the IBIRULES register for both cases */
 	i3c_bus_for_each_i3cdev(&master->base.bus, dev) {
-		if (I3C_BCR_DEVICE_ROLE(dev->info.bcr) == I3C_BCR_I3C_MASTER)
+		if (!(dev->info.bcr & I3C_BCR_IBI_REQ_CAP))
 			continue;
 
 		if (dev->info.bcr & I3C_BCR_IBI_PAYLOAD) {
--

2.34.1

#3 lore raw

PATCH v2 2/3 i3c: master: svc: Use readsb helper for reading MDB

In reply to Stanley Chu

From: Stanley Chu <[email protected]>

The target can send the MDB byte followed by additional data bytes. The readl on MRDATAB reads one actual byte, but the readsl advances the destination pointer by 4 bytes. This causes the subsequent payload to be copied to wrong position in the destination buffer.

Fixes dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver")
---
 drivers/i3c/master/svc-i3c-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -1
index a72ba5a7edd4..57b9dec6b5a8 100644
@@ -425,7 +425,7 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master,
 	       slot->len < SVC_I3C_FIFO_SIZE) {
 		mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);
 		count = SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl);
-		readsl(master->regs + SVC_I3C_MRDATAB, buf, count);
+		readsb(master->regs + SVC_I3C_MRDATAB, buf, count);
 		slot->len += count;
 		buf += count;
 	}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] i3c: master: svc: Use readsb helper for reading MDB

Quoted 10 lines · Stanley Chu

From: Stanley Chu <[email protected]>

The target can send the MDB byte followed by additional data bytes. The readl on MRDATAB reads one actual byte, but the readsl advances the destination pointer by 4 bytes. This causes the subsequent payload to be copied to wrong position in the destination buffer.

Fixes dd3c52846d59 ("i3c: master: svc: Add Silvaco I3C master driver")
Quoted 20 lines
---
 drivers/i3c/master/svc-i3c-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -2
index a72ba5a7edd4..57b9dec6b5a8 100644
@@ -425,7 +425,7 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master,
 	       slot->len < SVC_I3C_FIFO_SIZE) {
 		mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);
 		count = SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl);
-		readsl(master->regs + SVC_I3C_MRDATAB, buf, count);
+		readsb(master->regs + SVC_I3C_MRDATAB, buf, count);
 		slot->len += count;
 		buf += count;
 	}
--

2.34.1

#5 lore raw

PATCH v2 3/3 i3c: master: svc: Fix missing STOP for master request

In reply to Stanley Chu

From: Stanley Chu <[email protected]>

The controller driver nacked the master request but didn't emit a STOP to end the transaction. The driver shall refuse the unsupported requests and return the controller state to IDLE by emitting a STOP.

---
 drivers/i3c/master/svc-i3c-master.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
index 57b9dec6b5a8..e0cd3ce28b7f 100644
@@ -592,6 +592,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
 			queue_work(master->base.wq, &master->hj_work);
 		break;
 	case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST:
+		svc_i3c_master_emit_stop(master);
 	default:
 		break;
 	}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH v2 3/3] i3c: master: svc: Fix missing STOP for master request

Quoted 7 lines · Stanley Chu

From: Stanley Chu <[email protected]>

The controller driver nacked the master request but didn't emit a STOP to end the transaction. The driver shall refuse the unsupported requests and return the controller state to IDLE by emitting a STOP.

Quoted 19 lines
---
 drivers/i3c/master/svc-i3c-master.c | 1 +
 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -1
index 57b9dec6b5a8..e0cd3ce28b7f 100644
@@ -592,6 +592,7 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)
 			queue_work(master->base.wq, &master->hj_work);
 		break;
 	case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST:
+		svc_i3c_master_emit_stop(master);
 	default:
 		break;
 	}
--

2.34.1

maintainer Applied
#7 lore raw
In reply to Stanley Chu
Quoted 8 lines · Stanley Chu

This patchset adds some fixes for the Silvaco I3C controller driver.

Stanley Chu (3):
i3c: master: svc: Fix missing the IBI rules
i3c: master: svc: Use readsb helper for reading MDB
i3c: master: svc: Fix missing STOP for master request

[...]

Applied, thanks!

[1/3] i3c: master: svc: Fix missing the IBI rules

      https://git.kernel.org/abelloni/c/9cecad134d84
[2/3] i3c: master: svc: Use readsb helper for reading MDB
      https://git.kernel.org/abelloni/c/c06acf7143bd
[3/3] i3c: master: svc: Fix missing STOP for master request
      https://git.kernel.org/abelloni/c/0430bf9bc1ac

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com