Message ID | Y2rgbfpYfpbLKHaf@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp26165wru; Tue, 8 Nov 2022 15:09:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM7HREIe8dRXp+rxC4rqVrpSzGGKuKZ3BPbguE3aHvz2th2HdPss/RleFqJDsdj/wdDDqbgg X-Received: by 2002:a17:90a:2d8b:b0:213:b314:4652 with SMTP id p11-20020a17090a2d8b00b00213b3144652mr58172927pjd.96.1667948989319; Tue, 08 Nov 2022 15:09:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667948989; cv=none; d=google.com; s=arc-20160816; b=jnw/vukVYwdk4d12xYbCHhURv+dcgYnGMVTVa6wd5wWu0Eo76bUWFDg+/X840TdFiN HK1V6uArk7d8p/dfzTg9YRlcv54VTf5hiN9PZcp31BFs6Cfb1mBHoUkTMn+QdqaZ/LFm 83X6jXMbppkKgvDU9j6fbiOahTZMmd6nD8vndm78guO4XKhZBY6JA/54MhLoGp++vrtg tlbaxzgM4Nl8p8tLNhPGVd8U3NyBpm1aUt+uwRq7YlcupKpSaMzoTIEGgT62KSYXQQ0f eoWHV8UWYrJ6hLrurCFmj6w4ESO6JsyNlfzoG2SqYH/WSpNubOtkb5/seMjiGLMQd2VB aqcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=ulczSCiKyYKYeEYWVUdvnRHWt1pChHSadOU6tR5w8FA=; b=kpvD3lreSZjI5O1EbJL5i5Vjyq/IIEWzF8bb5f6ayK/TC6oV4nLiT4yXpfU345encQ a7K5KoGcxtA3V/60en4AK8ch5cIOOyap7DvVlc/BAFCCiPqHW0o5N0D/wA6IfNmq+7AS nMkE0y2G6Ar4dbFEi079QCC8ptxV3RriKWyqtMJgXYs7sJ+6yUbu3/w0GrA3iQB28Skx J5iiF10U7l0WHN8swEgO0HvToIewk9QPugz/kstLECP2AbzKhKaAtuCTPnTDj6YVBmNU f6BcbrhzfjwdGuCLY3UaRmnF1khXeHVs4333uZW03Wp3gIMjSQRDftrHYgwzMKVquxsD TqGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a29-20020a631a1d000000b0046b041e1408si15334681pga.744.2022.11.08.15.09.36; Tue, 08 Nov 2022 15:09:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiKHXF6 (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Tue, 8 Nov 2022 18:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbiKHXFs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Nov 2022 18:05:48 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 558CF657D9; Tue, 8 Nov 2022 15:05:47 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from <daniel@makrotopia.org>) id 1osXex-0005vp-Nv; Wed, 09 Nov 2022 00:05:35 +0100 Date: Tue, 8 Nov 2022 23:04:13 +0000 From: Daniel Golle <daniel@makrotopia.org> To: Jens Axboe <axboe@kernel.dk>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Davidlohr Bueso <dave@stgolabs.net>, Matthew Wilcox <willy@infradead.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Chaitanya Kulkarni <kch@nvidia.com>, Daniel Golle <daniel@makrotopia.org>, Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH v4 4/5] mtd_blkdevs: add option to enable scanning for partitions Message-ID: <Y2rgbfpYfpbLKHaf@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748971279199838646?= X-GMAIL-MSGID: =?utf-8?q?1748971279199838646?= |
Series |
partition parser for U-Boot's uImage.FIT
|
|
Commit Message
Daniel Golle
Nov. 8, 2022, 11:04 p.m. UTC
Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block partition parsers on non-NAND mtdblock devices in case it is selected. Signed-off-by: Daniel Golle <daniel@makrotopia.org> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/mtd/Kconfig | 11 +++++++++++ drivers/mtd/mtd_blkdevs.c | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-)
Comments
Hi Daniel, daniel@makrotopia.org wrote on Tue, 8 Nov 2022 23:04:13 +0000: > Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block > partition parsers on non-NAND mtdblock devices in case it is selected. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> > --- > drivers/mtd/Kconfig | 11 +++++++++++ > drivers/mtd/mtd_blkdevs.c | 4 +++- > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig > index 796a2eccbef0..12874dec1569 100644 > --- a/drivers/mtd/Kconfig > +++ b/drivers/mtd/Kconfig > @@ -69,6 +69,17 @@ config MTD_BLOCK_RO > You do not need this option for use with the DiskOnChip devices. For > those, enable NFTL support (CONFIG_NFTL) instead. > > +config MTD_BLOCK_PARTITIONS > + bool "Scan for partitions on MTD block devices" > + depends on MTD_BLOCK || MTD_BLOCK_RO > + default y if FIT_PARTITION > + help > + Scan MTD block devices for partitions (ie. MBR, GPT, uImage.FIT, ...). > + (NAND devices are omitted, ubiblock should be used instead when) > + > + Unless your MTD partitions contain sub-partitions mapped using a > + partition table, say no. Actually I know I've acked this patch in the past but I am now wondering again if this is the right way so I would like to discuss this again. I don't feel making partitions on top of blk devices like that is the right solution. Why not using the advanced partition parsers that we now have in MTD to create these subpartitions and then have blocks emulated on top of them? > + > comment "Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK." > depends on MTD_BLOCK || MTD_BLOCK_RO > > diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c > index 60b222799871..e6f2e0888246 100644 > --- a/drivers/mtd/mtd_blkdevs.c > +++ b/drivers/mtd/mtd_blkdevs.c > @@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) > } else { > snprintf(gd->disk_name, sizeof(gd->disk_name), > "%s%d", tr->name, new->devnum); > - gd->flags |= GENHD_FL_NO_PART; > + > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) > + gd->flags |= GENHD_FL_NO_PART; > } > > set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); Thanks, Miquèl
Hi Miquel, On Wed, Nov 09, 2022 at 01:45:26PM +0100, Miquel Raynal wrote: > Hi Daniel, > > daniel@makrotopia.org wrote on Tue, 8 Nov 2022 23:04:13 +0000: > > > Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block > > partition parsers on non-NAND mtdblock devices in case it is selected. > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> > > --- > > drivers/mtd/Kconfig | 11 +++++++++++ > > drivers/mtd/mtd_blkdevs.c | 4 +++- > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig > > index 796a2eccbef0..12874dec1569 100644 > > --- a/drivers/mtd/Kconfig > > +++ b/drivers/mtd/Kconfig > > @@ -69,6 +69,17 @@ config MTD_BLOCK_RO > > You do not need this option for use with the DiskOnChip devices. For > > those, enable NFTL support (CONFIG_NFTL) instead. > > > > +config MTD_BLOCK_PARTITIONS > > + bool "Scan for partitions on MTD block devices" > > + depends on MTD_BLOCK || MTD_BLOCK_RO > > + default y if FIT_PARTITION > > + help > > + Scan MTD block devices for partitions (ie. MBR, GPT, uImage.FIT, ...). > > + (NAND devices are omitted, ubiblock should be used instead when) > > + > > + Unless your MTD partitions contain sub-partitions mapped using a > > + partition table, say no. > > Actually I know I've acked this patch in the past but I am now > wondering again if this is the right way so I would like to discuss > this again. I don't feel making partitions on top of blk devices like > that is the right solution. Why not using the advanced partition > parsers that we now have in MTD to create these subpartitions and then > have blocks emulated on top of them? Simply because then we would need the same parser implemented one time as block/partitions/fit.c (for devices booting from SATA or eMMC, for example) and then another time as drivers/mtd/parsers/parse_fit.c (for devices using raw NOR flash) and for UBI there isn't even any infrastructure allowing the dynamic splitting of UBI volumes (hence we would need to invent a new splitting/partitioning mechanism on top of UBI just for that). Using the block partition parser as common ground for all three storage types typically found in embedded devices seemed like the best idea, as in that way I only had to implement the uImage.FIT parser once. > > > + > > comment "Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK." > > depends on MTD_BLOCK || MTD_BLOCK_RO > > > > diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c > > index 60b222799871..e6f2e0888246 100644 > > --- a/drivers/mtd/mtd_blkdevs.c > > +++ b/drivers/mtd/mtd_blkdevs.c > > @@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) > > } else { > > snprintf(gd->disk_name, sizeof(gd->disk_name), > > "%s%d", tr->name, new->devnum); > > - gd->flags |= GENHD_FL_NO_PART; > > + > > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) > > + gd->flags |= GENHD_FL_NO_PART; > > } > > > > set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); > > > Thanks, > Miquèl
----- Ursprüngliche Mail ----- > Von: "Daniel Golle" <daniel@makrotopia.org> > + > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) > + gd->flags |= GENHD_FL_NO_PART; I know that NAND should not get used with mtdblock because lack of wearleveling and in general too many writes. But what exactly is the rationale to deny part scanning for NAND? Thanks, //richard
On Thu, Nov 10, 2022 at 08:44:53PM +0100, Richard Weinberger wrote: > ----- Ursprüngliche Mail ----- > > Von: "Daniel Golle" <daniel@makrotopia.org> > > + > > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) > > + gd->flags |= GENHD_FL_NO_PART; > > I know that NAND should not get used with mtdblock because lack of wearleveling and > in general too many writes. But what exactly is the rationale to deny part scanning for NAND? As UBI should be used on NAND, partition scanning should be enabled for ubiblock devices to have uImage.FIT filesystem subimages mapped by the partition parser. If not skipping partition scanning on NAND-backed mtdblock devices the scanning itself will already trigger multiple warnings which now happen every time when a NAND-backed mtdblock device is being opened since commit 96a3295c ("mtdblock: warn if opened on NAND").
----- Ursprüngliche Mail ----- > On Thu, Nov 10, 2022 at 08:44:53PM +0100, Richard Weinberger wrote: >> ----- Ursprüngliche Mail ----- >> > Von: "Daniel Golle" <daniel@makrotopia.org> >> > + >> > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) >> > + gd->flags |= GENHD_FL_NO_PART; >> >> I know that NAND should not get used with mtdblock because lack of wearleveling >> and >> in general too many writes. But what exactly is the rationale to deny part >> scanning for NAND? > > As UBI should be used on NAND, partition scanning should be enabled for > ubiblock devices to have uImage.FIT filesystem subimages mapped by the > partition parser. > > If not skipping partition scanning on NAND-backed mtdblock devices the > scanning itself will already trigger multiple warnings which now happen > every time when a NAND-backed mtdblock device is being opened since > commit 96a3295c ("mtdblock: warn if opened on NAND"). I see, you want to promote UBI. Makes sense. In case you do a v5 series, please add a comment to the code. Thanks, //richard
On Thu, Nov 10, 2022 at 09:12:35PM +0100, Richard Weinberger wrote: > ----- Ursprüngliche Mail ----- > > On Thu, Nov 10, 2022 at 08:44:53PM +0100, Richard Weinberger wrote: > >> ----- Ursprüngliche Mail ----- > >> > Von: "Daniel Golle" <daniel@makrotopia.org> > >> > + > >> > + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) > >> > + gd->flags |= GENHD_FL_NO_PART; > >> > >> I know that NAND should not get used with mtdblock because lack of wearleveling > >> and > >> in general too many writes. But what exactly is the rationale to deny part > >> scanning for NAND? > > > > As UBI should be used on NAND, partition scanning should be enabled for > > ubiblock devices to have uImage.FIT filesystem subimages mapped by the > > partition parser. > > > > If not skipping partition scanning on NAND-backed mtdblock devices the > > scanning itself will already trigger multiple warnings which now happen > > every time when a NAND-backed mtdblock device is being opened since > > commit 96a3295c ("mtdblock: warn if opened on NAND"). > > I see, you want to promote UBI. Makes sense. > In case you do a v5 series, please add a comment to the code. Will do, I'm planning to send v5 early next week. If we are going to have only CONFIG_MTD_BLOCK_PARTITIONS and no other config symbol for ubiblock devices I'd also merge the two patches for mtdblock and ubiblock partition scanning into a single one. Thank you for reviewing! Daniel
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 796a2eccbef0..12874dec1569 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig @@ -69,6 +69,17 @@ config MTD_BLOCK_RO You do not need this option for use with the DiskOnChip devices. For those, enable NFTL support (CONFIG_NFTL) instead. +config MTD_BLOCK_PARTITIONS + bool "Scan for partitions on MTD block devices" + depends on MTD_BLOCK || MTD_BLOCK_RO + default y if FIT_PARTITION + help + Scan MTD block devices for partitions (ie. MBR, GPT, uImage.FIT, ...). + (NAND devices are omitted, ubiblock should be used instead when) + + Unless your MTD partitions contain sub-partitions mapped using a + partition table, say no. + comment "Note that in some cases UBI block is preferred. See MTD_UBI_BLOCK." depends on MTD_BLOCK || MTD_BLOCK_RO diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 60b222799871..e6f2e0888246 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) } else { snprintf(gd->disk_name, sizeof(gd->disk_name), "%s%d", tr->name, new->devnum); - gd->flags |= GENHD_FL_NO_PART; + + if (!IS_ENABLED(CONFIG_MTD_BLOCK_PARTITIONS) || mtd_type_is_nand(new->mtd)) + gd->flags |= GENHD_FL_NO_PART; } set_capacity(gd, ((u64)new->size * tr->blksize) >> 9);