diff mbox

[U-Boot] mtd: cfi_flash: fix polling for bit XSR.7 on Intel chips

Message ID 20160718121037.16677-1-daniel.schwierzeck@gmail.com
State Accepted
Commit 55edb9d4d521ff733d217ddf47ad7bf4650676be
Delegated to: Stefan Roese
Headers show

Commit Message

Daniel Schwierzeck July 18, 2016, 12:10 p.m. UTC
flash_full_status_check() checks bit XSR.7 on Intel chips. This
should be done by only checking bit 7 and not by comparing the
whole status byte or word with 0x80.

This fixes the non-working block erase in the pflash emulation
of Qemu when used with the MIPS Malta board. MIPS Malta uses x32
mode to access the pflash device. In x32 mode Qemu mirrors the
lower 16 bits of the status word into the upper 16 bits. Thus
the CFI driver gets a status word of 0x8080 in x32 mode. If
flash_full_status_check() uses flash_isequal(), then it polls for
XSR.7 by comparing 0x8080 with 0x80 which never becomes true.

Reported-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

---

 drivers/mtd/cfi_flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Roese July 20, 2016, 9:23 a.m. UTC | #1
Hi Daniel,

On 18.07.2016 14:10, Daniel Schwierzeck wrote:
> flash_full_status_check() checks bit XSR.7 on Intel chips. This
> should be done by only checking bit 7 and not by comparing the
> whole status byte or word with 0x80.
>
> This fixes the non-working block erase in the pflash emulation
> of Qemu when used with the MIPS Malta board. MIPS Malta uses x32
> mode to access the pflash device. In x32 mode Qemu mirrors the
> lower 16 bits of the status word into the upper 16 bits. Thus
> the CFI driver gets a status word of 0x8080 in x32 mode. If
> flash_full_status_check() uses flash_isequal(), then it polls for
> XSR.7 by comparing 0x8080 with 0x80 which never becomes true.
>
> Reported-by: Alon Bar-Lev <alon.barlev@gmail.com>
> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

Applied to u-boot-cfi-flash/master.

Thanks,
Stefan
diff mbox

Patch

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 8ccaff0..33c4a93 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -608,7 +608,7 @@  static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
 	case CFI_CMDSET_INTEL_EXTENDED:
 	case CFI_CMDSET_INTEL_STANDARD:
 		if ((retcode == ERR_OK)
-		    && !flash_isequal (info, sector, 0, FLASH_STATUS_DONE)) {
+		    && !flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
 			retcode = ERR_INVAL;
 			printf ("Flash %s error at address %lx\n", prompt,
 				info->start[sector]);