From patchwork Wed Nov 9 12:35:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: w.cappelle@televic.com X-Patchwork-Id: 692746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tDQfn4pd4z9tkH for ; Wed, 9 Nov 2016 23:37:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4S6n-0001Sh-9z; Wed, 09 Nov 2016 12:36:05 +0000 Received: from ip2.televic.com ([81.82.194.222] helo=exchange.televic.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4S6c-0001Hv-LC for linux-mtd@lists.infradead.org; Wed, 09 Nov 2016 12:35:55 +0000 X-AuditID: 0a011133-8ffff7000000653b-14-5823181314ca Received: from ip2.televic.com (Unknown_Domain [10.0.0.179]) by (Symantec Messaging Gateway) with SMTP id 1E.8D.25915.31813285; Wed, 9 Nov 2016 13:35:31 +0100 (CET) Received: from SRV-MAIL01.TELEVIC.COM (10.0.0.178) by SRV-MAIL02.TELEVIC.com (10.0.0.179) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Wed, 9 Nov 2016 13:35:30 +0100 Received: from TLV-THC-WC.televic.com (10.0.0.184) by SRV-MAIL01.TELEVIC.COM (10.0.0.178) with Microsoft SMTP Server id 15.0.1104.5 via Frontend Transport; Wed, 9 Nov 2016 13:35:31 +0100 From: To: Subject: [PATCH] nand gpmi fix erased block bitflip counting Date: Wed, 9 Nov 2016 13:35:20 +0100 Message-ID: <1478694920-6453-2-git-send-email-w.cappelle@televic.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478694920-6453-1-git-send-email-w.cappelle@televic.com> References: <1478694920-6453-1-git-send-email-w.cappelle@televic.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMLMWRmVeSWpSXmKPExsXCxcCwWVdYQjnC4PFNZYvdTcvYHRg9Ni+p D2CM4rZJSiwpC85Mz9O3S+DOODNhG3NBK2/Fj2Pf2BoYL3B1MXJySAiYSDSsn84CYgsJrGCU eDjZvIuRC8heyyjRvPI+C4Szj1Fi6uuJbCBVbAJyEku/L2btYuTgEBFQlvjxLxYkzCwgIzGn 8TM7iC0sYCMxaek6ZhCbRUBF4viPw0wgNq+Aq8Sci89YIRbLSdw81wlWwyngJvFs7n4miCNc JV4eugxlK0tM+D6BEaJXUOLkzCcsELskJA6+eME8gVFgFpLULCSpBYxMqxj5i5PS9UpSc1LL MpP1kvNzNzGCwotR0HgHY9cL3UOMAhyMSjy8BS8UI4RYE8uKK3MPMUpwMCuJ8KaLKUcI8aYk VlalFuXHF5XmpBYfYpTmYFES573nmxUuJJCeWJKanZpakFoEk2Xi4ATp5pISKU7NS0ktSiwt yYgHBX98MTD8pRoYVSc+tjN40Pw/LqHR/1vn0fxZAs6c7bMPx68/v0dO/8scmWfLb8n9mchc N+/Rg6S45W7xAfoSRlPYYzk5RbOm/fJs1Nnyat/Tzf0V2+aUyH1mWTP3t903mSCxwJD0FUHX f2dbee7WnDY74KzjsQumBe1Oie5qBTxld7Q27WWdNFPz2br1lYG3lViKMxINtZiLihMBsT+y /0YCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161109_043554_929940_573C1F2B X-CRM114-Status: GOOD ( 11.49 ) X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [81.82.194.222 listed in list.dnswl.org] -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: w.cappelle@televic.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Wouter Cappelle --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index 8339d4f..6ae118c 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1217,6 +1217,7 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this, int base = geo->ecc_chunkn_size * chunk; unsigned int flip_bits = 0, flip_bits_noecc = 0; uint64_t *buf = (uint64_t *)this->data_buffer_dma; + unsigned char *chunkbuf =(unsigned char*) this->data_buffer_dma; unsigned int threshold; int i; @@ -1224,13 +1225,6 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this, if (threshold > geo->ecc_strength) threshold = geo->ecc_strength; - /* Count bitflips */ - for (i = 0; i < geo->ecc_chunkn_size; i++) { - flip_bits += hweight8(~data[base + i]); - if (flip_bits > threshold) - return false; - } - /* * Read out the whole page with ECC disabled, and check it again, * This is more strict then just read out a chunk, and it makes @@ -1246,6 +1240,12 @@ static bool gpmi_erased_check(struct gpmi_nand_data *this, return false; } + /* Count bitflips in the current chunk for correct stats reporting */ + for (i = 0; i < geo->ecc_chunkn_size; i++) { + flip_bits += hweight8(~chunkbuf[base + i]); + } + + /* Tell the upper layer the bitflips we corrected. */ mtd->ecc_stats.corrected += flip_bits; *max_bitflips = max_t(unsigned int, *max_bitflips, flip_bits);