mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-16 11:32:41 +00:00
spi: Pump transfers inside calling context for spi_sync()
If we are using the standard SPI message pump (which all drivers should be transitioning over to) then special case the message enqueue and instead of starting the worker thread to push messages to the hardware do so in the context of the caller if the controller is idle. This avoids a context switch in the common case where the controller has a single user in a single thread, for short PIO transfers there may be no need to context switch away from the calling context to complete the transfer. The code is a bit more complex than is desirable in part due to the need to handle drivers not using the standard queue and in part due to handling the various combinations of bus locking and asynchronous submission in interrupt context. It is still suboptimal since it will still wake the message pump for each transfer in order to schedule idling of the hardware and if multiple contexts are using the controller simultaneously a caller may end up pumping a message for some random other thread rather than for itself, and if the thread ends up deferring due to another context idling the hardware then it will just busy wait. It can, however, have the benefit of aggregating power up and down of the hardware when a caller performs a series of transfers back to back without any need for the use of spi_async(). Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
983aee5d70
commit
0461a41498
2 changed files with 60 additions and 8 deletions
|
@ -260,6 +260,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
|||
* @pump_messages: work struct for scheduling work to the message pump
|
||||
* @queue_lock: spinlock to syncronise access to message queue
|
||||
* @queue: message queue
|
||||
* @idling: the device is entering idle state
|
||||
* @cur_msg: the currently in-flight message
|
||||
* @cur_msg_prepared: spi_prepare_message was called for the currently
|
||||
* in-flight message
|
||||
|
@ -425,6 +426,7 @@ struct spi_master {
|
|||
spinlock_t queue_lock;
|
||||
struct list_head queue;
|
||||
struct spi_message *cur_msg;
|
||||
bool idling;
|
||||
bool busy;
|
||||
bool running;
|
||||
bool rt;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue