i3c: dw: make struct dw_i3c_cmd smaller
Subsystems (2)
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
@@ -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
Quoted 13 lines · Jisheng Zhang
The
dw_i3c_cmdis dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.Signed-off-by Jisheng Zhang <[email protected]>--- drivers/i3c/master/dw-i3c-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/i3c/master/dw-i3c-master.c +0
-0
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
Quoted 9 lines · Frank Li
Quoted 8 lines · Jisheng Zhang
The
dw_i3c_cmdis dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.Signed-off-by Jisheng Zhang <[email protected]>--- 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@@ -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_lenandtx_bufshould 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
Frank Li
Reviewed-byQuoted 24 lines · Jisheng Zhang
Quoted 9 lines · Frank Li
Quoted 8 lines · Jisheng Zhang
The
dw_i3c_cmdis dynamically allocated, make it smaller. For example on 64bit platforms, we reduce the size from 48 bytes to 32 bytes.Signed-off-by Jisheng Zhang <[email protected]>--- 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@@ -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_lenandtx_bufshould 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 switchrx_lenandtx_bufon 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
Quoted 2 lines · Jisheng Zhang
The
dw_i3c_cmdis 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