mtd: nand: pxa3xx: Clear need_wait flag when starting a command

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jan 28 00:59:04 EST 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=d20d0a6cf75ba60cac5d00f9a4c2caabf611c51e
Commit:     d20d0a6cf75ba60cac5d00f9a4c2caabf611c51e
Parent:     919193cee04f49628ae9efdc45bf4af1e506205f
Author:     Ezequiel Garcia <ezequiel.garcia at free-electrons.com>
AuthorDate: Wed Dec 18 18:44:08 2013 -0300
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Jan 3 11:22:26 2014 -0800

    mtd: nand: pxa3xx: Clear need_wait flag when starting a command
    
    Currently the driver assumes all commands will eventually trigger a RnB
    transition, and thus a "device is ready" IRQ.
    
    This assumption means that on every issued command, the dev_ready completion
    handler is init'ed and the need_wait flag is set.
    
    However this is incorrect: some commands (such as NAND_CMD_STATUS) don't
    make the device 'busy' and thus a RnB transition never occurs.
    Given, the NAND core never calls waitfunc() after such commands, this
    is not a problem.
    
    Therefore, it's possible to only clear the need_wait flag on every command
    that is started.
    
    This fixes a current bug that can be reproduced on PXA boards by writing
    blank (all 0xff'ed) to a page:
    
      1. The kernel issues NAND_CMD_STATUS and sets need_wait=1. The flag
         won't be cleared for this command since no RnB transition is
         involved.
    
      2. NAND_CMD_PAGEPROG is issued but since the data is blank, the driver
         decides not to execute the command (and no IRQ activity is
         involved).
    
      3. The NAND core calls waitfunc() and waits for the dev_ready
         completion, which will never end since the device _is_ already ready.
    
    Tested-by: Arnaud Ebalard <arno at natisbad.org>
    Signed-off-by: Ezequiel Garcia <ezequiel.garcia at free-electrons.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/pxa3xx_nand.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 8f38abd..9828033 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -690,6 +690,7 @@ static void prepare_start_command(struct pxa3xx_nand_info *info, int command)
 	info->retcode		= ERR_NONE;
 	info->ecc_err_cnt	= 0;
 	info->ndcb3		= 0;
+	info->need_wait		= 0;
 
 	switch (command) {
 	case NAND_CMD_READ0:



More information about the linux-mtd-cvs mailing list