linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-spi@vger.kernel.org, Fabio Estevam <festevam@gmail.com>,
	Marek Vasut <marex@denx.de>
Cc: kernel@pengutronix.de, linux-imx@nxp.com,
	Mark Brown <broonie@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Baruch Siach <baruch@tkos.co.il>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH v1 9/9] spi: spi-imx: mx51_ecspi_prepare_message(): skip writing MX51_ECSPI_CONFIG register if unchanged
Date: Mon,  2 May 2022 19:54:57 +0200	[thread overview]
Message-ID: <20220502175457.1977983-10-mkl@pengutronix.de> (raw)
In-Reply-To: <20220502175457.1977983-1-mkl@pengutronix.de>

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 <mkl@pengutronix.de>
---
 drivers/spi/spi-imx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index fe2305e6e38e..bc97337fddf5 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -520,6 +520,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
 	u32 min_speed_hz = ~0U;
 	u32 testreg, delay;
 	u32 cfg = readl(spi_imx->base + MX51_ECSPI_CONFIG);
+	u32 current_cfg = cfg;
 
 	/* set Master or Slave mode */
 	if (spi_imx->slave_mode)
@@ -572,6 +573,9 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
 	else
 		cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select);
 
+	if (cfg == current_cfg)
+		return 0;
+
 	writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
 
 	/*
-- 
2.35.1



  parent reply	other threads:[~2022-05-02 18:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 17:54 [PATCH v1 0/9] spi: spi-imx: cleanups and performance improvements Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 1/9] spi: spi-imx: fix sparse warning: add identifier name to function definition Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 2/9] spi: spi-imx: avoid unnecessary line continuations Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 3/9] spi: spi-imx: mx51_ecspi_intctrl(): prefer 'unsigned int' to bare use of 'unsigned' Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 4/9] spi: spi-imx: spi_imx_buf_rx_swap_u32(): fix sparse warning: use swab32s() instead of cpu_to_be32() Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 5/9] spi: spi-imx: spi_imx_buf_rx_swap_u32(): replace open coded swahw32s() Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 6/9] spi: spi-imx: complete conversion from master -> controller Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 7/9] spi: spi-imx: replace struct spi_imx_data::bitbang by pointer to struct spi_controller Marc Kleine-Budde
2022-05-02 17:54 ` [PATCH v1 8/9] spi: spi-imx: add PIO polling support Marc Kleine-Budde
2022-05-02 17:54 ` Marc Kleine-Budde [this message]
2022-05-09 21:13 ` [PATCH v1 0/9] spi: spi-imx: cleanups and performance improvements Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220502175457.1977983-10-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=baruch@tkos.co.il \
    --cc=broonie@kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=marex@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).