From patchwork Tue Oct 10 14:20:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Engling, Uwe" X-Patchwork-Id: 824056 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yBV2V0mmTz9t61 for ; Wed, 11 Oct 2017 08:03:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D3AD3C21E3E; Tue, 10 Oct 2017 21:03:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4AE5BC21C8F; Tue, 10 Oct 2017 21:03:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 28AD8C21C50; Tue, 10 Oct 2017 14:21:01 +0000 (UTC) Received: from mail.ise.de (mail.isedevelop.de [217.6.20.165]) by lists.denx.de (Postfix) with ESMTPS id BCD38C21C26 for ; Tue, 10 Oct 2017 14:21:00 +0000 (UTC) Received: from ise-exch13.ise.de ([172.24.224.155]:32737 helo=mail.ise.de) by mail.ise.de with esmtps (TLSv1.2:AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1e1vOy-00074G-1B for u-boot@lists.denx.de; Tue, 10 Oct 2017 16:20:56 +0200 Received: from ise-exch13.ise.de (172.24.224.155) by ise-exch13.ise.de (172.24.224.155) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Tue, 10 Oct 2017 16:20:55 +0200 Received: from ise-exch13.ise.de ([fe80::746a:66cf:c7b8:878d]) by ise-exch13.ise.de ([fe80::746a:66cf:c7b8:878d%12]) with mapi id 15.00.1130.005; Tue, 10 Oct 2017 16:20:55 +0200 From: "Engling, Uwe" To: "u-boot@lists.denx.de" Thread-Topic: [U-Boot] [PATCH] jffs2: ECC corrected nand data is ignored Thread-Index: AdNB0s3UmSEN6+o9QDesINnREx9vuQ== Date: Tue, 10 Oct 2017 14:20:55 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.24.240.128] MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Oct 2017 21:03:19 +0000 Subject: [U-Boot] [PATCH] jffs2: ECC corrected nand data is ignored X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Hello, I ran into a problem with the JFFS2 filesystem driver implemented in U-Boot. I've got a NAND device that has correctable ECC errors (corrected somewhere in mtd/nand/nand_base.c). The NAND driver tells the filesystem layer (jffs2_1pass.c) above that there occurred correctable ECC errors and returns with a "value > 0". The JFFS2 driver recognizes the corrected ECC errors as real error and skips this block because the only accepts a "return value == 0" as correct. This problem exists for over 8 years (I checked version 2010.09) so I'm a little bit worried that I interpreted something wrong or didn't get the whole context. Can someone confirm this bug (and the bugfix) in the u-boot jffs2 driver? There was a mail in 2012 that mentioned the same problem, but there was no patch: http://u-boot.10912.n7.nabble.com/JFFS2-seems-to-drop-nand-data-with-ECC-corrections-td142008.html Sometime after this discussion the return value of nand_read() changed from -EUCLEAN as correctable ECC error to a positive value with the count of ECC corrected errors. With kind reguards, Uwe Engling diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 4c6dfbf..6bf1943 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -201,7 +201,7 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf) retlen = NAND_CACHE_SIZE; if (nand_read(mtd, nand_cache_off, - &retlen, nand_cache) != 0 || + &retlen, nand_cache) < 0 || retlen != NAND_CACHE_SIZE) { printf("read_nand_cached: error reading nand off %#x size %d bytes\n", nand_cache_off, NAND_CACHE_SIZE); @@ -300,7 +300,7 @@ static int read_onenand_cached(u32 off, u32 size, u_char *buf) retlen = ONENAND_CACHE_SIZE; if (onenand_read(&onenand_mtd, onenand_cache_off, retlen, - &retlen, onenand_cache) != 0 || + &retlen, onenand_cache) < 0 || retlen != ONENAND_CACHE_SIZE) { printf("read_onenand_cached: error reading nand off %#x size %d bytes\n", onenand_cache_off, ONENAND_CACHE_SIZE);