On 23.05.2022 16:48:32, David Jander wrote: > Btw, I just discovered that there was indeed another often unnecessary context > switch happening in spi_sync(). When spi_finalize_current_message() is called, > it will always queue work, even if we just managed to do everything in the > calling context: > > https://elixir.bootlin.com/linux/v5.18-rc7/source/drivers/spi/spi.c#L1909 > > This is needed to have the SPI worker thread unprepare transfer > hardware and free the dummy buffers if required. My question is why > this needs to be done from the thread. Putting the relevant code after > the call to ctlr->transfer_one_message() in __spi_pump_messages(), > saves this extra bounce to the worker thread if no more messages are > queued, saving ca 10-12us extra time between consecutive spi_sync > messages. Martin Sperl tried to do a delayed teardown, see: | 412e60373245 spi: core: avoid waking pump thread from spi_sync instead run teardown delayed But that turned out be not working properly: | https://lore.kernel.org/all/f86eaebb-0359-13be-f4a2-4f2b8832252e@nvidia.com/ Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |