linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCH v2 00/11] Optimize spi_sync path
@ 2022-06-15 12:46 David Jander
  2022-06-15 12:46 ` [RFC] [PATCH v2 01/11] spi: Move ctlr->cur_msg_prepared to struct spi_message David Jander
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: David Jander @ 2022-06-15 12:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, Marc Kleine-Budde, Andrew Lunn, David Jander

These patches optimize the spi_sync call for the common case that the
worker thread is idle and the queue is empty. It also opens the
possibility to potentially further optimize the async path also, since
it doesn't need to take into account the direct sync path anymore.

As an example for the performance gain, on an i.MX8MM SoC with a SPI CAN
controller attached (MCP2518FD), the time the interrupt line stays
active (which corresponds roughly with the time it takes to send 3
relatively short consecutive spi_sync messages) is reduced from 98us to
only 72us by this patch.

A note about message ordering:

This patch series should not change the behavior of message ordering when
coming from the same context. This means that if a client driver issues
one or more spi_async() messages immediately followed by a spi_sync()
message in the same context, it can still rely on these messages being
sent out in the order they were fired.

---
v2:
 - Avoid API change to spi_finalize_current_message
 - Fixed NULL-pointer dereference for drivers that rely on ctlr->cur_msg
 - Removed intentional printk() statement
 - Split out into small patches to document how code is morphed
 
David Jander (11):
  spi: Move ctlr->cur_msg_prepared to struct spi_message
  spi: Don't use the message queue if possible in spi_sync
  spi: Lock controller idling transition inside the io_mutex
  spi: __spi_pump_messages: Consolidate spin_unlocks to goto target
  spi: Remove check for controller idling in spi sync path
  spi: Remove check for idling in __spi_pump_messages()
  spi: Remove the now unused ctlr->idling flag
  spi: Remove unneeded READ_ONCE for ctlr->busy flag
  spi: Set ctlr->cur_msg also in the sync transfer case
  spi: Ensure the io_mutex is held until spi_finalize_current_message()
  spi: opportunistically skip ctlr->cur_msg_completion

 drivers/spi/spi.c       | 305 ++++++++++++++++++++++++----------------
 include/linux/spi/spi.h |  24 +++-
 2 files changed, 202 insertions(+), 127 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-06-21  6:15 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 12:46 [RFC] [PATCH v2 00/11] Optimize spi_sync path David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 01/11] spi: Move ctlr->cur_msg_prepared to struct spi_message David Jander
2022-06-15 12:46 ` [FRC] [PATCH v2 02/11] spi: Don't use the message queue if possible in spi_sync David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 03/11] spi: Lock controller idling transition inside the io_mutex David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 04/11] spi: __spi_pump_messages: Consolidate spin_unlocks to goto target David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 05/11] spi: Remove check for controller idling in spi sync path David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 06/11] spi: Remove check for idling in __spi_pump_messages() David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 07/11] spi: Remove the now unused ctlr->idling flag David Jander
2022-06-15 12:46 ` [RFC] [PATCH 08/11] spi: Remove unneeded READ_ONCE for ctlr->busy flag David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 09/11] spi: Set ctlr->cur_msg also in the sync transfer case David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 10/11] spi: Ensure the io_mutex is held until spi_finalize_current_message() David Jander
2022-06-15 12:46 ` [RFC] [PATCH v2 11/11] spi: opportunistically skip ctlr->cur_msg_completion David Jander
2022-06-15 13:31 ` [RFC] [PATCH v2 00/11] Optimize spi_sync path Marc Kleine-Budde
2022-06-15 14:13   ` David Jander
2022-06-20 18:15     ` Mark Brown
2022-06-21  6:15       ` David Jander
2022-06-16 13:22 ` Mark Brown
2022-06-16 14:13   ` David Jander
2022-06-16 14:55     ` Mark Brown
2022-06-16 15:30       ` David Jander
2022-06-17 12:08         ` David Jander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).