diff options
author | Mark Brown <broonie@kernel.org> | 2019-07-04 12:35:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-07-04 12:35:11 -0400 |
commit | 26ac56506b0ea598bd0b52dcbd2d697282af98ed (patch) | |
tree | 821c8c51c7077d45c1a9eac06a1d43307ca91975 | |
parent | 106dbe24d4146c0804cb025e450ac7af42d72356 (diff) | |
parent | 924b5867e7bd6a6a98014f0517b747465b108011 (diff) |
Merge remote-tracking branch 'spi/topic/pump-rt' into spi-next
-rw-r--r-- | drivers/spi/spi.c | 36 | ||||
-rw-r--r-- | include/linux/spi/spi.h | 2 |
2 files changed, 32 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) | |||
1417 | __spi_pump_messages(ctlr, true); | 1417 | __spi_pump_messages(ctlr, true); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | static int spi_init_queue(struct spi_controller *ctlr) | 1420 | /** |
1421 | * spi_set_thread_rt - set the controller to pump at realtime priority | ||
1422 | * @ctlr: controller to boost priority of | ||
1423 | * | ||
1424 | * This can be called because the controller requested realtime priority | ||
1425 | * (by setting the ->rt value before calling spi_register_controller()) or | ||
1426 | * because a device on the bus said that its transfers needed realtime | ||
1427 | * priority. | ||
1428 | * | ||
1429 | * NOTE: at the moment if any device on a bus says it needs realtime then | ||
1430 | * the thread will be at realtime priority for all transfers on that | ||
1431 | * controller. If this eventually becomes a problem we may see if we can | ||
1432 | * find a way to boost the priority only temporarily during relevant | ||
1433 | * transfers. | ||
1434 | */ | ||
1435 | static void spi_set_thread_rt(struct spi_controller *ctlr) | ||
1421 | { | 1436 | { |
1422 | struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; | 1437 | struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 }; |
1423 | 1438 | ||
1439 | dev_info(&ctlr->dev, | ||
1440 | "will run message pump with realtime priority\n"); | ||
1441 | sched_setscheduler(ctlr->kworker_task, SCHED_FIFO, ¶m); | ||
1442 | } | ||
1443 | |||
1444 | static int spi_init_queue(struct spi_controller *ctlr) | ||
1445 | { | ||
1424 | ctlr->running = false; | 1446 | ctlr->running = false; |
1425 | ctlr->busy = false; | 1447 | ctlr->busy = false; |
1426 | 1448 | ||
@@ -1440,11 +1462,8 @@ static int spi_init_queue(struct spi_controller *ctlr) | |||
1440 | * request and the scheduling of the message pump thread. Without this | 1462 | * request and the scheduling of the message pump thread. Without this |
1441 | * setting the message pump thread will remain at default priority. | 1463 | * setting the message pump thread will remain at default priority. |
1442 | */ | 1464 | */ |
1443 | if (ctlr->rt) { | 1465 | if (ctlr->rt) |
1444 | dev_info(&ctlr->dev, | 1466 | spi_set_thread_rt(ctlr); |
1445 | "will run message pump with realtime priority\n"); | ||
1446 | sched_setscheduler(ctlr->kworker_task, SCHED_FIFO, ¶m); | ||
1447 | } | ||
1448 | 1467 | ||
1449 | return 0; | 1468 | return 0; |
1450 | } | 1469 | } |
@@ -3071,6 +3090,11 @@ int spi_setup(struct spi_device *spi) | |||
3071 | 3090 | ||
3072 | spi_set_cs(spi, false); | 3091 | spi_set_cs(spi, false); |
3073 | 3092 | ||
3093 | if (spi->rt && !spi->controller->rt) { | ||
3094 | spi->controller->rt = true; | ||
3095 | spi_set_thread_rt(spi->controller); | ||
3096 | } | ||
3097 | |||
3074 | dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n", | 3098 | dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n", |
3075 | (int) (spi->mode & (SPI_CPOL | SPI_CPHA)), | 3099 | (int) (spi->mode & (SPI_CPOL | SPI_CPHA)), |
3076 | (spi->mode & SPI_CS_HIGH) ? "cs_high, " : "", | 3100 | (spi->mode & SPI_CS_HIGH) ? "cs_high, " : "", |
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 0ec11f2911af..af4f265d0f67 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
@@ -109,6 +109,7 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, | |||
109 | * This may be changed by the device's driver, or left at the | 109 | * This may be changed by the device's driver, or left at the |
110 | * default (0) indicating protocol words are eight bit bytes. | 110 | * default (0) indicating protocol words are eight bit bytes. |
111 | * The spi_transfer.bits_per_word can override this for each transfer. | 111 | * The spi_transfer.bits_per_word can override this for each transfer. |
112 | * @rt: Make the pump thread real time priority. | ||
112 | * @irq: Negative, or the number passed to request_irq() to receive | 113 | * @irq: Negative, or the number passed to request_irq() to receive |
113 | * interrupts from this device. | 114 | * interrupts from this device. |
114 | * @controller_state: Controller's runtime state | 115 | * @controller_state: Controller's runtime state |
@@ -143,6 +144,7 @@ struct spi_device { | |||
143 | u32 max_speed_hz; | 144 | u32 max_speed_hz; |
144 | u8 chip_select; | 145 | u8 chip_select; |
145 | u8 bits_per_word; | 146 | u8 bits_per_word; |
147 | bool rt; | ||
146 | u32 mode; | 148 | u32 mode; |
147 | #define SPI_CPHA 0x01 /* clock phase */ | 149 | #define SPI_CPHA 0x01 /* clock phase */ |
148 | #define SPI_CPOL 0x02 /* clock polarity */ | 150 | #define SPI_CPOL 0x02 /* clock polarity */ |