From patchwork Fri Apr 23 17:28:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 50855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 87C7EB7D1E for ; Sat, 24 Apr 2010 03:29:54 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O5Mfx-00014Z-Gr; Fri, 23 Apr 2010 17:28:25 +0000 Received: from chamillionaire.breakpoint.cc ([85.10.199.196]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1O5Mfv-00013K-4N for linux-mtd@lists.infradead.org; Fri, 23 Apr 2010 17:28:24 +0000 Received: id: bigeasy by Chamillionaire.breakpoint.cc with local (easymta 1.00 BETA 1) id 1O5Mfr-0007bq-J1; Fri, 23 Apr 2010 19:28:19 +0200 Date: Fri, 23 Apr 2010 19:28:19 +0200 From: Sebastian Andrzej Siewior To: Artem Bityutskiy Subject: [PATCH] mtd/ubi: recognize empty flash with errors as empty Message-ID: <20100423172819.GA29224@Chamillionaire.breakpoint.cc> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1271818257.11751.1372.camel@localhost.localdomain> X-Key-Id: FE3F4706 X-Key-Fingerprint: FFDA BBBB 3563 1B27 75C9 925B 98D5 5C1C FE3F 4706 User-Agent: Mutt/1.5.20 (2009-06-14) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100423_132823_470199_DF6FB472 X-CRM114-Status: GOOD ( 15.60 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [85.10.199.196 listed in list.dnswl.org] Cc: linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sebastian Andrzej Siewior Attaching empty nand with a block which contains a RS-Error which can't be fixed resulted in: | UBI: attaching mtd9 to ubi0 | UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 3399:0, read 64 bytes | Call Trace: | [cfbd5c60] [c0008558] show_stack+0x48/0x19c (unreliable) | [cfbd5ca0] [c01a71e8] ubi_io_read+0x188/0x288 | [cfbd5cf0] [c01a76e8] ubi_io_read_ec_hdr+0x74/0x2a4 | [cfbd5d20] [c01abe9c] ubi_scan+0x178/0x10b4 | [cfbd5d80] [c01a1464] ubi_attach_mtd_dev+0x67c/0xe44 | [cfbd5e80] [c01a1fc8] ctrl_cdev_ioctl+0x178/0x210 | [cfbd5ec0] [c008711c] do_ioctl+0x3c/0xc4 | [cfbd5ee0] [c0087224] vfs_ioctl+0x80/0x448 | [cfbd5f10] [c008762c] sys_ioctl+0x40/0x88 | [cfbd5f40] [c000f960] ret_from_syscall+0x0/0x38 | UBI error: ubi_read_volume_table: the layout volume was not found | UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22 Assuming that blocks which can only be read with errors are empty will let the volume attach. Another access to the block in question resulted here in: | UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 3399:0, read 64 bytes | nand_erase: Failed erase, page 0x000751c0 | nand_erase: Failed erase, page 0x000751c0 | nand_erase: Failed erase, page 0x000751c0 | nand_erase: Failed erase, page 0x000751c0 | UBI error: do_sync_erase: cannot erase PEB 3399, error -5 | UBI error: erase_worker: failed to erase PEB 3399, error -5 | UBI: mark PEB 3399 as bad | UBI: 39 PEBs left in the reserve Signed-off-by: Sebastian Andrzej Siewior --- drivers/mtd/ubi/scan.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index dc5f688..7529d46 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -756,7 +756,8 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, bitflips = 1; } - si->is_empty = 0; + if (err != UBI_IO_BAD_EC_HDR) + si->is_empty = 0; if (!ec_corr) { int image_seq; @@ -827,6 +828,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, return err; goto adjust_mean_ec; } + si->is_empty = 0; vol_id = be32_to_cpu(vidh->vol_id); if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID) {