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,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [RFC 9/9] spi: spi-imx: mx51_ecspi_prepare_message(): skip writing MX51_ECSPI_CONFIG register if unchanged
Date: Mon, 2 May 2022 18:52:10 +0200 [thread overview]
Message-ID: <20220502165210.1956397-10-mkl@pengutronix.de> (raw)
In-Reply-To: <20220502165210.1956397-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 798a5182b849..addfed56f1d4 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -519,6 +519,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)
@@ -576,6 +577,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
prev parent reply other threads:[~2022-05-02 16:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 16:52 [RFC 0/9] spi: spi-imx: cleanups and performance improvements Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 1/9] spi: spi-imx: fix sparse warning: add identifier name to function definition Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 2/9] spi: spi-imx: avoid unnecessary line continuations Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 3/9] spi: spi-imx: mx51_ecspi_intctrl(): prefer 'unsigned int' to bare use of 'unsigned' Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 4/9] spi: spi-imx: spi_imx_buf_rx_swap_u32(): fix sparse warning Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 5/9] spi: spi-imx: spi_imx_buf_rx_swap_u32(): replace open coded swahw32() Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 6/9] spi: spi-imx: complete conversion from master -> controller Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 7/9] spi: spi-imx: replace struct spi_imx_data::bitbang by pointer to struct spi_controller Marc Kleine-Budde
2022-05-02 17:14 ` Baruch Siach
2022-05-02 17:33 ` Marc Kleine-Budde
2022-05-02 16:52 ` [RFC 8/9] spi: spi-imx: add PIO polling support Marc Kleine-Budde
2022-05-02 16:52 ` Marc Kleine-Budde [this message]
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=20220502165210.1956397-10-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--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).