Skip to content

Commit 6b1773a

Browse files
pelwellpopcornmix
authored andcommitted
spi: bcm2835: Fix for shared interrupts
BCM2711 shares an interrupt betweem 5 SPI interfaces (0, 3, 4, 5 & 6). Another interrupt is shared between SPI1, SPI2 and UART1, which also affects BCM2835/6/7. Acting on an interrupt intended for another interface ought to be harmless (although potentially inefficient), but it can cause this driver to crash - presumably because some critical state is not ready. Add a test to the spi-bcm2835 interrupt service routine that interrupts are enabled on this interface to avoid the crash and improve efficiency. Suggested by GitHub user boe-pi. See: #5048 Signed-off-by: Phil Elwell <[email protected]>
1 parent 2845e96 commit 6b1773a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/spi/spi-bcm2835.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
372372
struct bcm2835_spi *bs = dev_id;
373373
u32 cs = bcm2835_rd(bs, BCM2835_SPI_CS);
374374

375+
/* Bail out early if interrupts are not enabled */
376+
if (!(cs & BCM2835_SPI_CS_INTR))
377+
return IRQ_NONE;
378+
375379
/*
376380
* An interrupt is signaled either if DONE is set (TX FIFO empty)
377381
* or if RXR is set (RX FIFO >= ¾ full).
@@ -384,10 +388,6 @@ static irqreturn_t bcm2835_spi_interrupt(int irq, void *dev_id)
384388
if (bs->tx_len && cs & BCM2835_SPI_CS_DONE)
385389
bcm2835_wr_fifo_blind(bs, BCM2835_SPI_FIFO_SIZE);
386390

387-
/* check if we got interrupt enabled */
388-
if (!(bcm2835_rd(bs, BCM2835_SPI_CS) & BCM2835_SPI_CS_INTR))
389-
return IRQ_NONE;
390-
391391
/* Read as many bytes as possible from FIFO */
392392
bcm2835_rd_fifo(bs);
393393
/* Write as many bytes as possible to FIFO */

0 commit comments

Comments
 (0)