Received: by 10.213.65.68 with SMTP id h4csp3634850imn; Tue, 10 Apr 2018 02:04:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49b5OS4imQWBDvUrWQdG6rLxxRGSETcUHZbdlmOvRbfqdQ58/Px4XUI5qgahuCMCeXdS2E3 X-Received: by 2002:a17:902:a701:: with SMTP id w1-v6mr41985605plq.109.1523351065262; Tue, 10 Apr 2018 02:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523351065; cv=none; d=google.com; s=arc-20160816; b=JL0nYKuorsV7a86HnI70Q/Yo+SM64WfBASelGgWV1S+zvf4KNy8HW5FqowEx4G4S0o uNqXU5dhiap2Q1fDZ3vcufJib6X34w0KUY9EtKYi0TCg7wOkbDu+DYuZB5qEeJltGd3/ J0gPtJgFTov7UaQIG1t0gXnh6r45hHAZlK/Ye1huwindpYVVg9IsBwkW/TpduQu7acHc /uIDWQ1uXQqGhThDysuQXmbJSlekhNF2Lf3OYt+8DynU/kW2TM8IC8MGiHL6O+5zxTtR +5Q+GU1d1q8zW0pa/uBswYqRogBJYB4h/z5WXq+gWByS5AWadlBa3LqNj4mn/z+qKE47 kiSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=m8MRTDN1W/10f/goDShHofrZiwadhtUkUFi4BSoFONw=; b=JMoSRnfdaQMh5efoaiQAfwZN4F/cxU89jlEBSJsRJ7o3GB4UcKyMmMaZ1GqlSXZwX8 ua6GZOHB1/AOT+HdCB542/3vEqfABJUYBFNP80u8vI5XdKUL9djDj0IX0+eWmdwGcOth 47sfxYNzSzqVzTcKZT94LIwVcCcHiYecgkBayIuW0gnttlB2gNMsdenYDa3emkM7q7PD d2bhmjWYJcEbhH+Qbs7YtzVQzBw5FAui055w+QDfGZO4cNCo55hWGCPupmrXaleJiZI7 RdMks6k/pw1+xFnyZCcdjJX1cq3Pfvy5MFl85jDZurCtk5uU6yQHuYQfNeZGDmDBDajF 96YQ== 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 k127si1453707pga.173.2018.04.10.02.03.46; Tue, 10 Apr 2018 02:04:25 -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 S1752724AbeDJI77 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Apr 2018 04:59:59 -0400 Received: from mail.bootlin.com ([62.4.15.54]:40389 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351AbeDJI75 (ORCPT ); Tue, 10 Apr 2018 04:59:57 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 1F42E2083D; Tue, 10 Apr 2018 10:59:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id B3608200FB; Tue, 10 Apr 2018 10:59:45 +0200 (CEST) Date: Tue, 10 Apr 2018 10:59:45 +0200 From: Miquel Raynal To: Abhishek Sahu Cc: Boris Brezillon , Archit Taneja , Richard Weinberger , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Andy Gross , Brian Norris , David Woodhouse Subject: Re: [PATCH 3/9] mtd: nand: qcom: erased page detection for uncorrectable errors only Message-ID: <20180410105945.65f2cade@xps13> In-Reply-To: <1522845745-6624-4-git-send-email-absahu@codeaurora.org> References: <1522845745-6624-1-git-send-email-absahu@codeaurora.org> <1522845745-6624-4-git-send-email-absahu@codeaurora.org> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Abhishek, On Wed, 4 Apr 2018 18:12:19 +0530, Abhishek Sahu wrote: > The NAND flash controller generates ECC uncorrectable error > first in case of completely erased page. Currently driver > applies the erased page detection logic for other operation > errors also so fix this and return EIO for other operational > errors. I am sorry I don't understand very well what is the purpose of this patch, could you please explain it again? Do you mean that you want to avoid having rising ECC errors when you read erased pages? > > Signed-off-by: Abhishek Sahu > --- > drivers/mtd/nand/qcom_nandc.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c > index 17321fc..57c16a6 100644 > --- a/drivers/mtd/nand/qcom_nandc.c > +++ b/drivers/mtd/nand/qcom_nandc.c > @@ -1578,6 +1578,7 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > struct nand_ecc_ctrl *ecc = &chip->ecc; > unsigned int max_bitflips = 0; > struct read_stats *buf; > + bool flash_op_err = false; > int i; > > buf = (struct read_stats *)nandc->reg_read_buf; > @@ -1599,7 +1600,7 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > buffer = le32_to_cpu(buf->buffer); > erased_cw = le32_to_cpu(buf->erased_cw); > > - if (flash & (FS_OP_ERR | FS_MPU_ERR)) { > + if ((flash & FS_OP_ERR) && (buffer & BS_UNCORRECTABLE_BIT)) { And later you have another "if (buffer & BS_UNCORRECTABLE_BIT)" which is then redundant, unless that is not what you actually want to do? Maybe you can add comments before the if ()/ else if () to explain in which case you enter each branch. > bool erased; > > /* ignore erased codeword errors */ > @@ -1641,6 +1642,8 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > max_t(unsigned int, max_bitflips, ret); > } > } > + } else if (flash & (FS_OP_ERR | FS_MPU_ERR)) { > + flash_op_err = true; > } else { > unsigned int stat; > > @@ -1654,6 +1657,9 @@ static int parse_read_errors(struct qcom_nand_host *host, u8 *data_buf, > oob_buf += oob_len + ecc->bytes; > } > > + if (flash_op_err) > + return -EIO; > + In you are propagating an error related to the controller, this is fine, but I think you just want to raise the fact that a NAND uncorrectable error occurred, in this case you should just increment mtd->ecc_stats.failed and return 0 (returning max_bitflips here would be fine too has it would be 0 too). > return max_bitflips; > } > Thanks, Miquèl -- Miquel Raynal, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com