Received: by 10.223.176.5 with SMTP id f5csp813896wra; Sat, 3 Feb 2018 10:54:21 -0800 (PST) X-Google-Smtp-Source: AH8x224lDPvmFDdIjs6zg/ir7Yui4aswSLERoJQD346u0mZ15XCZo00+jZSiAYAanYLNaeclbWa6 X-Received: by 10.99.113.75 with SMTP id b11mr35685429pgn.271.1517684061384; Sat, 03 Feb 2018 10:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517684061; cv=none; d=google.com; s=arc-20160816; b=SO6+u1WyHPH1l0GsD3i2Wlp11HPJ9uY1dGJCIWbTMpWD3ejqQ+snWYQtcsFiOz28cd Pr3wNDtv/IATZUiNDYLooJHsOtywibzQvFmuFrBSlgpJjmdHinIocqfinguFO8CQhJdW MO3G++IA63Ubp1uS6pcVd4DBdjxcwee8KJvaBm/fHkOr/0HgKhvr/AYVzQlKt7Mdox0x zJLEbBY2OAHANpNre1mQNXnDyotdXodc3TIl10/1n/uHcqUBy4WRZySY/ns5yYLKKmz1 kQPrdj/kcAh22FxUodlCyEdCcoZl2/bi4I6j2HbeYJQ6hP2+wd9GQYUU/UCujAhSPij5 6BmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=35roedMcVShjC+TWsUXMpZhNTNv9ellngUk9ngXUg9Y=; b=VMImWu/kxEA+Y/hg3KdLSUJCe8uq7zNR/Q4XBMMxO4r/AeDssr9F2CAjppAIRWXDYT PMyljgtld9bY0Skvf/qSyTQ9DQD6Yll2RGSylfugZZrcLoXAIKOsSP1BJEq/EtJWPrC1 f1q1RRFyq3Infp73nrp89fkm8vOINDAt/19o5LyZ2uuI9XhEW38KQAP3DTP0iq6hq4e0 TWZ16y/pGFRKO4fPqJJEDsErOmJYa+RmlhIFs5XRqkj/Iz31Q/HnwhawR9fUYnnMgTEG NFT9jCe3SEjxB7/G8sihCKkJjpouk7SE2fPoh6a/GW+cezmyT8xNIGieNRbBBvv6DKEZ QJbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=WJUhu6qD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si1296882pgp.65.2018.02.03.10.54.06; Sat, 03 Feb 2018 10:54:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=WJUhu6qD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186AbeBCSxN (ORCPT + 99 others); Sat, 3 Feb 2018 13:53:13 -0500 Received: from mail-bn3nam01on0138.outbound.protection.outlook.com ([104.47.33.138]:24890 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752822AbeBCSA6 (ORCPT ); Sat, 3 Feb 2018 13:00:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=35roedMcVShjC+TWsUXMpZhNTNv9ellngUk9ngXUg9Y=; b=WJUhu6qDu86yqXvjEqoOSYBjbqbwBb3cGvvk9vmhcNKzINx5Tmnjq37SG7obnhx7naq4BbcnsWnw+4Hmpps401KVuZMSK2t1Fp8eZUSISWSFOwoDChPEMucfFhlhSUZGny7rdMU3QH6S9Ny6a/rWvfOAWWrEz67k3ML3hEIbi88= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1043.namprd21.prod.outlook.com (52.132.24.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.506.3; Sat, 3 Feb 2018 18:00:35 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:00:35 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Sascha Hauer , Richard Weinberger , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 013/110] mtd: nand: gpmi: Fix failure when a erased page has a bitflip at BBM Thread-Topic: [PATCH AUTOSEL for 4.14 013/110] mtd: nand: gpmi: Fix failure when a erased page has a bitflip at BBM Thread-Index: AQHTnRjiareyuUT9y0+RiZ34WcmY3w== Date: Sat, 3 Feb 2018 18:00:32 +0000 Message-ID: <20180203180015.29073-13-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1043;7:lohyVPP4G3NWjiZBaeSRKEglSPifjQmPJe4XLWDSP11RwZ1vKktO4AFbMgmcrssqLCDUl4iiKPqhuLzLfkTLLXd2D+KWQpQKHkB9AHKFWTEiN20b0e03ZimFP+29kNFVo6ABukoRR0jEZakr1VNRKKrwJRSzTnuFhopkZ6w8fJ4YMNtWTqvLmiIvWibFiQDXTrE+n2d5nxil4Tst8GUEbpymkhyG0fk3hbj7SBbMLg/nndvUMvmX2EUsMDNyFShr x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0dcd4a42-f734-4443-3109-08d56b300665 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1043; x-ms-traffictypediagnostic: BL0PR2101MB1043: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(58145275503218); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(93006095)(93001095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:BL0PR2101MB1043;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1043; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(376002)(39860400002)(366004)(346002)(396003)(189003)(199004)(10290500003)(186003)(6486002)(14454004)(1076002)(102836004)(6506007)(76176011)(26005)(6346003)(66066001)(10090500001)(5250100002)(36756003)(6512007)(2501003)(110136005)(99286004)(54906003)(478600001)(53936002)(72206003)(6436002)(316002)(305945005)(7736002)(6666003)(2950100002)(2906002)(5660300001)(4326008)(106356001)(575784001)(86362001)(97736004)(25786009)(22452003)(2900100001)(3846002)(107886003)(8676002)(8936002)(6116002)(3280700002)(105586002)(81156014)(81166006)(3660700001)(86612001)(68736007)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1043;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: j97It8Hht5FHgkFZ2H1XEZxfe71bMDXXIosU+bCNPqyUYR8hAtq7OdAmL8kEuFYKJACWgZnq40RIcVHf3bTANA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0dcd4a42-f734-4443-3109-08d56b300665 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:00:32.6127 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1043 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sascha Hauer [ Upstream commit fdf2e821052958a114618a95ab18a300d0b080cb ] When erased subpages are read then the BCH decoder returns STATUS_ERASED if they are all empty, or STATUS_UNCORRECTABLE if there are bitflips. When there are bitflips, we have to set these bits again to show the upper layers a completely erased page. When a bitflip happens in the exact byte where the bad block marker is, then this byte is swapped with another byte in block_mark_swapping(). The correction code then detects a bitflip in another subpage and no longer corrects the bitflip where it really happens. Correct this behaviour by calling block_mark_swapping() after the bitflips have been corrected. In our case UBIFS failed with this bug because it expects erased pages to be really empty: UBIFS error (pid 187): ubifs_scan: corrupt empty space at LEB 36:118735 UBIFS error (pid 187): ubifs_scanned_corruption: corruption at LEB 36:11873= 5 UBIFS error (pid 187): ubifs_scanned_corruption: first 8192 bytes from LEB = 36:118735 UBIFS error (pid 187): ubifs_scan: LEB 36 scanning failed UBIFS error (pid 187): do_commit: commit failed, error -117 Signed-off-by: Sascha Hauer Reviewed-by: Richard Weinberger Acked-by: Boris Brezillon Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi= -nand/gpmi-nand.c index 50f8d4a1b983..d4d824ef64e9 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1067,9 +1067,6 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, s= truct nand_chip *chip, return ret; } =20 - /* handle the block mark swapping */ - block_mark_swapping(this, payload_virt, auxiliary_virt); - /* Loop over status bytes, accumulating ECC status. */ status =3D auxiliary_virt + nfc_geo->auxiliary_status_offset; =20 @@ -1158,6 +1155,9 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, s= truct nand_chip *chip, max_bitflips =3D max_t(unsigned int, max_bitflips, *status); } =20 + /* handle the block mark swapping */ + block_mark_swapping(this, buf, auxiliary_virt); + if (oob_required) { /* * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob() --=20 2.11.0