From patchwork Fri Aug 17 14:35:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 1338831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 26A71DF266 for ; Fri, 17 Aug 2012 14:39:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T2Nev-0001Gb-29; Fri, 17 Aug 2012 14:36:21 +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 1T2NeZ-00019Y-9Z; Fri, 17 Aug 2012 14:36:00 +0000 Received: by mail-wg0-f49.google.com with SMTP id ez12so2482603wgb.18 for ; Fri, 17 Aug 2012 07:35:58 -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=J2/vuIhjmvz8HddvgUVrjeHTt/KCD0HzAIcA6/n5rwE=; b=MkX9YYRrlGHqUUdBpxSSJlWajvbtU/IGEzBkGYK4n3+MeqaK08iHml1DtwIPBpTLNn 16n9hXJVxpbAmCj2sJ0k5p+R8jpBCku2hBc8fbAelS/JIhfCAmrKddX4ktx1k/QvbbdG qsy8lJ00+z04vcLhrkw0cJSN9jdq7Drz7LraLjg9psTpszLXf4MEGtCtyoiXsv/bL72k adtOuoWaqBXcl3AqCXDpNVBt1QZrlAmDherj9wq8C9I84oTrLZkI0l7qf771xN6RJ1lE 4lAylvYfPvu0wNbx3SUuuLCSmPSuxkA+Elwc2Me3EO+1xM1mMCad5i3SPIlmg5bK3i/q nKTw== Received: by 10.180.78.99 with SMTP id a3mr5430248wix.15.1345214158867; Fri, 17 Aug 2012 07:35:58 -0700 (PDT) Received: from localhost.localdomain (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPS id dc3sm10053154wib.7.2012.08.17.07.35.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 17 Aug 2012 07:35:58 -0700 (PDT) From: Richard Genoud To: Artem Bityutskiy Subject: [PATCH 6/8] UBI: replace MTD_UBI_BEB_LIMIT with module parameter Date: Fri, 17 Aug 2012 16:35:22 +0200 Message-Id: <1345214124-5478-7-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1345214124-5478-1-git-send-email-richard.genoud@gmail.com> References: <1345214124-5478-1-git-send-email-richard.genoud@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 (richard.genoud[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: Richard Genoud , linux-mtd@lists.infradead.org, Shmulik Ladkani , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch provides the possibility to adjust the "maximum expected number of bad blocks per 1024 blocks" (max_beb_per1024) for each mtd device. The majority of NAND devices have their max_beb_per1024 equal to 20, but sometimes it's more. Now, we can adjust that via a kernel parameter: ubi.mtd=[,[,max_beb_per1024]] Signed-off-by: Richard Genoud --- drivers/mtd/ubi/Kconfig | 2 ++ drivers/mtd/ubi/build.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index f326877..8b67bac 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -51,6 +51,8 @@ config MTD_UBI_BEB_LIMIT MTD partitions of the same size, UBI will reserve 40 eraseblocks when attaching a partition. + This option can be overridden by the kernel parameter ubi.mtd. + Leave the default value if unsure. config MTD_UBI_GLUEBI diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index ec7311f..cc05022 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -47,7 +47,7 @@ #define MTD_PARAM_LEN_MAX 64 /* Maximum number of comma-separated items in ht 'mtd=' parameter */ -#define MTD_PARAM_MAX_COUNT 2 +#define MTD_PARAM_MAX_COUNT 3 #ifdef CONFIG_MTD_UBI_MODULE #define ubi_is_module() 1 @@ -60,10 +60,12 @@ * @name: MTD character device node path, MTD device name, or MTD device number * string * @vid_hdr_offs: VID header offset + * @max_beb_per1024: maximum expected number of bad blocks per 1024 erase blocks */ struct mtd_dev_param { char name[MTD_PARAM_LEN_MAX]; int vid_hdr_offs; + int max_beb_per1024; }; /* Numbers of elements set in the @mtd_dev_param array */ @@ -1222,8 +1224,7 @@ static int __init ubi_init(void) mutex_lock(&ubi_devices_mutex); err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, - p->vid_hdr_offs, - CONFIG_MTD_UBI_BEB_LIMIT); + p->vid_hdr_offs, p->max_beb_per1024); mutex_unlock(&ubi_devices_mutex); if (err < 0) { ubi_err("cannot attach mtd%d", mtd->index); @@ -1343,6 +1344,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) char buf[MTD_PARAM_LEN_MAX]; char *pbuf = &buf[0]; char *tokens[MTD_PARAM_MAX_COUNT]; + int err; if (!val) return -EINVAL; @@ -1390,23 +1392,31 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) if (p->vid_hdr_offs < 0) return p->vid_hdr_offs; + if (tokens[2]) { + err = kstrtoint(tokens[2], 10, &p->max_beb_per1024); + if (err) { + pr_err("UBI error: bad value for max_beb_per1024 parameter: %s", + tokens[2]); + return -EINVAL; + } + } + mtd_devs += 1; return 0; } module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); -MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: " - "mtd=[,].\n" +MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=[,[,max_beb_per1024]].\n" "Multiple \"mtd\" parameters may be specified.\n" - "MTD devices may be specified by their number, name, or " - "path to the MTD character device node.\n" - "Optional \"vid_hdr_offs\" parameter specifies UBI VID " - "header position to be used by UBI.\n" - "Example 1: mtd=/dev/mtd0 - attach MTD device " - "/dev/mtd0.\n" - "Example 2: mtd=content,1984 mtd=4 - attach MTD device " - "with name \"content\" using VID header offset 1984, and " - "MTD device number 4 with default VID header offset."); + "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" + "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0 or not set)\n" + "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" + __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0 or not set)\n" + "\n" + "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" + "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" + "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" + "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)."); MODULE_VERSION(__stringify(UBI_VERSION)); MODULE_DESCRIPTION("UBI - Unsorted Block Images");