Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branch 'spi/topic/pump-rt' into spi-next

+32 -6
+30 -6
drivers/spi/spi.c
··· 1417 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 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, &param); 1442 + } 1443 + 1444 + static int spi_init_queue(struct spi_controller *ctlr) 1445 + { 1424 1446 ctlr->running = false; 1425 1447 ctlr->busy = false; 1426 1448 ··· 1462 1440 * request and the scheduling of the message pump thread. Without this 1463 1441 * setting the message pump thread will remain at default priority. 1464 1442 */ 1465 - if (ctlr->rt) { 1466 - dev_info(&ctlr->dev, 1467 - "will run message pump with realtime priority\n"); 1468 - sched_setscheduler(ctlr->kworker_task, SCHED_FIFO, &param); 1469 - } 1443 + if (ctlr->rt) 1444 + spi_set_thread_rt(ctlr); 1470 1445 1471 1446 return 0; 1472 1447 } ··· 3089 3070 status = spi->controller->setup(spi); 3090 3071 3091 3072 spi_set_cs(spi, false); 3073 + 3074 + if (spi->rt && !spi->controller->rt) { 3075 + spi->controller->rt = true; 3076 + spi_set_thread_rt(spi->controller); 3077 + } 3092 3078 3093 3079 dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n", 3094 3080 (int) (spi->mode & (SPI_CPOL | SPI_CPHA)),
+2
include/linux/spi/spi.h
··· 109 109 * This may be changed by the device's driver, or left at the 110 110 * default (0) indicating protocol words are eight bit bytes. 111 111 * The spi_transfer.bits_per_word can override this for each transfer. 112 + * @rt: Make the pump thread real time priority. 112 113 * @irq: Negative, or the number passed to request_irq() to receive 113 114 * interrupts from this device. 114 115 * @controller_state: Controller's runtime state ··· 144 143 u32 max_speed_hz; 145 144 u8 chip_select; 146 145 u8 bits_per_word; 146 + bool rt; 147 147 u32 mode; 148 148 #define SPI_CPHA 0x01 /* clock phase */ 149 149 #define SPI_CPOL 0x02 /* clock polarity */