diff mbox series

[v2] spi: fsl-qspi: Optimize fsl_qspi struct

Message ID 20250411-spi-v1-1-8d6dfb1a9262@gmail.com
State New
Headers show
Series [v2] spi: fsl-qspi: Optimize fsl_qspi struct | expand

Commit Message

Kevin Hao April 11, 2025, 7:06 a.m. UTC
Reorgize the members of the fsl_qspi struct to:
  - Reduce a hole in the struct.
  - Group members required by each op (e.g., iobase, ahb_addr,
    devtype_data and lock) into the same cacheline.

Before:
struct fsl_qspi {
	[...]

	/* size: 176, cachelines: 3, members: 11 */
	/* sum members: 168, holes: 1, sum holes: 4 */
	/* padding: 4 */
	/* member types with holes: 1, total: 1 */
	/* last cacheline: 48 bytes */
};

after:
struct fsl_qspi {
	void *                     iobase;               /*     0     8 */
	void *                     ahb_addr;             /*     8     8 */
	const struct fsl_qspi_devtype_data  * devtype_data; /*    16     8 */
	struct mutex               lock;                 /*    24    32 */
	struct completion          c;                    /*    56    32 */

	/* XXX last struct has 1 hole */

	/* --- cacheline 1 boundary (64 bytes) was 24 bytes ago --- */
	struct clk *               clk;                  /*    88     8 */
	struct clk *               clk_en;               /*    96     8 */
	struct pm_qos_request      pm_qos_req;           /*   104    48 */
	/* --- cacheline 2 boundary (128 bytes) was 24 bytes ago --- */
	struct device *            dev;                  /*   152     8 */
	int                        selected;             /*   160     4 */
	u32                        memmap_phy;           /*   164     4 */

	/* size: 168, cachelines: 3, members: 11 */
	/* member types with holes: 1, total: 1 */
	/* last cacheline: 40 bytes */
};

Reviewed-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
v2:
  - Fix a typo in subject.
  - Add Reviewed-by from Han Xu.

Background:
This patch was originally created while I was working on a bug in
fsl-qspi [1]. However, we eventually adopted an alternative
implementation [2] to address this issue, leaving this patch dangling
in the patch queue.

While this patch is a minor optimization and may not result in
measurable improvements, it is still harmless and could be beneficial.
Please consider applying it.

[1] https://lore.kernel.org/r/20250321-spi-v1-0-b9939baa64b6@gmail.com
[2] https://lore.kernel.org/r/20250326224152.2147099-1-han.xu@nxp.com
---
 drivers/spi/spi-fsl-qspi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


---
base-commit: 29e7bf01ed8033c9a14ed0dc990dfe2736dbcd18
change-id: 20250411-spi-4bd32c8ee08c

Best regards,

Comments

Mark Brown April 14, 2025, 10:03 a.m. UTC | #1
On Fri, 11 Apr 2025 15:06:41 +0800, Kevin Hao wrote:
> Reorgize the members of the fsl_qspi struct to:
>   - Reduce a hole in the struct.
>   - Group members required by each op (e.g., iobase, ahb_addr,
>     devtype_data and lock) into the same cacheline.
> 
> Before:
> struct fsl_qspi {
> 	[...]
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: fsl-qspi: Optimize fsl_qspi struct
      commit: 279b418f477fd6c1c21b1cf212837622c774f15f

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
index 5c59fddb32c1b9cc030e7abb49484662ec7b382c..8f45d43bc502ac516ffa357f36acc7eece65ae9b 100644
--- a/drivers/spi/spi-fsl-qspi.c
+++ b/drivers/spi/spi-fsl-qspi.c
@@ -264,14 +264,14 @@  static const struct fsl_qspi_devtype_data ls2080a_data = {
 struct fsl_qspi {
 	void __iomem *iobase;
 	void __iomem *ahb_addr;
-	u32 memmap_phy;
-	struct clk *clk, *clk_en;
-	struct device *dev;
-	struct completion c;
 	const struct fsl_qspi_devtype_data *devtype_data;
 	struct mutex lock;
+	struct completion c;
+	struct clk *clk, *clk_en;
 	struct pm_qos_request pm_qos_req;
+	struct device *dev;
 	int selected;
+	u32 memmap_phy;
 };
 
 static inline int needs_swap_endian(struct fsl_qspi *q)