Skip to contentSkip to conversation

mtd_blkdevs: add option to enable scanning for partitions

PATCH Superseded Daniel Golle 2 participants 3 messages May 12, 2022 – Jun 7, 2022

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 4/5 mtd_blkdevs: add option to enable scanning for partitions

Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block partition parsers on non-NAND mtdblock devices in case it is selected.

---
 drivers/mtd/Kconfig       | 11 +++++++++++
 drivers/mtd/mtd_blkdevs.c |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/Kconfig +11 -0
index 796a2eccbef0b8..12874dec15692a 100644
@@ -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
 
drivers/mtd/mtd_blkdevs.c +3 -1
index f7317211146550..c67ce2e6fbeb0a 100644
@@ -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);
Signature · 1 line
2.36.0
maintainer Acked-by on v3 4/5
#1 lore raw

Hi Daniel,

[email protected] wrote on Thu, 12 May 2022 20:39:27 +0100:

Quoted 36 lines

Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block partition parsers on non-NAND mtdblock devices in case it is selected.

---
 drivers/mtd/Kconfig       | 11 +++++++++++
 drivers/mtd/mtd_blkdevs.c |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/Kconfig +11 -0
index 796a2eccbef0b8..12874dec15692a 100644
@@ -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
 
drivers/mtd/mtd_blkdevs.c +0 -0
index f7317211146550..c67ce2e6fbeb0a 100644

drivers/mtd/mtd_blkdevs.c int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) · line 364

Quoted 7 lines
drivers/mtd/mtd_blkdevs.c +3 -1
@@ -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;

I really wonder if we need this in mtdblock ? Isn't ubiblock enough?

Anyhow,

I'll let Richard ack the ubiblock patch.

Thanks,
Miquèl

#2 lore raw
Quoted 35 lines · Miquel Raynal

Hi Daniel,

[email protected] wrote on Thu, 12 May 2022 20:39:27 +0100:

Quoted 31 lines

Add Kconfig boolean CONFIG_MTD_BLOCK_PARTITIONS and enable block partition parsers on non-NAND mtdblock devices in case it is selected.

---
 drivers/mtd/Kconfig       | 11 +++++++++++
 drivers/mtd/mtd_blkdevs.c |  4 +++-
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/Kconfig +11 -0
index 796a2eccbef0b8..12874dec15692a 100644
@@ -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
 
Quoted 14 lines

drivers/mtd/mtd_blkdevs.c int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) · line 364

Quoted 12 lines
drivers/mtd/mtd_blkdevs.c +3 -1
index f7317211146550..c67ce2e6fbeb0a 100644
@@ -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;

I really wonder if we need this in mtdblock ? Isn't ubiblock enough?

One of the ideas behind this series is to be able to use the exact same image (which includes a rootfs filesystem sub-image) on devices with different boot storage options instead of having to write kernel and root filesystems separately in a storage-type specific manner.

So the very same uImage.FIT on devices with block-based storage can be written into a GPT partition (see 3/5), on devices with NAND flash where UBI is used into a UBI volume (see 5/5) and on devices with NOR flash into an MTD partition (this patch).

Quoted 3 lines

Anyhow,

Thank you for the review!

Quoted 9 lines

I'll let Richard ack the ubiblock patch.

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/