From patchwork Wed Jul 4 08:06:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shmulik Ladkani X-Patchwork-Id: 168919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DCB2E2C01EA for ; Wed, 4 Jul 2012 18:13:43 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmKgU-0007Oa-6N; Wed, 04 Jul 2012 08:11:38 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmKdm-0006q7-3A; Wed, 04 Jul 2012 08:08:53 +0000 Received: by wgbds1 with SMTP id ds1so4897615wgb.18 for ; Wed, 04 Jul 2012 01:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=ylIVlmO7C3ZcpiXStpz1qTTWBNPWgB+uUCB0LO6hk+U=; b=ONo7sQK6WRSwyXOSEjJAxHb0YDDDzZwG9pYMSDYMS2URxFGym6Lanw/C7CSlEMVgr9 OX3JXCez7lFyy31p3RK/CG4FOcHqNNHfcdq8mAsZ2Dpj2HvxfragUVOMfzzpfc9sFiPZ 26PKm61XcP9uXzfdJmhi7t0jWl8CJJy0tq+smdmw+ArqRMN9tGfJFKxAAVX72Wb6wVjW 3Pv197jAuJ4Ein86C8Ebwz2mESJ+2O6i7vH51L7QTWGIMSuBq2sndvet3supHEJMHOPw +Fsz5+1qLNBcn1JfurhpAxe95eWKwRSIMvTT7bB3wxc2cIwhEPTytr/1gEakNz+ad2+G 1IfA== Received: by 10.216.226.198 with SMTP id b48mr6045788weq.186.1341389253284; Wed, 04 Jul 2012 01:07:33 -0700 (PDT) Received: from pixies.home.jungo.com (212-150-239-254.bb.netvision.net.il. [212.150.239.254]) by mx.google.com with ESMTPS id f7sm64342240wiv.2.2012.07.04.01.07.30 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jul 2012 01:07:32 -0700 (PDT) From: Shmulik Ladkani To: Artem Bityutskiy , Andrew Victor Subject: [PATCH 1/5] ubi: introduce ubi->bad_peb_limit Date: Wed, 4 Jul 2012 11:06:00 +0300 Message-Id: <1341389164-24409-2-git-send-email-shmulik.ladkani@gmail.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1341389164-24409-1-git-send-email-shmulik.ladkani@gmail.com> References: <1341389164-24409-1-git-send-email-shmulik.ladkani@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shmulik.ladkani[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Russell King , Richard Genoud , Richard Weinberger , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Shmulik Ladkani , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Introduce 'ubi->bad_peb_limit', which specifies an upper limit of PEBs ubi expects to go bad. Currently, it is initialized to a fixed percentage of total PEBs in the ubi device (configurable via CONFIG_MTD_UBI_BEB_LIMIT). The 'bad_peb_limit' is intended to be used for calculating the amount of PEBs ubi needs to reserve for bad eraseblock handling. Signed-off-by: Shmulik Ladkani --- arch/arm/configs/sam9_l9260_defconfig | 1 + drivers/mtd/ubi/Kconfig | 11 +++++++++++ drivers/mtd/ubi/build.c | 13 ++++++++++++- drivers/mtd/ubi/ubi.h | 2 ++ 4 files changed, 26 insertions(+), 1 deletions(-) diff --git a/arch/arm/configs/sam9_l9260_defconfig b/arch/arm/configs/sam9_l9260_defconfig index ecf2531..f6917c9 100644 --- a/arch/arm/configs/sam9_l9260_defconfig +++ b/arch/arm/configs/sam9_l9260_defconfig @@ -40,6 +40,7 @@ CONFIG_MTD_NAND_ATMEL=y CONFIG_MTD_NAND_PLATFORM=y CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BEB_RESERVE=3 +CONFIG_MTD_UBI_BEB_LIMIT=3 CONFIG_MTD_UBI_GLUEBI=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_RAM=y diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 738ee8d..8df256f 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -42,6 +42,17 @@ config MTD_UBI_BEB_RESERVE eraseblocks (e.g. NOR flash), this value is ignored and nothing is reserved. Leave the default value if unsure. +config MTD_UBI_BEB_LIMIT + int "Percentage of maximum expected bad eraseblocks" + default 2 + range 0 25 + help + This option specifies the maximum bad eraseblocks UBI expects on the + ubi device (percents of total number of flash eraseblocks). + If the underlying flash does not admit of bad eraseblocks (e.g. NOR + flash), this value is ignored. + Leave the default value if unsure. + config MTD_UBI_GLUEBI tristate "MTD devices emulation driver (gluebi)" help diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 2c5ed5c..62cc6ce 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -607,8 +607,19 @@ static int io_init(struct ubi_device *ubi) ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd); ubi->flash_size = ubi->mtd->size; - if (mtd_can_have_bb(ubi->mtd)) + if (mtd_can_have_bb(ubi->mtd)) { ubi->bad_allowed = 1; + if (CONFIG_MTD_UBI_BEB_LIMIT > 0) { + int percent = CONFIG_MTD_UBI_BEB_LIMIT; + int beb_limit; + + beb_limit = mult_frac(ubi->peb_count, percent, 100); + /* round it up */ + if (mult_frac(beb_limit, 100, percent) < ubi->peb_count) + beb_limit++; + ubi->bad_peb_limit = beb_limit; + } + } if (ubi->mtd->type == MTD_NORFLASH) { ubi_assert(ubi->mtd->writesize == 1); diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index a1a81c9..b5217ef 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -363,6 +363,7 @@ struct ubi_wl_entry; * @flash_size: underlying MTD device size (in bytes) * @peb_count: count of physical eraseblocks on the MTD device * @peb_size: physical eraseblock size + * @bad_peb_limit: top limit of expected bad physical eraseblocks * @bad_peb_count: count of bad physical eraseblocks * @good_peb_count: count of good physical eraseblocks * @corr_peb_count: count of corrupted physical eraseblocks (preserved and not @@ -410,6 +411,7 @@ struct ubi_device { int avail_pebs; int beb_rsvd_pebs; int beb_rsvd_level; + int bad_peb_limit; int autoresize_vol_id; int vtbl_slots;