Skip to contentSkip to conversation

i3c: dw: make struct dw_i3c_cmd smaller

PATCH Applied Jisheng Zhang 3 participants 5 messages Aug 13 – Aug 18

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

PATCH 1/1 i3c: dw: make struct dw_i3c_cmd smaller

The dw_i3c_cmd is dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.

---
 drivers/i3c/master/dw-i3c-master.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/dw-i3c-master.c +2 -2
index 6ba84a97765f..d6f84f0f4c2d 100644
@@ -247,10 +247,10 @@ struct dw_i3c_cmd {
 	u32 cmd_lo;
 	u32 cmd_hi;
 	u16 tx_len;
-	const void *tx_buf;
 	u16 rx_len;
-	void *rx_buf;
 	u8 error;
+	const void *tx_buf;
+	void *rx_buf;
 };
 
 struct dw_i3c_xfer {
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#1 lore raw
Quoted 13 lines · Jisheng Zhang

The dw_i3c_cmd is dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.

---
 drivers/i3c/master/dw-i3c-master.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/dw-i3c-master.c +0 -0
index 6ba84a97765f..d6f84f0f4c2d 100644

drivers/i3c/master/dw-i3c-master.c struct dw_i3c_cmd { · line 250

Quoted 5 lines
drivers/i3c/master/dw-i3c-master.c +0 -1
@@ -247,10 +247,10 @@ struct dw_i3c_cmd {
 	u32 cmd_lo;
 	u32 cmd_hi;
 	u16 tx_len;
-	const void *tx_buf;
 	u16 rx_len;

only switch rx_len and tx_buf should be enough. otherwise there are data pad after u8 error.

Frank

Quoted 10 lines
drivers/i3c/master/dw-i3c-master.c +2 -2
-	void *rx_buf;
 	u8 error;
+	const void *tx_buf;
+	void *rx_buf;
 };
 
 struct dw_i3c_xfer {
--

2.51.0

#2 lore raw
Quoted 9 lines · Frank Li
Quoted 8 lines · Jisheng Zhang

The dw_i3c_cmd is dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.

---
 drivers/i3c/master/dw-i3c-master.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/i3c/master/dw-i3c-master.c struct dw_i3c_cmd { · line 250

Quoted 10 lines
drivers/i3c/master/dw-i3c-master.c +0 -1
index 6ba84a97765f..d6f84f0f4c2d 100644
@@ -247,10 +247,10 @@ struct dw_i3c_cmd {
 	u32 cmd_lo;
 	u32 cmd_hi;
 	u16 tx_len;
-	const void *tx_buf;
 	u16 rx_len;

only switch rx_len and tx_buf should be enough. otherwise there are data pad after u8 error.

If we keep the error at the end of the struct, there's still padding after the u8 error.
There's no big difference between current sol and only switch rx_len and tx_buf on 32bit platforms. But on 64bit platforms, the current version makes use of the pad to store the error, thus saves 8 byte more.

Thanks

Quoted 13 lines

Frank

Quoted 10 lines
drivers/i3c/master/dw-i3c-master.c +2 -2
-	void *rx_buf;
 	u8 error;
+	const void *tx_buf;
+	void *rx_buf;
 };
 
 struct dw_i3c_xfer {
--

2.51.0

Reviewed-by
#3 lore raw
Quoted 24 lines · Jisheng Zhang
Quoted 9 lines · Frank Li
Quoted 8 lines · Jisheng Zhang

The dw_i3c_cmd is dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.

---
 drivers/i3c/master/dw-i3c-master.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/i3c/master/dw-i3c-master.c struct dw_i3c_cmd { · line 250

Quoted 10 lines
drivers/i3c/master/dw-i3c-master.c +0 -1
index 6ba84a97765f..d6f84f0f4c2d 100644
@@ -247,10 +247,10 @@ struct dw_i3c_cmd {
 	u32 cmd_lo;
 	u32 cmd_hi;
 	u16 tx_len;
-	const void *tx_buf;
 	u16 rx_len;

only switch rx_len and tx_buf should be enough. otherwise there are data pad after u8 error.

Quoted 5 lines

If we keep the error at the end of the struct, there's still padding after the u8 error.
There's no big difference between current sol and only switch rx_len and tx_buf on 32bit platforms. But on 64bit platforms, the current version makes use of the pad to store the error, thus saves 8 byte more.

Yes, I missed caculate.

Quoted 15 lines

Thanks

Quoted 13 lines

Frank

Quoted 10 lines
drivers/i3c/master/dw-i3c-master.c +2 -2
-	void *rx_buf;
 	u8 error;
+	const void *tx_buf;
+	void *rx_buf;
 };
 
 struct dw_i3c_xfer {
--

2.51.0

maintainer Applied
#4 lore raw
In reply to Jisheng Zhang
Quoted 2 lines · Jisheng Zhang

The dw_i3c_cmd is dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.

Applied, thanks!

[1/1] i3c: dw: make struct dw_i3c_cmd smaller

      https://git.kernel.org/i3c/c/9939e4cf593d

Best regards,

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