]> git.baikalelectronics.ru Git - kernel.git/commit
spi: spi-geni-qcom: Avoid clock setting if not needed
authorDouglas Anderson <dianders@chromium.org>
Thu, 2 Jul 2020 00:45:07 +0000 (17:45 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 13 Jul 2020 23:29:32 +0000 (16:29 -0700)
commit45955f2c22f89f6f0b8fdae3e668d26ce723d3c1
tree058e266c5d34828f9cd5bead7f9657b87f142e1d
parentfe13c6cfabe449f2155432affbcfcb3862d54f1c
spi: spi-geni-qcom: Avoid clock setting if not needed

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 2aea8da997bc ("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.

Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Akash Asthana<akashast@codeaurora.org>
Fixes: 2aea8da997bc ("spi: spi-geni-qcom: Add interconnect support")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20200701174506.1.Icfdcee14649fc0a6c38e87477b28523d4e60bab3@changeid
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/spi/spi-geni-qcom.c