diff options
author | Mark Brown <broonie@kernel.org> | 2019-07-04 17:35:11 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-07-04 17:35:11 +0100 |
commit | 26ac56506b0ea598bd0b52dcbd2d697282af98ed (patch) | |
tree | 821c8c51c7077d45c1a9eac06a1d43307ca91975 /drivers | |
parent | 106dbe24d4146c0804cb025e450ac7af42d72356 (diff) | |
parent | 924b5867e7bd6a6a98014f0517b747465b108011 (diff) |
Merge remote-tracking branch 'spi/topic/pump-rt' into spi-next
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 81e4d9f7c0f4..91673351bcf3 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1417,10 +1417,32 @@ static void spi_pump_messages(struct kthread_work *work) __spi_pump_messages(ctlr, true); } -static int spi_init_queue(struct spi_controller *ctlr) +/** + * spi_set_thread_rt - set the controller to pump at realtime priority + * @ctlr: controller to boost priority of + * + * This can be called because the controller requested realtime priority + * (by setting the ->rt value before calling spi_register_controller()) or + * because a device on the bus said that its transfers needed realtime + * priority. + * + * NOTE: at the moment if any device on a bus says it needs realtime then + * the thread will be at realtime priority for all transfers on that + * controller. If this eventually becomes a problem we may see if we can + * find a way to boost the priority only temporarily during relevant + * transfers. + */ +static void spi_set_thread_rt(struct spi_controller *ctlr) { struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; + dev_info(&ctlr->dev, + "will run message pump with realtime priority\n"); + sched_setscheduler(ctlr->kworker_task, SCHED_FIFO, ¶m); +} + +static int spi_init_queue(struct spi_controller *ctlr) +{ ctlr->running = false; ctlr->busy = false; @@ -1440,11 +1462,8 @@ static int spi_init_queue(struct spi_controller *ctlr) * request and the scheduling of the message pump thread. Without this * setting the message pump thread will remain at default priority. */ - if (ctlr->rt) { - dev_info(&ctlr->dev, - "will run message pump with realtime priority\n"); - sched_setscheduler(ctlr->kworker_task, SCHED_FIFO, ¶m); - } + if (ctlr->rt) + spi_set_thread_rt(ctlr); return 0; } @@ -3071,6 +3090,11 @@ int spi_setup(struct spi_device *spi) spi_set_cs(spi, false); + if (spi->rt && !spi->controller->rt) { + spi->controller->rt = true; + spi_set_thread_rt(spi->controller); + } + dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n", (int) (spi->mode & (SPI_CPOL | SPI_CPHA)), (spi->mode & SPI_CS_HIGH) ? "cs_high, " : "", |