Skip to content

Commit 6282697

Browse files
committed
spi: Add cond_resched() in main message processing loop
When a controller has only PIO support it is very likely that we will run into use cases where we spend a very large amount of time consuming CPU. Code that does this should call cond_resched() every once in a while to give other tasks more of a chance to run so do that in the main SPI loop, the overhead is negligable if it's not needed. Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 556351f commit 6282697

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,9 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
11841184
return;
11851185
}
11861186
mutex_unlock(&master->bus_lock_mutex);
1187+
1188+
/* Prod the scheduler in case transfer_one() was busy waiting */
1189+
cond_resched();
11871190
}
11881191

11891192
/**

0 commit comments

Comments
 (0)