Skip to content

Commit

Permalink
spi: spi-geni-qcom: Don't set the cs if it was already right
Browse files Browse the repository at this point in the history
Setting the chip select on the Qualcomm geni SPI controller isn't
exactly cheap.  Let's cache the current setting and avoid setting the
chip select if it's already right.

Using "flashrom" to read or write the EC firmware on a Chromebook
shows roughly a 25% reduction in interrupts and a 15% speedup.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20200626151946.1.I06134fd669bf91fd387dc6ecfe21d44c202bd412@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Douglas Anderson authored and Mark Brown committed Jun 29, 2020
1 parent 1ac6f21 commit 638d848
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/spi/spi-geni-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct spi_geni_master {
unsigned int oversampling;
spinlock_t lock;
int irq;
bool cs_flag;
};

static int get_spi_clk_cfg(unsigned int speed_hz,
Expand Down Expand Up @@ -146,10 +147,15 @@ static void spi_geni_set_cs(struct spi_device *slv, bool set_flag)
struct geni_se *se = &mas->se;
unsigned long time_left;

pm_runtime_get_sync(mas->dev);
if (!(slv->mode & SPI_CS_HIGH))
set_flag = !set_flag;

if (set_flag == mas->cs_flag)
return;

mas->cs_flag = set_flag;

pm_runtime_get_sync(mas->dev);
spin_lock_irq(&mas->lock);
reinit_completion(&mas->cs_done);
if (set_flag)
Expand Down

0 comments on commit 638d848

Please sign in to comment.