From patchwork Mon Apr 14 19:35:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 339044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C8B6814008B for ; Tue, 15 Apr 2014 05:38:55 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZmgi-00032D-2s; Mon, 14 Apr 2014 19:37:04 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZmgb-000318-Mk for linux-mtd@bombadil.infradead.org; Mon, 14 Apr 2014 19:36:57 +0000 Received: from c-67-176-60-102.hsd1.co.comcast.net ([67.176.60.102] helo=pearl.egauge.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZmgR-0000IA-3u for linux-mtd@lists.infradead.org; Mon, 14 Apr 2014 19:36:48 +0000 Received: by pearl.egauge.net (Postfix, from userid 1000) id 99168541F84; Mon, 14 Apr 2014 13:35:52 -0600 (MDT) From: David Mosberger To: linux-mtd@lists.infradead.org, computersforpeace@gmail.com, dedekind1@gmail.com, gsi@denx.de, pekon@ti.com Subject: [PATCH v5 4/5] mtd: nand: Allocate extra buffers needed for on-die ECC controller. Date: Mon, 14 Apr 2014 13:35:33 -0600 Message-Id: <1397504134-32178-5-git-send-email-davidm@egauge.net> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397504134-32178-1-git-send-email-davidm@egauge.net> References: <1397504134-32178-1-git-send-email-davidm@egauge.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_153647_302623_400B2B56 X-CRM114-Status: GOOD ( 13.48 ) X-Spam-Score: 3.7 (+++) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (3.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.176.60.102 listed in dnsbl.sorbs.net] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.176.60.102 listed in zen.spamhaus.org] 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.176.60.102 listed in bl.score.senderscore.com] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Cc: David Mosberger 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 To avoid unnecessary rewrites, it is necessary to count the number of actual bitflips that occurred when the NAND_STATUS_REWRITE bit is set. This patch introduces the extra buffers needed to implement that counting. The actual counting is in the next patch. Signed-off-by: David Mosberger --- drivers/mtd/nand/nand_base.c | 13 ++++++++++++- include/linux/mtd/nand.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 7092875..84409db 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3939,13 +3939,24 @@ int nand_scan_tail(struct mtd_info *mtd) !(chip->bbt_options & NAND_BBT_USE_FLASH)); if (!(chip->options & NAND_OWN_BUFFERS)) { + size_t on_die_bufsz = 0; + + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) + on_die_bufsz = 2*(mtd->writesize + mtd->oobsize); + nbuf = kzalloc(sizeof(*nbuf) + mtd->writesize - + mtd->oobsize * 3, GFP_KERNEL); + + mtd->oobsize * 3 + on_die_bufsz, GFP_KERNEL); if (!nbuf) return -ENOMEM; nbuf->ecccalc = (uint8_t *)(nbuf + 1); nbuf->ecccode = nbuf->ecccalc + mtd->oobsize; nbuf->databuf = nbuf->ecccode + mtd->oobsize; + if (chip->ecc.mode == NAND_ECC_HW_ON_DIE) { + nbuf->chkbuf = (nbuf->databuf + mtd->writesize + + mtd->oobsize); + nbuf->rawbuf = (nbuf->chkbuf + mtd->writesize + + mtd->oobsize); + } chip->buffers = nbuf; } else { diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index d09f0a0..7725bbc 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -533,6 +533,8 @@ struct nand_buffers { uint8_t *ecccalc; uint8_t *ecccode; uint8_t *databuf; + uint8_t *chkbuf; + uint8_t *rawbuf; }; /**