Skip to content

Commit 184434f

Browse files
marckleinebuddebroonie
authored andcommitted
spi: spi-imx: mx51_ecspi_prepare_message(): skip writing MX51_ECSPI_CONFIG register if unchanged
In mx51_ecspi_prepare_message() the MX51_ECSPI_CONFIG register is setup for the current spi_message. After writing the register, there is a delay to ensure that the changes hit the hardware. This patch checks if the register MX51_ECSPI_CONFIG actually needs to be changed. If the register content is unchanged the function is left early, skipping the write to the hardware and the delay. This leads to a small, but measurable performance increase. For a given workload with small transfers on an imx6 single core the CPU load decreases from 30% to ~27%. Signed-off-by: Marc Kleine-Budde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 07e7593 commit 184434f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/spi/spi-imx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
520520
u32 min_speed_hz = ~0U;
521521
u32 testreg, delay;
522522
u32 cfg = readl(spi_imx->base + MX51_ECSPI_CONFIG);
523+
u32 current_cfg = cfg;
523524

524525
/* set Master or Slave mode */
525526
if (spi_imx->slave_mode)
@@ -572,6 +573,9 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
572573
else
573574
cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select);
574575

576+
if (cfg == current_cfg)
577+
return 0;
578+
575579
writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
576580

577581
/*

0 commit comments

Comments
 (0)