From patchwork Fri Jun 29 15:14:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 168140 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 4E2A3B6EE9 for ; Sat, 30 Jun 2012 01:16:48 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SkcvD-0006mJ-5X; Fri, 29 Jun 2012 15:15:47 +0000 Received: from a.ns.miles-group.at ([95.130.255.143] helo=radon.swed.at) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SkcuH-0006TE-0o for linux-mtd@lists.infradead.org; Fri, 29 Jun 2012 15:14:50 +0000 Received: (qmail 20890 invoked by uid 89); 29 Jun 2012 15:14:49 -0000 Received: by simscan 1.3.1 ppid: 20657, pid: 20887, t: 0.1264s scanners: attach: 1.3.1 clamav: 0.96.5/m:53 Received: from unknown (HELO localhost.localdomain) (richard@nod.at@212.62.202.73) by radon.swed.at with ESMTPA; 29 Jun 2012 15:14:49 -0000 From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 11/11] UBI: Fastmap: Add a module parameter to enable fastmap Date: Fri, 29 Jun 2012 17:14:29 +0200 Message-Id: <1340982869-77042-12-git-send-email-richard@nod.at> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1340982869-77042-1-git-send-email-richard@nod.at> References: <1340982869-77042-1-git-send-email-richard@nod.at> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: nyoushchenko@mvista.com, artem.bityutskiy@linux.intel.com, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, Heinz.Egger@linutronix.de, thomas.wucher@linutronix.de, shmulik.ladkani@gmail.com, Richard Weinberger , tglx@linutronix.de, Marius.Mazarel@ugal.ro, tim.bird@am.sony.com 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 The new parameter, ubi.fm_auto is per default 0. If you attach an old image without a fastmap installed UBI will not install a fastmap an work like in the old days. But attaching by fastmap will work too if you attach a new image. Of course in this case the fastmap will also get updated. Is ubi.fm_auto set to 1 UBI automatically installs a fastmap on old images. This can be used to convert old images to have fastmap support. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/attach.c | 2 +- drivers/mtd/ubi/build.c | 8 +++++++- drivers/mtd/ubi/fastmap.c | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index c55ad0f..a343a41 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -1394,7 +1394,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan) if (!ai) return -ENOMEM; - if (force_scan || ubi->fm_disabled) + if (force_scan) err = scan_all(ubi, ai, 0); else { err = scan_fast(ubi, ai); diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 7b5dc5d..50b7590 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -67,6 +67,8 @@ static int __initdata mtd_devs; /* MTD devices specification parameters */ static struct mtd_dev_param __initdata mtd_dev_param[UBI_MAX_DEVICES]; +/* UBI module parameter to enable fastmap automatically on non-fastmap images */ +static bool fm_auto; /* Root UBI "class" object (corresponds to '//class/ubi/') */ struct class *ubi_class; @@ -899,7 +901,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) ubi->fm_pool.max_size = UBI_FM_MIN_POOL_SIZE; ubi->fm_wl_pool.max_size = UBI_FM_WL_POOL_SIZE; - ubi->fm_disabled = 1; + ubi->fm_disabled = !fm_auto; ubi_msg("default fastmap pool size: %d", ubi->fm_pool.max_size); ubi_msg("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); @@ -1392,6 +1394,10 @@ MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: " "with name \"content\" using VID header offset 1984, and " "MTD device number 4 with default VID header offset."); +module_param(fm_auto, bool, 000); +MODULE_PARM_DESC(fm_auto, "Set this parameter to enable fastmap automatically " + "on images without a fastmap."); + MODULE_VERSION(__stringify(UBI_VERSION)); MODULE_DESCRIPTION("UBI - Unsorted Block Images"); MODULE_AUTHOR("Artem Bityutskiy"); diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 0c9466d..d995105 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -1044,8 +1044,10 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ubi->fm = fm; ubi->fm_pool.max_size = ubi->fm->max_pool_size; ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size; + ubi_msg("attached by fastmap"); ubi_msg("fastmap pool size: %d", ubi->fm_pool.max_size); ubi_msg("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); + ubi->fm_disabled = 0; free_hdr: ubi_free_vid_hdr(ubi, vh);