Skip to content

Commit

Permalink
spi/fsl-espi: Don't spin forever on SPIE_RXCNT
Browse files Browse the repository at this point in the history
Infinite loop on SPIE_RXCNT occurred.

while (SPIE_RXCNT(events) < min(4, mspi->len)) {
        cpu_relax();
        events = mpc8xxx_spi_read_reg(&reg_base->event);
}

We met a soft lockup at fsl_espi_cpu_irq() because of this.

Fix it by using spin_event_timeout() so that fsl_espi_cpu_irq()
can break loop with timeouts dmesg.

Signed-off-by: Nobuteru Hayashi <hayashi.nbb@ncos.nec.co.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Nobuteru Hayashi authored and Mark Brown committed Mar 28, 2016
1 parent f55532a commit a12ddd6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/spi/spi-fsl-espi.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,18 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
if (events & SPIE_NE) {
u32 rx_data, tmp;
u8 rx_data_8;
int ret;

/* Spin until RX is done */
while (SPIE_RXCNT(events) < min(4, mspi->len)) {
cpu_relax();
events = mpc8xxx_spi_read_reg(&reg_base->event);
if (SPIE_RXCNT(events) < min(4, mspi->len)) {
ret = spin_event_timeout(
!(SPIE_RXCNT(events =
mpc8xxx_spi_read_reg(&reg_base->event)) <
min(4, mspi->len)),
10000, 0); /* 10 msec */
if (!ret)
dev_err(mspi->dev,
"tired waiting for SPIE_RXCNT\n");
}

if (mspi->len >= 4) {
Expand Down

0 comments on commit a12ddd6

Please sign in to comment.