Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/63959 )
Change subject: drivers/spi: Add better error reporting to spi_flash_cmd_poll_bit ......................................................................
drivers/spi: Add better error reporting to spi_flash_cmd_poll_bit
It's useful to know how many attempts were made at polling the status bit.
BUG=b:228289365 TEST=Boot guybrush
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ifcc79a339707fbaab33e128807d4c0b26aa90108 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63959 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Rob Barnes robbarnes@google.com --- M src/drivers/spi/spi_flash.c 1 file changed, 11 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Rob Barnes: Looks good to me, approved
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 0142fad..9934f55 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -192,19 +192,28 @@ { const struct spi_slave *spi = &flash->spi; int ret; + int attempt = 0; u8 status; struct stopwatch sw;
stopwatch_init_msecs_expire(&sw, timeout); do { + attempt++; + ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1); - if (ret) + if (ret) { + printk(BIOS_WARNING, + "SF: SPI command failed on attempt %d with rc %d\n", attempt, + ret); return -1; + } + if ((status & poll_bit) == 0) return 0; } while (!stopwatch_expired(&sw));
- printk(BIOS_WARNING, "SF: timeout at %ld msec\n", stopwatch_duration_msecs(&sw)); + printk(BIOS_WARNING, "SF: timeout at %ld msec after %d attempts\n", + stopwatch_duration_msecs(&sw), attempt);
return -1; }