All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size
@ 2016-07-18  7:18 Hector Palacios
  2016-07-18  7:39 ` Hector Palacios
  0 siblings, 1 reply; 2+ messages in thread
From: Hector Palacios @ 2016-07-18  7:18 UTC (permalink / raw)
  To: u-boot

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 <partition>
	=> nand write $loadaddr <partition> 7ff

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size
  2016-07-18  7:18 [U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size Hector Palacios
@ 2016-07-18  7:39 ` Hector Palacios
  0 siblings, 0 replies; 2+ messages in thread
From: Hector Palacios @ 2016-07-18  7:39 UTC (permalink / raw)
  To: u-boot

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 <partition>
> 	=> nand write $loadaddr <partition> 7ff
> 
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>
> 
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-18  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18  7:18 [U-Boot] [PATCH 1/1] mtd: nand-base: fix bug writing 1 byte less than page size Hector Palacios
2016-07-18  7:39 ` Hector Palacios

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.