[PATCH] spi:fsl-espi: Ignore spurious interrupts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Corey Minyard <cminyard@xxxxxxxxxx>

If a interrupt comes in for the device and nothing is waiting, it will
crash the system.  Avoid the crash.

Signed-off-by: Corey Minyard <cminyard@xxxxxxxxxx>
---
I was working on a system where the firmware seemed to leave the SPI
device in a state where an interrupt was pending.  As soon as interrupts
were enabled the system would crash.

It seems that the interrupt handler will crash if an interrupt comes in
and nothing is pending.  This seems like a bad idea; this patch adds
checking to make sure something is pending before trying to process it.

 drivers/spi/spi-fsl-espi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index e60581283a24..091f0c681ff6 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -217,6 +217,9 @@ static void fsl_espi_fill_tx_fifo(struct fsl_espi *espi, u32 events)
 	unsigned int tx_left;
 	const void *tx_buf;
 
+	if (!espi->tx_t) /* In case we get a spurious interrupt. */
+		return;
+
 	/* if events is zero transfer has not started and tx fifo is empty */
 	tx_fifo_avail = events ? SPIE_TXCNT(events) :  FSL_ESPI_FIFO_SIZE;
 start:
@@ -274,6 +277,8 @@ static void fsl_espi_read_rx_fifo(struct fsl_espi *espi, u32 events)
 	unsigned int rx_left;
 	void *rx_buf;
 
+	if (!rx_fifo_avail) /* In case we get a spurious interrupt. */
+		return;
 start:
 	rx_left = espi->rx_t->len - espi->rx_pos;
 	rx_buf = espi->rx_t->rx_buf;
-- 
2.17.1




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux