From patchwork Tue Jul 3 13:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 938675 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=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dX32mf/y"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="JD7kCBmg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="TdCj0A3O"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 41KlTp5pvbz9s29 for ; Tue, 3 Jul 2018 23:34:38 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From: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=Ucut3iMG/RawlG+V+279VJf04jBYe13t7ZI6urnevfQ=; b=dX3 2mf/yAjqemIoiTPbXFtx6FkyU4wQknJ7BCNRgvP93NrXL6hg8innAEHE9VXSC3EiPTCIgfmXYHZ+r GtgrLxjbX/o9vhRLcu8fsb4h8W5s1zjb5r3Icc10EQj2uhlgL3Rp07QuUNqUVPRTAsu4XeTeZmv4o 2v3hCJvoSLseH2CvhREh6asQ6iLyC0VgyPN8sokatv6128hnY0nQSxxkim2XQvlN/SUIndalfRFuR BOYt5rDsYStOXmIbmzTsr9u2w8wXnbSGtWwD2VaTL20q18/9V2KwGQJNUYL2XUntwoqSKmUDXobqI xr4m1YZi7lqKWNadDBh9UULgkqjwBSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1faLRv-0004ma-Pz; Tue, 03 Jul 2018 13:34:31 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1faLRs-0004l6-HY for linux-mtd@lists.infradead.org; Tue, 03 Jul 2018 13:34:30 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 38F4F601A8; Tue, 3 Jul 2018 13:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530624858; bh=dAwH33eotjnlVsOht7d9rhAgXOscZtW9W2LYyToDBO4=; h=From:To:Cc:Subject:Date:From; b=JD7kCBmgW6lTorphfMTlbpfFSE99xYAjazAlXlcPwfbFmRp/h3FBtCGdXq0U+2V18 lPCMTjPboc/WXtp4N3payiVtkIbRt6hVvgimEuFdalinsKkKf5FDJs633G2huxc/HK dibz86UG4TAvtf3TkcgV6YoqBu3jtPSCGQI68/Fc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B4791605A4; Tue, 3 Jul 2018 13:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530624857; bh=dAwH33eotjnlVsOht7d9rhAgXOscZtW9W2LYyToDBO4=; h=From:To:Cc:Subject:Date:From; b=TdCj0A3O6YwYAXNKf1a89qx5GjQuavcXgvtnvXgyZ4ei8FFqnc/0Evi0lpmSyQdIW d0hZz/7O173ix08Yc75HjUpWzQfNtqPAEIbm03qhhCBTofvap4tHMlr58xxsnDhvy2 kZCJHCA03l+obkz7uP5fMbarjv3lUHQYSI/WJVQ8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B4791605A4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: stable@vger.kernel.org Subject: [BACKPORT PATCH] mtd: nand: fix return value check for bad block status Date: Tue, 3 Jul 2018 19:04:05 +0530 Message-Id: <1530624845-28319-1-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180703_063428_604339_63B8F96E X-CRM114-Status: GOOD ( 13.74 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [198.145.29.96 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 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-arm-msm@vger.kernel.org, Abhishek Sahu , linux-mtd@lists.infradead.org, Boris Brezillon , Miquel Raynal MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org commit e9893e6fa932f42c90c4ac5849fa9aa0f0f00a34 upstream. Positive return value from read_oob() is making false BAD blocks. For some of the NAND controllers, OOB bytes will be protected with ECC and read_oob() will return number of bitflips. If there is any bitflip in ECC protected OOB bytes for BAD block status page, then that block is getting treated as BAD. Fixes: c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check") Cc: Signed-off-by: Abhishek Sahu Reviewed-by: Miquel Raynal Signed-off-by: Boris Brezillon [backported to 4.14.y] Signed-off-by: Abhishek Sahu --- This is backported patch for failed patch mentioned in https://www.spinics.net/lists/stable/msg245833.html The failure happened due to file rename. drivers/mtd/nand/nand_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 528e04f..d410de3 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs) for (; page < page_end; page++) { res = chip->ecc.read_oob(mtd, chip, page); - if (res) + if (res < 0) return res; bad = chip->oob_poi[chip->badblockpos];