Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp862091pxf; Wed, 7 Apr 2021 13:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU6zjKasxpVKOQxX7VAgDRabkaG8Nh5Xa/agqEbDTyaV5JJ1FNnDBuE2dEqe/dMLvKnE33 X-Received: by 2002:a50:e702:: with SMTP id a2mr6874900edn.3.1617827593836; Wed, 07 Apr 2021 13:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617827593; cv=none; d=google.com; s=arc-20160816; b=D4R31NJAzHg+Fz94aDOlBCYLyRsiLcbdWQSf72FzGeZd9CkUwlL91puI+br9Wg8INT ToD/vPCDP4XCyweRPBTVpRttxF2NlW4m600RbB3z8PVsNpg7CWJgT7ZYfedjv8FypDEq f3HEI7FHHarRdw6UmHbJhVPhWVh281KiHnhiOsZxYPT7jafQRwSsZ/TQseiHjQ4gPU+L Ivh+NBJ+8kaOH5euqx1dAKrxepsn7rMlnxwdWbzdMCAck/P3tvBVfq1mE1XVOGDQqkgZ Kf8pSEXjnHlR4YkbeM4fmxFYGxcZeXbA4YkhD8naahguk0gmjncs6U+to1MTzOYBKglg XRwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=9QlaQ4rnD0HeA7lMYYn2m5i0o/RRuMHpFAiHHaQYA0g=; b=ufYk2Uvi8TezhXNwdq5V9fEYot4B2UC42T0M1X57hnudQ/2xSnA4wTClXNDi1V/KhD gVyk+S5T4+d/Bl3/5mNHb4YwypUu7r+H866kg9XG90qf1cKpeumkQWaYO9LYDruXzt/+ ALspzSOLh6VqdEEm6XJMmpcWEfGogeGJkN10w1/ZoSsK4ShHkCD7QgLkvHJWnVhoRVTy iD740sGTuMekGpeXsg9QgAnBLLGB1rUFbDwdaE4sJY0JfyKCT7cpdYvN1uXotSAPsqNA FbAxC8FOQtSQy+ZnMbSUMQVR88jVMsobyPlg6S4cjxs+V3T/S7GRwvJbKzVJenMICaMK 8M8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx23si9548731edb.466.2021.04.07.13.32.50; Wed, 07 Apr 2021 13:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244618AbhDGICv convert rfc822-to-8bit (ORCPT + 99 others); Wed, 7 Apr 2021 04:02:51 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:39605 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244592AbhDGICZ (ORCPT ); Wed, 7 Apr 2021 04:02:25 -0400 X-Originating-IP: 90.89.138.59 Received: from xps13 (lfbn-tou-1-1325-59.w90-89.abo.wanadoo.fr [90.89.138.59]) (Authenticated sender: miquel.raynal@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 9D409FF80E; Wed, 7 Apr 2021 08:02:05 +0000 (UTC) Date: Wed, 7 Apr 2021 10:02:04 +0200 From: Miquel Raynal To: Daniel Palmer Cc: linux-mtd@lists.infradead.org, Linux Kernel Mailing List Subject: Re: [PATCH v2] mtd: spinand: add support for Foresee FS35ND01G-S1Y2 Message-ID: <20210407100204.08d894ca@xps13> In-Reply-To: References: <20210213095724.3411058-1-daniel@0x0f.com> <20210215112409.1a755bf0@xps13> <20210215121653.4edd86c4@xps13> <20210322193213.18520b9a@xps13> <20210323113233.3523d66b@xps13> <20210323150603.6b942a60@xps13> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, Daniel Palmer wrote on Fri, 26 Mar 2021 23:09:28 +0900: > Hi Miquel, > > Sorry for the constant pestering on this.. > > On Tue, 23 Mar 2021 at 23:06, Miquel Raynal wrote: > > > # nandbiterrs -i /dev/mtd1 > > > incremental biterrors test > > > Successfully corrected 0 bit errors per subpage > > > Inserted biterror @ 0/5 > > > Read reported 4 corrected bit errors > > > ECC failure, invalid data despite read success > > > > This is not a valid behavior. There is something wrong with the way ECC > > status is read/retrieved. The read should indeed report 4 corrected bit > > errors, but then the data should be valid. Here it means that the > > introduced error appears corrected but in fact is not. > > We need to understand what status are available and write the > > appropriate vendor code. > > I looked at the datasheet again and the encoding for ecc status seems > a bit funky. > The chip seems to have only two bits for ECC status with this encoding: > 0 - Read success with 0-3 flipped bits. > 1 - Read success with 4 flipped bits. > 2 - Uncorrectable. > 3 - Reserved. > Very nice information. > This looks almost the same as the Winbond chips with 0 and 1 being successes > but with no totally error free status. > > Anyhow, if 4 bits were corrected is returned for 1 then nandbiterrs > reports "ECC failure, invalid data despite read success". > If I return 3 bit errors for 0 and -EBADMSG for anything else > nandbiterrs doesn't complain anymore but is this right?: You may look at micron_8_ecc_get_status() helper to guide you. But IMHO, if there are 0-3 bf, you should probably assume there were 3 bf and return 3, if there were 4, return 4, if it's uncorrectable return -EBADMSG otherwise -EINVAL. We should verify that this does not mess with UBI wear leveling though. Please check that returning 3-bit errors no matter the actual number of flipped bits does not lead UBI to move the data away (I think it's fine but we need to be sure otherwise the implementation proposal is not valid). Thanks, Miquèl