mbox series

[v4,0/3] Introduce mtdblock device

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

Message

Alexey Romanov May 24, 2024, 10:29 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.

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/


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       |  69 +++++++++++
 drivers/mtd/nand/spi/core.c |  20 ++++
 include/linux/mtd/mtd.h     |  12 ++
 include/part.h              |   3 +
 9 files changed, 336 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/mtdblock.c

Comments

Dario Binacchi May 27, 2024, 7:37 a.m. UTC | #1
Hi Alexey,

The CI still detects some errors when applying both series:
- Introduce mtdblock device
- Introduce UBI block device

As an example:

+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccOTHlvl.ltrans4.ltrans.o: in function `mtd_blk_read':
6816+drivers/mtd/mtdblock.c:95:(.text.mtd_blk_read+0x40): undefined
reference to `mtd_read'
6817+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccOTHlvl.ltrans4.ltrans.o: in function `mtd_blk_write':
6818+drivers/mtd/mtdblock.c:162:(.text.mtd_blk_write+0x9a): undefined
reference to `mtd_read'
6819+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
drivers/mtd/mtdblock.c:122:(.text.mtd_blk_write+0xf4): undefined
reference to `mtd_erase'
6820+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccOTHlvl.ltrans4.ltrans.o:drivers/mtd/mtdblock.c:126:(.text.mtd_blk_write+0x110):
undefined reference to `mtd_write'
6821+collect2: error: ld returned 1 exit status
6822+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccaNKMBK.ltrans2.ltrans.o: in function `mtd_blk_read':
6823+drivers/mtd/mtdblock.c:95:(.text.mtd_blk_read+0x36): undefined
reference to `mtd_read'
6824+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccaNKMBK.ltrans2.ltrans.o: in function `mtd_blk_write':
6825+drivers/mtd/mtdblock.c:162:(.text.mtd_blk_write+0x88): undefined
reference to `mtd_read'
6826+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
drivers/mtd/mtdblock.c:122:(.text.mtd_blk_write+0xe0): undefined
reference to `mtd_erase'
6827+/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/13.2.0/../../../../arm-linux-gnueabi/bin/ld:
/tmp/ccaNKMBK.ltrans2.ltrans.o:drivers/mtd/mtdblock.

Furthermore, I need to fix something in applying the patches.
So, please rebase your series on master and run the tests locally:
Please read tools/buildman/buildman.rst and .gitlab-ci.yml to get info.

Thanks and regards,
Dario

On Fri, May 24, 2024 at 12:29 PM Alexey Romanov
<avromanov@salutedevices.com> 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.
>
> 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/
>
>
> 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       |  69 +++++++++++
>  drivers/mtd/nand/spi/core.c |  20 ++++
>  include/linux/mtd/mtd.h     |  12 ++
>  include/part.h              |   3 +
>  9 files changed, 336 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/mtd/mtdblock.c
>
> --
> 2.34.1
>