Skip to contentSkip to conversation

Introduce mtdblock device

PATCH Superseded Alexey Romanov 3 participants 10 messages Jun 4, 2024 – Jun 26, 2024

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Introduce mtdblock device

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1] https://lore.kernel.org/all/[email protected]/
- [2] https://lore.kernel.org/all/[email protected]/
- [3] https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4] https://lore.kernel.org/all/[email protected]/
- [5] https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v5 1/3 disk: support MTD partitions

Add new MTD partition driver, which can be useful with mtdblock driver combination.

---
 disk/part.c           |  3 +-
 drivers/mtd/Kconfig   |  1 +
 drivers/mtd/mtdpart.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 include/part.h        |  3 ++
 4 files changed, 82 insertions(+), 1 deletion(-)
disk/part.c +2 -1
index 2bee669582..3f0fce5cfa 100644
@@ -305,7 +305,8 @@ static void print_part_header(const char *type, struct blk_desc *desc)
 	CONFIG_IS_ENABLED(DOS_PARTITION) || \
 	CONFIG_IS_ENABLED(ISO_PARTITION) || \
 	CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
-	CONFIG_IS_ENABLED(EFI_PARTITION)
+	CONFIG_IS_ENABLED(EFI_PARTITION) || \
+	CONFIG_IS_ENABLED(MTD_PARTITIONS)
 	printf("\nPartition Map for %s device %d  --   Partition Type: %s\n\n",
 	       uclass_get_name(desc->uclass_id), desc->devnum, type);
 #endif /* any CONFIG_..._PARTITION */
drivers/mtd/Kconfig +1 -0
index 4fdc9645d0..e4e29e0a3c 100644
@@ -2,6 +2,7 @@ menu "MTD Support"
 
 config MTD_PARTITIONS
 	bool
+	select PARTITIONS
 
 config MTD
 	bool "Enable MTD layer"
drivers/mtd/mtdpart.c +76 -0

85 lines not on this page · raw message

include/part.h +3 -0
index 32ee404885..40419fdf2f 100644
@@ -30,12 +30,15 @@ struct block_drvr {
 #define PART_TYPE_ISO		0x03
 #define PART_TYPE_AMIGA		0x04
 #define PART_TYPE_EFI		0x05
+#define PART_TYPE_MTD		0x06
 
 /* maximum number of partition entries supported by search */
 #define DOS_ENTRY_NUMBERS	8
 #define ISO_ENTRY_NUMBERS	64
 #define MAC_ENTRY_NUMBERS	64
 #define AMIGA_ENTRY_NUMBERS	8
+#define MTD_ENTRY_NUMBERS	64
+
 /*
  * Type string for U-Boot bootable partitions
  */
Signature · 1 line
2.34.1
#2 lore raw

PATCH v5 2/3 drivers: introduce mtdblock abstraction

In reply to Alexey Romanov

MTD block - abstraction over MTD subsystem, allowing to read and write in blocks using BLK UCLASS.

---
 drivers/block/blk-uclass.c |   1 +
 drivers/mtd/Makefile       |   1 +
 drivers/mtd/mtdblock.c     | 227 +++++++++++++++++++++++++++++++++++++
 include/linux/mtd/mtd.h    |  21 ++++
 4 files changed, 250 insertions(+)
 create mode 100644 drivers/mtd/mtdblock.c
drivers/block/blk-uclass.c +1 -0
index 77066da352..ab0a9105c9 100644
@@ -37,6 +37,7 @@ static struct {
 	{ UCLASS_PVBLOCK, "pvblock" },
 	{ UCLASS_BLKMAP, "blkmap" },
 	{ UCLASS_RKMTD, "rkmtd" },
+	{ UCLASS_MTD, "mtd" },
 };
 
 static enum uclass_id uclass_name_to_iftype(const char *uclass_idname)
drivers/mtd/Makefile +1 -0
index c2fc80b10f..f7eab71bcd 100644
@@ -26,6 +26,7 @@ obj-y += onenand/
 obj-y += spi/
 obj-$(CONFIG_MTD_UBI) += ubi/
 obj-$(CONFIG_NVMXIP) += nvmxip/
+obj-$(CONFIG_BLK) += mtdblock.o
 
 #SPL/TPL build
 else
drivers/mtd/mtdblock.c new file +227 -0

227 lines not on this page · raw message

include/linux/mtd/mtd.h +21 -0
index ee18a63e46..f06389e4e3 100644
@@ -26,6 +26,9 @@
 #include <dm/device.h>
 #endif
 #include <dm/ofnode.h>
+#if IS_ENABLED(CONFIG_BLK)
+#include <blk.h>
+#endif
 
 #define MAX_MTD_DEVICES 32
 #endif
@@ -412,6 +415,24 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 		    const u_char *buf);
 
+#if CONFIG_IS_ENABLED(BLK)
+static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)
+{
+	void *priv = dev_get_priv(bdesc->bdev);
+	if (!priv)
+		return NULL;
+
+	return *((struct mtd_info **)priv);
+}
+
+int mtd_bind(struct udevice *dev, struct mtd_info **mtd);
+#else
+static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)
+{
+	return NULL;
+}
+#endif
+
 int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops);
 int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops);
 
Signature · 1 line
2.34.1
#3 lore raw

PATCH v5 3/3 spinand: bind mtdblock

In reply to Alexey Romanov

Bind SPI-NAND driver to MTD block driver.

---
 drivers/mtd/nand/spi/core.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/mtd/nand/spi/core.c +20 -0
index 62c28aa422..8edb468aed 100644
@@ -34,6 +34,10 @@
 #include <linux/printk.h>
 #endif
 
+struct spinand_plat {
+	struct mtd_info *mtd;
+};
+
 /* SPI NAND index visible in MTD names */
 static int spi_nand_idx;
 
@@ -1173,12 +1177,24 @@ static void spinand_cleanup(struct spinand_device *spinand)
 	kfree(spinand->scratchbuf);
 }
 
+static int spinand_bind(struct udevice *dev)
+{
+	if (blk_enabled()) {
+		struct spinand_plat *plat = dev_get_plat(dev);
+
+		return mtd_bind(dev, &plat->mtd);
+	}
+
+	return 0;
+}
+
 static int spinand_probe(struct udevice *dev)
 {
 	struct spinand_device *spinand = dev_get_priv(dev);
 	struct spi_slave *slave = dev_get_parent_priv(dev);
 	struct mtd_info *mtd = dev_get_uclass_priv(dev);
 	struct nand_device *nand = spinand_to_nand(spinand);
+	struct spinand_plat *plat = dev_get_plat(dev);
 	int ret;
 
 #ifndef __UBOOT__
@@ -1218,6 +1234,8 @@ static int spinand_probe(struct udevice *dev)
 	if (ret)
 		goto err_spinand_cleanup;
 
+	plat->mtd = mtd;
+
 	return 0;
 
 err_spinand_cleanup:
@@ -1287,4 +1305,6 @@ U_BOOT_DRIVER(spinand) = {
 	.of_match = spinand_ids,
 	.priv_auto	= sizeof(struct spinand_device),
 	.probe = spinand_probe,
+	.bind = spinand_bind,
+	.plat_auto = sizeof(struct spinand_plat),
 };
Signature · 1 line
2.34.1
#4 lore raw
In reply to Alexey Romanov

Hi Alexey,

Quoted 74 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

--
2.34.1

#5 lore raw

Hi Simon,
your message is empty.

Quoted 79 lines · Simon Glass

Hi Alexey,

Quoted 74 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

--
2.34.1

Signature · 2 lines
Thank you,
Alexey
#6 lore raw

Hi Alexey,

Quoted 85 lines · Alexey Romanov

Hi Simon,
your message is empty.

Quoted 79 lines · Simon Glass

Hi Alexey,

Quoted 74 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

--
2.34.1

Are you able to add a sandbox test for this code?

Regards,
Simon

#7 lore raw

Hi Alexey,

I'm still encountering errors raised by the CI:

$ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
--board ${TEST_PY_BD} ${OVERRIDE}
34Building current source for 1 boards (1 thread, 32 jobs per thread)
35 arm: + evb-ast2500
36+In file included from include/nand.h:19,
37+ from cmd/bootm.c:17:
38+include/linux/mtd/mtd.h:430:55: error: 'struct blk_desc' declared
inside parameter list will not be visible outside of this definition
or declaration [-Werror]
39+ 430 | static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)

Thanks and regards,
Dario

Quoted 94 lines · Simon Glass

Hi Alexey,

Quoted 85 lines · Alexey Romanov

Hi Simon,
your message is empty.

Quoted 79 lines · Simon Glass

Hi Alexey,

Quoted 74 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

--
2.34.1

Are you able to add a sandbox test for this code?

Regards,
Simon

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com
#8 lore raw

Hello,

Quoted 3 lines · Dario Binacchi

Hi Alexey,

I'm still encountering errors raised by the CI:

I'm sorry. I tested my patches with GitHub + Azure Pipelines and didn't get any errors like that. I thought testing there uses buildman. I'll try to run it locally.

Quoted 132 lines
$ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
--board ${TEST_PY_BD} ${OVERRIDE}
34Building current source for 1 boards (1 thread, 32 jobs per thread)
35 arm: + evb-ast2500
36+In file included from include/nand.h:19,
37+ from cmd/bootm.c:17:
38+include/linux/mtd/mtd.h:430:55: error: 'struct blk_desc' declared
inside parameter list will not be visible outside of this definition
or declaration [-Werror]
39+ 430 | static inline struct mtd_info *blk_desc_to_mtd(struct blk_desc *bdesc)

Thanks and regards,
Dario

Quoted 94 lines · Simon Glass

Hi Alexey,

Quoted 85 lines · Alexey Romanov

Hi Simon,
your message is empty.

Quoted 79 lines · Simon Glass

Hi Alexey,

Quoted 74 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

--
2.34.1

Are you able to add a sandbox test for this code?

Regards,
Simon

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com
Signature · 2 lines
Thank you,
Alexey
#9 lore raw
In reply to Simon Glass

Hi Simon,

Quoted 83 lines · Simon Glass

Hi Alexey,

Quoted 80 lines · Alexey Romanov

Hi Simon,
your message is empty.

Quoted 75 lines · Simon Glass

Hi Alexey,

Quoted 70 lines · On Mon, Jun 3, 2024, 09:57 Alexey Romanov <[email protected]> wrote:

Hello!

This series adds support for the mtdblock device, which allows to read/write data block by block. For example, it can now be used for BCB or Android AB command:

  $ bcb load mtd 0 part_name

Tested only on SPI NAND, so bind is made only for
SPI NAND drivers.

---

Changes V1 -> V2 [1]:

- Drop patch [2].
- Add warning if bind NAND mtdblock device.
- Move documentation of mtdblock implementation from commit message to the source code.
- Remove __maybe_unused from mtd partition functions description.
- Use blk_enabled() instead of #ifdefs.

Changes V2 -> V3 [2]:

- Rebased over [3].
- Rename mtd_bread/bwrite -> mtd_blk_read/write.
- Fix GPL-2.0 license short name definiton in headers.
- Add empty line after MTD_ENTRY_NUMBERS define.

Changes V3 -> V4 [4]:

- Fix build warnings: use LBAF printf format string for lbaint_t types.

Changes V4 -> V5 [5]:

- Rebased over u-boot/master.
- Fix build errors and warnings if CONFIG_BLK isn't enabled.
- Fix failed tests in cases is mtdblock device isn't binded.

Links:

- [1]
https://lore.kernel.org/all/[email protected]/
- [2]
https://lore.kernel.org/all/[email protected]/
- [3]
https://lore.kernel.org/u-boot/[email protected]/T/#u
- [4]
https://lore.kernel.org/all/[email protected]/
- [5]
https://lore.kernel.org/all/[email protected]/

Alexey Romanov (3):
disk: support MTD partitions
drivers: introduce mtdblock abstraction
spinand: bind mtdblock

 disk/part.c                 |   3 +-
 drivers/block/blk-uclass.c  |   1 +
 drivers/mtd/Kconfig         |   1 +
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  21 ++++
 include/part.h              |   3 +
 9 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

--
2.34.1

Are you able to add a sandbox test for this code?

I think no. mtd/ubi block devices at the moment binds to real SPI NAND devices, which makes it impossible and useless to test it with sandbox.

Quoted 3 lines

Regards,
Simon

Signature · 2 lines
Thank you,
Alexey