Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751543AbbBPULi (ORCPT ); Mon, 16 Feb 2015 15:11:38 -0500 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:50186 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbbBPULg (ORCPT ); Mon, 16 Feb 2015 15:11:36 -0500 X-ME-Helo: beldin X-ME-Date: Mon, 16 Feb 2015 21:11:32 +0100 X-ME-IP: 90.16.210.142 From: Robert Jarzmik To: Maxime Ripard Cc: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Ezequiel Garcia , Brian Norris , Lior Amsalem , Tawfik Bayouk , Thomas Petazzoni , Seif Mazareeb , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sudhakar Gundubogula , Nadav Haklai , Boris Brezillon , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 1/2] mtd: nand: pxa3xx: Fix PIO FIFO draining References: <1424091072-7738-1-git-send-email-maxime.ripard@free-electrons.com> <1424091072-7738-2-git-send-email-maxime.ripard@free-electrons.com> X-URL: http://belgarath.falguerolles.org/ Date: Mon, 16 Feb 2015 21:11:24 +0100 In-Reply-To: <1424091072-7738-2-git-send-email-maxime.ripard@free-electrons.com> (Maxime Ripard's message of "Mon, 16 Feb 2015 13:51:11 +0100") Message-ID: <87oaotaa6r.fsf@free.fr> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1934 Lines: 58 Maxime Ripard writes: > drivers/mtd/nand/pxa3xx_nand.c | 47 ++++++++++++++++++++++++++++++++++++------ > 1 file changed, 41 insertions(+), 6 deletions(-) > > diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c > index 96b0b1d27df1..b2d8d6960765 100644 > --- a/drivers/mtd/nand/pxa3xx_nand.c > +++ b/drivers/mtd/nand/pxa3xx_nand.c > @@ -480,6 +480,41 @@ static void disable_int(struct pxa3xx_nand_info *info, uint32_t int_mask) > nand_writel(info, NDCR, ndcr | int_mask); > } > > +static void drain_fifo(struct pxa3xx_nand_info *info, void *data, int len) > +{ > + if (info->ecc_bch) { > + int index = 0; > + > + while (index < (len * 4)) { > + u32 timeout; > + > + __raw_readsl(info->mmio_base + NDDB, data + index, 8); > + > + /* > + * According to the datasheet, when reading > + * from NDDB with BCH enabled, after each 32 > + * bytes reads, we have to make sure that the > + * NDSR.RDDREQ bit is set > + */ > + for (timeout = 0; > + !(nand_readl(info, NDSR) & NDSR_RDDREQ); > + timeout++) { > + if (timeout >= 5) { > + dev_err(&info->pdev->dev, > + "Timeout on RDDREQ while draining the FIFO\n"); > + return; > + } > + > + mdelay(1); So in worst case, we'll end up with 4 times mdelay(1) times len / 32. For a 2048 page, it is : 256ms where everything is stuck (mdelay and not msleep). I know you had no choice because this is called from interrupt handler (top half). But having a irq handler and a irq thread handler would solve that issue, and you'll end up with msleep(1) in this code. I don't think an mdelay(256) is acceptable. Cheers. -- Robert -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/