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

spi: pl022: add a message state STATE_TIMEOUT for timeout transfer

When transfer timeout, give -EAGAIN to the message's status, and it can
make the spi device driver choose repeated transimation or not. And if
transfer timeout, output some useful information for tracing the issue.

Signed-off-by: Jiwei Sun <jiwei.sun@windriver.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jiwei Sun and committed by
Mark Brown
7aef2b64 2e236baf

+29 -1
+29 -1
drivers/spi/spi-pl022.c
··· 253 253 #define STATE_RUNNING ((void *) 1) 254 254 #define STATE_DONE ((void *) 2) 255 255 #define STATE_ERROR ((void *) -1) 256 + #define STATE_TIMEOUT ((void *) -2) 256 257 257 258 /* 258 259 * SSP State - Whether Enabled or Disabled ··· 1485 1484 writew(irqflags, SSP_IMSC(pl022->virtbase)); 1486 1485 } 1487 1486 1487 + static void print_current_status(struct pl022 *pl022) 1488 + { 1489 + u32 read_cr0; 1490 + u16 read_cr1, read_dmacr, read_sr; 1491 + 1492 + if (pl022->vendor->extended_cr) 1493 + read_cr0 = readl(SSP_CR0(pl022->virtbase)); 1494 + else 1495 + read_cr0 = readw(SSP_CR0(pl022->virtbase)); 1496 + read_cr1 = readw(SSP_CR1(pl022->virtbase)); 1497 + read_dmacr = readw(SSP_DMACR(pl022->virtbase)); 1498 + read_sr = readw(SSP_SR(pl022->virtbase)); 1499 + 1500 + dev_warn(&pl022->adev->dev, "spi-pl022 CR0: %x\n", read_cr0); 1501 + dev_warn(&pl022->adev->dev, "spi-pl022 CR1: %x\n", read_cr1); 1502 + dev_warn(&pl022->adev->dev, "spi-pl022 DMACR: %x\n", read_dmacr); 1503 + dev_warn(&pl022->adev->dev, "spi-pl022 SR: %x\n", read_sr); 1504 + dev_warn(&pl022->adev->dev, 1505 + "spi-pl022 exp_fifo_level/fifodepth: %u/%d\n", 1506 + pl022->exp_fifo_level, 1507 + pl022->vendor->fifodepth); 1508 + 1509 + } 1510 + 1488 1511 static void do_polling_transfer(struct pl022 *pl022) 1489 1512 { 1490 1513 struct spi_message *message = NULL; ··· 1560 1535 if (time_after(time, timeout)) { 1561 1536 dev_warn(&pl022->adev->dev, 1562 1537 "%s: timeout!\n", __func__); 1563 - message->state = STATE_ERROR; 1538 + message->state = STATE_TIMEOUT; 1539 + print_current_status(pl022); 1564 1540 goto out; 1565 1541 } 1566 1542 cpu_relax(); ··· 1579 1553 /* Handle end of message */ 1580 1554 if (message->state == STATE_DONE) 1581 1555 message->status = 0; 1556 + else if (message->state == STATE_TIMEOUT) 1557 + message->status = -EAGAIN; 1582 1558 else 1583 1559 message->status = -EIO; 1584 1560