From: Douglas Anderson <dianders@chromium.org>
To: Mark Brown <broonie@kernel.org>, Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: akashast@codeaurora.org, linux-arm-msm@vger.kernel.org,
mkshah@codeaurora.org, swboyd@chromium.org,
georgi.djakov@linaro.org, ctheegal@codeaurora.org,
mka@chromium.org, Douglas Anderson <dianders@chromium.org>,
linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org
Subject: [PATCH 1/3] spi: spi-geni-qcom: Avoid clock setting if not needed
Date: Wed, 1 Jul 2020 17:45:07 -0700 [thread overview]
Message-ID: <20200701174506.1.Icfdcee14649fc0a6c38e87477b28523d4e60bab3@changeid> (raw)
In-Reply-To: <20200702004509.2333554-1-dianders@chromium.org>
Every SPI transfer could have a different clock rate. The
spi-geni-qcom controller code to deal with this was never very well
optimized and has always had a lot of code plus some calls into the
clk framework which, at the very least, would grab a mutex. However,
until recently, the overhead wasn't _too_ much. That changed with
commit 0e3b8a81f5df ("spi: spi-geni-qcom: Add interconnect support")
we're now calling geni_icc_set_bw(), which leads to a bunch of math
plus:
geni_icc_set_bw()
icc_set_bw()
apply_constraints()
qcom_icc_set()
qcom_icc_bcm_voter_commit()
rpmh_invalidate()
rpmh_write_batch()
...and those rpmh commands can be a bit beefy if you call them too
often.
We already know what speed we were running at before, so if we see
that nothing has changed let's avoid the whole pile of code.
On my hardware, this made spi_geni_prepare_message() drop down from
~145 us down to ~14 us.
NOTE: Potentially it might also make sense to add some code into the
interconnect framework to avoid executing so much code when bandwidth
isn't changing, but even if we did that we still want to short circuit
here to save the extra math / clock calls.
Fixes: 0e3b8a81f5df ("spi: spi-geni-qcom: Add interconnect support")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/spi/spi-geni-qcom.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index e01c782ef7d0..bb4cdda2dec8 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -201,6 +201,9 @@ static int geni_spi_set_clock_and_bw(struct spi_geni_master *mas,
struct geni_se *se = &mas->se;
int ret;
+ if (clk_hz == mas->cur_speed_hz)
+ return 0;
+
ret = get_spi_clk_cfg(clk_hz, mas, &idx, &div);
if (ret) {
dev_err(mas->dev, "Err setting clk to %lu: %d\n", clk_hz, ret);
@@ -339,11 +342,9 @@ static void setup_fifo_xfer(struct spi_transfer *xfer,
}
/* Speed and bits per word can be overridden per transfer */
- if (xfer->speed_hz != mas->cur_speed_hz) {
- ret = geni_spi_set_clock_and_bw(mas, xfer->speed_hz);
- if (ret)
- return;
- }
+ ret = geni_spi_set_clock_and_bw(mas, xfer->speed_hz);
+ if (ret)
+ return;
mas->tx_rem_bytes = 0;
mas->rx_rem_bytes = 0;
--
2.27.0.383.g050319c2ae-goog
next prev parent reply other threads:[~2020-07-02 0:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 0:45 [PATCH 0/3] spi: spi-geni-qcom: Avoid a bunch of per-transfer overhead Douglas Anderson
2020-07-02 0:45 ` Douglas Anderson [this message]
2020-07-07 10:16 ` [PATCH 1/3] spi: spi-geni-qcom: Avoid clock setting if not needed Akash Asthana
2020-07-07 12:08 ` Mark Brown
2020-07-07 12:53 ` Doug Anderson
2020-07-08 10:01 ` Mark Brown
2020-07-08 15:22 ` Doug Anderson
2020-07-08 17:02 ` Mark Brown
2020-07-08 12:48 ` Mark Brown
2020-07-02 0:45 ` [PATCH 2/3] spi: spi-geni-qcom: Set an autosuspend delay of 250 ms Douglas Anderson
2020-07-07 10:18 ` Akash Asthana
2020-07-02 0:45 ` [PATCH 3/3] spi: spi-geni-qcom: Get rid of most overhead in prepare_message() Douglas Anderson
2020-07-07 13:37 ` Akash Asthana
2020-07-08 12:49 ` Mark Brown
2020-07-07 14:17 ` [PATCH 0/3] spi: spi-geni-qcom: Avoid a bunch of per-transfer overhead 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=20200701174506.1.Icfdcee14649fc0a6c38e87477b28523d4e60bab3@changeid \
--to=dianders@chromium.org \
--cc=agross@kernel.org \
--cc=akashast@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=ctheegal@codeaurora.org \
--cc=georgi.djakov@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mka@chromium.org \
--cc=mkshah@codeaurora.org \
--cc=swboyd@chromium.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.