spi: Don't use the message queue if possible in spi_sync
authorDavid Jander <david@protonic.nl>
Tue, 21 Jun 2022 06:12:25 +0000 (08:12 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 27 Jun 2022 12:27:17 +0000 (13:27 +0100)
commitae7d2346dc89ae89a6e0aabe6037591a11e593c0
tree23155ebdfdee2cf38b3ed9bd918e323c1fcc5ca8
parent1714582a3a087eda8786d5a1b32b2ec86ca8a303
spi: Don't use the message queue if possible in spi_sync

The interaction with the controller message queue and its corresponding
auxiliary flags and variables requires the use of the queue_lock which is
costly. Since spi_sync will transfer the complete message anyway, and not
return until it is finished, there is no need to put the message into the
queue if the queue is empty. This can save a lot of overhead.

As an example of how significant this is, when using the MCP2518FD SPI CAN
controller on a i.MX8MM SoC, the time during which the interrupt line
stays active (during 3 relatively short spi_sync messages), is reduced
from 98us to 72us by this patch.

Signed-off-by: David Jander <david@protonic.nl>
Link: https://lore.kernel.org/r/20220621061234.3626638-3-david@protonic.nl
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h