From patchwork Mon Jan 9 20:23:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 135102 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1D383B6FA7 for ; Tue, 10 Jan 2012 07:26:03 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RkLlx-0004Dq-S4; Mon, 09 Jan 2012 20:24:50 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RkLlu-0004Da-S3 for linux-mtd@lists.infradead.org; Mon, 09 Jan 2012 20:24:47 +0000 Received: by iadk27 with SMTP id k27so8400220iad.36 for ; Mon, 09 Jan 2012 12:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=72d2HeZw6HV94GNQv2txyaK6YKghXro0HAB/Cu5jC8Q=; b=EKKZ2NAn94pq/UH58yiaR+6DGYZNri1Lkc5hojm3Cd6fT9KLfdspp//CpEJK2uR5rM 5ZJh4U2Hhp4yYAn11naS2BoG7hgEnh60VLuFhs6g1ndkgIQoJYJu0IeFyPesMf6qh5LH yCp3R9PAy7MzoDM0u/50uqbyRMcHXNRCAyHQU= Received: by 10.42.151.65 with SMTP id d1mr18913442icw.18.1326140686484; Mon, 09 Jan 2012 12:24:46 -0800 (PST) Received: from localhost.localdomain (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPS id l28sm254752027ibc.3.2012.01.09.12.24.41 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jan 2012 12:24:45 -0800 (PST) From: Brian Norris To: Subject: [PATCH v3 1/6] mtd: nand: add NAND_NO_WRITE_OOB option Date: Mon, 9 Jan 2012 12:23:27 -0800 Message-Id: <1326140612-26323-2-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1326140612-26323-1-git-send-email-computersforpeace@gmail.com> References: <1326140612-26323-1-git-send-email-computersforpeace@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -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: Dan Carpenter , Kulikov Vasiliy , Sebastian Andrzej Siewior , Nicolas Ferre , Dominik Brodowski , Peter Wippich , Gabor Juhos , Guillaume LECERF , Jonas Gorski , Jamie Iles , Ivan Djelic , Robert Jarzmik , David Woodhouse , Maxim Levitsky , Dmitry Eremin-Solenikov , Kevin Cernekee , Barry Song <21cnbao@gmail.com>, Jim Quinlan , Andres Salomon , Axel Lin , Anatolij Gustschin , Mike Frysinger , Arnd Bergmann , Lei Wen , Sascha Hauer , Artem Bityutskiy , Florian Fainelli , Artem Bityutskiy , Adrian Hunter , Matthieu CASTET , Kyungmin Park , Shmulik Ladkani , Wolfram Sang , Chuanxiao Dong , Joe Perches , Brian Norris , Roman Tereshonkov X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 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-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some systems cannot use the OOB area for storing any information, not even bad block markers (for instance, if ECC uses entire spare area). Thus, we implement an option to prevent ever writing to OOB. This will be useful for determining whether to record bad blocks by writing to the flash-based BBT, the bad block's OOB region, or both. Signed-off-by: Brian Norris --- drivers/mtd/nand/nand_base.c | 8 ++++++-- include/linux/mtd/nand.h | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 35b4565..b9dbf0c 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2187,6 +2187,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, int ret, subpage; ops->retlen = 0; + ops->oobretlen = 0; if (!writelen) return 0; @@ -2238,7 +2239,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, wbuf = chip->buffers->databuf; } - if (unlikely(oob)) { + if (unlikely(oob) && !(chip->options & NAND_NO_WRITE_OOB)) { size_t len = min(oobwritelen, oobmaxlen); oob = nand_fill_oob(mtd, oob, len, ops); oobwritelen -= len; @@ -2270,7 +2271,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, } ops->retlen = ops->len - writelen; - if (unlikely(oob)) + if (unlikely(oob) && !(chip->options & NAND_NO_WRITE_OOB)) ops->oobretlen = ops->ooblen; return ret; } @@ -2372,6 +2373,9 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, pr_debug("%s: to = 0x%08x, len = %i\n", __func__, (unsigned int)to, (int)ops->ooblen); + if (chip->options & NAND_NO_WRITE_OOB) + return 0; + if (ops->mode == MTD_OPS_AUTO_OOB) len = chip->ecc.layout->oobavail; else diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 63b5a8b..3547205 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -228,6 +228,12 @@ typedef enum { #define NAND_OWN_BUFFERS 0x00020000 /* Chip may not exist, so silence any errors in scan */ #define NAND_SCAN_SILENT_NODEV 0x00040000 +/* + * Do not write to OOB. Useful, e.g., when ECC takes up entire OOB. Should be + * used with flash-based BBT, since the bad block markers will no longer be + * reliable. + */ +#define NAND_NO_WRITE_OOB 0x00080000 /* Options set by nand scan */ /* Nand scan has allocated controller struct */