From: oferh at marvell.com Date: Wed, 6 Dec 2017 08:55:43 +0200 Subject: [U-Boot] [RFC PATCH v3 05/10] mtd: nand: pxa3xx-nand: fix random command timeouts In-Reply-To: <1512543348-1673-1-git-send-email-oferh@marvell.com> References: <1512543348-1673-1-git-send-email-oferh@marvell.com> Message-ID: <1512543348-1673-6-git-send-email-oferh@marvell.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Ofer Heifetz When 2 commands are submitted in a row, and the second is very quick, the completion of the second command might never come. This happens especially if the second command is quick, such as a status read after an erase [ Linux commit 21fc0ef9652f0c809dc0d3e0a67f1e1bf6ff8255 ] Cc: Robert Jarzmik Signed-off-by: Chris Packham Reviewed-by: Ofer Heifetz Tested-by: Ofer Heifetz --- drivers/mtd/nand/pxa3xx_nand.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index 5d37f22..d83efea 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c @@ -624,8 +624,14 @@ static irqreturn_t pxa3xx_nand_irq(struct pxa3xx_nand_info *info) is_ready = 1; } + /* + * Clear all status bit before issuing the next command, which + * can and will alter the status bits and will deserve a new + * interrupt on its own. This lets the controller exit the IRQ + */ + nand_writel(info, NDSR, status); + if (status & NDSR_WRCMDREQ) { - nand_writel(info, NDSR, NDSR_WRCMDREQ); status &= ~NDSR_WRCMDREQ; info->state = STATE_CMD_HANDLE; @@ -646,8 +652,6 @@ static irqreturn_t pxa3xx_nand_irq(struct pxa3xx_nand_info *info) nand_writel(info, NDCB0, info->ndcb3); } - /* clear NDSR to let the controller exit the IRQ */ - nand_writel(info, NDSR, status); if (is_completed) info->cmd_complete = 1; if (is_ready) -- 1.9.1