Received: by 10.192.165.156 with SMTP id m28csp41135imm; Tue, 10 Apr 2018 16:00:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx497e6+n9hALmlgB7Yp9L8o0gh/8txuzarGckwAWvEf0XHFZbhuQ5HpPe03Y+BkEXoHDi0Yt X-Received: by 2002:a17:902:a70f:: with SMTP id w15-v6mr2394457plq.344.1523401207561; Tue, 10 Apr 2018 16:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401207; cv=none; d=google.com; s=arc-20160816; b=dH8pvp3SjdFHcG2QBbtn7PbtV8ic5jQX8omUiHD15pAFVEYgZFIDJoObvm6id4u7wO voBqVldE3tmuOUunrrvXFKvKQLpVScpyF8BWUPw2xZoBHOSOMLDCVez3afbJH/WI2tJZ nqkd7RmHF8ijkRGipiOlx90Bu75AZVXYsZIw6iOMZMEjAvhDEvO45LajUQlSdqdsL8WO nbAUrN1M1XLtWXYS9zLqxGEgWHKxSy+uLcE/LIleZ0xV/dq2tBJIlMdsTFpFM6IgwXOa RharCqMCwGvGHep2aUfifg5cXoHi/fNmDlGhV+5hLjhyVcAWLhXlT04/mwoyw+4mSS59 5bYQ== 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=K76yLd3ndQiBu4oLHvBiOkVA2zhw+Z6nXW2sgM/daUY=; b=lnlmoyAPYPQtIw6EwkrktvU0kk4WkELo23axXEn0AYxUq270pNSouTXRjGH3Z5BF4p sewWTsOf06TSaWOXRBwSOqM4ZYINYxgNtEYyVGdPcr8rm0SAMBLVELvCVVA2HvoS0GvX fi9gK/IsC8dmoDI3fifXtKGh01qvlZ9vcdUpFg3Ahq3JWDpOv2mwNBwLv3hBceIIt4FL eqTbWfP04N3sqy8SLbm59XSCTvteM2U5Jo/IZp0YSj5MLKY609VtwnmWe+czNVrPPBPR /reThXTGObPdx8Qv9zXD6utp3uq8JsMeVMEP8aa758TGARvMQrzK/PNCl6mlRGZLJr6q k1tA== 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 d9si2348479pgo.687.2018.04.10.15.59.30; Tue, 10 Apr 2018 16:00:07 -0700 (PDT) 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 S932408AbeDJWhM (ORCPT + 99 others); Tue, 10 Apr 2018 18:37:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43670 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755778AbeDJWhI (ORCPT ); Tue, 10 Apr 2018 18:37:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E1C04BB6; Tue, 10 Apr 2018 22:37:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal , Boris Brezillon , Sasha Levin Subject: [PATCH 4.14 078/138] mtd: mtd_oobtest: Handle bitflips during reads Date: Wed, 11 Apr 2018 00:24:28 +0200 Message-Id: <20180410212911.198142284@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miquel Raynal [ Upstream commit 12663b442e5ac5aa3d6097cd3f287c71ba46d26e ] Reads from NAND devices usually trigger bitflips, this is an expected behavior. While bitflips are under a given threshold, the MTD core returns 0. However, when the number of corrected bitflips is above this same threshold, -EUCLEAN is returned to inform the upper layer that this block is slightly dying and soon the ECC engine will be overtaken so actions should be taken to move the data out of it. This particular condition should not be treated like an error and the test should continue. Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/tests/oobtest.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c @@ -193,6 +193,9 @@ static int verify_eraseblock(int ebnum) ops.datbuf = NULL; ops.oobbuf = readbuf; err = mtd_read_oob(mtd, addr, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err || ops.oobretlen != use_len) { pr_err("error: readoob failed at %#llx\n", (long long)addr); @@ -227,6 +230,9 @@ static int verify_eraseblock(int ebnum) ops.datbuf = NULL; ops.oobbuf = readbuf; err = mtd_read_oob(mtd, addr, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err || ops.oobretlen != mtd->oobavail) { pr_err("error: readoob failed at %#llx\n", (long long)addr); @@ -286,6 +292,9 @@ static int verify_eraseblock_in_one_go(i /* read entire block's OOB at one go */ err = mtd_read_oob(mtd, addr, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err || ops.oobretlen != len) { pr_err("error: readoob failed at %#llx\n", (long long)addr); @@ -527,6 +536,9 @@ static int __init mtd_oobtest_init(void) pr_info("attempting to start read past end of OOB\n"); pr_info("an error is expected...\n"); err = mtd_read_oob(mtd, addr0, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err) { pr_info("error occurred as expected\n"); err = 0; @@ -571,6 +583,9 @@ static int __init mtd_oobtest_init(void) pr_info("attempting to read past end of device\n"); pr_info("an error is expected...\n"); err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err) { pr_info("error occurred as expected\n"); err = 0; @@ -615,6 +630,9 @@ static int __init mtd_oobtest_init(void) pr_info("attempting to read past end of device\n"); pr_info("an error is expected...\n"); err = mtd_read_oob(mtd, mtd->size - mtd->writesize, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err) { pr_info("error occurred as expected\n"); err = 0; @@ -684,6 +702,9 @@ static int __init mtd_oobtest_init(void) ops.datbuf = NULL; ops.oobbuf = readbuf; err = mtd_read_oob(mtd, addr, &ops); + if (mtd_is_bitflip(err)) + err = 0; + if (err) goto out; if (memcmpshow(addr, readbuf, writebuf,