From patchwork Fri Jun 22 23:35:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 166688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [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 71CF4B6F86 for ; Sat, 23 Jun 2012 09:37:37 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SiDOc-0004p9-OH; Fri, 22 Jun 2012 23:36:10 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SiDO8-0004ge-0g for linux-mtd@lists.infradead.org; Fri, 22 Jun 2012 23:35:43 +0000 Received: by mail-pb0-f49.google.com with SMTP id rq13so4463121pbb.36 for ; Fri, 22 Jun 2012 16:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=OTxAJ0LqbI9Yk54vMZwlh7SVZOb64Uz9EDBcnuIHd6o=; b=fnMqs41l1bGqLTV/uzHQQVvjB3gtwCH5Yu7sNJmXrOD78OBU85jUqwtvlhHqHDFxaT AxlO22lo4crwX1e5Afbz9RNv62gsWqhY0iGXajI3TdtFYTmWBfZd53RBIiu86exxtllZ KjYwVrokZ5J5XAT59/FD505ho+8K3CJcPL7zP+Qk5EzhSSujsQL8BMqFsfBo8jprq18C NfBlBL+JgDCoe4pb/cAZP+j2T2z1i7Kfz+QWUbRf5klprasXDBokRWbF81JhWg4WyQVK GMK+ADLwcdXvH7edS9lFAp0b7myqFmkJjqEGW+v99YxhrH8mcZHAayFPOZ5bLD9eb5nz FPpA== Received: by 10.68.236.102 with SMTP id ut6mr14608783pbc.113.1340408139710; Fri, 22 Jun 2012 16:35:39 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPS id vc6sm516963pbc.6.2012.06.22.16.35.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jun 2012 16:35:39 -0700 (PDT) From: Brian Norris To: Subject: [PATCH 8/8] mtd: nand: use ECC, if present, when scanning OOB Date: Fri, 22 Jun 2012 16:35:45 -0700 Message-Id: <1340408145-24531-9-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1340408145-24531-1-git-send-email-computersforpeace@gmail.com> References: <1340408145-24531-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.160.49 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: Mike Dunn , Artem Bityutskiy , Sebastian Andrzej Siewior , Shmulik Ladkani , Brian Norris , David Woodhouse 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 scan_read_raw_oob() is used in only in places where the MTD_OPS_PLACE_OOB mode is preferable MTD_OPS_RAW mode, so use MTD_OPS_PLACE_OOB instead. MTD_OPS_PLACE_OOB provides the same functionality with the potential[1] added bonus of error correction. This brings scan_block_full() in line with scan_block_fast() so that they both read bad block markers with MTD_OPS_PLACE_OOB. This can help in preventing 0xff markers (in good blocks) from being interpreted as bad block indicators in the presence of a single bitflip. Note that ECC error codes (EUCLEAN or EBADMSG) are already silently ignored in all users of scan_read_raw_oob(). [1] Few drivers perform proper error correction on OOB data. In those cases, the use of MTD_OPS_RAW vs. MTD_OPS_PLACE_OOB is not significant. Signed-off-by: Brian Norris Cc: Shmulik Ladkani Cc: Mike Dunn Cc: Sebastian Andrzej Siewior --- drivers/mtd/nand/nand_bbt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 45cdb97..7b9a0a7 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -289,14 +289,24 @@ static int scan_read_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs, return mtd_read(mtd, offs, len, &retlen, buf); } -/* Scan read data from flash */ +/** + * scan_read_oob - [GENERIC] Scan data+OOB region to buffer + * @mtd: MTD device structure + * @buf: temporary buffer + * @offs: offset at which to scan + * @len: length of data region to read + * + * Scan read data from data+OOB. May traverse multiple pages, interleaving + * page,OOB,page,OOB,... in buf. Completes transfer and returns the "strongest" + * ECC condition (error or bitflip). May quit on the first (non-ECC) error. + */ static int scan_read_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs, size_t len) { struct mtd_oob_ops ops; - int res; + int res, ret = 0; - ops.mode = MTD_OPS_RAW; + ops.mode = MTD_OPS_PLACE_OOB; ops.ooboffs = 0; ops.ooblen = mtd->oobsize; @@ -306,15 +316,18 @@ static int scan_read_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs, ops.oobbuf = buf + ops.len; res = mtd_read_oob(mtd, offs, &ops); - - if (res) - return res; + if (res) { + if (!mtd_is_bitflip_or_eccerr(res)) + return res; + else if (mtd_is_eccerr(res) || !ret) + ret = res; + } buf += mtd->oobsize + mtd->writesize; len -= mtd->writesize; offs += mtd->writesize; } - return 0; + return ret; } static int scan_read(struct mtd_info *mtd, uint8_t *buf, loff_t offs,