mbox series

[v7,0/3] Introduce mtdblock device

Message ID 20240718054606.799665-1-avromanov@salutedevices.com
Headers show
Series Introduce mtdblock device | expand

Message

Alexey Romanov July 18, 2024, 5:46 a.m. UTC
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.

Changes V5 -> V6 [6]:

  - Rebased over u-boot/master.
  - Fix build errors when CONFIG_MTD isn't enabled.
  - Use auto blk device devnum generation when call
    blk_create_devicef (pass -1 parameter instead of dev_seq(dev)).

Changes V6 -> V7 [7]:

  - Rebased over u-boot/master.
  - Introduce CONFIG_MTD_BLOCK which is disabled by default.

Links:

  - [1] https://lore.kernel.org/all/20240227100441.1811047-1-avromanov@salutedevices.com/
  - [2] https://lore.kernel.org/all/20240227100441.1811047-5-avromanov@salutedevices.com/
  - [3] https://lore.kernel.org/u-boot/20240403114047.84030-1-heinrich.schuchardt@canonical.com/T/#u
  - [4] https://lore.kernel.org/all/20240404105813.1520732-1-avromanov@salutedevices.com/
  - [5] https://lore.kernel.org/all/20240524102920.2631731-1-avromanov@salutedevices.com/
  - [6] https://lore.kernel.org/all/20240603155702.1840464-1-avromanov@salutedevices.com/
  - [7] https://lore.kernel.org/all/20240626104440.2811686-1-avromanov@salutedevices.com/

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         |   9 ++
 drivers/mtd/Makefile        |   1 +
 drivers/mtd/mtdblock.c      | 227 ++++++++++++++++++++++++++++++++++++
 drivers/mtd/mtdpart.c       |  76 ++++++++++++
 drivers/mtd/nand/spi/core.c |  21 ++++
 include/linux/mtd/mtd.h     |  25 ++++
 include/part.h              |   3 +
 9 files changed, 365 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

Comments

Michael Walle July 19, 2024, 6:57 a.m. UTC | #1
Hi,

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

If tried to test this with the SPI NOR framework but I couldn't get
it to work. The SPI NOR flash didn't register with/was found by the
mtdblock subsystem. I guess that is probably because the SPI NOR
flash has it's own UCLASS_SPI_FLASH. There is some kind of
compatibility layer (drivers/mtd/spi/sf_mtd.c) but it doesn't
register a UCLASS_MTD.

Do you have any idea how to get this to work?

-michael
Alexey Romanov July 24, 2024, 10:31 a.m. UTC | #2
Hi Michael,

Sorry for the late reply.

On Fri, Jul 19, 2024 at 08:57:04AM +0200, Michael Walle wrote:
> Hi,
> 
> > Tested only on SPI NAND, so bind is made only for
> > SPI NAND drivers.
> 
> If tried to test this with the SPI NOR framework but I couldn't get
> it to work. The SPI NOR flash didn't register with/was found by the
> mtdblock subsystem. I guess that is probably because the SPI NOR
> flash has it's own UCLASS_SPI_FLASH. There is some kind of
> compatibility layer (drivers/mtd/spi/sf_mtd.c) but it doesn't
> register a UCLASS_MTD.
> 
> Do you have any idea how to get this to work?

I think you have to try bind driver via mtd_bind(), just like
I do for SPI-NAND in patch "spinand: bind mtdblock".

I see what in file drivers/mtd/spi/sf_probe.c there is struct
mtd_info and also you have U_BOOT_DRIVER. Maybe try to bind there?

> 
> -michael