Skip to content

Commit 3918c21

Browse files
committed
Mark writes: "spi: Fixes for v4.19 As well as one driver fix there's a couple of fixes here which address issues with the use of IDRs for allocation of dynamic bus numbers, ensuring that dynamic bus numbers interact well with static bus numbers assigned via DT and otherwise." * tag 'spi-fix-v4.19-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: spi-fsl-dspi: fix broken DSPI_EOQ_MODE spi: Fix double IDR allocation with DT aliases spi: fix IDR collision on systems with both fixed and dynamic SPI bus numbers
2 parents ad3273d + 5223c9c commit 3918c21

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

drivers/spi/spi-fsl-dspi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030

3131
#define DRIVER_NAME "fsl-dspi"
3232

33+
#ifdef CONFIG_M5441x
34+
#define DSPI_FIFO_SIZE 16
35+
#else
3336
#define DSPI_FIFO_SIZE 4
37+
#endif
3438
#define DSPI_DMA_BUFSIZE (DSPI_FIFO_SIZE * 1024)
3539

3640
#define SPI_MCR 0x00
@@ -623,9 +627,11 @@ static void dspi_tcfq_read(struct fsl_dspi *dspi)
623627
static void dspi_eoq_write(struct fsl_dspi *dspi)
624628
{
625629
int fifo_size = DSPI_FIFO_SIZE;
630+
u16 xfer_cmd = dspi->tx_cmd;
626631

627632
/* Fill TX FIFO with as many transfers as possible */
628633
while (dspi->len && fifo_size--) {
634+
dspi->tx_cmd = xfer_cmd;
629635
/* Request EOQF for last transfer in FIFO */
630636
if (dspi->len == dspi->bytes_per_word || fifo_size == 0)
631637
dspi->tx_cmd |= SPI_PUSHR_CMD_EOQ;

drivers/spi/spi.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,8 +2143,17 @@ int spi_register_controller(struct spi_controller *ctlr)
21432143
*/
21442144
if (ctlr->num_chipselect == 0)
21452145
return -EINVAL;
2146-
/* allocate dynamic bus number using Linux idr */
2147-
if ((ctlr->bus_num < 0) && ctlr->dev.of_node) {
2146+
if (ctlr->bus_num >= 0) {
2147+
/* devices with a fixed bus num must check-in with the num */
2148+
mutex_lock(&board_lock);
2149+
id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
2150+
ctlr->bus_num + 1, GFP_KERNEL);
2151+
mutex_unlock(&board_lock);
2152+
if (WARN(id < 0, "couldn't get idr"))
2153+
return id == -ENOSPC ? -EBUSY : id;
2154+
ctlr->bus_num = id;
2155+
} else if (ctlr->dev.of_node) {
2156+
/* allocate dynamic bus number using Linux idr */
21482157
id = of_alias_get_id(ctlr->dev.of_node, "spi");
21492158
if (id >= 0) {
21502159
ctlr->bus_num = id;

0 commit comments

Comments
 (0)