From patchwork Wed Sep 13 19:15:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Nagendran X-Patchwork-Id: 813591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QAo7JhOm"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bBfbCvK3"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xsrx500Bbz9sP1 for ; Thu, 14 Sep 2017 05:16:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Subject:To:From:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=MKdb+8eANMAgHGJag5TakSNOH9W5eZe4IibrU5nnuWM=; b=QAo7JhOm48VMpw MC6T3DcI1qmnku1h7WDL14SpMrslzU3R0YXCNE3+yYGcxYiqTTEEWM8hkxsxV33XibXFxPFtUucRR 2P894Nn+fl31Ub6jUcWBvDLzgk7qWUqaW4FKWE+tFuzeRVe6gEQ/iyv0iQ/xciyjwuXTVcvxtqWPK VNcV/9B1rvtb/AuQVrMJmh+hpEvBvH5fJ6RCATqLCQkEbkhpmw51nAUPnxnkKB69FvfwTqNvNX6qX 3gRPXdiV8YXaFf+KZRRQnqEeuOlfvTS90b6B2xJmwamvwB6jt/lXlRPfU1A3uUhGnkcIiKpcectql D2AF0LsdwOVWIh5W+Ktg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dsD8f-0001uT-Ah; Wed, 13 Sep 2017 19:15:57 +0000 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dsD8b-0001s5-Cx for linux-mtd@lists.infradead.org; Wed, 13 Sep 2017 19:15:56 +0000 Received: by mail-qk0-x244.google.com with SMTP id r66so699449qke.4 for ; Wed, 13 Sep 2017 12:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:cc:subject:mime-version:content-disposition :user-agent; bh=v9nixQk4TvcipoCoT46Ub0PebpatQIwYsF1b8THkPcQ=; b=bBfbCvK3bHBz4QiW9bxav54aU1S2qV5cMqIFgczTNOWz1Ksf0Tv66Nwf5itKbQlntW mz3I7PnvJgPw7q2k9FyZOmRnnKtGPeiXuPDhNqkXSCTMpvL0OpWhoIH2LyFDCC4AXuPI 4OQbS0yIIyQmsek3S8zwz+g07mA6aWikOG8B+YY78EkFKvQoWzmv+ILMWqAvmtz35DJX sTf/2dIBUtuIFFihPNWuGDMCP29e+kA6bxvzy4RBVHCByBkyRxt+5bLRfyq2Q+DeHc5W 70ZWj+B1+LnLSA7jTDf/3TCFeNLRImHFqEsRftH6AOEsojU3CpZIGz7WYxNj/UjjrYbh 8c2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:to:cc:subject:mime-version :content-disposition:user-agent; bh=v9nixQk4TvcipoCoT46Ub0PebpatQIwYsF1b8THkPcQ=; b=Ia/vQdZh7g9spgPol5ySsfXMNV4m0jlwk5ulkfrerrU8wfnYzMVFvEqW2UXbmpIY3+ NAwtwnoLgkpzvYguzPSVsddRqPR/YoXLsaj75TAti1xopkJyg5OfSzt2NQOWgO9o+INQ 3THlxTuSaoCen8DzytqlOoX//ez37mzlvyJ627ymplbsTlvO8KxGH9hz6OughbszN33l 9E+DhhNnN2BPVoTkJPXPTBHs/KVmYIPabQXAPcLQ9I//VA4r43ctolLQMJyB5U8FzRgB lKUoyyFeuOpDqHN+SFqnX5MayhcNzJG3G+nueX0yMlvPhpHifn1o/SkryxboU9HSe37i xKxA== X-Gm-Message-State: AHPjjUhwAjzRFFXm+7FT+WHNTsbIkQb7O2OeBNZT1AR+xx3MzopsR1kA eBRN5F45BibjtiUE X-Google-Smtp-Source: AOwi7QDc7isLcsgHyf6VdHBF+u1JB8hewNXTbZkClJbjhMGEPjbQ/sq8iUp27d4WXepMNJ/m8MCQcg== X-Received: by 10.55.104.132 with SMTP id d126mr26633718qkc.142.1505330127644; Wed, 13 Sep 2017 12:15:27 -0700 (PDT) Received: from arunluma ([204.77.239.78]) by smtp.gmail.com with ESMTPSA id i124sm9773262qkf.84.2017.09.13.12.15.26 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Sep 2017 12:15:26 -0700 (PDT) Message-ID: <59b983ce.82b8370a.04a2.b72a@mx.google.com> X-Google-Original-Message-ID: <20170913191526.GA27375@arun@getluma.com> Date: Wed, 13 Sep 2017 15:15:26 -0400 From: Arun Nagendran To: gregkh@linuxfoundation.org Subject: [PATCH] Enable the read ECC before program the page MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170913_121553_563239_7A5830BC X-CRM114-Status: GOOD ( 12.12 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (arunrasppi[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400d:c09:0:0:0:244 listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, manonuevo@micron.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Current program_page function did following operation: 1. read page (with ECC OFF) 2. modify the page 3. write the page (with ECC ON) For some case(buggy flash Chip), while read the page without ECC ON, we may read the page with bit flip error and modify that bad page without knowing the bit flip error on that page. also we re-calculate the hash for bad page and write it. This could bring potential in-consistency problem with Flash data. Verify this logic with GIGA DEVICE Part(GD5F2GQ4RCFIG): we see this in-conststency problem wit Giga Device and fix on this patch resovle that issue. Signed-off-by: Arun Nagendran --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 13eaf16..87595c5 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -496,8 +496,12 @@ static int spinand_program_page(struct spi_device *spi_nand, if (!wbuf) return -ENOMEM; - enable_read_hw_ecc = 0; - spinand_read_page(spi_nand, page_id, 0, CACHE_BUF, wbuf); + enable_read_hw_ecc = 1; + retval = spinand_read_page(spi_nand, page_id, 0, CACHE_BUF, wbuf); + if (retval < 0) { + dev_err(&spi_nand->dev, "ecc error on read page!!!\n"); + return retval; + } for (i = offset, j = 0; i < len; i++, j++) wbuf[i] &= buf[j];