From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hector Palacios Date: Mon, 18 Jul 2016 09:39:09 +0200 Subject: [U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size In-Reply-To: <1468826329-4586-1-git-send-email-hector.palacios@digi.com> References: <1468826329-4586-1-git-send-email-hector.palacios@digi.com> Message-ID: <578C879D.1010703@digi.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 07/18/2016 09:18 AM, Hector Palacios wrote: > nand_do_write_ops() determines if it is writing a partial page with the > formula: > if (column || (writelen < mtd->writesize - 1)) > > When 'writelen' is exactly 1 byte less than the NAND page size the formula > equates to zero, so the code doesn't process it as a partial write, although > it should. > As a consequence the function remains in the while(1) loop with 'writelen' > becoming 0xffffffff and iterating until the watchdog timeout triggers. > > To reproduce the issue on a NAND with 2K page (0x800): > => nand erase.part > => nand write $loadaddr 7ff > > Signed-off-by: Hector Palacios > > https://jira.digi.com/browse/DUB-619 > --- > drivers/mtd/nand/nand_base.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index c0e381ad2d15..cb15bb21e2f0 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -2524,7 +2524,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, > > WATCHDOG_RESET(); > /* Partial page write? */ > - if (unlikely(column || writelen < (mtd->writesize - 1))) { > + if (unlikely(column || writelen < mtd->writesize)) { > cached = 0; > bytes = min_t(int, bytes - column, (int) writelen); > chip->pagebuf = -1; > Please disregard. This patch was generated over U-Boot v2015.04. I sent a corrected v2 patch. -- Hector Palacios