Skip to contentSkip to conversation

i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter

PATCH Superseded Frank Li 3 participants 5 messages Oct 24, 2024 – Oct 31, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH 1/1 i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter

Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable counter, ensuring that the system IBI interrupt is disabled only when all I3C devices have IBI disabled.

Fixes 7ff730ca458e ("i3c: master: svc: enable the interrupt in the enable ibi function")
---
 drivers/i3c/master/svc-i3c-master.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/i3c/master/svc-i3c-master.c +5 -5
index d1ebfba3739c1..66fe0fc12c897 100644
@@ -130,8 +130,8 @@
 /* This parameter depends on the implementation and may be tuned */
 #define SVC_I3C_FIFO_SIZE 16
 
-#define SVC_I3C_EVENT_IBI	BIT(0)
-#define SVC_I3C_EVENT_HOTJOIN	BIT(1)
+#define SVC_I3C_EVENT_IBI	GENMASK(7, 0)
+#define SVC_I3C_EVENT_HOTJOIN	BIT(31)
 
 struct svc_i3c_cmd {
 	u8 addr;
@@ -214,7 +214,7 @@ struct svc_i3c_master {
 		spinlock_t lock;
 	} ibi;
 	struct mutex lock;
-	int enabled_events;
+	u32 enabled_events;
 };
 
 /**
@@ -1532,7 +1532,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)
 		return ret;
 	}
 
-	master->enabled_events |= SVC_I3C_EVENT_IBI;
+	master->enabled_events++;
 	svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART);
 
 	return i3c_master_enec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR);
@@ -1544,7 +1544,7 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)
 	struct svc_i3c_master *master = to_svc_i3c_master(m);
 	int ret;
 
-	master->enabled_events &= ~SVC_I3C_EVENT_IBI;
+	master->enabled_events--;
 	if (!master->enabled_events)
 		svc_i3c_master_disable_interrupts(master);
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Frank,

[email protected] wrote on Thu, 24 Oct 2024 16:38:55 -0400:

Quoted 2 lines

Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable

Is this bitfield arbitrary?

Is there a rationale behind it?

Quoted 6 lines

counter, ensuring that the system IBI interrupt is disabled only when all I3C devices have IBI disabled.

Fixes 7ff730ca458e ("i3c: master: svc: enable the interrupt in the enable ibi function")

Anyway,

Thanks,
Miquèl

author maintainer
#2 lore raw
Quoted 10 lines · Miquel Raynal

Hi Frank,

[email protected] wrote on Thu, 24 Oct 2024 16:38:55 -0400:

Quoted 2 lines

Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable

Is this bitfield arbitrary?

Is there a rationale behind it?

Max devices number under a I3C bus is 128 because dynamic address is 7 bit. So 8 bits for it should be enough.

Bit31 as hotjoin, Bit30 reserved as control switch request.

Frank

Quoted 14 lines
Quoted 7 lines

counter, ensuring that the system IBI interrupt is disabled only when all I3C devices have IBI disabled.

Fixes 7ff730ca458e ("i3c: master: svc: enable the interrupt in the enable ibi function")

Anyway,

Thanks,
Miquèl

maintainer
#3 lore raw

Hi Frank,

[email protected] wrote on Fri, 25 Oct 2024 10:00:50 -0400:

Quoted 8 lines · Miquel Raynal
Quoted 7 lines

Hi Frank,

[email protected] wrote on Thu, 24 Oct 2024 16:38:55 -0400:

Quoted 2 lines

Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable

Quoted 8 lines
Quoted 3 lines

Is this bitfield arbitrary?

Is there a rationale behind it?

Max devices number under a I3C bus is 128 because dynamic address is 7 bit. So 8 bits for it should be enough.

Bit31 as hotjoin, Bit30 reserved as control switch request.

Makes sense.

Thanks,
Miquèl

#4 lore raw
In reply to Frank Li

Hello,

Quoted 8 lines · Frank Li

Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable counter, ensuring that the system IBI interrupt is disabled only when all I3C devices have IBI disabled.

Fixes 7ff730ca458e ("i3c: master: svc: enable the interrupt in the enable ibi function")

This doesn't apply on i3c/next after applying your patches, can you rebase?

Quoted 49 lines
---
 drivers/i3c/master/svc-i3c-master.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/i3c/master/svc-i3c-master.c +5 -5
index d1ebfba3739c1..66fe0fc12c897 100644
@@ -130,8 +130,8 @@
 /* This parameter depends on the implementation and may be tuned */
 #define SVC_I3C_FIFO_SIZE 16
 
-#define SVC_I3C_EVENT_IBI	BIT(0)
-#define SVC_I3C_EVENT_HOTJOIN	BIT(1)
+#define SVC_I3C_EVENT_IBI	GENMASK(7, 0)
+#define SVC_I3C_EVENT_HOTJOIN	BIT(31)
 
 struct svc_i3c_cmd {
 	u8 addr;
@@ -214,7 +214,7 @@ struct svc_i3c_master {
 		spinlock_t lock;
 	} ibi;
 	struct mutex lock;
-	int enabled_events;
+	u32 enabled_events;
 };
 
 /**
@@ -1532,7 +1532,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)
 		return ret;
 	}
 
-	master->enabled_events |= SVC_I3C_EVENT_IBI;
+	master->enabled_events++;
 	svc_i3c_master_enable_interrupts(master, SVC_I3C_MINT_SLVSTART);
 
 	return i3c_master_enec_locked(m, dev->info.dyn_addr, I3C_CCC_EVENT_SIR);
@@ -1544,7 +1544,7 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)
 	struct svc_i3c_master *master = to_svc_i3c_master(m);
 	int ret;
 
-	master->enabled_events &= ~SVC_I3C_EVENT_IBI;
+	master->enabled_events--;
 	if (!master->enabled_events)
 		svc_i3c_master_disable_interrupts(master);
 
Signature · 1 line
2.34.1
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com