From ef561a293f1641750bba635a9af4f380a9dfd32e Mon Sep 17 00:00:00 2001 From: Shamile Khan Date: Wed, 23 Mar 2016 16:02:59 -0700 Subject: spi_flash: Reload watchdog before writing a flash page When EC receives many flash write requests from host and PDCMD, CHARGE and USB_CHG_P0 tasks are all ready to run, the HOOK task may not get scheduled in time to pet the watchdog resulting in an EC reset. BUG=chrome-os-partner:51438 BRANCH=None TEST=Manual on lars, determine two EC versions that have enough differences so that replacing one image with the other will require all or most of the flash pages to be updated. Alternate between flashing the two images with flashrom using a script. Atleast 1000 iterations should pass. Change-Id: I8b5c8b680a2935b945f3740e371dee2d218ec4c5 Signed-off-by: Shamile Khan Reviewed-on: https://chromium-review.googlesource.com/334457 Reviewed-by: Stefan Reinauer Reviewed-by: Aseda Aboagye (cherry picked from commit a537d1ac44c40e7f6e1131e8cc852b030ccdba52) Reviewed-on: https://chromium-review.googlesource.com/334903 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye --- common/spi_flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/spi_flash.c b/common/spi_flash.c index 41138c5362..c19253f518 100644 --- a/common/spi_flash.c +++ b/common/spi_flash.c @@ -272,6 +272,7 @@ int spi_flash_write(unsigned int offset, unsigned int bytes, return EC_ERROR_INVAL; while (bytes > 0) { + watchdog_reload(); /* Write length can not go beyond the end of the flash page */ write_size = MIN(bytes, SPI_FLASH_MAX_WRITE_SIZE - (offset & (SPI_FLASH_MAX_WRITE_SIZE - 1))); @@ -540,8 +541,6 @@ static int command_spi_flashwrite(int argc, char **argv) ccprintf("Writing %d bytes to 0x%x...\n", bytes, offset); while (bytes > 0) { - watchdog_reload(); - /* First write multiples of 256, then (bytes % 256) last */ write_len = ((bytes % SPI_FLASH_MAX_WRITE_SIZE) == bytes) ? bytes : SPI_FLASH_MAX_WRITE_SIZE; -- cgit v1.2.1