From patchwork Mon Mar 17 17:39:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 331089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 673912C0099 for ; Tue, 18 Mar 2014 04:40:47 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPbWe-0001s1-0D; Mon, 17 Mar 2014 17:40:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPbWc-0001cM-Ch; Mon, 17 Mar 2014 17:40:34 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WPbWa-0001bU-5v for linux-mtd@lists.infradead.org; Mon, 17 Mar 2014 17:40:32 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id AB71089F; Mon, 17 Mar 2014 18:40:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost.localdomain (unknown [190.2.108.71]) by mail.free-electrons.com (Postfix) with ESMTPSA id 26EEE859; Mon, 17 Mar 2014 18:40:12 +0100 (CET) From: Ezequiel Garcia To: , Brian Norris , David Woodhouse Subject: [RFC/PATCH] mtd: nand: Account the blocks used by the BBT in the ecc_stats Date: Mon, 17 Mar 2014 14:39:45 -0300 Message-Id: <1395077985-8065-1-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.9.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140317_134032_324229_7C36C0D8 X-CRM114-Status: GOOD ( 11.39 ) 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.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Thomas Petazzoni , Gregory Clement , Lior Amsalem , Ezequiel Garcia , Tawfik Bayouk 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 Strictly speaking we should be updating the ecc_stats in the master MTD object, with the blocks used by the bad block table. This is already being done for bad and reserved blocks detected doing the BBT search, but not for the blocks used by the BBT itself. This commit adds the latter. It should be noted that the ecc_stats structure is kept only for userspace information, accesible through an ioctl. However, since the master MTD object is not tied to any /dev/mtd{N} device node in the filesystem, there's currently no way to retrieve this information. This ecc_stats is used for the MTD partitions typically allocated and registered by mtd_device_parse_register(). These have a device node, but scan for bad blocks and updates the ecc_stats in a different code path. Signed-off-by: Ezequiel Garcia --- For the reasons exposed above, it's not clear we should remove the ecc_stats update in the master MTD altogether or simply take account of the BBT blocks for consistency. I've chosen the latter, for it seemed a safer changer. I'm open to discussion. drivers/mtd/nand/nand_bbt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index c0615d1..ea9a266 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c @@ -991,6 +991,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); oldval = bbt_get_entry(this, block); bbt_mark_entry(this, block, BBT_BLOCK_RESERVED); + mtd->ecc_stats.bbtblocks++; if ((oldval != BBT_BLOCK_RESERVED) && td->reserved_block_code) nand_update_bbt(mtd, (loff_t)block << @@ -1005,6 +1006,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) for (j = 0; j < td->maxblocks; j++) { oldval = bbt_get_entry(this, block); bbt_mark_entry(this, block, BBT_BLOCK_RESERVED); + mtd->ecc_stats.bbtblocks++; if (oldval != BBT_BLOCK_RESERVED) update = 1; block++;