From 7ca2ded36434d388b872e548726f590c69c25c92 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Tue, 13 Sep 2011 22:41:24 -0700 Subject: Report SPI driver write errors. The ICH SPI controller can't handle more than 64 bytes in one write transaction, but the SPI chips' drivers routinely invoke controller transfer function (spi_xfer()) trying to write a full SPI chip page, which often exceeds the ICH SPI controller capacity. This condition goes unnoticed, resulting in only the first 64 bytes of the data written into the flash, the rest gets dropped on the floor. With this change an error value will be returned to the caller and an error message will be printed on the screen. Also, it turned out that the chip level flash drivers interpret as errors only the negative values returned by the SPI interface driver. But the SPI interface driver in ich.c was returning +1 to report errors. This CL takes care of this discrepancy too. BUG=chromium-os:20105 TEST=manual . modify the '#ifdef CONFIG_ICH_SPI' line to read '#ifdef CONFIG_ICH_SPIxx' in include/spi_flash.h . build x86-alex bootloader image . program the image on an alex device . restart the device . at the 'boot>' prompt run the 'saveenv' command Observe the command failed and the error message printed on the console. . restore include/spi_flash.h . build x86-alex bootloader image . program the image on an alex device . restart the device . at the 'boot>' prompt run the following commands: setenv xyz 'this is a string' saveenv . reboot the device . at the 'boot>' prompt run 'printenv' Observe the environment include the new variable (xyz) Change-Id: I528a85b208213c10fdf8cf3e908caf7bea94bc62 Signed-off-by: Vadim Bendebury Reviewed-on: http://gerrit.chromium.org/gerrit/7697 Reviewed-by: Simon Glass Reviewed-by: David Hendricks --- include/spi_flash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/spi_flash.h b/include/spi_flash.h index 525a3497cd..f8b177a4e3 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -33,7 +33,8 @@ #ifdef CONFIG_ICH_SPI #define CONTROLLER_PAGE_LIMIT 64 #else -#define CONTROLLER_PAGE_LIMIT MAX_INT +/* any number larger than 4K would do, actually */ +#define CONTROLLER_PAGE_LIMIT ((int)(~0U>>1)) #endif struct spi_flash { -- cgit v1.2.3