From patchwork Tue Mar 5 07:26:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 224954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B42972C033D for ; Tue, 5 Mar 2013 18:28:19 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UCmH4-0000Ar-7v; Tue, 05 Mar 2013 07:26:58 +0000 Received: from smtp29.i.mail.ru ([94.100.177.89]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UCmH2-0000AP-4T for linux-mtd@lists.infradead.org; Tue, 05 Mar 2013 07:26:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Message-Id:Date:Subject:Cc:To:From; bh=hWZpBxtE1oTlraVyvRmaW/afA0YtzlVYsQY4dJtdQvQ=; b=RUoz0e1P1HihaPJvrettrhWSNCN5ZTprokNjYWO2lR0nBSF/W9l5vEBJYUQhezO8jDyXBfgQPBBODkb7FScSyZvASLZKLA9lZiSOitAIXx/0Zu0Ey572oiiyPRPYQS3P; Received: from [217.119.30.118] (port=15687 helo=localhost.localdomain) by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1UCmGz-0007FZ-58; Tue, 05 Mar 2013 11:26:53 +0400 From: Alexander Shiyan To: linux-mtd@lists.infradead.org Subject: [RFC] mtd: nand_base: Make Diskonchip work again Date: Tue, 5 Mar 2013 11:26:51 +0400 Message-Id: <1362468411-15534-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.7.3.4 X-Spam: Not detected X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130305_022656_509048_475968A0 X-CRM114-Status: GOOD ( 12.30 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.8 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [217.119.30.118 listed in dnsbl.sorbs.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Brian Norris , Alexander Shiyan , Artem Bityutskiy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org According to my post (http://permalink.gmane.org/gmane.linux.drivers.mtd/45657), I created a patch to fix the DiskOnChip regression. Patch partially revert "mtd: nand: kill NAND_NO_READRDY". We create NAND_NEED_READDRY option as a replacement NAND_NO_READRDY but with different logic, and restore RDY expectations in reading function, if this option is set. At least, Disconchip works again, so probably it can help in solving other NAND-related bugs in the latest kernels. Signed-off-by: Alexander Shiyan --- drivers/mtd/nand/diskonchip.c | 1 + drivers/mtd/nand/nand_base.c | 16 ++++++++++++++++ include/linux/mtd/nand.h | 2 ++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 81fa578..19992f2 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -1580,6 +1580,7 @@ static int __init doc_probe(unsigned long physadr) nand->dev_ready = doc200x_dev_ready; nand->waitfunc = doc200x_wait; nand->block_bad = doc200x_block_bad; + nand->options = NAND_NEED_READRDY; nand->ecc.hwctl = doc200x_enable_hwecc; nand->ecc.calculate = doc200x_calculate_ecc; nand->ecc.correct = doc200x_correct_data; diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 4321415..42c6392 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1523,6 +1523,14 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, oobreadlen -= toread; } } + + if (chip->options & NAND_NEED_READRDY) { + /* Apply delay or wait for ready/busy pin */ + if (!chip->dev_ready) + udelay(chip->chip_delay); + else + nand_wait_ready(mtd); + } } else { memcpy(buf, chip->buffers->databuf + col, bytes); buf += bytes; @@ -1787,6 +1795,14 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, len = min(len, readlen); buf = nand_transfer_oob(chip, buf, ops, len); + if (chip->options & NAND_NEED_READRDY) { + /* Apply delay or wait for ready/busy pin */ + if (!chip->dev_ready) + udelay(chip->chip_delay); + else + nand_wait_ready(mtd); + } + readlen -= len; if (!readlen) break; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 7ccb3c5..1c13582 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -187,6 +187,8 @@ typedef enum { * This happens with the Renesas AG-AND chips, possibly others. */ #define BBT_AUTO_REFRESH 0x00000080 +/* Chip require ready check on read */ +#define NAND_NEED_READRDY 0x00000100 /* Chip does not allow subpage writes */ #define NAND_NO_SUBPAGE_WRITE 0x00000200