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

Merge tag 'spi-v4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
"A collection of driver specific fixes to which the usual comments
about them being important if you see them mostly apply (except for
the comment fix). The pl022 one is particularly nasty for anyone
affected by it"

* tag 'spi-v4.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
spi: pl022: Fix race in giveback() leading to driver lock-up
spi: dw-mid: avoid potential NULL dereference
spi: img-spfi: Verify max spfi transfer length
spi: fix a typo in comment.
spi: atmel: Fix interrupt setup for PDC transfers
spi: dw: revisit FIFO size detection again
spi: dw-pci: correct number of chip selects
drivers: spi: ti-qspi: wait for busy bit clear before data write/read

+47 -12
+6 -6
drivers/spi/spi-atmel.c
··· 764 764 (unsigned long long)xfer->rx_dma); 765 765 } 766 766 767 - /* REVISIT: We're waiting for ENDRX before we start the next 767 + /* REVISIT: We're waiting for RXBUFF before we start the next 768 768 * transfer because we need to handle some difficult timing 769 - * issues otherwise. If we wait for ENDTX in one transfer and 770 - * then starts waiting for ENDRX in the next, it's difficult 771 - * to tell the difference between the ENDRX interrupt we're 772 - * actually waiting for and the ENDRX interrupt of the 769 + * issues otherwise. If we wait for TXBUFE in one transfer and 770 + * then starts waiting for RXBUFF in the next, it's difficult 771 + * to tell the difference between the RXBUFF interrupt we're 772 + * actually waiting for and the RXBUFF interrupt of the 773 773 * previous transfer. 774 774 * 775 775 * It should be doable, though. Just not now... 776 776 */ 777 - spi_writel(as, IER, SPI_BIT(ENDRX) | SPI_BIT(OVRES)); 777 + spi_writel(as, IER, SPI_BIT(RXBUFF) | SPI_BIT(OVRES)); 778 778 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); 779 779 } 780 780
+6
drivers/spi/spi-dw-mid.c
··· 139 139 1, 140 140 DMA_MEM_TO_DEV, 141 141 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 142 + if (!txdesc) 143 + return NULL; 144 + 142 145 txdesc->callback = dw_spi_dma_tx_done; 143 146 txdesc->callback_param = dws; 144 147 ··· 187 184 1, 188 185 DMA_DEV_TO_MEM, 189 186 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 187 + if (!rxdesc) 188 + return NULL; 189 + 190 190 rxdesc->callback = dw_spi_dma_rx_done; 191 191 rxdesc->callback_param = dws; 192 192
+2 -2
drivers/spi/spi-dw-pci.c
··· 36 36 37 37 static struct spi_pci_desc spi_pci_mid_desc_1 = { 38 38 .setup = dw_spi_mid_init, 39 - .num_cs = 32, 39 + .num_cs = 5, 40 40 .bus_num = 0, 41 41 }; 42 42 43 43 static struct spi_pci_desc spi_pci_mid_desc_2 = { 44 44 .setup = dw_spi_mid_init, 45 - .num_cs = 4, 45 + .num_cs = 2, 46 46 .bus_num = 1, 47 47 }; 48 48
+2 -2
drivers/spi/spi-dw.c
··· 621 621 if (!dws->fifo_len) { 622 622 u32 fifo; 623 623 624 - for (fifo = 2; fifo <= 256; fifo++) { 624 + for (fifo = 1; fifo < 256; fifo++) { 625 625 dw_writew(dws, DW_SPI_TXFLTR, fifo); 626 626 if (fifo != dw_readw(dws, DW_SPI_TXFLTR)) 627 627 break; 628 628 } 629 629 dw_writew(dws, DW_SPI_TXFLTR, 0); 630 630 631 - dws->fifo_len = (fifo == 2) ? 0 : fifo - 1; 631 + dws->fifo_len = (fifo == 1) ? 0 : fifo; 632 632 dev_dbg(dev, "Detected FIFO size: %u bytes\n", dws->fifo_len); 633 633 } 634 634 }
+7
drivers/spi/spi-img-spfi.c
··· 459 459 unsigned long flags; 460 460 int ret; 461 461 462 + if (xfer->len > SPFI_TRANSACTION_TSIZE_MASK) { 463 + dev_err(spfi->dev, 464 + "Transfer length (%d) is greater than the max supported (%d)", 465 + xfer->len, SPFI_TRANSACTION_TSIZE_MASK); 466 + return -EINVAL; 467 + } 468 + 462 469 /* 463 470 * Stop all DMA and reset the controller if the previous transaction 464 471 * timed-out and never completed it's DMA.
+1 -1
drivers/spi/spi-pl022.c
··· 534 534 pl022->cur_msg = NULL; 535 535 pl022->cur_transfer = NULL; 536 536 pl022->cur_chip = NULL; 537 - spi_finalize_current_message(pl022->master); 538 537 539 538 /* disable the SPI/SSP operation */ 540 539 writew((readw(SSP_CR1(pl022->virtbase)) & 541 540 (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase)); 542 541 542 + spi_finalize_current_message(pl022->master); 543 543 } 544 544 545 545 /**
+22
drivers/spi/spi-ti-qspi.c
··· 101 101 #define QSPI_FLEN(n) ((n - 1) << 0) 102 102 103 103 /* STATUS REGISTER */ 104 + #define BUSY 0x01 104 105 #define WC 0x02 105 106 106 107 /* INTERRUPT REGISTER */ ··· 200 199 ti_qspi_write(qspi, ctx_reg->clkctrl, QSPI_SPI_CLOCK_CNTRL_REG); 201 200 } 202 201 202 + static inline u32 qspi_is_busy(struct ti_qspi *qspi) 203 + { 204 + u32 stat; 205 + unsigned long timeout = jiffies + QSPI_COMPLETION_TIMEOUT; 206 + 207 + stat = ti_qspi_read(qspi, QSPI_SPI_STATUS_REG); 208 + while ((stat & BUSY) && time_after(timeout, jiffies)) { 209 + cpu_relax(); 210 + stat = ti_qspi_read(qspi, QSPI_SPI_STATUS_REG); 211 + } 212 + 213 + WARN(stat & BUSY, "qspi busy\n"); 214 + return stat & BUSY; 215 + } 216 + 203 217 static int qspi_write_msg(struct ti_qspi *qspi, struct spi_transfer *t) 204 218 { 205 219 int wlen, count; ··· 227 211 wlen = t->bits_per_word >> 3; /* in bytes */ 228 212 229 213 while (count) { 214 + if (qspi_is_busy(qspi)) 215 + return -EBUSY; 216 + 230 217 switch (wlen) { 231 218 case 1: 232 219 dev_dbg(qspi->dev, "tx cmd %08x dc %08x data %02x\n", ··· 285 266 286 267 while (count) { 287 268 dev_dbg(qspi->dev, "rx cmd %08x dc %08x\n", cmd, qspi->dc); 269 + if (qspi_is_busy(qspi)) 270 + return -EBUSY; 271 + 288 272 ti_qspi_write(qspi, cmd, QSPI_SPI_CMD_REG); 289 273 if (!wait_for_completion_timeout(&qspi->transfer_complete, 290 274 QSPI_COMPLETION_TIMEOUT)) {
+1 -1
include/linux/spi/spi.h
··· 649 649 * sequence completes. On some systems, many such sequences can execute as 650 650 * as single programmed DMA transfer. On all systems, these messages are 651 651 * queued, and might complete after transactions to other devices. Messages 652 - * sent to a given spi_device are alway executed in FIFO order. 652 + * sent to a given spi_device are always executed in FIFO order. 653 653 * 654 654 * The code that submits an spi_message (and its spi_transfers) 655 655 * to the lower layers is responsible for managing its memory.