spi: bcm2835: Speed up RX-only DMA transfers by zero-filling TX FIFO
authorLukas Wunner <lukas@wunner.de>
Wed, 11 Sep 2019 10:15:30 +0000 (12:15 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 11 Sep 2019 14:57:46 +0000 (15:57 +0100)
commit2b8279aec1829da4dc645e8731c28d2f5458d652
tree2fe66ade86b3267c5455b6d6d691fc36d40888fd
parent8259bf667a0f9ea1a37bb71c7af9ebd550e9251d
spi: bcm2835: Speed up RX-only DMA transfers by zero-filling TX FIFO

The BCM2835 SPI driver currently sets the SPI_CONTROLLER_MUST_TX flag.
When performing an RX-only transfer, this flag causes the SPI core to
allocate and DMA-map a dummy buffer which is copied to the TX FIFO.
The dummy buffer is necessary because the chip is not capable of
automatically clocking out null bytes.

Avoid the overhead induced by the dummy buffer by preallocating a
reusable DMA transaction which fills the TX FIFO by cyclically copying
from the zero page.  The transaction requires very little CPU time to
submit and generates no interrupts while running.  Specifics are
provided in kerneldoc comments.

[Nathan Chancellor contributed a DMA mapping fixup for an early version
of this commit, hence his Signed-off-by.]

Tested-by: Nuno Sá <nuno.sa@analog.com>
Tested-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Stefan Wahren <wahrenst@gmx.net>
Acked-by: Martin Sperl <kernel@martin.sperl.org>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Link: https://lore.kernel.org/r/f45920af18dbf06e34129bbc406f53dc9c5d1075.1568187525.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bcm2835.c