From patchwork Thu May 6 06:15:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 51787 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 EED5FB7D2F for ; Thu, 6 May 2010 16:18:11 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O9uNe-0000Ui-8w; Thu, 06 May 2010 06:16:18 +0000 Received: from smtp.nokia.com ([192.100.122.230] helo=mgw-mx03.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1O9uNa-0000UN-3i; Thu, 06 May 2010 06:16:16 +0000 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o466FUUJ014676; Thu, 6 May 2010 09:16:05 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 May 2010 09:16:00 +0300 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 May 2010 09:15:59 +0300 Received: from [172.21.40.75] (esdhcp04075.research.nokia.com [172.21.40.75]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o466FwvN017578; Thu, 6 May 2010 09:15:58 +0300 Subject: Re: [PATCH V2] ubi: init even if mtd device cannot be attached, if built into kernel From: Artem Bityutskiy To: Marc Kleine-Budde In-Reply-To: <1273047445-23411-1-git-send-email-mkl@pengutronix.de> References: <1273047445-23411-1-git-send-email-mkl@pengutronix.de> Date: Thu, 06 May 2010 09:15:25 +0300 Message-ID: <1273126525.3702.196.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) X-OriginalArrivalTime: 06 May 2010 06:15:59.0904 (UTC) FILETIME=[98D0EA00:01CAECE3] X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100506_021614_540021_F1E81D48 X-CRM114-Status: GOOD ( 42.11 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.100.122.230 listed in list.dnswl.org] 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: Andi Kleen , Dmitry Pervushin , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: dedekind1@gmail.com 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 On Wed, 2010-05-05 at 10:17 +0200, Marc Kleine-Budde wrote: > Ubi can be built into the kernel or be compiled as a kernel module. > Further on the command line one can specify mtd devices to be attach to > ubi while loading. In the current implementation the ubi driver refuses > to load if one of the mtd devices cannot be attached. > > Consider: > 1) ubi compiled into the kernel and > 2) a mtd device specified on the command line and > 3) this mtd device contains bogus data (for whatever reason). > > During init ubi tries to attach the mtd device is this fails the whole > ubi subsystem isn't initialized. Later the userspace cannot attach any > mtd to ubi because ubi isn't loaded. > > This patch keeps the current behaviour: if ubi is compiled as a module > and a mtd device cannot be attached the ubi module cannot be loaded, > but changes it for the ubi-is-built-into-the-kernel usecase. > > If ubi is builtin, a not attachable mtd device doen't stop ubi from > initializing. This slightly modifies the behaviour if multiple mtd > devices are specified on the command line. Now every mtd device is > probed and, if possible, attached, i.e. a faulty mtd device doesn't > stop the others from being attached. > > V2: integrated comments from Artem Bityutskiy: > use defines instead of static inline functions > > Signed-off-by: Marc Kleine-Budde > --- > drivers/mtd/ubi/build.c | 12 ++++++++++-- > 1 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c > index fad40aa..d0447a5 100644 > --- a/drivers/mtd/ubi/build.c > +++ b/drivers/mtd/ubi/build.c > @@ -49,6 +49,12 @@ > /* Maximum length of the 'mtd=' parameter */ > #define MTD_PARAM_LEN_MAX 64 > > +#ifdef CONFIG_MTD_UBI_MODULE > +#define ubi_is_module() 1 > +#else > +#define ubi_is_module() 0 > +#endif > + > /** > * struct mtd_dev_param - MTD device parameter description data structure. > * @name: MTD character device node path, MTD device name, or MTD device number > @@ -1240,9 +1246,11 @@ static int __init ubi_init(void) > p->vid_hdr_offs); > mutex_unlock(&ubi_devices_mutex); > if (err < 0) { > - put_mtd_device(mtd); > ubi_err("cannot attach mtd%d", mtd->index); > - goto out_detach; > + if (ubi_is_module()) { > + put_mtd_device(mtd); We should put the MTD device even if we continue, because we did not attach it. > + goto out_detach; > + } > } > } > I've added a comment and fixed your patch, and pushed to ubi-2.6.git. Please, check it. >From af7ad7a0a6c0c1d8497a25b6b8b3b2ce9f52ff04 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Wed, 5 May 2010 10:17:25 +0200 Subject: [PATCH] UBI: init even if MTD device cannot be attached, if built into kernel UBI can be built into the kernel or be compiled as a kernel module. Further on the command line one can specify MTD devices to be attach to UBI while loading. In the current implementation the UBI driver refuses to load if one of the MTD devices cannot be attached. Consider: 1) UBI compiled into the kernel and 2) a MTD device specified on the command line and 3) this MTD device contains bogus data (for whatever reason). During init UBI tries to attach the MTD device is this fails the whole UBI subsystem isn't initialized. Later the userspace cannot attach any MTD to UBI because UBI isn't loaded. This patch keeps the current behaviour: if UBI is compiled as a module and a MTD device cannot be attached the UBI module cannot be loaded, but changes it for the UBI-is-built-into-the-kernel usecase. If UBI is builtin, a not attachable MTD device doen't stop UBI from initializing. This slightly modifies the behaviour if multiple MTD devices are specified on the command line. Now every MTD device is probed and, if possible, attached, i.e. a faulty MTD device doesn't stop the others from being attached. Artem: tweaked the patch Signed-off-by: Marc Kleine-Budde Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/build.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3a59a1d..13b05cb 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -49,6 +49,12 @@ /* Maximum length of the 'mtd=' parameter */ #define MTD_PARAM_LEN_MAX 64 +#ifdef CONFIG_MTD_UBI_MODULE +#define ubi_is_module() 1 +#else +#define ubi_is_module() 0 +#endif + /** * struct mtd_dev_param - MTD device parameter description data structure. * @name: MTD character device node path, MTD device name, or MTD device number @@ -1206,9 +1212,24 @@ static int __init ubi_init(void) p->vid_hdr_offs); mutex_unlock(&ubi_devices_mutex); if (err < 0) { - put_mtd_device(mtd); ubi_err("cannot attach mtd%d", mtd->index); - goto out_detach; + put_mtd_device(mtd); + + /* + * Originally UBI stopped initializing on any error. + * However, later on it was found out that this + * behavior is not very good when UBI is compiled into + * the kernel and the MTD devices to attach are passed + * through the command line. Indeed, UBI failure + * stopped whole boot sequence. + * + * To fix this, we changed the behavior for the + * non-module case, but preserved the old behavior for + * the module case, just for compatibility. This is a + * little inconsistent, though. + */ + if (ubi_is_module()) + goto out_detach; } }