Received: by 10.223.185.116 with SMTP id b49csp8508084wrg; Fri, 2 Mar 2018 03:06:49 -0800 (PST) X-Google-Smtp-Source: AG47ELvtBHICZj9XON2PV1lwUAH73+cT7nCWnVKG8db4VVsTCI2FTjuXVmwAPPLdZqoC8qIJjCi1 X-Received: by 10.98.76.215 with SMTP id e84mr5336541pfj.45.1519988809275; Fri, 02 Mar 2018 03:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519988809; cv=none; d=google.com; s=arc-20160816; b=UQ5cq0yj+jx3GRNx8HNdjP3sy1uGwWMVgg5+D5SBM3Grp4cxh+fkf4qeUiDU3wq2Qk q/o/lO9LrKd98Oa77UztplQvQ013dl8+CJ78Taz8zQv18pW8NTLkv+/Kds0GbDJFK0/3 b9ScZEeXc7LhVuOO1PQZ0CQXnGB9OI0MPxx59Yq1nQwnGoWF/JIC/wUyJ4bfBiTHDj0X 6QunH37fDaOqYQqgnTUroqGiNsimNDoDmjuWJcxx8L/NY1NkYVWCntr+cPLOPDoAxH/3 WJGsaSUeBGeMqMiEJCT46tBc3Qhi3gkbEmderiyHvWe3fo0p1DocQRLcY5Vz2yAsfVba GHhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WRVIrsRaQ9tIJecP4ZY/bvmpf8qQdOZETx+5sXRZh+A=; b=gANV7HwmaUMOF1I5ZSVb3Lmq1NiY5hWTJM8E58kQRzSH2VqKkNyJPtxBBpkrCMJGjf qJQQE+Lgii2DAZpm8kyi4hn0COqO12/B7aM1hfnW6va19aJF9zdmU1o+z+FGeDUHGonL gjpMqh7nyOHUEMsFI77IXZLCS8Ly3lMiGyl3etSYyh9u9hSDOafBU2PqErlw9DO7YrfR 0evYpsVWRXcTiF7H9wjgQ+jveSb+R/GjNIWM+PsN8vaQEZfqCIcKUpIw3o6EVf+Puryw 5/T4fGlsjmNxokY3wZX2NYl6xkl7v/puIjBTzRuJ4JKZeBvNKqCIrLKErOsETkYIMUwr 4rgg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i30si3876561pgn.252.2018.03.02.03.06.34; Fri, 02 Mar 2018 03:06:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423635AbeCBIzO (ORCPT + 99 others); Fri, 2 Mar 2018 03:55:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50716 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423609AbeCBIzL (ORCPT ); Fri, 2 Mar 2018 03:55:11 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AE3E0121D; Fri, 2 Mar 2018 08:55:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sascha Hauer , Richard Weinberger , Boris Brezillon , Sasha Levin Subject: [PATCH 4.4 03/34] mtd: nand: gpmi: Fix failure when a erased page has a bitflip at BBM Date: Fri, 2 Mar 2018 09:50:59 +0100 Message-Id: <20180302084436.171257760@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ 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:118735 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 Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -1029,9 +1029,6 @@ static int gpmi_ecc_read_page(struct mtd return ret; } - /* handle the block mark swapping */ - block_mark_swapping(this, payload_virt, auxiliary_virt); - /* Loop over status bytes, accumulating ECC status. */ status = auxiliary_virt + nfc_geo->auxiliary_status_offset; @@ -1047,6 +1044,9 @@ static int gpmi_ecc_read_page(struct mtd max_bitflips = max_t(unsigned int, max_bitflips, *status); } + /* 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()