spl: Use common function for loading/parsing images
Subsystems (6)
v6 cover spl: Use common function for loading/parsing images
This series adds support for loading all image types (Legacy (with and without LZMA), FIT (with and without LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR, NET, FAT, EXT, NVMe, and semihosting load methods. It does this by introducing a helper function which handles the minutiae of invoking the proper parsing function, and reading the rest of the image.
Hopefully, this will make it easier for load methods to support all image types that U-Boot supports, without having undocumented unsupported image types. I applied this to several loaders which were invoking spl_load_simple_fit and/or spl_parse_image_header, but I did not use it with others (e.g. DFU/RAM) which had complications in the mix.
This series is organized roughly into two parts. Patches up to "spl: Add generic spl_load function" are all setup or size-reduction oriented. Later patches generally convert various load functions to spl_load.
bloat-o-meter results (for CONFIG_SPL only) at [1]. Size growth has been the bigegst challenge to preparing this series. I have used every trick I can think of to reduce bloat. Some SAMA boards no longer fit, but I have a plan to fix them [2].
This is bar far the largest and most-difficult revision of this series to-date. There are probably still things which can reduce the size, but I have been working on this series for the better part of two months and I think it is a good idea to get some feedback. Because of the SAMA bloat, this series will not pass CI, so I expect to do a v7 before this is ready to apply. Feel free, however, to apply patches in the first half (especially the fixes).
This version of the series is better-tested than ever before, thanks to some new unit tests. However, things like the i.MX ROMAPI are untested. NAND should also be tested more-widely, for reasons listed in the commit message. I encourage you try this series out on your favorite board.
This series depends on [3]. (Almost passing) CI at [4].
[1] https://gist.github.com/Forty-Bot/5bfe88676dd3c2aec6ebc23abb08e06f
This includes some changes to am335x_evm_spiboot and am65x_evm_r5_usbdfu which have since been undone.
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/[email protected]/
[4] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18447
Changes in v6:
- Fix uninitialized return value when we can't get a blk_desc
- Don't close fd before spl_load_simple_fit
- Remove NULL assignments in spl_load_info
- Remove dev from spl_load_info
- Take advantage of bl_len's power-of-twoness
- Refactor spl_load_info->read to use units of bytes
- Remove filename from spl_load_info
- Only support bl_len when we have to
- Remove spl_nand_legacy_read
- Split off LZMA decompression into its own function
- Support testing LEGACY_LZMA filesystem images
- Use pseudo-LTO for spl_load
- Align reads to bl_len
- Add SYS_MMCSD_RAW_MODE to help determine whether SPL_MMC loads anything directly.
- Convert nand to spl_load
- Fix LZMA support
- Fix load address
- Fix invalid return from spl_blk_load_image
- Fix soft reset after loading from SPI
- Explicitly initialize load_info members to reduce text size
- Rebase on u-boot/next
- Add option to disable DMA alignment for FAT
Changes in v5:
- Make SHOW_ERRORS depend on LIBCOMMON
- Load the header in spl_load as well
- Don't bother trying to DMA-align the buffer, since we can't really fix it.
- Convert NVMe to spl_load
Changes in v4:
- Fix format specifiers in debug prints
- Reword/fix some of the doc comments for spl_load
- Rebase on u-boot/master
Changes in v3:
- Fix using ffs instead of fls
- Fix using not initializing bl_len when info->filename was NULL
- Fix failing on success
Changes in v2:
- Use reverse-xmas-tree style for locals in spl_simple_read. This is not complete, since overhead depends on bl_mask.
- Convert semihosting as well
- Consolidate spi_load_image_os into spl_spi_load_image
Sean Anderson (25):
spl: blk_fs: Fix uninitialized return value when we can't get a
blk_desc
arm: Disable SPL_FS_FAT when it isn't used
spl: Make SHOW_ERRORS depend on LIBCOMMON
spl: semihosting: Don't close fd before spl_load_simple_fit
spl: Remove NULL assignments in spl_load_info
spl: Remove dev from spl_load_info
spl: Take advantage of bl_len's power-of-twoness
spl: Refactor spl_load_info->read to use units of bytes
spl: Remove filename from spl_load_info
spl: Only support bl_len when we have to
spl: nand: Remove spl_nand_legacy_read
spl: legacy: Split off LZMA decompression into its own function
test: spl: Support testing LEGACY_LZMA filesystem images
spl: Add generic spl_load function
spl: Convert ext to use spl_load
spl: Convert fat to spl_load
spl: Convert mmc to spl_load
spl: Convert nand to spl_load
spl: Convert net to spl_load
spl: Convert nor to spl_load
spl: Convert NVMe to spl_load
spl: Convert semihosting to spl_load
spl: Convert spi to spl_load
spl: spi: Consolidate spi_load_image_os into spl_spi_load_image
spl: fat: Add option to disable DMA alignment
arch/arm/mach-imx/spl_imx_romapi.c | 24 ++-- arch/arm/mach-sunxi/spl_spi_sunxi.c | 5 +- common/spl/Kconfig | 37 +++++- common/spl/spl.c | 13 +- common/spl/spl_blk_fs.c | 73 +++-------- common/spl/spl_ext.c | 36 +++--- common/spl/spl_fat.c | 62 ++++------ common/spl/spl_fit.c | 74 ++++------- common/spl/spl_imx_container.c | 55 ++++----- common/spl/spl_legacy.c | 110 ++++------------- common/spl/spl_mmc.c | 101 ++------------- common/spl/spl_nand.c | 104 ++++------------ common/spl/spl_net.c | 29 +---- common/spl/spl_nor.c | 42 ++----- common/spl/spl_ram.c | 2 +- common/spl/spl_semihosting.c | 65 ++-------- common/spl/spl_spi.c | 130 ++++--------------- common/spl/spl_ymodem.c | 4 +- configs/am335x_evm_spiboot_defconfig | 2 +- configs/am65x_evm_r5_usbdfu_defconfig | 1 - configs/xilinx_zynqmp_mini_qspi_defconfig | 3 + configs/zynq_cse_nand_defconfig | 3 + configs/zynq_cse_nor_defconfig | 3 + configs/zynq_cse_qspi_defconfig | 3 + drivers/usb/gadget/f_sdp.c | 10 +- include/spl.h | 60 +++++++-- include/spl_load.h | 144 ++++++++++++++++++++++ include/test/spl.h | 4 + test/image/Kconfig | 1 + test/image/spl_load.c | 13 +- test/image/spl_load_fs.c | 32 +++-- test/image/spl_load_nand.c | 2 + test/image/spl_load_net.c | 2 + test/image/spl_load_nor.c | 2 + test/image/spl_load_os.c | 16 ++- test/image/spl_load_spi.c | 1 + 36 files changed, 536 insertions(+), 732 deletions(-) create mode 100644 include/spl_load.h
Signature · 1 line
2.37.1
PATCH v6 1/25 spl: blk_fs: Fix uninitialized return value when we can't get a blk_desc
Initialize ret to avoid returning garbage if blk_get_devnum_by_uclass_id fails.
---
Changes in v6:
- New
common/spl/spl_blk_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl_blk_fs.c +1 -1
@@ -50,7 +50,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,struct blk_desc *blk_desc;loff_t actlen, filesize;struct blk_dev dev; -int ret; +int ret = -ENODEV ; blk_desc =blk_get_devnum_by_uclass_id (uclass_id, devnum);if (!blk_desc) {
Signature · 1 line
2.37.1
Re: [PATCH v6 01/25] spl: blk_fs: Fix uninitialized return value when we can't get a blk_desc
Quoted 6 lines · Sean Anderson
Initialize ret to avoid returning garbage if
blk_get_devnum_by_uclass_idfails.Fixes 8ce6a2e1757 ("spl: blk: Support loading images from fs")Signed-off-by Sean Anderson <[email protected]>
Quoted 8 lines
---
Changes in v6:
- Newcommon/spl/spl_blk_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v6 2/25 arm: Disable SPL_FS_FAT when it isn't used
In reply to Sean AndersonSeveral boards enable SPL_FS_FAT and SPL_LIBDISK_SUPPORT when they can't be used (as there is no block device support enabled). Disable these configs. The list of boards was generated with the following command:
$ tools/qconfig.py -f SPL SPL_FS_FAT ~SPL_MMC ~SPL_BLK_FS ~SPL_SATA \
~SPL_USB_STORAGE ~ENV_IS_IN_FAT ~EFILIBDISK was left enabled for the am* boards, since it seems to result in actual size reduction, indicating that partitions are being used for something.
---
(no changes since v1)
configs/am335x_evm_spiboot_defconfig | 2 +- configs/am65x_evm_r5_usbdfu_defconfig | 1 - configs/xilinx_zynqmp_mini_qspi_defconfig | 3 +++ configs/zynq_cse_nand_defconfig | 3 +++ configs/zynq_cse_nor_defconfig | 3 +++ configs/zynq_cse_qspi_defconfig | 3 +++ 6 files changed, 13 insertions(+), 2 deletions(-)
configs/am335x_evm_spiboot_defconfig +1 -1
@@ -13,6 +13,7 @@ CONFIG_CLOCK_SYNTHESIZER=y # CONFIG_OF_LIBFDT_OVERLAY is not set # CONFIG_SPL_MMC is not set CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_TIMESTAMP=y
@@ -27,7 +28,6 @@ CONFIG_SPL_SYS_MALLOC=y CONFIG_SPL_SYS_MALLOC_SIZE=0x800000 CONFIG_SPL_FIT_IMAGE_TINY=y # CONFIG_SPL_FS_EXT4 is not set -CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img" CONFIG_SPL_MTD=y # CONFIG_SPL_NAND_SUPPORT is not set CONFIG_SPL_DM_SPI_FLASH=y
configs/am65x_evm_r5_usbdfu_defconfig +0 -1
@@ -21,7 +21,6 @@ CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_SPL_SIZE_LIMIT=0x7ec00 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x2000 -CONFIG_SPL_FS_FAT=y CONFIG_SPL_LIBDISK_SUPPORT=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL_LOAD_FIT=y
configs/xilinx_zynqmp_mini_qspi_defconfig +3 -0
@@ -11,6 +11,8 @@ CONFIG_ENV_SIZE=0x80 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-mini-qspi" CONFIG_SPL_STACK=0xfffffffc CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set CONFIG_SYS_MEM_RSVD_FOR_MMU=y CONFIG_ZYNQMP_NO_DDR=y # CONFIG_PSCI_RESET is not set
@@ -89,6 +91,7 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_ARM_DCC=y CONFIG_SPI=y CONFIG_ZYNQMP_GQSPI=y +CONFIG_FS_FAT=y # CONFIG_FAT_WRITE is not set CONFIG_PANIC_HANG=y # CONFIG_GZIP is not set
configs/zynq_cse_nand_defconfig +3 -0
@@ -13,6 +13,8 @@ CONFIG_DEFAULT_DEVICE_TREE="zynq-cse-nand" CONFIG_SPL_STACK_R_ADDR=0x200000 CONFIG_SPL_STACK=0xfffffe00 CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set CONFIG_SYS_LOAD_ADDR=0x0 CONFIG_REMAKE_ELF=y CONFIG_SYS_CUSTOM_LDSCRIPT=y
@@ -78,6 +80,7 @@ CONFIG_MTD_RAW_NAND=y CONFIG_NAND_ZYNQ=y CONFIG_SYS_NAND_ONFI_DETECTION=y CONFIG_ARM_DCC=y +CONFIG_FS_FAT=y CONFIG_SYS_TIMER_COUNTS_DOWN=y # CONFIG_GZIP is not set # CONFIG_LMB is not set
configs/zynq_cse_nor_defconfig +3 -0
@@ -13,6 +13,8 @@ CONFIG_DEFAULT_DEVICE_TREE="zynq-cse-nor" CONFIG_SPL_STACK_R_ADDR=0x200000 CONFIG_SPL_STACK=0xfffffe00 CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set CONFIG_SYS_LOAD_ADDR=0x0 CONFIG_REMAKE_ELF=y CONFIG_SYS_CUSTOM_LDSCRIPT=y
@@ -81,6 +83,7 @@ CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_SYS_FLASH_CFI=y CONFIG_SYS_FLASH_QUIET_TEST=y CONFIG_ARM_DCC=y +CONFIG_FS_FAT=y CONFIG_SYS_TIMER_COUNTS_DOWN=y # CONFIG_GZIP is not set # CONFIG_LMB is not set
configs/zynq_cse_qspi_defconfig +3 -0
@@ -16,6 +16,8 @@ CONFIG_SPL_STACK=0xfffffe00 CONFIG_SPL=y CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 +# CONFIG_SPL_FS_FAT is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set # CONFIG_ZYNQ_DDRC_INIT is not set # CONFIG_CMD_ZYNQ is not set CONFIG_SYS_LOAD_ADDR=0x0
@@ -90,6 +92,7 @@ CONFIG_SPI_FLASH_WINBOND=y # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set CONFIG_ARM_DCC=y CONFIG_ZYNQ_QSPI=y +CONFIG_FS_FAT=y CONFIG_SYS_TIMER_COUNTS_DOWN=y # CONFIG_GZIP is not set # CONFIG_LMB is not set
Signature · 1 line
2.37.1
Michal Simek
maintainerRe: [PATCH v6 02/25] arm: Disable SPL_FS_FAT when it isn't used
Quoted 70 lines · Sean Anderson
Several boards enable
SPL_FS_FATandSPL_LIBDISK_SUPPORTwhen they can't be used (as there is no block device support enabled). Disable these configs. The list of boards was generated with the following command:$ tools/qconfig.py -f SPL SPL_FS_FAT ~SPL_MMC ~SPL_BLK_FS ~SPL_SATA \ ~SPL_USB_STORAGE ~ENV_IS_IN_FAT ~EFILIBDISK was left enabled for the am* boards, since it seems to result in actual size reduction, indicating that partitions are being used for something.
Signed-off-by Sean Anderson <[email protected]>---
(no changes since v1)
configs/am335x_evm_spiboot_defconfig | 2 +- configs/am65x_evm_r5_usbdfu_defconfig | 1 - configs/xilinx_zynqmp_mini_qspi_defconfig | 3 +++ configs/zynq_cse_nand_defconfig | 3 +++ configs/zynq_cse_nor_defconfig | 3 +++ configs/zynq_cse_qspi_defconfig | 3 +++ 6 files changed, 13 insertions(+), 2 deletions(-)configs/am335x_evm_spiboot_defconfig +1
-1@@ -13,6 +13,7 @@ CONFIG_CLOCK_SYNTHESIZER=y # CONFIG_OF_LIBFDT_OVERLAY is not set # CONFIG_SPL_MMC is not set CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_TIMESTAMP=y@@ -27,7 +28,6 @@ CONFIG_SPL_SYS_MALLOC=y CONFIG_SPL_SYS_MALLOC_SIZE=0x800000 CONFIG_SPL_FIT_IMAGE_TINY=y # CONFIG_SPL_FS_EXT4 is not set -CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img" CONFIG_SPL_MTD=y # CONFIG_SPL_NAND_SUPPORT is not set CONFIG_SPL_DM_SPI_FLASH=yconfigs/am65x_evm_r5_usbdfu_defconfig +0
-1@@ -21,7 +21,6 @@ CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_SPL_SIZE_LIMIT=0x7ec00 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x2000 -CONFIG_SPL_FS_FAT=y CONFIG_SPL_LIBDISK_SUPPORT=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SPL_LOAD_FIT=yconfigs/xilinx_zynqmp_mini_qspi_defconfig +2
-0@@ -11,6 +11,8 @@ CONFIG_ENV_SIZE=0x80 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-mini-qspi" CONFIG_SPL_STACK=0xfffffffc CONFIG_SPL=y +# CONFIG_SPL_FS_FAT is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set CONFIG_SYS_MEM_RSVD_FOR_MMU=y CONFIG_ZYNQMP_NO_DDR=y # CONFIG_PSCI_RESET is not set
configs/xilinx_zynqmp_mini_qspi_defconfig CONFIG_SPI_FLASH_WINBOND=y · line 94
Quoted 4 lines
configs/xilinx_zynqmp_mini_qspi_defconfig +1
-0@@ -89,6 +91,7 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_ARM_DCC=y CONFIG_SPI=y CONFIG_ZYNQMP_GQSPI=y +CONFIG_FS_FAT=y
This can be also removed and also for zynq_cse boards below. There is no need to have FAT support.
Thanks,
Michal
PATCH v6 3/25 spl: Make SHOW_ERRORS depend on LIBCOMMON
In reply to Sean AndersonThe purpose of SHOW_ERRORS is to print extra information. Make it depend on LIBCOMMON to avoid having to check for two configs.
---
(no changes since v5)
Changes in v5:
- New
common/spl/Kconfig | 1 + common/spl/spl.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
common/spl/Kconfig +1 -0
@@ -183,6 +183,7 @@ config SPL_SYS_REPORT_STACK_F_USAGE config SPL_SHOW_ERRORS bool "Show more information when something goes wrong" + depends on SPL_LIBCOMMON_SUPPORT help This enabled more verbose error messages and checking when something goes wrong in SPL. For example, it shows the error code when U-Boot
common/spl/spl.c +1 -2
@@ -718,8 +718,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) ret =boot_from_devices (&spl_image, spl_boot_list,ARRAY_SIZE (spl_boot_list));if (ret) { -if (CONFIG_IS_ENABLED (SHOW_ERRORS ) && -CONFIG_IS_ENABLED (LIBCOMMON_SUPPORT )) +if (CONFIG_IS_ENABLED (SHOW_ERRORS ))printf (SPL_TPL_PROMPT "failed to boot from all boot devices (err=%d)\n" , ret);else
Signature · 1 line
2.37.1
Re: [PATCH v6 03/25] spl: Make SHOW_ERRORS depend on LIBCOMMON
Quoted 8 lines · Sean Anderson
The purpose of
SHOW_ERRORSis to print extra information. Make it depend on LIBCOMMON to avoid having to check for two configs.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Tom Rini <[email protected]>---
Quoted 9 lines
(no changes since v5)
Changes in v5:
- Newcommon/spl/Kconfig | 1 + common/spl/spl.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH v6 4/25 spl: semihosting: Don't close fd before spl_load_simple_fit
In reply to Sean AndersonOn real hardware, semihosting calls tends to have a large constant overhead (on the order of tens of milliseconds). Reduce the number of calls by one by reusing the existing fd in smh_fit_read, and closing it at the end of spl_smh_load_image.
---
Changes in v6:
- New
common/spl/spl_semihosting.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
common/spl/spl_semihosting.c +8 -12
@@ -24,18 +24,14 @@ static int smh_read_full(long fd, void *memp, size_t len)static ulong smh_fit_read (struct spl_load_info *load,ulong file_offset,ulong size,void *buf) { -long fd; +long fd = *(long *)load->priv;ulong ret; - fd =smh_open (load->filename,MODE_READ |MODE_BINARY ); -if (fd <0 ) { -log_debug ("could not open %s: %ld\n" , load->filename, fd); +if (smh_seek (fd, file_offset))return 0 ; - } + ret =smh_read (fd, buf, size); -smh_close (fd); - -return ret; +return ret <0 ?0 : ret; } static int spl_smh_load_image(struct spl_image_info *spl_image,
@@ -73,11 +69,11 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = smh_fit_read; load.bl_len =1 ; - load.filename = filename; - load.priv =NULL ; -smh_close (fd); + load.filename =NULL ; + load.priv = &fd; -return spl_load_simple_fit (spl_image, &load,0 , header); + ret =spl_load_simple_fit (spl_image, &load,0 , header); + goto out; } ret =spl_parse_image_header (spl_image, bootdev, header);
Signature · 1 line
2.37.1
Re: [PATCH v6 04/25] spl: semihosting: Don't close fd before spl_load_simple_fit
Quoted 6 lines · Sean Anderson
On real hardware, semihosting calls tends to have a large constant overhead (on the order of tens of milliseconds). Reduce the number of calls by one by reusing the existing fd in
smh_fit_read, and closing it at the end ofspl_smh_load_image.
Quoted 8 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Newcommon/spl/spl_semihosting.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
PATCH v6 5/25 spl: Remove NULL assignments in spl_load_info
In reply to Sean AndersonRemove NULL assignments to fields in spl_load_info when .load doesn't reference these fields. This can result in more efficient code. filename must stay even if it is unused, since load_simple_fit uses it.
---
Changes in v6:
- New
arch/arm/mach-sunxi/spl_spi_sunxi.c | 2 -- common/spl/spl_fat.c | 1 - common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 4 ---- common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - 6 files changed, 12 deletions(-)
arch/arm/mach-sunxi/spl_spi_sunxi.c +0 -2
@@ -354,8 +354,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT image\n" ); - load.dev =NULL ; - load.priv =NULL ; load.filename =NULL ; load.bl_len =1 ; load.read = spi_load_read;
common/spl/spl_fat.c +0 -1
@@ -99,7 +99,6 @@ int spl_load_image_fat(struct spl_image_info *spl_image, load.read = spl_fit_read; load.bl_len =1 ; load.filename = (void *)filename; - load.priv =NULL ;return spl_load_simple_fit (spl_image, &load,0 , header); }else {
common/spl/spl_mmc.c +0 -2
@@ -106,7 +106,6 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.dev = mmc; - load.priv =NULL ; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;
@@ -116,7 +115,6 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load; load.dev = mmc; - load.priv =NULL ; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;
common/spl/spl_nand.c +0 -4
@@ -91,7 +91,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev =NULL ; load.priv = &offset; load.filename =NULL ; load.bl_len = bl_len;
@@ -101,7 +100,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev =NULL ; load.priv = &offset; load.filename =NULL ; load.bl_len = bl_len;
@@ -112,8 +110,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found legacy image\n" ); - load.dev =NULL ; - load.priv =NULL ; load.filename =NULL ; load.bl_len =IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ; load.read = spl_nand_legacy_read;
common/spl/spl_spi.c +0 -2
@@ -152,7 +152,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.dev = flash; - load.priv =NULL ; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;
@@ -164,7 +163,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load; load.dev = flash; - load.priv =NULL ; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;
common/spl/spl_ymodem.c +0 -1
@@ -134,7 +134,6 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,struct ymodem_fit_info info;debug ("Found FIT\n" ); - load.dev =NULL ; load.priv = (void *)&info; load.filename =NULL ; load.bl_len =1 ;
Signature · 1 line
2.37.1
Re: [PATCH v6 05/25] spl: Remove NULL assignments in spl_load_info
Hi Sean,
Quoted 11 lines · Sean Anderson
Remove NULL assignments to fields in
spl_load_infowhen .load doesn't reference these fields. This can result in more efficient code. filename must stay even if it is unused, sinceload_simple_fituses it.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- New
Quoted 7 lines
arch/arm/mach-sunxi/spl_spi_sunxi.c | 2 -- common/spl/spl_fat.c | 1 - common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 4 ---- common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - 6 files changed, 12 deletions(-)
This makes me wonder if we should have a function to clear it out (using memset() and perhaps a bl_len parameter)? Having said that, the info-field use is pretty self-contained with these files.
Re: [PATCH v6 05/25] spl: Remove NULL assignments in spl_load_info
Quoted 22 lines · Simon Glass
Hi Sean,
Quoted 11 lines · Sean Anderson
Remove NULL assignments to fields in
spl_load_infowhen .load doesn't reference these fields. This can result in more efficient code. filename must stay even if it is unused, sinceload_simple_fituses it.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- NewQuoted 7 lines
arch/arm/mach-sunxi/spl_spi_sunxi.c | 2 -- common/spl/spl_fat.c | 1 - common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 4 ---- common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - 6 files changed, 12 deletions(-)
Quoted 5 lines
This makes me wonder if we should have a function to clear it out (using
memset()and perhaps abl_lenparameter)? Having said that, the info-field use is pretty self-contained with these files.Reviewed-by Simon Glass <[email protected]>
It would be simpler, but this series causes bloat in other areas and this is a very simple way to reduce text size.
--Sean
PATCH v6 6/25 spl: Remove dev from spl_load_info
In reply to Sean Andersondev and priv server the same purpose, and are never set at the same time. Remove dev and convert all users to priv. While we're at it, reorder bl_len to be last for better alignment.
---
Changes in v6:
- New
common/spl/spl_mmc.c | 6 +++--- common/spl/spl_spi.c | 6 +++--- drivers/usb/gadget/f_sdp.c | 6 +++--- include/spl.h | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-)
common/spl/spl_mmc.c +3 -3
@@ -65,7 +65,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image,static ulong h_spl_load_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct mmc *mmc = load->dev; +struct mmc *mmc = load->priv;return blk_dread (mmc_get_blk_desc (mmc), sector, count, buf); }
@@ -105,7 +105,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;
@@ -114,7 +114,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;
common/spl/spl_spi.c +3 -3
@@ -59,7 +59,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct spi_flash *flash = load->dev; +struct spi_flash *flash = load->priv;ulong ret; ret =spi_flash_read (flash, sector, count, buf);
@@ -151,7 +151,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;
@@ -162,7 +162,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;
drivers/usb/gadget/f_sdp.c +3 -3
@@ -744,7 +744,7 @@ static ulong sdp_load_read(struct spl_load_info *load, ulong sector, {debug ("%s: sector %lx, count %lx, buf %lx\n" , __func__, sector, count, (ulong )buf); -memcpy (buf, (void *)(load->dev + sector), count); +memcpy (buf, (void *)(load->priv + sector), count);return count; }
@@ -844,7 +844,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read; spl_load_simple_fit(spl_image, &load, 0,
@@ -857,7 +857,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read;spl_load_imx_container (spl_image, &load,0 );
include/spl.h +1 -3
@@ -285,16 +285,13 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info)/** * Information required to load data from a device * -* @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device * @bl_len: Block length for reading in bytes * @filename: Name of the fit image file. * @read: Function to call to read from the device */ struct spl_load_info { -void *dev;void *priv; -int bl_len;const char *filename;/** * read() - Read from device
@@ -307,6 +304,7 @@ struct spl_load_info {*/ ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf); +int bl_len; };/*
Signature · 1 line
2.37.1
Re: [PATCH v6 06/25] spl: Remove dev from spl_load_info
Hi Sean,
Quoted 2 lines · Sean Anderson
dev and priv server the same purpose, and are never set at the same time.
serve
Quoted 2 lines
Remove dev and convert all users to priv. While we're at it, reorder
bl_lento be last for better alignment.
It's a bit unfortunate to drop the device, isn't it? But then, as before, this is self-contained so Is suppose it doesn't matter what we store.
Regards,
Simon
Quoted 138 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Newcommon/spl/spl_mmc.c | 6 +++--- common/spl/spl_spi.c | 6 +++--- drivers/usb/gadget/f_sdp.c | 6 +++--- include/spl.h | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-)common/spl/spl_mmc.c +3
-3@@ -65,7 +65,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image,static ulong h_spl_load_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct mmc *mmc = load->dev; +struct mmc *mmc = load->priv;return blk_dread (mmc_get_blk_desc (mmc), sector, count, buf); }@@ -105,7 +105,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;@@ -114,7 +114,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;common/spl/spl_spi.c +3
-3@@ -59,7 +59,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct spi_flash *flash = load->dev; +struct spi_flash *flash = load->priv;ulong ret; ret =spi_flash_read (flash, sector, count, buf);@@ -151,7 +151,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;@@ -162,7 +162,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;drivers/usb/gadget/f_sdp.c +3
-3@@ -744,7 +744,7 @@ static ulong sdp_load_read(struct spl_load_info *load, ulong sector, {debug ("%s: sector %lx, count %lx, buf %lx\n" , __func__, sector, count, (ulong )buf); -memcpy (buf, (void *)(load->dev + sector), count); +memcpy (buf, (void *)(load->priv + sector), count);return count; }@@ -844,7 +844,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read; spl_load_simple_fit(spl_image, &load, 0,@@ -857,7 +857,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read;spl_load_imx_container (spl_image, &load,0 );include/spl.h +1
-4@@ -285,16 +285,13 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info)/** * Information required to load data from a device * -* @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device * @bl_len: Block length for reading in bytes * @filename: Name of the fit image file. * @read: Function to call to read from the device */ struct spl_load_info { -void *dev;void *priv; -int bl_len;const char *filename;/** * read() - Read from device @@ -307,6 +304,7 @@ struct spl_load_info {*/ ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf); +int bl_len; };/* -- 2.37.1
Re: [PATCH v6 06/25] spl: Remove dev from spl_load_info
Quoted 6 lines · Simon Glass
Hi Sean,
Quoted 2 lines · Sean Anderson
dev and priv server the same purpose, and are never set at the same time.
Quoted 8 lines
serve
Quoted 2 lines
Remove dev and convert all users to priv. While we're at it, reorder
bl_lento be last for better alignment.It's a bit unfortunate to drop the device, isn't it? But then, as before, this is self-contained so Is suppose it doesn't matter what we store.
The original goal was to have something like
struct spl_load load = SPL_LOAD_INFO(my_load_function, my_private_data);
but I had to cut it because it was resulting in too many unnecessary assignments.
--Sean
Quoted 145 lines
Reviewed-by Simon Glass <[email protected]>Regards,
SimonQuoted 138 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Newcommon/spl/spl_mmc.c | 6 +++--- common/spl/spl_spi.c | 6 +++--- drivers/usb/gadget/f_sdp.c | 6 +++--- include/spl.h | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-)common/spl/spl_mmc.c +3
-3@@ -65,7 +65,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image,static ulong h_spl_load_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct mmc *mmc = load->dev; +struct mmc *mmc = load->priv;return blk_dread (mmc_get_blk_desc (mmc), sector, count, buf); }@@ -105,7 +105,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;@@ -114,7 +114,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = mmc; + load.priv = mmc; load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read;common/spl/spl_spi.c +3
-3@@ -59,7 +59,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) { -struct spi_flash *flash = load->dev; +struct spi_flash *flash = load->priv;ulong ret; ret =spi_flash_read (flash, sector, count, buf);@@ -151,7 +151,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;@@ -162,7 +162,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = flash; + load.priv = flash; load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;drivers/usb/gadget/f_sdp.c +3
-3@@ -744,7 +744,7 @@ static ulong sdp_load_read(struct spl_load_info *load, ulong sector, {debug ("%s: sector %lx, count %lx, buf %lx\n" , __func__, sector, count, (ulong )buf); -memcpy (buf, (void *)(load->dev + sector), count); +memcpy (buf, (void *)(load->priv + sector), count);return count; }@@ -844,7 +844,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read; spl_load_simple_fit(spl_image, &load, 0,@@ -857,7 +857,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image, valid_container_hdr((void *)header)) {struct spl_load_info load; - load.dev = header; + load.priv = header; load.bl_len =1 ; load.read = sdp_load_read;spl_load_imx_container (spl_image, &load,0 );include/spl.h +1
-4@@ -285,16 +285,13 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info)/** * Information required to load data from a device * -* @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device * @bl_len: Block length for reading in bytes * @filename: Name of the fit image file. * @read: Function to call to read from the device */ struct spl_load_info { -void *dev;void *priv; -int bl_len;const char *filename;/** * read() - Read from device @@ -307,6 +304,7 @@ struct spl_load_info {*/ ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf); +int bl_len; };/* -- 2.37.1
PATCH v6 7/25 spl: Take advantage of bl_len's power-of-twoness
In reply to Sean Andersonbl_len must be a power of two, so we can use ALIGN instead of roundup and similar tricks to avoid divisions.
---
Changes in v6:
- New
common/spl/spl_fit.c | 2 +- common/spl/spl_imx_container.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
common/spl/spl_fit.c +1 -1
@@ -194,7 +194,7 @@ static int get_aligned_image_overhead(struct spl_load_info *info, int offset)if (info->filename)return offset & (ARCH_DMA_MINALIGN -1 ); -return offset % info->bl_len; +return offset & (info->bl_len -1 ); } static int get_aligned_image_size(struct spl_load_info *info, int data_size,
common/spl/spl_imx_container.c +4 -4
@@ -33,13 +33,13 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image, images = (struct boot_img_t *)((u8 *)container +sizeof (struct container_hdr )); -if (images[image_index].offset % info->bl_len) { +if (!IS_ALIGNED (images[image_index].offset, info->bl_len)) {printf ("%s: image%d offset not aligned to %u\n" , __func__, image_index, info->bl_len);return NULL ; } - sectors =roundup (images[image_index].size, info->bl_len) / + sectors =ALIGN (images[image_index].size, info->bl_len) / info->bl_len; sector = images[image_index].offset / info->bl_len + container_sector;
@@ -69,7 +69,7 @@ static int read_auth_container(struct spl_image_info *spl_image,u32 sectors;int i, size, ret =0 ; - size =roundup (CONTAINER_HDR_ALIGNMENT , info->bl_len); + size =ALIGN (CONTAINER_HDR_ALIGNMENT , info->bl_len); sectors = size / info->bl_len;/*
@@ -103,7 +103,7 @@ static int read_auth_container(struct spl_image_info *spl_image,debug ("Container length %u\n" , length);if (length >CONTAINER_HDR_ALIGNMENT ) { - size =roundup (length, info->bl_len); + size =ALIGN (length, info->bl_len); sectors = size / info->bl_len;free (container);
Signature · 1 line
2.37.1
Re: [PATCH v6 07/25] spl: Take advantage of bl_len's power-of-twoness
Quoted 5 lines · Sean Anderson
bl_lenmust be a power of two, so we can use ALIGN instead of roundup and similar tricks to avoid divisions.Signed-off-by Sean Anderson <[email protected]>
Quoted 8 lines
---
Changes in v6:
- Newcommon/spl/spl_fit.c | 2 +- common/spl/spl_imx_container.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
PATCH v6 8/25 spl: Refactor spl_load_info->read to use units of bytes
In reply to Sean AndersonSimplify things a bit for callers of spl_load_info->read by refactoring it to use units of bytes instead of bl_len. This generally simplifies the logic, as MMC is the only loader which actually works in sectors. It will also allow further refactoring to remove the special-case handling of filename. spl_load_legacy_img already works in units of bytes (oops) so it doesn't need to be changed.
---
Changes in v6:
- New
arch/arm/mach-imx/spl_imx_romapi.c | 16 +++------- common/spl/spl_fit.c | 51 +++++++++++++++--------------- common/spl/spl_imx_container.c | 45 +++++++++++--------------- common/spl/spl_mmc.c | 24 ++++++++------ common/spl/spl_nand.c | 8 ++--- include/spl.h | 16 ++++++---- test/image/spl_load_os.c | 13 ++++---- 7 files changed, 80 insertions(+), 93 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +4 -12
@@ -53,16 +53,10 @@ static int is_boot_from_stream_device(u32 boot) }static ulong spl_romapi_read_seekable (struct spl_load_info *load, -ulong sector,ulong count, +ulong offset,ulong byte,void *buf) { -u32 pagesize = *(u32 *)load->priv; -ulong byte = count * pagesize; -u32 offset; - - offset = sector * pagesize; - -return spl_romapi_raw_seekable_read (offset, byte, buf) / pagesize; +return spl_romapi_raw_seekable_read (offset, byte, buf); } static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
@@ -109,8 +103,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,memset (&load,0 ,sizeof (load)); load.bl_len = pagesize; load.read = spl_romapi_read_seekable; - load.priv = &pagesize; -return spl_load_simple_fit (spl_image, &load, offset / pagesize, header); +return spl_load_simple_fit (spl_image, &load, offset, header); }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) &&valid_container_hdr ((void *)header)) {struct spl_load_info load;
@@ -118,9 +111,8 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,memset (&load,0 ,sizeof (load)); load.bl_len = pagesize; load.read = spl_romapi_read_seekable; - load.priv = &pagesize; - ret =spl_load_imx_container (spl_image, &load, offset / pagesize); + ret =spl_load_imx_container (spl_image, &load, offset); }else {/* TODO */ puts ("Can't support legacy image\n" );
common/spl/spl_fit.c +25 -26
172 lines not on this page · raw message
common/spl/spl_imx_container.c +19 -26
101 lines not on this page · raw message
common/spl/spl_mmc.c +14 -10
@@ -62,12 +62,14 @@ static int mmc_load_legacy(struct spl_image_info *spl_image,return 0 ; } -static ulong h_spl_load_read (struct spl_load_info *load,ulong sector, -ulong count,void *buf) +static ulong h_spl_load_read (struct spl_load_info *load,ulong off, +ulong size,void *buf) { -struct mmc *mmc = load->priv; +struct blk_desc *bd = load->priv; +lbaint_t sector = off >> bd->log2blksz; +lbaint_t count = size >> bd->log2blksz; -return blk_dread (mmc_get_blk_desc (mmc), sector, count, buf); +return blk_dread (bd, sector, count, buf) << bd->log2blksz; }static __maybe_unused unsigned long spl_mmc_raw_uboot_offset (int part)
@@ -105,21 +107,23 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.priv = mmc; + load.priv = bd; load.filename =NULL ; - load.bl_len = mmc->read_bl_len; + load.bl_len = bd->blksz; load.read = h_spl_load_read; - ret =spl_load_simple_fit (spl_image, &load, sector, header); + ret =spl_load_simple_fit (spl_image, &load, + sector << bd->log2blksz, header); }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) &&valid_container_hdr ((void *)header)) {struct spl_load_info load; - load.priv = mmc; + load.priv = bd; load.filename =NULL ; - load.bl_len = mmc->read_bl_len; + load.bl_len = bd->blksz; load.read = h_spl_load_read; - ret =spl_load_imx_container (spl_image, &load, sector); + ret =spl_load_imx_container (spl_image, &load, + sector << bd->log2blksz); }else { ret =mmc_load_legacy (spl_image, bootdev, mmc, sector, header); }
common/spl/spl_nand.c +3 -5
@@ -49,14 +49,12 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,ulong sector; sector = *(int *)load->priv; - offs *= load->bl_len; - size *= load->bl_len; offs = sector +nand_spl_adjust_offset (sector, offs - sector); err =nand_spl_load_image (offs, size, dst);if (err)return 0 ; -return size / load->bl_len; +return size; } static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs,
@@ -95,7 +93,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, load.filename =NULL ; load.bl_len = bl_len; load.read = spl_nand_fit_read; -return spl_load_simple_fit (spl_image, &load, offset / bl_len, header); +return spl_load_simple_fit (spl_image, &load, offset, header); }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) &&valid_container_hdr ((void *)header)) {struct spl_load_info load;
@@ -104,7 +102,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, load.filename =NULL ; load.bl_len = bl_len; load.read = spl_nand_fit_read; -return spl_load_imx_container (spl_image, &load, offset / bl_len); +return spl_load_imx_container (spl_image, &load, offset); }else if (IS_ENABLED (CONFIG_SPL_LEGACY_IMAGE_FORMAT ) &&image_get_magic (header) ==IH_MAGIC ) {struct spl_load_info load;
include/spl.h +9 -7
@@ -297,10 +297,10 @@ struct spl_load_info {* read() - Read from device * * @load: Information about the load state -* @sector: Sector number to read from (each @load->bl_len bytes) -* @count: Number of sectors to read +* @offset: Offset to read from in bytes, in multiples of @load->bl_len +* @count: Number of bytes to read, in multiples of @load->bl_len * @buf: Buffer to read into -* @return number of sectors read, 0 on error +* @return number of bytes read, 0 on error */ ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf);
@@ -368,7 +368,8 @@ void *spl_load_simple_fit_fix_load(const void *fit);* spl_load_simple_fit() - Loads a fit image from a device. * @spl_image: Image description to set up * @info: Structure containing the information required to load data. -* @sector: Sector number where FIT image is located in the device +* @offset: Offset where FIT image is located in the device. Must be aligned +* to the device's bl_len. * @fdt: Pointer to the copied FIT header. * * Reads the FIT image @sector in the device. Loads u-boot image to
@@ -376,7 +377,7 @@ void *spl_load_simple_fit_fix_load(const void *fit);* Returns 0 on success. */ int spl_load_simple_fit (struct spl_image_info *spl_image, -struct spl_load_info *info,ulong sector,void *fdt); +struct spl_load_info *info,ulong offset,void *fdt);#define SPL_COPY_PAYLOAD_ONLY 1#define SPL_FIT_FOUND 2
@@ -402,13 +403,14 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,* spl_load_imx_container() - Loads a imx container image from a device. * @spl_image: Image description to set up * @info: Structure containing the information required to load data. -* @sector: Sector number where container image is located in the device +* @sector: Offset where container image is located in the device. Must be +* aligned to the device block size. * * Reads the container image @sector in the device. Loads u-boot image to * specified load address. */ int spl_load_imx_container (struct spl_image_info *spl_image, -struct spl_load_info *info,ulong sector); +struct spl_load_info *info,ulong offset);/* SPL common functions */ void preloader_console_init (void );
test/image/spl_load_os.c +6 -7
@@ -16,14 +16,13 @@ struct text_ctx {int fd; }; -static ulong read_fit_image (struct spl_load_info *load,ulong sector, -ulong count,void *buf) +static ulong read_fit_image (struct spl_load_info *load,ulong offset, +ulong size,void *buf) {struct text_ctx *text_ctx = load->priv; -off_t offset, ret; +off_t ret;ssize_t res; - offset = sector * load->bl_len; ret =os_lseek (text_ctx->fd, offset,OS_SEEK_SET );if (ret != offset) { printf("Failed to seek to %zx, got %zx (errno=%d)\n", offset,
@@ -31,14 +30,14 @@ static ulong read_fit_image(struct spl_load_info *load, ulong sector,return 0 ; } - res =os_read (text_ctx->fd, buf, count * load->bl_len); + res =os_read (text_ctx->fd, buf, size);if (res ==-1 ) {printf ("Failed to read %lx bytes, got %ld (errno=%d)\n" , - count * load->bl_len, res, errno); + size, res, errno);return 0 ; } -return count; +return size; }static int spl_test_load (struct unit_test_state *uts)
Signature · 1 line
2.37.1
Re: [PATCH v6 08/25] spl: Refactor spl_load_info->read to use units of bytes
Thanks for your work. I'm still reading... but...
El Sun, Nov 05, 2023 at 09:25:46PM -0500, Sean Anderson deia:
include/spl.h struct spl_load_info { · line 301
Quoted 12 lines
include/spl.h +2
-2@@ -297,10 +297,10 @@ struct spl_load_info {* read() - Read from device * * @load: Information about the load state -* @sector: Sector number to read from (each @load->bl_len bytes) -* @count: Number of sectors to read +* @offset: Offset to read from in bytes, in multiples of @load->bl_len +* @count: Number of bytes to read, in multiples of @load->bl_len
I'm no native English speaker, but would it be easier to understand? :
+ * @offset: Offset to read from in bytes, a multiple of @load->bl_len
+ * @count: Number of bytes to read, a multiple of @load->bl_len
Re: [PATCH v6 08/25] spl: Refactor spl_load_info->read to use units of bytes
Quoted 22 lines · Xavier Drudis Ferran
Thanks for your work. I'm still reading... but...
El Sun, Nov 05, 2023 at 09:25:46PM -0500, Sean Anderson deia:
include/spl.h struct spl_load_info { · line 301
Quoted 12 lines
include/spl.h +2
-2@@ -297,10 +297,10 @@ struct spl_load_info {* read() - Read from device * * @load: Information about the load state -* @sector: Sector number to read from (each @load->bl_len bytes) -* @count: Number of sectors to read +* @offset: Offset to read from in bytes, in multiples of @load->bl_len +* @count: Number of bytes to read, in multiples of @load->bl_len I'm no native English speaker, but would it be easier to understand? :
Review
Quoted 2 lines
(quoted diff) +2
-0+ * @offset: Offset to read from in bytes, a multiple of @load->bl_len + * @count: Number of bytes to read, a multiple of @load->bl_len
I think it would have to be worded
@offset: Offset to read from in bytes, as a multiple of @load->bl_len
but to me these both mean the same thing.
--Sean
Re: [PATCH v6 08/25] spl: Refactor spl_load_info->read to use units of bytes
El Mon, Nov 06, 2023 at 08:54:03AM -0500, Sean Anderson deia:
Quoted 28 lines · Xavier Drudis Ferran
Quoted 22 lines
Thanks for your work. I'm still reading... but...
El Sun, Nov 05, 2023 at 09:25:46PM -0500, Sean Anderson deia:
include/spl.h struct spl_load_info { · line 301
Quoted 12 lines
include/spl.h +2
-2@@ -297,10 +297,10 @@ struct spl_load_info {* read() - Read from device * * @load: Information about the load state -* @sector: Sector number to read from (each @load->bl_len bytes) -* @count: Number of sectors to read +* @offset: Offset to read from in bytes, in multiples of @load->bl_len +* @count: Number of bytes to read, in multiples of @load->bl_len I'm no native English speaker, but would it be easier to understand? :
Review
Quoted 2 lines
(quoted diff) +2
-0+ * @offset: Offset to read from in bytes, a multiple of @load->bl_len + * @count: Number of bytes to read, a multiple of @load->bl_lenI think it would have to be worded
Quoted 5 lines
@offset: Offset to read from in bytes, as a multiple of @load->bl_len
but to me these both mean the same thing.
--Sean
Ah, OK. I doubted on whether it should be a comma or "as". Apparently it was both.
They may mean the same, but I got confused by having "in bytes", and "in multiples" so close.
"in bytes" means the value should be the correct answer to the question "how many bytes" (not a number of bits, not a number of sectors)
but "in multiples of..." doesn't mean the value should be the correct answer to "how many of multiples". Should the value be a number of sectors (first multiple of bl_len) a number of dozens of sectors (another multiple of bl_len) or ...?
In the first part "in" introduces a unit of measure, but in the second the same word introduces a constraint on a value. That was confusing to me.
Not saying it doesn't mean the same or even that you should change it, just elaborating why I said it.
Re: [PATCH v6 08/25] spl: Refactor spl_load_info->read to use units of bytes
Quoted 50 lines · Xavier Drudis Ferran
El Mon, Nov 06, 2023 at 08:54:03AM -0500, Sean Anderson deia:
Quoted 28 lines · Xavier Drudis Ferran
Quoted 22 lines
Thanks for your work. I'm still reading... but...
El Sun, Nov 05, 2023 at 09:25:46PM -0500, Sean Anderson deia:
include/spl.h struct spl_load_info { · line 301
Quoted 12 lines
include/spl.h +2
-2@@ -297,10 +297,10 @@ struct spl_load_info {* read() - Read from device * * @load: Information about the load state -* @sector: Sector number to read from (each @load->bl_len bytes) -* @count: Number of sectors to read +* @offset: Offset to read from in bytes, in multiples of @load->bl_len +* @count: Number of bytes to read, in multiples of @load->bl_len I'm no native English speaker, but would it be easier to understand? :
Review
Quoted 2 lines
(quoted diff) +2
-0+ * @offset: Offset to read from in bytes, a multiple of @load->bl_len + * @count: Number of bytes to read, a multiple of @load->bl_lenI think it would have to be worded
Quoted 5 lines
@offset: Offset to read from in bytes, as a multiple of @load->bl_len
but to me these both mean the same thing.
--Sean
Ah, OK. I doubted on whether it should be a comma or "as". Apparently it was both.
They may mean the same, but I got confused by having "in bytes", and "in multiples" so close.
"in bytes" means the value should be the correct answer to the question "how many bytes" (not a number of bits, not a number of sectors)
but "in multiples of..." doesn't mean the value should be the correct answer to "how many of multiples". Should the value be a number of sectors (first multiple of
bl_len) a number of dozens of sectors (another multiple ofbl_len) or ...?
Quoted 7 lines
In the first part "in" introduces a unit of measure, but in the second the same word introduces a constraint on a value. That was confusing to me.
Not saying it doesn't mean the same or even that you should change it, just elaborating why I said it.
OK, what about
@offset: Offset to read from in bytes. This must be a multiple of @load->bl_len.
--Sean
Re: [PATCH v6 08/25] spl: Refactor spl_load_info->read to use units of bytes
El Wed, Nov 08, 2023 at 10:59:13AM -0500, Sean Anderson deia:
Quoted 6 lines
OK, what about
@offset: Offset to read from in bytes. This must be a multiple of @load->bl_len.
--Sean
Great. Thank you.
PATCH v6 9/25 spl: Remove filename from spl_load_info
In reply to Sean AndersonFor filesystems, filename serves the same purpose as priv. However, spl_load_fit_image also uses it to determine whether to use a DMA-aligned buffer. This is beneficial for FAT, which uses a bounce-buffer if the destination is not DMA-aligned. Remove this logic, and instead achieve it by setting bl_len to ARCH_DMA_MINALIGN. With this done, we can remove filename entirely.
One wrinkle bears mentioning: because filesystems are not block-based, we may read less than the size passed to spl_load_info.read. This can happen if the file size is not DMA-aligned. This is fine as long as we read the amount we originally wanted to. Modify the conditions for callers of spl_load_info.read to check against the original, unaligned size to avoid failing spuriously.
---
Changes in v6:
- New
arch/arm/mach-sunxi/spl_spi_sunxi.c | 1 - common/spl/spl_blk_fs.c | 10 ++++++---- common/spl/spl_fat.c | 6 +++--- common/spl/spl_fit.c | 23 +---------------------- common/spl/spl_imx_container.c | 8 +++++--- common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 3 --- common/spl/spl_semihosting.c | 1 - common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - include/spl.h | 2 -- test/image/spl_load_os.c | 1 - 12 files changed, 15 insertions(+), 45 deletions(-)
arch/arm/mach-sunxi/spl_spi_sunxi.c +0 -1
@@ -354,7 +354,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT image\n" ); - load.filename =NULL ; load.bl_len =1 ; load.read = spi_load_read; ret = spl_load_simple_fit(spl_image, &load,
common/spl/spl_blk_fs.c +6 -4
@@ -9,10 +9,12 @@#include <spl.h> #include <image.h> #include <fs.h> +#include <asm/cache.h> #include <asm/io.h> struct blk_dev {const char *ifname; +const char *filename;char dev_part_str[8 ]; };
@@ -30,11 +32,11 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,return ret; } - ret =fs_read (load->filename,virt_to_phys (buf), file_offset, size, + ret =fs_read (dev->filename,virt_to_phys (buf), file_offset, size, &actlen);if (ret <0 ) {printf ("spl: error reading image %s. Err - %d\n" , - load->filename, ret); + dev->filename, ret);return ret; }
@@ -85,9 +87,9 @@ int spl_blk_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = spl_fit_read; - load.bl_len =1 ; - load.filename = (void *)filename; + load.bl_len =ARCH_DMA_MINALIGN ; load.priv = &dev; + dev.filename = filename;return spl_load_simple_fit (spl_image, &load,0 , header); }
common/spl/spl_fat.c +3 -3
@@ -51,7 +51,7 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, {loff_t actread;int ret; -char *filename = (char *)load->filename; +char *filename = load->priv; ret =fat_read_file (filename, buf, file_offset, size, &actread);if (ret)
@@ -97,8 +97,8 @@ int spl_load_image_fat(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = spl_fit_read; - load.bl_len =1 ; - load.filename = (void *)filename; + load.bl_len =ARCH_DMA_MINALIGN ; + load.priv = (void *)filename;return spl_load_simple_fit (spl_image, &load,0 , header); }else {
common/spl/spl_fit.c +1 -22
@@ -14,7 +14,6 @@#include <mapmem.h> #include <spl.h> #include <sysinfo.h> -#include <asm/cache.h> #include <asm/global_data.h> #include <asm/io.h> #include <linux/libfdt.h>
@@ -172,28 +171,11 @@ static int spl_fit_get_image_node(const struct spl_fit_info *ctx,static int get_aligned_image_offset (struct spl_load_info *info,int offset) { -/* -* If it is a FS read, get the first address before offset which is -* aligned to ARCH_DMA_MINALIGN. If it is raw read return the -* block number to which offset belongs. -*/ -if (info->filename) -return offset & ~(ARCH_DMA_MINALIGN -1 ); -return ALIGN_DOWN (offset, info->bl_len); }static int get_aligned_image_overhead (struct spl_load_info *info,int offset) { -/* -* If it is a FS read, get the difference between the offset and -* the first address before offset which is aligned to -* ARCH_DMA_MINALIGN. If it is raw read return the offset within the -* block. -*/ -if (info->filename) -return offset & (ARCH_DMA_MINALIGN -1 ); -return offset & (info->bl_len -1 ); }
@@ -202,9 +184,6 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, { data_size = data_size +get_aligned_image_overhead (info, offset); -if (info->filename) -return data_size; -return ALIGN (data_size, info->bl_len); }
@@ -295,7 +274,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,if (info->read (info, fit_offset +get_aligned_image_offset (info, offset), size, - src_ptr) != size) + src_ptr) < length)return -EIO ; debug("External data: dst=%p, offset=%x, size=%lx\n",
common/spl/spl_imx_container.c +5 -3
@@ -45,7 +45,8 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image, container, offset, size);if (info->read (info, offset, size,map_sysmem (images[image_index].dst - overhead, - images[image_index].size)) != size) { + images[image_index].size)) < + images[image_index].size) {printf ("%s wrong\n" , __func__);return NULL ; }
@@ -77,7 +78,8 @@ static int read_auth_container(struct spl_image_info *spl_image,debug ("%s: container: %p offset: %lu size: %u\n" , __func__, container, offset, size); -if (info->read (info, offset, size, container) != size) { +if (info->read (info, offset, size, container) < +CONTAINER_HDR_ALIGNMENT ) { ret = -EIO ; goto end; }
@@ -107,7 +109,7 @@ static int read_auth_container(struct spl_image_info *spl_image,debug ("%s: container: %p offset: %lu size: %u\n" , __func__, container, offset, size); -if (info->read (info, offset, size, container) != size) { +if (info->read (info, offset, size, container) < length) { ret = -EIO ; goto end; }
common/spl/spl_mmc.c +0 -2
@@ -108,7 +108,6 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = bd; - load.filename =NULL ; load.bl_len = bd->blksz; load.read = h_spl_load_read; ret = spl_load_simple_fit(spl_image, &load,
@@ -118,7 +117,6 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = bd; - load.filename =NULL ; load.bl_len = bd->blksz; load.read = h_spl_load_read;
common/spl/spl_nand.c +0 -3
@@ -90,7 +90,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = &offset; - load.filename =NULL ; load.bl_len = bl_len; load.read = spl_nand_fit_read;return spl_load_simple_fit (spl_image, &load, offset, header);
@@ -99,7 +98,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = &offset; - load.filename =NULL ; load.bl_len = bl_len; load.read = spl_nand_fit_read;return spl_load_imx_container (spl_image, &load, offset);
@@ -108,7 +106,6 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found legacy image\n" ); - load.filename =NULL ; load.bl_len =IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ; load.read = spl_nand_legacy_read;
common/spl/spl_semihosting.c +0 -1
@@ -69,7 +69,6 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = smh_fit_read; load.bl_len =1 ; - load.filename =NULL ; load.priv = &fd; ret =spl_load_simple_fit (spl_image, &load,0 , header);
common/spl/spl_spi.c +0 -2
@@ -152,7 +152,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = flash; - load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read; err = spl_load_simple_fit(spl_image, &load,
@@ -163,7 +162,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = flash; - load.filename =NULL ; load.bl_len =1 ; load.read = spl_spi_fit_read;
common/spl/spl_ymodem.c +0 -1
@@ -135,7 +135,6 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = (void *)&info; - load.filename =NULL ; load.bl_len =1 ; info.buf = buf; info.image_read =BUF_SIZE ;
include/spl.h +0 -2
@@ -287,12 +287,10 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info)* * @priv: Private data for the device * @bl_len: Block length for reading in bytes -* @filename: Name of the fit image file. * @read: Function to call to read from the device */ struct spl_load_info {void *priv; -const char *filename;/** * read() - Read from device *
test/image/spl_load_os.c +0 -1
@@ -57,7 +57,6 @@ static int spl_test_load(struct unit_test_state *uts) ret =sandbox_find_next_phase (fname,sizeof (fname), true);if (ret)ut_assertf (0 ,"%s not found, error %d\n" , fname, ret); - load.filename = fname; header =spl_get_load_buffer (-sizeof (*header),sizeof (*header));
Signature · 1 line
2.37.1
Re: [PATCH v6 09/25] spl: Remove filename from spl_load_info
Quoted 21 lines · Sean Anderson
For filesystems, filename serves the same purpose as priv. However,
spl_load_fit_imagealso uses it to determine whether to use a DMA-aligned buffer. This is beneficial for FAT, which uses a bounce-buffer if the destination is not DMA-aligned. Remove this logic, and instead achieve it by settingbl_lentoARCH_DMA_MINALIGN. With this done, we can remove filename entirely.One wrinkle bears mentioning: because filesystems are not block-based, we may read less than the size passed to spl_load_info.read. This can happen if the file size is not DMA-aligned. This is fine as long as we read the amount we originally wanted to. Modify the conditions for callers of spl_load_info.read to check against the original, unaligned size to avoid failing spuriously.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- New
Quoted 13 lines
arch/arm/mach-sunxi/spl_spi_sunxi.c | 1 - common/spl/spl_blk_fs.c | 10 ++++++---- common/spl/spl_fat.c | 6 +++--- common/spl/spl_fit.c | 23 +---------------------- common/spl/spl_imx_container.c | 8 +++++--- common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 3 --- common/spl/spl_semihosting.c | 1 - common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - include/spl.h | 2 -- test/image/spl_load_os.c | 1 - 12 files changed, 15 insertions(+), 45 deletions(-)
Er, I think
but I wonder if this patch could be split?
Re: [PATCH v6 09/25] spl: Remove filename from spl_load_info
Quoted 36 lines · Simon Glass
Quoted 21 lines · Sean Anderson
For filesystems, filename serves the same purpose as priv. However,
spl_load_fit_imagealso uses it to determine whether to use a DMA-aligned buffer. This is beneficial for FAT, which uses a bounce-buffer if the destination is not DMA-aligned. Remove this logic, and instead achieve it by settingbl_lentoARCH_DMA_MINALIGN. With this done, we can remove filename entirely.One wrinkle bears mentioning: because filesystems are not block-based, we may read less than the size passed to spl_load_info.read. This can happen if the file size is not DMA-aligned. This is fine as long as we read the amount we originally wanted to. Modify the conditions for callers of spl_load_info.read to check against the original, unaligned size to avoid failing spuriously.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- NewQuoted 13 lines
arch/arm/mach-sunxi/spl_spi_sunxi.c | 1 - common/spl/spl_blk_fs.c | 10 ++++++---- common/spl/spl_fat.c | 6 +++--- common/spl/spl_fit.c | 23 +---------------------- common/spl/spl_imx_container.c | 8 +++++--- common/spl/spl_mmc.c | 2 -- common/spl/spl_nand.c | 3 --- common/spl/spl_semihosting.c | 1 - common/spl/spl_spi.c | 2 -- common/spl/spl_ymodem.c | 1 - include/spl.h | 2 -- test/image/spl_load_os.c | 1 - 12 files changed, 15 insertions(+), 45 deletions(-)
Quoted 5 lines
Er, I think
Reviewed-by Simon Glass <[email protected]>but I wonder if this patch could be split?
Into the filesystem bl_len stuff and the removal of filename? Yeah, probably.
--Sean
PATCH v6 10/25 spl: Only support bl_len when we have to
In reply to Sean AndersonAligning addresses and sizes causes overhead which is unnecessary when we are not loading from block devices. Remove bl_len when it is not needed.
For example, on iot2050 we save 144 bytes with this patch (once the rest of this series is applied):
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-144 (-144)
Function old new delta spl_load_simple_fit 920 904 -16 load_simple_fit 496 444 -52 spl_spi_load_image 384 308 -76
Total: Before=87431, After=87287, chg -0.16%
We use panic() instead of BUILD_BUG_ON in spl_set_bl_len because we still need to be able to compile it for things like mmc_load_image_raw_sector, even if that function will not be used.
---
Changes in v6:
- New
arch/arm/mach-imx/spl_imx_romapi.c | 8 ++++---- arch/arm/mach-sunxi/spl_spi_sunxi.c | 2 +- common/spl/Kconfig | 14 +++++++++++++- common/spl/spl_blk_fs.c | 2 +- common/spl/spl_fat.c | 2 +- common/spl/spl_fit.c | 6 +++--- common/spl/spl_imx_container.c | 10 +++++----- common/spl/spl_legacy.c | 4 ++-- common/spl/spl_mmc.c | 4 ++-- common/spl/spl_nand.c | 6 +++--- common/spl/spl_net.c | 2 +- common/spl/spl_nor.c | 8 ++++---- common/spl/spl_ram.c | 2 +- common/spl/spl_semihosting.c | 2 +- common/spl/spl_spi.c | 4 ++-- common/spl/spl_ymodem.c | 2 +- drivers/usb/gadget/f_sdp.c | 4 ++-- include/spl.h | 25 +++++++++++++++++++++++++ test/image/Kconfig | 1 + test/image/spl_load.c | 9 ++++----- test/image/spl_load_os.c | 2 +- 21 files changed, 78 insertions(+), 41 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +4 -4
@@ -101,7 +101,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,struct spl_load_info load;memset (&load,0 ,sizeof (load)); - load.bl_len = pagesize; +spl_set_bl_len (&load, pagesize); load.read = spl_romapi_read_seekable;return spl_load_simple_fit (spl_image, &load, offset, header); } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
@@ -109,7 +109,7 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,struct spl_load_info load;memset (&load,0 ,sizeof (load)); - load.bl_len = pagesize; +spl_set_bl_len (&load, pagesize); load.read = spl_romapi_read_seekable; ret =spl_load_imx_container (spl_image, &load, offset);
@@ -334,7 +334,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, ss.pagesize = pagesize;memset (&load,0 ,sizeof (load)); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_romapi_read_stream; load.priv = &ss;
@@ -358,7 +358,7 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image,printf ("ROM download failure %d\n" , imagesize);memset (&load,0 ,sizeof (load)); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_ram_load_read;if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ))
arch/arm/mach-sunxi/spl_spi_sunxi.c +1 -1
@@ -354,7 +354,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT image\n" ); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spi_load_read; ret =spl_load_simple_fit (spl_image, &load, load_offset, header);
common/spl/Kconfig +13 -1
@@ -280,8 +280,15 @@ config SPL_BOARD_INIT spl_board_init() from board_init_r(). This function should be provided by the board. +config SPL_LOAD_BLOCK + bool + help + Support loading images from block devices. This adds a bl_len member + to struct spl_load_info. + config SPL_BOOTROM_SUPPORT bool "Support returning to the BOOTROM" + select SPL_LOAD_BLOCK if MACH_IMX help Some platforms (e.g. the Rockchip RK3368) provide support in their ROM for loading the next boot-stage after performing basic setup
@@ -482,6 +489,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR ARCH_AT91 || ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \ OMAP44XX || OMAP54XX || AM33XX || AM43XX || \ TARGET_SIFIVE_UNLEASHED || TARGET_SIFIVE_UNMATCHED + select SPL_LOAD_BLOCK if SPL_MMC help Use sector number for specifying U-Boot location on MMC/SD in raw mode.
@@ -518,6 +526,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" + select SPL_LOAD_BLOCK if SPL_MMC help Use a partition for loading U-Boot when using MMC/SD in raw mode.
@@ -678,6 +687,7 @@ config SPL_FS_SQUASHFS config SPL_FS_FAT bool "Support FAT filesystems" select FS_FAT + select SPL_LOAD_BLOCK help Enable support for FAT and VFAT filesystems with SPL. This permits U-Boot (or Linux in Falcon mode) to be loaded from a FAT
@@ -877,6 +887,7 @@ config SPL_MUSB_NEW config SPL_NAND_SUPPORT bool "Support NAND flash" + select SPL_LOAD_BLOCK help Enable support for NAND (Negative AND) flash in SPL. NAND flash can be used to allow SPL to load U-Boot from supported devices.
@@ -1102,6 +1113,7 @@ config SYS_OS_BASE config SPL_FALCON_BOOT_MMCSD bool "Enable Falcon boot from MMC or SD media" depends on SPL_OS_BOOT && SPL_MMC + select SPL_LOAD_BLOCK help Select this if the Falcon mode OS image mode is on MMC or SD media.
@@ -1260,9 +1272,9 @@ config SPL_SATA_RAW_U_BOOT_SECTOR config SPL_NVME bool "NVM Express device support" depends on BLK - select HAVE_BLOCK_DEVICE select FS_LOADER select SPL_BLK_FS + select SPL_LOAD_BLOCK help This option enables support for NVM Express devices. It supports basic functions of NVMe (read/write).
common/spl/spl_blk_fs.c +1 -1
@@ -87,7 +87,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = spl_fit_read; - load.bl_len =ARCH_DMA_MINALIGN ; +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); load.priv = &dev; dev.filename = filename;
common/spl/spl_fat.c +1 -1
@@ -97,7 +97,7 @@ int spl_load_image_fat(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = spl_fit_read; - load.bl_len =ARCH_DMA_MINALIGN ; +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); load.priv = (void *)filename;return spl_load_simple_fit (spl_image, &load,0 , header);
common/spl/spl_fit.c +3 -3
@@ -171,12 +171,12 @@ static int spl_fit_get_image_node(const struct spl_fit_info *ctx,static int get_aligned_image_offset (struct spl_load_info *info,int offset) { -return ALIGN_DOWN (offset, info->bl_len); +return ALIGN_DOWN (offset,spl_get_bl_len (info)); }static int get_aligned_image_overhead (struct spl_load_info *info,int offset) { -return offset & (info->bl_len -1 ); +return offset & (spl_get_bl_len (info) -1 ); } static int get_aligned_image_size(struct spl_load_info *info, int data_size,
@@ -184,7 +184,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, { data_size = data_size +get_aligned_image_overhead (info, offset); -return ALIGN (data_size, info->bl_len); +return ALIGN (data_size,spl_get_bl_len (info)); }/**
common/spl/spl_imx_container.c +5 -5
@@ -32,13 +32,13 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image, images = (struct boot_img_t *)((u8 *)container +sizeof (struct container_hdr )); -if (!IS_ALIGNED (images[image_index].offset, info->bl_len)) { +if (!IS_ALIGNED (images[image_index].offset,spl_get_bl_len (info))) {printf ("%s: image%d offset not aligned to %u\n" , - __func__, image_index, info->bl_len); + __func__, image_index,spl_get_bl_len (info));return NULL ; } - size =ALIGN (images[image_index].size, info->bl_len); + size =ALIGN (images[image_index].size,spl_get_bl_len (info)); offset = images[image_index].offset + container_offset; debug("%s: container: %p offset: %lu size: %lu\n", __func__,
@@ -66,7 +66,7 @@ static int read_auth_container(struct spl_image_info *spl_image,u16 length;int i, size, ret =0 ; - size =ALIGN (CONTAINER_HDR_ALIGNMENT , info->bl_len); + size =ALIGN (CONTAINER_HDR_ALIGNMENT ,spl_get_bl_len (info));/* * It will not override the ATF code, so safe to use it here,
@@ -100,7 +100,7 @@ static int read_auth_container(struct spl_image_info *spl_image,debug ("Container length %u\n" , length);if (length >CONTAINER_HDR_ALIGNMENT ) { - size =ALIGN (length, info->bl_len); + size =ALIGN (length,spl_get_bl_len (info));free (container); container =malloc (size);
common/spl/spl_legacy.c +2 -2
@@ -139,9 +139,9 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, lzma_len =LZMA_LEN ;/* dataptr points to compressed payload */ - dataptr =ALIGN_DOWN (sizeof (*hdr), load->bl_len); + dataptr =ALIGN_DOWN (sizeof (*hdr),spl_get_bl_len (load)); overhead =sizeof (*hdr) - dataptr; - size =ALIGN (spl_image->size + overhead, load->bl_len); + size =ALIGN (spl_image->size + overhead,spl_get_bl_len (load)); dataptr += offset; debug("LZMA: Decompressing %08lx to %08lx\n",
common/spl/spl_mmc.c +2 -2
@@ -108,7 +108,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = bd; - load.bl_len = bd->blksz; +spl_set_bl_len (&load, bd->blksz); load.read = h_spl_load_read; ret =spl_load_simple_fit (spl_image, &load, sector << bd->log2blksz, header);
@@ -117,7 +117,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = bd; - load.bl_len = bd->blksz; +spl_set_bl_len (&load, bd->blksz); load.read = h_spl_load_read; ret = spl_load_imx_container(spl_image, &load,
common/spl/spl_nand.c +3 -3
@@ -90,7 +90,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = &offset; - load.bl_len = bl_len; +spl_set_bl_len (&load, bl_len); load.read = spl_nand_fit_read;return spl_load_simple_fit (spl_image, &load, offset, header); } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
@@ -98,7 +98,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = &offset; - load.bl_len = bl_len; +spl_set_bl_len (&load, bl_len); load.read = spl_nand_fit_read;return spl_load_imx_container (spl_image, &load, offset); } else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) &&
@@ -106,7 +106,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found legacy image\n" ); - load.bl_len =IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ; +spl_set_bl_len (&load,IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ); load.read = spl_nand_legacy_read;return spl_load_legacy_img (spl_image, bootdev, &load, offset, header);
common/spl/spl_net.c +1 -1
@@ -54,7 +54,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_net_load_read; rv =spl_load_simple_fit (spl_image, &load,0 , header); }else {
common/spl/spl_nor.c +4 -4
@@ -49,7 +49,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,int ret;debug ("Found FIT\n" ); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_nor_load_read; ret = spl_load_simple_fit(spl_image, &load,
@@ -97,7 +97,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,#ifdef CONFIG_SPL_LOAD_FIT if (image_get_magic (header) ==FDT_MAGIC ) {debug ("Found FIT format U-Boot\n" ); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_nor_load_read; return spl_load_simple_fit(spl_image, &load, spl_nor_get_uboot_base(),
@@ -106,7 +106,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,#endif if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) &&valid_container_hdr ((void *)header)) { - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_nor_load_read;return spl_load_imx_container (spl_image, &load,spl_nor_get_uboot_base ());
@@ -114,7 +114,7 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,/* Legacy image handling */ if (IS_ENABLED (CONFIG_SPL_LEGACY_IMAGE_FORMAT )) { - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_nor_load_read; return spl_load_legacy_img(spl_image, bootdev, &load, spl_nor_get_uboot_base(),
common/spl/spl_ram.c +1 -1
@@ -70,7 +70,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,struct spl_load_info load;debug ("Found FIT\n" ); - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_ram_load_read; ret =spl_load_simple_fit (spl_image, &load,0 , header); }else {
common/spl/spl_semihosting.c +1 -1
@@ -68,7 +68,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.read = smh_fit_read; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.priv = &fd; ret =spl_load_simple_fit (spl_image, &load,0 , header);
common/spl/spl_spi.c +2 -2
@@ -152,7 +152,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = flash; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_spi_fit_read; err = spl_load_simple_fit(spl_image, &load, payload_offs,
@@ -162,7 +162,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = flash; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = spl_spi_fit_read; err = spl_load_imx_container(spl_image, &load,
common/spl/spl_ymodem.c +1 -1
@@ -135,7 +135,7 @@ int spl_ymodem_load_image(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = (void *)&info; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); info.buf = buf; info.image_read =BUF_SIZE ; load.read = ymodem_read_fit;
drivers/usb/gadget/f_sdp.c +2 -2
@@ -845,7 +845,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = header; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = sdp_load_read;spl_load_simple_fit (spl_image, &load,0 , header);
@@ -858,7 +858,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image,struct spl_load_info load; load.priv = header; - load.bl_len =1 ; +spl_set_bl_len (&load,1 ); load.read = sdp_load_read;spl_load_imx_container (spl_image, &load,0 );return SDP_EXIT ;
include/spl.h +25 -0
@@ -302,9 +302,34 @@ struct spl_load_info {*/ ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf); +#if IS_ENABLED (CONFIG_SPL_LOAD_BLOCK ) int bl_len; }; +static inline int spl_get_bl_len (struct spl_load_info *info) +{ +return info->bl_len; +} + +static inline void spl_set_bl_len (struct spl_load_info *info,int bl_len) +{ + info->bl_len = bl_len; +} +#else +}; + +static inline int spl_get_bl_len (struct spl_load_info *info) +{ +return 1 ; +} + +static inline void spl_set_bl_len (struct spl_load_info *info,int bl_len) +{ +if (bl_len !=1 ) +panic ("CONFIG_SPL_LOAD_BLOCK not enabled" ); +} +#endif +/* * We need to know the position of U-Boot in memory so we can jump to it. We * allow any U-Boot binary to be used (u-boot.bin, u-boot-nodtb.bin,
test/image/Kconfig +1 -0
@@ -52,6 +52,7 @@ config SPL_UT_LOAD_SPI config SPL_UT_LOAD_OS bool "Test loading from the host OS" depends on SANDBOX && SPL_LOAD_FIT + select SPL_LOAD_BLOCK default y help Smoke test to ensure that loading U-boot works in sandbox.
test/image/spl_load.c +4 -5
@@ -342,12 +342,11 @@ static int spl_test_image(struct unit_test_state *uts, const char *test_name,if (check_image_info (uts, &info_write, &info_read))return CMD_RET_FAILURE ; }else { -struct spl_load_info load = { - .bl_len =1 , - .priv = img, - .read = spl_test_read, - }; +struct spl_load_info load; +spl_set_bl_len (&load,1 ); + load.priv = img; + load.read = spl_test_read;if (type ==IMX8 )ut_assertok (spl_load_imx_container (&info_read, &load,0 ));
test/image/spl_load_os.c +1 -1
@@ -51,7 +51,7 @@ static int spl_test_load(struct unit_test_state *uts)int fd;memset (&load,'\0' ,sizeof (load)); - load.bl_len =512 ; +spl_set_bl_len (&load,512 ); load.read = read_fit_image; ret =sandbox_find_next_phase (fname,sizeof (fname), true);
Signature · 1 line
2.37.1
Re: [PATCH v6 10/25] spl: Only support bl_len when we have to
Quoted 38 lines · Sean Anderson
Aligning addresses and sizes causes overhead which is unnecessary when we are not loading from block devices. Remove
bl_lenwhen it is not needed.For example, on iot2050 we save 144 bytes with this patch (once the rest of this series is applied):
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-144 (-144)
Function old new delta spl_load_simple_fit 920 904 -16 load_simple_fit 496 444 -52 spl_spi_load_image 384 308 -76Total: Before=87431, After=87287, chg -0.16%
We use
panic()instead ofBUILD_BUG_ONinspl_set_bl_lenbecause we still need to be able to compile it for things likemmc_load_image_raw_sector, even if that function will not be used.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Newarch/arm/mach-imx/spl_imx_romapi.c | 8 ++++---- arch/arm/mach-sunxi/spl_spi_sunxi.c | 2 +- common/spl/Kconfig | 14 +++++++++++++- common/spl/spl_blk_fs.c | 2 +- common/spl/spl_fat.c | 2 +- common/spl/spl_fit.c | 6 +++--- common/spl/spl_imx_container.c | 10 +++++----- common/spl/spl_legacy.c | 4 ++-- common/spl/spl_mmc.c | 4 ++-- common/spl/spl_nand.c | 6 +++--- common/spl/spl_net.c | 2 +- common/spl/spl_nor.c | 8 ++++---- common/spl/spl_ram.c | 2 +- common/spl/spl_semihosting.c | 2 +-
Quoted 9 lines
common/spl/spl_spi.c | 4 ++-- common/spl/spl_ymodem.c | 2 +- drivers/usb/gadget/f_sdp.c | 4 ++-- include/spl.h | 25 +++++++++++++++++++++++++ test/image/Kconfig | 1 + test/image/spl_load.c | 9 ++++----- test/image/spl_load_os.c | 2 +- 21 files changed, 78 insertions(+), 41 deletions(-)
PATCH v6 11/25 spl: nand: Remove spl_nand_legacy_read
In reply to Sean AndersonNow that spl_nand_fit_read works in units of bytes, it can be combined with spl_nand_legacy_read. Rename the resulting function spl_nand_read, since it is no longer FIT-specific.
---
Changes in v6:
- New
common/spl/spl_nand.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
common/spl/spl_nand.c +13 -20
@@ -42,29 +42,22 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, }#else -static ulong spl_nand_fit_read (struct spl_load_info *load,ulong offs, -ulong size,void *dst) +__weak u32 nand_spl_adjust_offset (u32 sector,u32 offs) +{ +return offs; +} + +static ulong spl_nand_read (struct spl_load_info *load,ulong offs,ulong size, +void *dst) {int err;ulong sector; - sector = *(int *)load->priv; - offs = sector +nand_spl_adjust_offset (sector, offs - sector); - err =nand_spl_load_image (offs, size, dst); -if (err) -return 0 ; - -return size; -} - -static ulong spl_nand_legacy_read (struct spl_load_info *load,ulong offs, -ulong size,void *dst) -{ -int err; -debug ("%s: offs %lx, size %lx, dst %p\n" , __func__, offs, size, dst); + sector = *(int *)load->priv; + offs = sector +nand_spl_adjust_offset (sector, offs - sector); err =nand_spl_load_image (offs, size, dst);if (err)return 0 ;
@@ -91,7 +84,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,debug ("Found FIT\n" ); load.priv = &offset;spl_set_bl_len (&load, bl_len); - load.read = spl_nand_fit_read; + load.read = spl_nand_read;return spl_load_simple_fit (spl_image, &load, offset, header); }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) &&valid_container_hdr ((void *)header)) {
@@ -99,16 +92,16 @@ static int spl_nand_load_element(struct spl_image_info *spl_image, load.priv = &offset;spl_set_bl_len (&load, bl_len); - load.read = spl_nand_fit_read; + load.read = spl_nand_read;return spl_load_imx_container (spl_image, &load, offset); }else if (IS_ENABLED (CONFIG_SPL_LEGACY_IMAGE_FORMAT ) &&image_get_magic (header) ==IH_MAGIC ) {struct spl_load_info load;debug ("Found legacy image\n" ); + load.priv = &offset;spl_set_bl_len (&load,IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ); - load.read = spl_nand_legacy_read; - + load.read = spl_nand_read;return spl_load_legacy_img (spl_image, bootdev, &load, offset, header); }else { err =spl_parse_image_header (spl_image, bootdev, header);
Signature · 1 line
2.37.1
Re: [PATCH v6 11/25] spl: nand: Remove spl_nand_legacy_read
Quoted 5 lines · Sean Anderson
Now that
spl_nand_fit_readworks in units of bytes, it can be combined withspl_nand_legacy_read. Rename the resulting functionspl_nand_read, since it is no longer FIT-specific.
Quoted 8 lines
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Newcommon/spl/spl_nand.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
PATCH v6 12/25 spl: legacy: Split off LZMA decompression into its own function
In reply to Sean AndersonTo allow for easier reuse of this functionality, split it off into its own function.
---
Changes in v6:
- New
common/spl/spl_legacy.c | 73 ++++++++++++++++++++++------------------- include/spl.h | 13 ++++++++ 2 files changed, 52 insertions(+), 34 deletions(-)
common/spl/spl_legacy.c +39 -34
@@ -82,6 +82,43 @@ int spl_parse_legacy_header(struct spl_image_info *spl_image,return 0 ; } +int spl_load_legacy_lzma (struct spl_image_info *spl_image, +struct spl_load_info *load,ulong offset) +{ +SizeT lzma_len =LZMA_LEN ; +void *src; +ulong dataptr, overhead, size; +int ret; + +/* dataptr points to compressed payload */ + dataptr =ALIGN_DOWN (sizeof (struct legacy_img_hdr ), +spl_get_bl_len (load)); + overhead =sizeof (struct legacy_img_hdr ) - dataptr; + size =ALIGN (spl_image->size + overhead,spl_get_bl_len (load)); + dataptr += offset; + +debug ("LZMA: Decompressing %08lx to %08lx\n" , + dataptr, spl_image->load_addr); + src =malloc (size); +if (!src) { +printf ("Unable to allocate %d bytes for LZMA\n" , + spl_image->size); +return -ENOMEM ; + } + + load->read (load, dataptr, size, src); + ret =lzmaBuffToBuffDecompress (map_sysmem (spl_image->load_addr, + spl_image->size), &lzma_len, + src + overhead, spl_image->size); +if (ret) { +printf ("LZMA decompression error: %d\n" , ret); +return ret; + } + + spl_image->size = lzma_len; +return 0 ; +} +/* * This function is added explicitly to avoid code size increase, when * no compression method is enabled. The compiler will optimize the
@@ -101,8 +138,6 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, struct spl_load_info *load, ulong offset, struct legacy_img_hdr *hdr) { - __maybe_unused SizeT lzma_len; -__maybe_unused void *src; ulong dataptr;int ret;
@@ -133,39 +168,9 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, map_sysmem(spl_image->load_addr, spl_image->size));break ; -case IH_COMP_LZMA : { -ulong overhead, size; +case IH_COMP_LZMA : +return spl_load_legacy_lzma (spl_image, load, offset); - lzma_len =LZMA_LEN ; - -/* dataptr points to compressed payload */ - dataptr =ALIGN_DOWN (sizeof (*hdr),spl_get_bl_len (load)); - overhead =sizeof (*hdr) - dataptr; - size =ALIGN (spl_image->size + overhead,spl_get_bl_len (load)); - dataptr += offset; - -debug ("LZMA: Decompressing %08lx to %08lx\n" , - dataptr, spl_image->load_addr); - src =malloc (size); -if (!src) { -printf ("Unable to allocate %d bytes for LZMA\n" , - spl_image->size); -return -ENOMEM ; - } - - load->read (load, dataptr, size, src); - ret =lzmaBuffToBuffDecompress (map_sysmem (spl_image->load_addr, - spl_image->size), - &lzma_len, src + overhead, - spl_image->size); -if (ret) { -printf ("LZMA decompression error: %d\n" , ret); -return ret; - } - - spl_image->size = lzma_len; -break ; - }default :debug ("Compression method %s is not supported\n" ,genimg_get_comp_short_name (image_get_comp (hdr)));
include/spl.h +13 -0
@@ -405,6 +405,19 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,#define SPL_COPY_PAYLOAD_ONLY 1#define SPL_FIT_FOUND 2 +/** +* spl_load_legacy_lzma() - Load an LZMA-compressed legacy image +* @spl_image: Image description (already set up) +* @load: Structure containing the information required to load data. +* @offset: Pointer to image +* +* Load/decompress an LZMA-compressed legacy image from the device. +* +* Return: 0 on success, or a negative error on failure +*/ +int spl_load_legacy_lzma (struct spl_image_info *spl_image, +struct spl_load_info *load,ulong offset); +/** * spl_load_legacy_img() - Loads a legacy image from a device. * @spl_image: Image description to set up
Signature · 1 line
2.37.1
Re: [PATCH v6 12/25] spl: legacy: Split off LZMA decompression into its own function
Quoted 5 lines · Sean Anderson
To allow for easier reuse of this functionality, split it off into its own function.
Signed-off-by Sean Anderson <[email protected]>
Quoted 9 lines
---
Changes in v6:
- Newcommon/spl/spl_legacy.c | 73 ++++++++++++++++++++++------------------- include/spl.h | 13 ++++++++ 2 files changed, 52 insertions(+), 34 deletions(-)
PATCH v6 13/25 test: spl: Support testing LEGACY_LZMA filesystem images
In reply to Sean AndersonThese will soon be supported, so we need to be able to test it. Export the lzma data and generally use the same process in spl_test_mmc_fs as do_spl_test_load. If we end up needing this in third place in the future, it would probably be good to refactor things out.
---
Changes in v6:
- New
include/test/spl.h | 4 ++++ test/image/spl_load.c | 4 +++- test/image/spl_load_fs.c | 23 ++++++++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-)
include/test/spl.h +4 -0
@@ -81,6 +81,10 @@ size_t create_image(void *dst, enum spl_test_image type,int check_image_info (struct unit_test_state *uts,struct spl_image_info *info1,struct spl_image_info *info2); +/* Some compressed data and it size */ +extern const char lzma_compressed[]; +extern const size_t lzma_compressed_size; +/** * typedef write_image_t - Callback for writing an image * @uts: Current unit test state
test/image/spl_load.c +3 -1
@@ -374,7 +374,7 @@ SPL_IMG_TEST(spl_test_image, FIT_EXTERNAL, 0);* LZMA is too complex to generate on the fly, so let's use some data I put in * the oven^H^H^H^H compressed earlier */ -static const char lzma_compressed[] = { +const char lzma_compressed[] = {0x5d ,0x00 ,0x00 ,0x80 ,0x00 ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0xff ,0x00 ,0x02 ,0x05 ,0x55 ,0x4e ,0x82 ,0xbc ,0xc2 ,0x42 ,0xf6 ,0x88 ,0x6c ,0x99 ,0xd6 ,0x82 ,0x48 ,0xa6 ,0x06 ,0x67 ,0xf8 ,0x46 ,0x7c ,0xe9 ,
@@ -610,6 +610,8 @@ static const char lzma_compressed[] = { 0x1e, 0xff, 0xff, 0x80, 0x8e, 0x00, 0x00 }; +const size_t lzma_compressed_size =sizeof (lzma_compressed); +int do_spl_test_load (struct unit_test_state *uts,const char *test_name,enum spl_test_image type,struct spl_image_loader *loader,int (*write_image)(struct unit_test_state *,void *,size_t ))
test/image/spl_load_fs.c +18 -5
@@ -320,10 +320,11 @@ static int spl_test_mmc_fs(struct unit_test_state *uts, const char *test_name,const char *filename =CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ;struct blk_desc *dev_desc;size_t fs_size, fs_data, img_size, img_data, - data_size =SPL_TEST_DATA_SIZE ; + plain_size =SPL_TEST_DATA_SIZE ;struct spl_image_info info_write = { .name = test_name, - .size = data_size, + .size = type ==LEGACY_LZMA ? lzma_compressed_size : + plain_size, }, info_read = { };struct disk_partition part = { .start =1 ,
@@ -335,7 +336,7 @@ static int spl_test_mmc_fs(struct unit_test_state *uts, const char *test_name, .boot_device = loader->boot_device, };void *fs; -char *data; +char *data, *plain; img_size =create_image (NULL , type, &info_write, &img_data);ut_assert (img_size);
@@ -345,7 +346,15 @@ static int spl_test_mmc_fs(struct unit_test_state *uts, const char *test_name,ut_assertnonnull (fs); data = fs + fs_data + img_data; -generate_data (data, data_size, test_name); +if (type ==LEGACY_LZMA ) { + plain =malloc (plain_size); +ut_assertnonnull (plain); +generate_data (plain, plain_size,"lzma" ); +memcpy (data, lzma_compressed, lzma_compressed_size); + }else { + plain = data; +generate_data (plain, plain_size, test_name); + }ut_asserteq (img_size,create_image (fs + fs_data, type, &info_write,NULL ));ut_asserteq (fs_size,create_fs (fs, img_size, filename,NULL ));
@@ -366,8 +375,12 @@ static int spl_test_mmc_fs(struct unit_test_state *uts, const char *test_name,ut_assertok (loader->load_image (&info_read, &bootdev));if (check_image_info (uts, &info_write, &info_read))return CMD_RET_FAILURE ; -ut_asserteq_mem (data,phys_to_virt (info_write.load_addr), data_size); +if (type ==LEGACY_LZMA ) +ut_asserteq (plain_size, info_read.size); +ut_asserteq_mem (plain,phys_to_virt (info_write.load_addr), plain_size); +if (type ==LEGACY_LZMA ) +free (plain);free (fs);return 0 ; }
Signature · 1 line
2.37.1
Re: [PATCH v6 13/25] test: spl: Support testing LEGACY_LZMA filesystem images
Quoted 9 lines · Sean Anderson
These will soon be supported, so we need to be able to test it. Export the lzma data and generally use the same process in
spl_test_mmc_fsasdo_spl_test_load. If we end up needing this in third place in the future, it would probably be good to refactor things out.Signed-off-by Sean Anderson <[email protected]>---
Quoted 7 lines
Changes in v6:
- Newinclude/test/spl.h | 4 ++++ test/image/spl_load.c | 4 +++- test/image/spl_load_fs.c | 23 ++++++++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-)
PATCH v6 14/25 spl: Add generic spl_load function
In reply to Sean AndersonImplementers of SPL_LOAD_IMAGE_METHOD have to correctly determine what type of image is being loaded and then call the appropriate image load function correctly. This is tricky, because some image load functions expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL), some will load the image automatically using spl_load_info.read() (CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse the header and expect the caller to do the actual loading afterwards (legacy/raw images). Load methods often only support a subset of the above methods, meaning that not all image types can be used with all load methods. Further, the code to invoke these functions is duplicated between different load functions.
To address this problem, this commit introduces a "spl_load" function. It aims to handle image detection and correct invocation of each of the parse/load functions.
Although this function generally results in a size reduction with several users, it tends to bloat boards with only a single user. This is generally because programmers open-coding the contents of this function can make optimizations based on the specific loader. For example, NOR flash is memory-mapped, so it never bothers calling load->read. The compiler can't really make these optimizations across translation units. LTO solves this, but it is only available on some arches. To address this, perform "pseudo-LTO" by inlining spl_load when there are one or fewer users. At the moment, there are no users, so define SPL_LOAD_USERS to be 0.
---
Changes in v6:
- Use pseudo-LTO for spl_load
- Align reads to bl_len
Changes in v5:
- Load the header in spl_load as well
- Don't bother trying to DMA-align the buffer, since we can't really fix it.
Changes in v4:
- Fix format specifiers in debug prints
- Reword/fix some of the doc comments for spl_load
Changes in v3:
- Fix using ffs instead of fls
- Fix using not initializing bl_len when info->filename was NULL
Changes in v2:
- Use reverse-xmas-tree style for locals in spl_simple_read. This is not complete, since overhead depends on bl_mask.
common/spl/spl.c | 10 ++++ include/spl_load.h | 135 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 include/spl_load.h
common/spl/spl.c +10 -0
@@ -19,6 +19,7 @@#include <mapmem.h> #include <serial.h> #include <spl.h> +#include <spl_load.h> #include <system-constants.h> #include <asm/global_data.h> #include <asm-generic/gpio.h>
@@ -352,6 +353,15 @@ int spl_parse_image_header(struct spl_image_info *spl_image,return 0 ; } +#if SPL_LOAD_USERS >1 +int spl_load (struct spl_image_info *spl_image, +const struct spl_boot_device *bootdev,struct spl_load_info *info, +size_t size,size_t offset) +{ +return _spl_load (spl_image, bootdev, info, size, offset); +} +#endif +__weak void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image) {typedef void __noreturn (*image_entry_noargs_t )(void );
include/spl_load.h new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [PATCH v6 14/25] spl: Add generic spl_load function
Quoted 48 lines · Sean Anderson
Implementers of
SPL_LOAD_IMAGE_METHODhave to correctly determine what type of image is being loaded and then call the appropriate image load function correctly. This is tricky, because some image load functions expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL), some will load the image automatically usingspl_load_info.read()(CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse the header and expect the caller to do the actual loading afterwards (legacy/raw images). Load methods often only support a subset of the above methods, meaning that not all image types can be used with all load methods. Further, the code to invoke these functions is duplicated between different load functions.To address this problem, this commit introduces a "
spl_load" function. It aims to handle image detection and correct invocation of each of the parse/load functions.Although this function generally results in a size reduction with several users, it tends to bloat boards with only a single user. This is generally because programmers open-coding the contents of this function can make optimizations based on the specific loader. For example, NOR flash is memory-mapped, so it never bothers calling
load->read. The compiler can't really make these optimizations across translation units. LTO solves this, but it is only available on some arches. To address this, perform "pseudo-LTO" by inliningspl_loadwhen there are one or fewer users. At the moment, there are no users, so defineSPL_LOAD_USERSto be 0.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Use pseudo-LTO forspl_load
- Align reads tobl_lenChanges in v5:
- Load the header inspl_loadas well
- Don't bother trying to DMA-align the buffer, since we can't really fix it.Changes in v4:
- Fix format specifiers in debug prints
- Reword/fix some of the doc comments forspl_loadChanges in v3:
- Fix using ffs instead of fls
- Fix using not initializingbl_lenwheninfo->filenamewas NULL
Quoted 9 lines
Changes in v2:
- Use reverse-xmas-tree style for locals inspl_simple_read. This is not complete, since overhead depends onbl_mask.common/spl/spl.c | 10 ++++ include/spl_load.h | 135 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 include/spl_load.h
Definitely a lot of effort on code size!
PATCH v6 15/25 spl: Convert ext to use spl_load
In reply to Sean AndersonThis converts the ext load method to use spl_load. As a consequence, it also adds support for FIT and IMX images.
---
Changes in v6:
- Explicitly initialize load_info members
Changes in v5:
- Rework to load header in spl_load
common/spl/spl_ext.c | 36 ++++++++++++++++++------------------ include/spl_load.h | 1 + test/image/spl_load_fs.c | 9 ++++++--- 3 files changed, 25 insertions(+), 21 deletions(-)
common/spl/spl_ext.c +18 -18
@@ -2,25 +2,35 @@#include <common.h> #include <env.h> -#include <mapmem.h> #include <part.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <ext4fs.h> #include <errno.h> #include <image.h> +static ulong spl_fit_read (struct spl_load_info *load,ulong file_offset, +ulong size,void *buf) +{ +int ret; +loff_t actlen; + + ret =ext4fs_read (buf, file_offset, size, &actlen); +if (ret) +return ret; +return actlen; +} +int spl_load_image_ext (struct spl_image_info *spl_image,struct spl_boot_device *bootdev,struct blk_desc *block_dev,int partition,const char *filename) {s32 err; -struct legacy_img_hdr *header; -loff_t filelen, actlen; +loff_t filelen;struct disk_partition part_info = {}; - - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); +struct spl_load_info load;if (part_get_info (block_dev, partition, &part_info)) {printf ("spl: no partition table found\n" );
@@ -42,20 +52,10 @@ int spl_load_image_ext(struct spl_image_info *spl_image,puts ("spl: ext4fs_open failed\n" ); goto end; } - err =ext4fs_read ((char *)header,0 ,sizeof (struct legacy_img_hdr ), &actlen); -if (err <0 ) { -puts ("spl: ext4fs_read failed\n" ); - goto end; - } - err =spl_parse_image_header (spl_image, bootdev, header); -if (err <0 ) { -puts ("spl: ext: failed to parse image header\n" ); - goto end; - } - - err =ext4fs_read (map_sysmem (spl_image->load_addr, filelen),0 , filelen, - &actlen); +spl_set_bl_len (&load,1 ); + load.read = spl_fit_read; + err =spl_load (spl_image, bootdev, &load, filelen,0 ); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
include/spl_load.h +1 -0
@@ -95,6 +95,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,* inline if there is one caller, and extern otherwise. */ #define SPL_LOAD_USERS \ + IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_fs.c +6 -3
@@ -422,20 +422,23 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,spl_mmc_clear_cache ();spl_fat_force_reregister (); -if (type ==LEGACY && -spl_test_mmc_fs (uts, test_name, type, create_ext2, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && +if (type !=IMX8 && type !=LEGACY_LZMA &&spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ; +if (type ==LEGACY_LZMA ) +return 0 ; +return do_spl_test_load (uts, test_name, type,SPL_LOAD_IMAGE_GET (0 ,BOOT_DEVICE_MMC1 , spl_mmc_load_image), spl_test_mmc_write_image); }SPL_IMG_TEST (spl_test_mmc,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_mmc,LEGACY_LZMA ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_EXTERNAL ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_INTERNAL ,DM_FLAGS );
Signature · 1 line
2.37.1
Re: [PATCH v6 15/25] spl: Convert ext to use spl_load
Hi Sean,
Quoted 10 lines · Sean Anderson
This converts the ext load method to use
spl_load. As a consequence, it also adds support for FIT and IMX images.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Explicitly initializeload_infomembers
Quoted 7 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/spl_ext.c | 36 ++++++++++++++++++------------------ include/spl_load.h | 1 + test/image/spl_load_fs.c | 9 ++++++--- 3 files changed, 25 insertions(+), 21 deletions(-)
but nit below
Quoted 89 lines
common/spl/spl_ext.c +18
-18@@ -2,25 +2,35 @@#include <common.h> #include <env.h> -#include <mapmem.h> #include <part.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <ext4fs.h> #include <errno.h> #include <image.h> +static ulong spl_fit_read (struct spl_load_info *load,ulong file_offset, +ulong size,void *buf) +{ +int ret; +loff_t actlen; + + ret =ext4fs_read (buf, file_offset, size, &actlen); +if (ret) +return ret; +return actlen; +} +int spl_load_image_ext (struct spl_image_info *spl_image,struct spl_boot_device *bootdev,struct blk_desc *block_dev,int partition,const char *filename) {s32 err; -struct legacy_img_hdr *header; -loff_t filelen, actlen; +loff_t filelen;struct disk_partition part_info = {}; - - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); +struct spl_load_info load;if (part_get_info (block_dev, partition, &part_info)) {printf ("spl: no partition table found\n" );@@ -42,20 +52,10 @@ int spl_load_image_ext(struct spl_image_info *spl_image,puts ("spl: ext4fs_open failed\n" ); goto end; } - err =ext4fs_read ((char *)header,0 ,sizeof (struct legacy_img_hdr ), &actlen); -if (err <0 ) { -puts ("spl: ext4fs_read failed\n" ); - goto end; - } - err =spl_parse_image_header (spl_image, bootdev, header); -if (err <0 ) { -puts ("spl: ext: failed to parse image header\n" ); - goto end; - } - - err =ext4fs_read (map_sysmem (spl_image->load_addr, filelen),0 , filelen, - &actlen); +spl_set_bl_len (&load,1 ); + load.read = spl_fit_read; + err =spl_load (spl_image, bootdev, &load, filelen,0 ); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORTinclude/spl_load.h +1
-0@@ -95,6 +95,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,* inline if there is one caller, and extern otherwise. */ #define SPL_LOAD_USERS \ + IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ 0#if SPL_LOAD_USERS >1 test/image/spl_load_fs.c +0
-0@@ -422,20 +422,23 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,spl_mmc_clear_cache ();spl_fat_force_reregister ();
test/image/spl_load_fs.c static int spl_test_mmc(struct unit_test_state *uts, const char *test_name, · line 430
Quoted 10 lines
test/image/spl_load_fs.c +2
-3-if (type ==LEGACY && -spl_test_mmc_fs (uts, test_name, type, create_ext2, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && +if (type !=IMX8 && type !=LEGACY_LZMA &&spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ;
This is not a command.
How about:
if (type != IMX8 && type != LEGACY_LZMA &&
ut_assertok(spl_test_mmc_fs(...
Quoted 15 lines
test/image/spl_load_fs.c +4
-1+if (type ==LEGACY_LZMA ) +return 0 ; +return do_spl_test_load (uts, test_name, type,SPL_LOAD_IMAGE_GET (0 ,BOOT_DEVICE_MMC1 , spl_mmc_load_image), spl_test_mmc_write_image); }SPL_IMG_TEST (spl_test_mmc,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_mmc,LEGACY_LZMA ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_EXTERNAL ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_INTERNAL ,DM_FLAGS ); --
Quoted 2 lines
2.37.1
Regards,
Simon
Re: [PATCH v6 15/25] spl: Convert ext to use spl_load
Quoted 127 lines · Simon Glass
Hi Sean,
Quoted 10 lines · Sean Anderson
This converts the ext load method to use
spl_load. As a consequence, it also adds support for FIT and IMX images.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Explicitly initializeload_infomembersQuoted 7 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/spl_ext.c | 36 ++++++++++++++++++------------------ include/spl_load.h | 1 + test/image/spl_load_fs.c | 9 ++++++--- 3 files changed, 25 insertions(+), 21 deletions(-)Reviewed-by Simon Glass <[email protected]>but nit below
Quoted 89 lines
common/spl/spl_ext.c +18
-18@@ -2,25 +2,35 @@#include <common.h> #include <env.h> -#include <mapmem.h> #include <part.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <ext4fs.h> #include <errno.h> #include <image.h> +static ulong spl_fit_read (struct spl_load_info *load,ulong file_offset, +ulong size,void *buf) +{ +int ret; +loff_t actlen; + + ret =ext4fs_read (buf, file_offset, size, &actlen); +if (ret) +return ret; +return actlen; +} +int spl_load_image_ext (struct spl_image_info *spl_image,struct spl_boot_device *bootdev,struct blk_desc *block_dev,int partition,const char *filename) {s32 err; -struct legacy_img_hdr *header; -loff_t filelen, actlen; +loff_t filelen;struct disk_partition part_info = {}; - - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); +struct spl_load_info load;if (part_get_info (block_dev, partition, &part_info)) {printf ("spl: no partition table found\n" );@@ -42,20 +52,10 @@ int spl_load_image_ext(struct spl_image_info *spl_image,puts ("spl: ext4fs_open failed\n" ); goto end; } - err =ext4fs_read ((char *)header,0 ,sizeof (struct legacy_img_hdr ), &actlen); -if (err <0 ) { -puts ("spl: ext4fs_read failed\n" ); - goto end; - } - err =spl_parse_image_header (spl_image, bootdev, header); -if (err <0 ) { -puts ("spl: ext: failed to parse image header\n" ); - goto end; - } - - err =ext4fs_read (map_sysmem (spl_image->load_addr, filelen),0 , filelen, - &actlen); +spl_set_bl_len (&load,1 ); + load.read = spl_fit_read; + err =spl_load (spl_image, bootdev, &load, filelen,0 ); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORTinclude/spl_load.h +1
-0@@ -95,6 +95,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,* inline if there is one caller, and extern otherwise. */ #define SPL_LOAD_USERS \ + IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ 0#if SPL_LOAD_USERS >1 test/image/spl_load_fs.c +0
-0@@ -422,20 +422,23 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,spl_mmc_clear_cache ();spl_fat_force_reregister ();test/image/spl_load_fs.c static int spl_test_mmc(struct unit_test_state *uts, const char *test_name, · line 430
Quoted 10 lines
test/image/spl_load_fs.c +2
-3-if (type ==LEGACY && -spl_test_mmc_fs (uts, test_name, type, create_ext2, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && +if (type !=IMX8 && type !=LEGACY_LZMA &&spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ;This is not a command.
Quoted 4 lines
How about:
if (type != IMX8 && type !=
LEGACY_LZMA&&ut_assertok(spl_test_mmc_fs(...
There are already assertions in spl_test_mmc_fs. So if we fail here, we already have something printed on the console.
--Sean
Quoted 20 lines
Quoted 15 lines
test/image/spl_load_fs.c +4
-1+if (type ==LEGACY_LZMA ) +return 0 ; +return do_spl_test_load (uts, test_name, type,SPL_LOAD_IMAGE_GET (0 ,BOOT_DEVICE_MMC1 , spl_mmc_load_image), spl_test_mmc_write_image); }SPL_IMG_TEST (spl_test_mmc,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_mmc,LEGACY_LZMA ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_EXTERNAL ,DM_FLAGS );SPL_IMG_TEST (spl_test_mmc,FIT_INTERNAL ,DM_FLAGS ); --Quoted 2 lines
2.37.1
Regards,
Simon
PATCH v6 16/25 spl: Convert fat to spl_load
In reply to Sean AndersonThis converts the fat loader to use spl_load. Some platforms are very tight on space, so we take care to only include the code we really need.
---
(no changes since v5)
Changes in v5:
- Rework to load header in spl_load
Changes in v3:
- Fix failing on success
common/spl/spl_fat.c | 56 +++++++++++++--------------------------- include/spl_load.h | 1 + test/image/spl_load_fs.c | 3 +-- 3 files changed, 20 insertions(+), 40 deletions(-)
common/spl/spl_fat.c +18 -38
@@ -11,8 +11,8 @@#include <common.h> #include <env.h> #include <log.h> -#include <mapmem.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <fat.h> #include <errno.h>
@@ -66,58 +66,38 @@ int spl_load_image_fat(struct spl_image_info *spl_image, const char *filename) {int err; -struct legacy_img_hdr *header; +loff_t size; +struct spl_load_info load; err =spl_register_fat_device (block_dev, partition);if (err) goto end; - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); - - err =file_fat_read (filename, header,sizeof (struct legacy_img_hdr )); -if (err <=0 ) - goto end; - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL ) && -image_get_magic (header) ==FDT_MAGIC ) { - err =file_fat_read (filename, -map_sysmem (CONFIG_SYS_LOAD_ADDR ,0 ),0 ); -if (err <=0 ) - goto end; - err =spl_parse_image_header (spl_image, bootdev, -map_sysmem (CONFIG_SYS_LOAD_ADDR , - err)); -if (err == -EAGAIN ) -return err; -if (err ==0 ) - err =1 ; - }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); - load.priv = (void *)filename; - -return spl_load_simple_fit (spl_image, &load,0 , header); - }else { - err =spl_parse_image_header (spl_image, bootdev, header); +/* +* Avoid pulling in this function for other image types since we are +* very short on space on some boards. +*/ +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )) { + err =fat_size (filename, &size);if (err) goto end; - - err =file_fat_read (filename,map_sysmem (spl_image->load_addr, - spl_image->size),0 ); + }else { + size =0 ; } + load.read = spl_fit_read; +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); + load.priv = (void *)filename; + err =spl_load (spl_image, bootdev, &load, size,0 ); + end:#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -if (err <=0 ) +if (err <0 )printf ("%s: error reading image %s, err - %d\n" , __func__, filename, err);#endif -return (err <=0 ); +return err; }#if CONFIG_IS_ENABLED (OS_BOOT )
include/spl_load.h +1 -0
@@ -96,6 +96,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,*/ #define SPL_LOAD_USERS \ IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ + IS_ENABLED(CONFIG_SPL_FS_FAT) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_fs.c +1 -2
@@ -425,8 +425,7 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && type !=LEGACY_LZMA && -spl_test_mmc_fs (uts, test_name, type, create_fat, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ;if (type ==LEGACY_LZMA )
Signature · 1 line
2.37.1
Re: [PATCH v6 16/25] spl: Convert fat to spl_load
Hi Sean,
Quoted 12 lines · Sean Anderson
This converts the fat loader to use
spl_load. Some platforms are very tight on space, so we take care to only include the code we really need.Signed-off-by Sean Anderson <[email protected]>---
(no changes since v5)
Changes in v5:
- Rework to load header inspl_load
Quoted 7 lines
Changes in v3:
- Fix failing on successcommon/spl/spl_fat.c | 56 +++++++++++++--------------------------- include/spl_load.h | 1 + test/image/spl_load_fs.c | 3 +-- 3 files changed, 20 insertions(+), 40 deletions(-)
nits below
Quoted 74 lines
common/spl/spl_fat.c +12
-36@@ -11,8 +11,8 @@#include <common.h> #include <env.h> #include <log.h> -#include <mapmem.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <fat.h> #include <errno.h> @@ -66,58 +66,38 @@ int spl_load_image_fat(struct spl_image_info *spl_image, const char *filename) {int err; -struct legacy_img_hdr *header; +loff_t size; +struct spl_load_info load; err =spl_register_fat_device (block_dev, partition);if (err) goto end; - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); - - err =file_fat_read (filename, header,sizeof (struct legacy_img_hdr )); -if (err <=0 ) - goto end; - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL ) && -image_get_magic (header) ==FDT_MAGIC ) { - err =file_fat_read (filename, -map_sysmem (CONFIG_SYS_LOAD_ADDR ,0 ),0 ); -if (err <=0 ) - goto end; - err =spl_parse_image_header (spl_image, bootdev, -map_sysmem (CONFIG_SYS_LOAD_ADDR , - err)); -if (err == -EAGAIN ) -return err; -if (err ==0 ) - err =1 ; - }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); - load.priv = (void *)filename; - -return spl_load_simple_fit (spl_image, &load,0 , header); - }else { - err =spl_parse_image_header (spl_image, bootdev, header); +/* +* Avoid pulling in this function for other image types since we are +* very short on space on some boards. +*/ +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )) { + err =fat_size (filename, &size);if (err) goto end; - - err =file_fat_read (filename,map_sysmem (spl_image->load_addr, - spl_image->size),0 ); + }else { + size =0 ; } + load.read = spl_fit_read;
common/spl/spl_fat.c int spl_load_image_fat(struct spl_image_info *spl_image, · line 97
Quoted 10 lines
common/spl/spl_fat.c +5
-1+spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); + load.priv = (void *)filename; + err =spl_load (spl_image, bootdev, &load, size,0 ); + end:#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -if (err <=0 ) +if (err <0 )printf ("%s: error reading image %s, err - %d\n" , __func__, filename, err);
Do we still need this sort of #ifdef? I thought printf() would melt away without SPL_LIBCOMMON_SUPPORT? I haven't looked though. Also it isn't related to your patch.
Quoted 34 lines
common/spl/spl_fat.c +1
-1#endif -return (err <=0 ); +return err; }#if CONFIG_IS_ENABLED (OS_BOOT )include/spl_load.h +1
-0@@ -96,6 +96,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,*/ #define SPL_LOAD_USERS \ IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ + IS_ENABLED(CONFIG_SPL_FS_FAT) + \ 0#if SPL_LOAD_USERS >1 test/image/spl_load_fs.c +1
-3@@ -425,8 +425,7 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && type !=LEGACY_LZMA && -spl_test_mmc_fs (uts, test_name, type, create_fat, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ;if (type ==LEGACY_LZMA ) --
Quoted 2 lines
2.37.1
Regards,
Simon
Re: [PATCH v6 16/25] spl: Convert fat to spl_load
Quoted 100 lines · Simon Glass
Hi Sean,
Quoted 12 lines · Sean Anderson
This converts the fat loader to use
spl_load. Some platforms are very tight on space, so we take care to only include the code we really need.Signed-off-by Sean Anderson <[email protected]>---
(no changes since v5)
Changes in v5:
- Rework to load header inspl_loadQuoted 7 lines
Changes in v3:
- Fix failing on successcommon/spl/spl_fat.c | 56 +++++++++++++--------------------------- include/spl_load.h | 1 + test/image/spl_load_fs.c | 3 +-- 3 files changed, 20 insertions(+), 40 deletions(-)Reviewed-by Simon Glass <[email protected]>nits below
Quoted 73 lines
common/spl/spl_fat.c +11
-36@@ -11,8 +11,8 @@#include <common.h> #include <env.h> #include <log.h> -#include <mapmem.h> #include <spl.h> +#include <spl_load.h> #include <asm/u-boot.h> #include <fat.h> #include <errno.h> @@ -66,58 +66,38 @@ int spl_load_image_fat(struct spl_image_info *spl_image, const char *filename) {int err; -struct legacy_img_hdr *header; +loff_t size; +struct spl_load_info load; err =spl_register_fat_device (block_dev, partition);if (err) goto end; - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); - - err =file_fat_read (filename, header,sizeof (struct legacy_img_hdr )); -if (err <=0 ) - goto end; - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL ) && -image_get_magic (header) ==FDT_MAGIC ) { - err =file_fat_read (filename, -map_sysmem (CONFIG_SYS_LOAD_ADDR ,0 ),0 ); -if (err <=0 ) - goto end; - err =spl_parse_image_header (spl_image, bootdev, -map_sysmem (CONFIG_SYS_LOAD_ADDR , - err)); -if (err == -EAGAIN ) -return err; -if (err ==0 ) - err =1 ; - }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); - load.priv = (void *)filename; - -return spl_load_simple_fit (spl_image, &load,0 , header); - }else { - err =spl_parse_image_header (spl_image, bootdev, header); +/* +* Avoid pulling in this function for other image types since we are +* very short on space on some boards. +*/ +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )) { + err =fat_size (filename, &size);if (err) goto end; - - err =file_fat_read (filename,map_sysmem (spl_image->load_addr, - spl_image->size),0 ); + }else { + size =0 ; }
Quoted 15 lines
common/spl/spl_fat.c int spl_load_image_fat(struct spl_image_info *spl_image, · line 97
Quoted 11 lines
common/spl/spl_fat.c +6
-1+ load.read = spl_fit_read; +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); + load.priv = (void *)filename; + err =spl_load (spl_image, bootdev, &load, size,0 ); + end:#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -if (err <=0 ) +if (err <0 )printf ("%s: error reading image %s, err - %d\n" , __func__, filename, err);Do we still need this sort of #ifdef? I thought
printf()would melt away withoutSPL_LIBCOMMON_SUPPORT? I haven't looked though. Also it isn't related to your patch.
From what I can tell, printf implementation is orthogonal to LIBCOMMON_SUPPORT.
--Sean
Quoted 39 lines
Quoted 34 lines
common/spl/spl_fat.c +1
-1#endif -return (err <=0 ); +return err; }#if CONFIG_IS_ENABLED (OS_BOOT )include/spl_load.h +1
-0@@ -96,6 +96,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,*/ #define SPL_LOAD_USERS \ IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ + IS_ENABLED(CONFIG_SPL_FS_FAT) + \ 0#if SPL_LOAD_USERS >1 test/image/spl_load_fs.c +1
-3@@ -425,8 +425,7 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,if (spl_test_mmc_fs (uts, test_name, type, create_ext2, false))return CMD_RET_FAILURE ; -if (type !=IMX8 && type !=LEGACY_LZMA && -spl_test_mmc_fs (uts, test_name, type, create_fat, false)) +if (spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ;if (type ==LEGACY_LZMA ) --Quoted 2 lines
2.37.1
Regards,
Simon
PATCH v6 17/25 spl: Convert mmc to spl_load
In reply to Sean AndersonThis converts the mmc loader to spl_load. Legacy images are handled by spl_load (via spl_parse_image_header), so mmc_load_legacy can be omitted. To accurately determine whether mmc_load_image_raw_sector is used (which might not be the case if SYS_MMCSD_FS_BOOT is enabled), we introduce a helper config SYS_MMCSD_RAW_MODE. This ensures we can inline spl_load correctly when a board only boots from filesystems. We still need to check for SPL_MMC, since some boards enable configure raw mode even without MMC support.
---
Changes in v6:
- Add SYS_MMCSD_RAW_MODE to help determine whether SPL_MMC loads anything directly.
- Explicitly initialize load_info members
Changes in v5:
- Rework to load header in spl_load
common/spl/Kconfig | 8 ++++ common/spl/spl_mmc.c | 89 ++++------------------------------------ include/spl_load.h | 1 + test/image/spl_load_fs.c | 3 -- 4 files changed, 16 insertions(+), 85 deletions(-)
common/spl/Kconfig +8 -0
@@ -481,6 +481,11 @@ config SPL_DISPLAY_PRINT banner ("U-Boot SPL ..."). This function should be provided by the board. +config SPL_SYS_MMCSD_RAW_MODE + bool + help + Support booting from an MMC without a filesystem. + config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR bool "MMC raw mode: by sector" default y if ARCH_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER || \
@@ -490,6 +495,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR OMAP44XX || OMAP54XX || AM33XX || AM43XX || \ TARGET_SIFIVE_UNLEASHED || TARGET_SIFIVE_UNMATCHED select SPL_LOAD_BLOCK if SPL_MMC + select SPL_SYS_MMCSD_RAW_MODE if SPL_MMC help Use sector number for specifying U-Boot location on MMC/SD in raw mode.
@@ -527,6 +533,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" select SPL_LOAD_BLOCK if SPL_MMC + select SPL_SYS_MMCSD_RAW_MODE if SPL_MMC help Use a partition for loading U-Boot when using MMC/SD in raw mode.
@@ -1114,6 +1121,7 @@ config SPL_FALCON_BOOT_MMCSD bool "Enable Falcon boot from MMC or SD media" depends on SPL_OS_BOOT && SPL_MMC select SPL_LOAD_BLOCK + select SPL_SYS_MMCSD_RAW_MODE help Select this if the Falcon mode OS image mode is on MMC or SD media.
common/spl/spl_mmc.c +7 -82
111 lines not on this page · raw message
include/spl_load.h +1 -0
@@ -97,6 +97,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,#define SPL_LOAD_USERS \ IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ IS_ENABLED(CONFIG_SPL_FS_FAT) + \ + IS_ENABLED(CONFIG_SPL_SYS_MMCSD_RAW_MODE) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_fs.c +0 -3
@@ -428,9 +428,6 @@ static int spl_test_mmc(struct unit_test_state *uts, const char *test_name,if (spl_test_mmc_fs (uts, test_name, type, create_fat, false))return CMD_RET_FAILURE ; -if (type ==LEGACY_LZMA ) -return 0 ; - return do_spl_test_load(uts, test_name, type, SPL_LOAD_IMAGE_GET(0, BOOT_DEVICE_MMC1, spl_mmc_load_image),
Signature · 1 line
2.37.1
Re: [PATCH v6 17/25] spl: Convert mmc to spl_load
Quoted 18 lines · Sean Anderson
This converts the mmc loader to
spl_load. Legacy images are handled byspl_load(viaspl_parse_image_header), sommc_load_legacycan be omitted. To accurately determine whethermmc_load_image_raw_sectoris used (which might not be the case ifSYS_MMCSD_FS_BOOTis enabled), we introduce a helper configSYS_MMCSD_RAW_MODE. This ensures we can inlinespl_loadcorrectly when a board only boots from filesystems. We still need to check forSPL_MMC, since some boards enable configure raw mode even without MMC support.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- AddSYS_MMCSD_RAW_MODEto help determine whetherSPL_MMCloads anything directly.
- Explicitly initializeload_infomembers
Quoted 8 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/Kconfig | 8 ++++ common/spl/spl_mmc.c | 89 ++++------------------------------------ include/spl_load.h | 1 + test/image/spl_load_fs.c | 3 -- 4 files changed, 16 insertions(+), 85 deletions(-)
PATCH v6 18/25 spl: Convert nand to spl_load
In reply to Sean AndersonThis converts the nand load method to use spl_load. nand_page_size may not be valid until after nand_spl_load_image is called (see e.g. fsl_ifc_spl), so we set bl_len in spl_nand_read. Since spl_load reads the header for us, we can remove that argument from spl_nand_load_element.
There are two possible regressions which could result from this commit. First, we ask for a negative address from spl_get_load_buffer. That is, instead of
header = spl_get_load_buffer(0, sizeof(*header));
we do
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
this could cause a problem if spl_get_load_buffer does not return valid memory for negative offsets. Second, we now set bl_len for legacy images. This can cause memory up to a bl_len - 1 before the image load address to be written, which might not have been the case before. If this turns out to be a problem, we can add an option for a bounce buffer.
We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NAND_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression.
---
Changes in v6:
- New
common/spl/spl_nand.c | 70 +++++++++----------------------------- include/spl_load.h | 1 + test/image/spl_load_nand.c | 2 ++ 3 files changed, 19 insertions(+), 54 deletions(-)
common/spl/spl_nand.c +16 -54
@@ -10,6 +10,7 @@#include <imx_container.h> #include <log.h> #include <spl.h> +#include <spl_load.h> #include <asm/io.h> #include <mapmem.h> #include <nand.h>
@@ -59,6 +60,7 @@ static ulong spl_nand_read(struct spl_load_info *load, ulong offs, ulong size, sector = *(int *)load->priv; offs = sector +nand_spl_adjust_offset (sector, offs - sector); err =nand_spl_load_image (offs, size, dst); +spl_set_bl_len (load,nand_page_size ());if (err)return 0 ;
@@ -66,60 +68,20 @@ static ulong spl_nand_read(struct spl_load_info *load, ulong offs, ulong size, }static int spl_nand_load_element (struct spl_image_info *spl_image, -struct spl_boot_device *bootdev, -int offset,struct legacy_img_hdr *header) +struct spl_boot_device *bootdev,int offset) { -int bl_len; -int err; +struct spl_load_info load; - err =nand_spl_load_image (offset,sizeof (*header), (void *)header); -if (err) -return err; - - bl_len =nand_page_size (); -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.priv = &offset; -spl_set_bl_len (&load, bl_len); - load.read = spl_nand_read; -return spl_load_simple_fit (spl_image, &load, offset, header); - }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) && -valid_container_hdr ((void *)header)) { -struct spl_load_info load; - - load.priv = &offset; -spl_set_bl_len (&load, bl_len); - load.read = spl_nand_read; -return spl_load_imx_container (spl_image, &load, offset); - }else if (IS_ENABLED (CONFIG_SPL_LEGACY_IMAGE_FORMAT ) && -image_get_magic (header) ==IH_MAGIC ) { -struct spl_load_info load; - -debug ("Found legacy image\n" ); - load.priv = &offset; -spl_set_bl_len (&load,IS_ENABLED (CONFIG_SPL_LZMA ) ? bl_len :1 ); - load.read = spl_nand_read; -return spl_load_legacy_img (spl_image, bootdev, &load, offset, header); - }else { - err =spl_parse_image_header (spl_image, bootdev, header); -if (err) -return err; -return nand_spl_load_image (offset, spl_image->size, -map_sysmem (spl_image->load_addr, - spl_image->size)); - } + load.priv = &offset; +spl_set_bl_len (&load,1 ); + load.read = spl_nand_read; +return spl_load (spl_image, bootdev, &load,0 , offset); }static int spl_nand_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) {int err; -struct legacy_img_hdr *header; - int *src __attribute__((unused)); - int *dst __attribute__((unused));#ifdef CONFIG_SPL_NAND_SOFTECC debug ("spl: nand - using sw ecc\n" );
@@ -128,10 +90,12 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,#endif nand_init (); - header =spl_get_load_buffer (0 ,sizeof (*header)); -#if CONFIG_IS_ENABLED (OS_BOOT )if (!spl_start_uboot ()) { +int *src, *dst; +struct legacy_img_hdr *header = +spl_get_load_buffer (0 ,sizeof (*header)); +/* * load parameter image * load to temp position since nand_spl_load_image reads
@@ -174,20 +138,18 @@ static int spl_nand_load_image(struct spl_image_info *spl_image, }#endif #ifdef CONFIG_NAND_ENV_DST -spl_nand_load_element (spl_image, bootdev,CONFIG_ENV_OFFSET , header); +spl_nand_load_element (spl_image, bootdev,CONFIG_ENV_OFFSET );#ifdef CONFIG_ENV_OFFSET_REDUND -spl_nand_load_element (spl_image, bootdev,CONFIG_ENV_OFFSET_REDUND , header); +spl_nand_load_element (spl_image, bootdev,CONFIG_ENV_OFFSET_REDUND );#endif #endif /* Load u-boot */ - err =spl_nand_load_element (spl_image, bootdev,spl_nand_get_uboot_raw_page (), - header); + err =spl_nand_load_element (spl_image, bootdev,spl_nand_get_uboot_raw_page ());#ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND #if CONFIG_SYS_NAND_U_BOOT_OFFS !=CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND if (err) err =spl_nand_load_element (spl_image, bootdev, -CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND , - header); +CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND );#endif #endif nand_deselect ();
include/spl_load.h +1 -0
@@ -98,6 +98,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,IS_ENABLED (CONFIG_SPL_FS_EXT4 ) + \IS_ENABLED (CONFIG_SPL_FS_FAT ) + \IS_ENABLED (CONFIG_SPL_SYS_MMCSD_RAW_MODE ) + \ + (IS_ENABLED (CONFIG_SPL_NAND_SUPPORT ) && !IS_ENABLED (CONFIG_SPL_UBI )) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_nand.c +2 -0
@@ -51,4 +51,6 @@ SPL_IMG_TEST(spl_test_nand, LEGACY, DM_FLAGS);SPL_IMG_TEST (spl_test_nand,LEGACY_LZMA ,DM_FLAGS );SPL_IMG_TEST (spl_test_nand,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_nand,FIT_INTERNAL ,DM_FLAGS ); +#if !IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )SPL_IMG_TEST (spl_test_nand,FIT_EXTERNAL ,DM_FLAGS ); +#endif
Signature · 1 line
2.37.1
Re: [PATCH v6 18/25] spl: Convert nand to spl_load
Quoted 29 lines · Sean Anderson
This converts the nand load method to use
spl_load.nand_page_sizemay not be valid until afternand_spl_load_imageis called (see e.g.fsl_ifc_spl), so we setbl_leninspl_nand_read. Sincespl_loadreads the header for us, we can remove that argument fromspl_nand_load_element.There are two possible regressions which could result from this commit. First, we ask for a negative address from
spl_get_load_buffer. That is, instead ofheader = spl_get_load_buffer(0, sizeof(*header));we do
header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));this could cause a problem if
spl_get_load_bufferdoes not return valid memory for negative offsets. Second, we now setbl_lenfor legacy images. This can cause memory up to abl_len- 1 before the image load address to be written, which might not have been the case before. If this turns out to be a problem, we can add an option for a bounce buffer.We can't load FITs with external data with
SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enableSPL_NAND_SUPPORTandSPL_LOAD_FIT_FULL, so this is not a regression.Signed-off-by Sean Anderson <[email protected]>---
Quoted 8 lines
Changes in v6:
- Newcommon/spl/spl_nand.c | 70 +++++++++----------------------------- include/spl_load.h | 1 + test/image/spl_load_nand.c | 2 ++ 3 files changed, 19 insertions(+), 54 deletions(-)
PATCH v6 19/25 spl: Convert net to spl_load
In reply to Sean AndersonThis converts the net load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images.
---
Changes in v6:
- Explicitly initialize load_info members
Changes in v5:
- Rework to load header in spl_load
common/spl/spl_net.c | 29 +++++------------------------ include/spl_load.h | 1 + test/image/spl_load_net.c | 2 ++ 3 files changed, 8 insertions(+), 24 deletions(-)
common/spl/spl_net.c +5 -24
@@ -11,8 +11,8 @@#include <errno.h> #include <image.h> #include <log.h> -#include <mapmem.h> #include <spl.h> +#include <spl_load.h> #include <net.h> #include <linux/libfdt.h>
@@ -29,8 +29,7 @@ static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,static int spl_net_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct legacy_img_hdr *header =map_sysmem (image_load_addr, -sizeof (*header)); +struct spl_load_info load;int rv;env_init ();
@@ -49,27 +48,9 @@ static int spl_net_load_image(struct spl_image_info *spl_image, return rv; } -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); -spl_set_bl_len (&load,1 ); - load.read = spl_net_load_read; - rv =spl_load_simple_fit (spl_image, &load,0 , header); - }else { -debug ("Legacy image\n" ); - - rv =spl_parse_image_header (spl_image, bootdev, header); -if (rv) -return rv; - -memcpy (map_sysmem (spl_image->load_addr, spl_image->size), -map_sysmem (image_load_addr, spl_image->size), - spl_image->size); - } - -return rv; +spl_set_bl_len (&load,1 ); + load.read = spl_net_load_read; +return spl_load (spl_image, bootdev, &load,0 ,0 ); }#endif
include/spl_load.h +1 -0
@@ -99,6 +99,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,IS_ENABLED (CONFIG_SPL_FS_FAT ) + \IS_ENABLED (CONFIG_SPL_SYS_MMCSD_RAW_MODE ) + \ (IS_ENABLED (CONFIG_SPL_NAND_SUPPORT ) && !IS_ENABLED (CONFIG_SPL_UBI )) + \ +IS_ENABLED (CONFIG_SPL_NET ) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_net.c +2 -0
@@ -248,5 +248,7 @@ static int spl_test_net(struct unit_test_state *uts, const char *test_name,return ret; }SPL_IMG_TEST (spl_test_net,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_net,LEGACY_LZMA ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_net,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_net,FIT_INTERNAL ,DM_FLAGS );SPL_IMG_TEST (spl_test_net,FIT_EXTERNAL ,DM_FLAGS );
Signature · 1 line
2.37.1
Re: [PATCH v6 19/25] spl: Convert net to spl_load
Quoted 10 lines · Sean Anderson
This converts the net load method to use
spl_load. As a result, it also adds support forLOAD_FIT_FULLand IMX images.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Explicitly initializeload_infomembers
Quoted 8 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/spl_net.c | 29 +++++------------------------ include/spl_load.h | 1 + test/image/spl_load_net.c | 2 ++ 3 files changed, 8 insertions(+), 24 deletions(-)
PATCH v6 20/25 spl: Convert nor to spl_load
In reply to Sean AndersonThis converts the nor load method to use spl_load. As a result it also adds support for LOAD_FIT_FULL. Since this is the last caller of spl_load_legacy_img, it has been removed.
We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NOR_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression.
---
Changes in v6:
- Fix LZMA support
- Fix load address
- Explicitly initialize load_info members
Changes in v5:
- Rework to load header in spl_load
common/spl/spl_legacy.c | 61 --------------------------------------- common/spl/spl_nor.c | 40 +++++-------------------- include/spl_load.h | 1 + test/image/spl_load_nor.c | 2 ++ 4 files changed, 10 insertions(+), 94 deletions(-)
common/spl/spl_legacy.c +0 -61
@@ -118,64 +118,3 @@ int spl_load_legacy_lzma(struct spl_image_info *spl_image, spl_image->size = lzma_len;return 0 ; } - -/* -* This function is added explicitly to avoid code size increase, when -* no compression method is enabled. The compiler will optimize the -* following switch/case statement in spl_load_legacy_img() away due to -* Dead Code Elimination. -*/ -static inline int spl_image_get_comp (const struct legacy_img_hdr *hdr) -{ -if (IS_ENABLED (CONFIG_SPL_LZMA )) -return image_get_comp (hdr); - -return IH_COMP_NONE ; -} - -int spl_load_legacy_img (struct spl_image_info *spl_image, -struct spl_boot_device *bootdev, -struct spl_load_info *load,ulong offset, -struct legacy_img_hdr *hdr) -{ -ulong dataptr; -int ret; - -/* -* If the payload is compressed, the decompressed data should be -* directly write to its load address. -*/ -if (spl_image_get_comp (hdr) !=IH_COMP_NONE ) - spl_image->flags |=SPL_COPY_PAYLOAD_ONLY ; - - ret =spl_parse_image_header (spl_image, bootdev, hdr); -if (ret) -return ret; - -/* Read image */ -switch (spl_image_get_comp (hdr)) { -case IH_COMP_NONE : - dataptr = offset; - -/* -* Image header will be skipped only if SPL_COPY_PAYLOAD_ONLY -* is set -*/ -if (spl_image->flags &SPL_COPY_PAYLOAD_ONLY ) - dataptr +=sizeof (*hdr); - - load->read (load, dataptr, spl_image->size, -map_sysmem (spl_image->load_addr, spl_image->size)); -break ; - -case IH_COMP_LZMA : -return spl_load_legacy_lzma (spl_image, load, offset); - -default : -debug ("Compression method %s is not supported\n" , -genimg_get_comp_short_name (image_get_comp (hdr))); -return -EINVAL ; - } - -return 0 ; -}
common/spl/spl_nor.c +7 -33
@@ -7,8 +7,8 @@#include <image.h> #include <imx_container.h> #include <log.h> -#include <mapmem.h> #include <spl.h> +#include <spl_load.h> static ulong spl_nor_load_read (struct spl_load_info *load,ulong sector,ulong count,void *buf)
@@ -28,8 +28,7 @@ unsigned long __weak spl_nor_get_uboot_base(void)static int spl_nor_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) { -struct legacy_img_hdr *header; -__maybe_unused struct spl_load_info load; +struct spl_load_info load;/* * Loading of the payload to SDRAM is done with skipping of
@@ -43,7 +42,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,* Load Linux from its location in NOR flash to its defined * location in SDRAM */ - header = (void *)CONFIG_SYS_OS_BASE ; +const struct legacy_img_hdr *header = + (const struct legacy_img_hdr *)CONFIG_SYS_OS_BASE ;#ifdef CONFIG_SPL_LOAD_FIT if (image_get_magic (header) ==FDT_MAGIC ) {int ret;
@@ -93,34 +93,8 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,* Load real U-Boot from its location in NOR flash to its * defined location in SDRAM */ - header =map_sysmem (spl_nor_get_uboot_base (),sizeof (*header)); -#ifdef CONFIG_SPL_LOAD_FIT -if (image_get_magic (header) ==FDT_MAGIC ) { -debug ("Found FIT format U-Boot\n" ); -spl_set_bl_len (&load,1 ); - load.read = spl_nor_load_read; -return spl_load_simple_fit (spl_image, &load, -spl_nor_get_uboot_base (), - (void *)header); - } -#endif -if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) && -valid_container_hdr ((void *)header)) { -spl_set_bl_len (&load,1 ); - load.read = spl_nor_load_read; -return spl_load_imx_container (spl_image, &load, -spl_nor_get_uboot_base ()); - } - -/* Legacy image handling */ -if (IS_ENABLED (CONFIG_SPL_LEGACY_IMAGE_FORMAT )) { -spl_set_bl_len (&load,1 ); - load.read = spl_nor_load_read; -return spl_load_legacy_img (spl_image, bootdev, &load, -spl_nor_get_uboot_base (), - header); - } - -return -EINVAL ; +spl_set_bl_len (&load,1 ); + load.read = spl_nor_load_read; +return spl_load (spl_image, bootdev, &load,0 ,spl_nor_get_uboot_base ()); }SPL_LOAD_IMAGE_METHOD ("NOR" ,0 ,BOOT_DEVICE_NOR , spl_nor_load_image);
include/spl_load.h +1 -0
@@ -100,6 +100,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,IS_ENABLED (CONFIG_SPL_SYS_MMCSD_RAW_MODE ) + \ (IS_ENABLED (CONFIG_SPL_NAND_SUPPORT ) && !IS_ENABLED (CONFIG_SPL_UBI )) + \IS_ENABLED (CONFIG_SPL_NET ) + \ +IS_ENABLED (CONFIG_SPL_NOR_SUPPORT ) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_nor.c +2 -0
@@ -36,4 +36,6 @@ SPL_IMG_TEST(spl_test_nor, LEGACY, 0);SPL_IMG_TEST (spl_test_nor,LEGACY_LZMA ,0 );SPL_IMG_TEST (spl_test_nor,IMX8 ,0 );SPL_IMG_TEST (spl_test_nor,FIT_INTERNAL ,0 ); +#if !IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )SPL_IMG_TEST (spl_test_nor,FIT_EXTERNAL ,0 ); +#endif
Signature · 1 line
2.37.1
Re: [PATCH v6 20/25] spl: Convert nor to spl_load
Quoted 17 lines · Sean Anderson
This converts the nor load method to use
spl_load. As a result it also adds support forLOAD_FIT_FULL. Since this is the last caller ofspl_load_legacy_img, it has been removed.We can't load FITs with external data with
SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enableSPL_NOR_SUPPORTandSPL_LOAD_FIT_FULL, so this is not a regression.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Fix LZMA support
- Fix load address
- Explicitly initializeload_infomembers
Quoted 9 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/spl_legacy.c | 61 --------------------------------------- common/spl/spl_nor.c | 40 +++++-------------------- include/spl_load.h | 1 + test/image/spl_load_nor.c | 2 ++ 4 files changed, 10 insertions(+), 94 deletions(-)
PATCH v6 21/25 spl: Convert NVMe to spl_load
In reply to Sean AndersonThis converts the blk load method (used exclusively by NVMe) to use spl_load. As a consequence, it also adds support for LOAD_FIT_FULL and IMX images.
---
Changes in v6:
- Fix invalid return from spl_blk_load_image
- Explicitly initialize load_info members
Changes in v5:
- New
common/spl/spl_blk_fs.c | 66 +++++++--------------------------------- include/spl_load.h | 1 + test/image/spl_load_fs.c | 2 ++ 3 files changed, 14 insertions(+), 55 deletions(-)
common/spl/spl_blk_fs.c +11 -55
@@ -7,6 +7,7 @@#include <common.h> #include <spl.h> +#include <spl_load.h> #include <image.h> #include <fs.h> #include <asm/cache.h>
@@ -48,11 +49,11 @@ int spl_blk_load_image(struct spl_image_info *spl_image, enum uclass_id uclass_id, int devnum, int partnum) { const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME; -struct legacy_img_hdr *header;struct blk_desc *blk_desc; -loff_t actlen, filesize; +loff_t filesize;struct blk_dev dev; -int ret = -ENODEV ; +struct spl_load_info load; +int ret; blk_desc =blk_get_devnum_by_uclass_id (uclass_id, devnum);if (!blk_desc) {
@@ -61,8 +62,8 @@ int spl_blk_load_image(struct spl_image_info *spl_image, }blk_show_device (uclass_id, devnum); - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); + dev.filename = filename; dev.ifname =blk_get_uclass_name (uclass_id);snprintf (dev.dev_part_str,sizeof (dev.dev_part_str) -1 ,"%x:%x" , devnum, partnum);
@@ -70,63 +71,18 @@ int spl_blk_load_image(struct spl_image_info *spl_image,if (ret) {printf ("spl: unable to set blk_dev %s %s. Err - %d\n" , dev.ifname, dev.dev_part_str, ret); - goto out; - } - - ret =fs_read (filename,virt_to_phys (header),0 , -sizeof (struct legacy_img_hdr ), &actlen); -if (ret) { -printf ("spl: unable to read file %s. Err - %d\n" , filename, - ret); - goto out; - } - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); - load.priv = &dev; - dev.filename = filename; - -return spl_load_simple_fit (spl_image, &load,0 , header); - } - - ret =spl_parse_image_header (spl_image, bootdev, header); -if (ret) { -printf ("spl: unable to parse image header. Err - %d\n" , - ret); - goto out; - } - - ret =fs_set_blk_dev (dev.ifname, dev.dev_part_str,FS_TYPE_ANY ); -if (ret) { -printf ("spl: unable to set blk_dev %s %s. Err - %d\n" , - dev.ifname, dev.dev_part_str, ret); - goto out; +return ret; } ret =fs_size (filename, &filesize);if (ret) {printf ("spl: unable to get file size: %s. Err - %d\n" , filename, ret); - goto out; +return ret; } - ret =fs_set_blk_dev (dev.ifname, dev.dev_part_str,FS_TYPE_ANY ); -if (ret) { -printf ("spl: unable to set blk_dev %s %s. Err - %d\n" , - dev.ifname, dev.dev_part_str, ret); - goto out; - } - - ret =fs_read (filename, (ulong )spl_image->load_addr,0 , filesize, - &actlen); -if (ret) -printf ("spl: unable to read file %s. Err - %d\n" , - filename, ret); -out: -return ret; + load.read = spl_fit_read; +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); + load.priv = &dev; +return spl_load (spl_image, bootdev, &load, filesize,0 ); }
include/spl_load.h +1 -0
@@ -95,6 +95,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,* inline if there is one caller, and extern otherwise. */ #define SPL_LOAD_USERS \ + IS_ENABLED(CONFIG_SPL_BLK_FS) + \ IS_ENABLED(CONFIG_SPL_FS_EXT4) + \ IS_ENABLED(CONFIG_SPL_FS_FAT) + \ IS_ENABLED(CONFIG_SPL_SYS_MMCSD_RAW_MODE) + \
test/image/spl_load_fs.c +2 -0
@@ -395,6 +395,8 @@ static int spl_test_blk(struct unit_test_state *uts, const char *test_name,return spl_test_mmc_fs (uts, test_name, type, create_ext2, true); }SPL_IMG_TEST (spl_test_blk,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_blk,LEGACY_LZMA ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_blk,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_blk,FIT_EXTERNAL ,DM_FLAGS );SPL_IMG_TEST (spl_test_blk,FIT_INTERNAL ,DM_FLAGS );
Signature · 1 line
2.37.1
Re: [PATCH v6 21/25] spl: Convert NVMe to spl_load
Quoted 12 lines · Sean Anderson
This converts the blk load method (used exclusively by NVMe) to use
spl_load. As a consequence, it also adds support forLOAD_FIT_FULLand IMX images.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Fix invalid return fromspl_blk_load_image
- Explicitly initializeload_infomembers
Quoted 7 lines
Changes in v5:
- Newcommon/spl/spl_blk_fs.c | 66 +++++++--------------------------------- include/spl_load.h | 1 + test/image/spl_load_fs.c | 2 ++ 3 files changed, 14 insertions(+), 55 deletions(-)
PATCH v6 22/25 spl: Convert semihosting to spl_load
In reply to Sean AndersonThis converts the semihosting load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images.
---
Changes in v6:
- Explicitly initialize load_info members
Changes in v5:
- Rework to load header in spl_load
Changes in v2:
- New
common/spl/spl_semihosting.c | 52 +++++------------------------------- include/spl_load.h | 1 + 2 files changed, 7 insertions(+), 46 deletions(-)
common/spl/spl_semihosting.c +6 -46
@@ -8,18 +8,7 @@#include <log.h> #include <semihosting.h> #include <spl.h> - -static int smh_read_full (long fd,void *memp,size_t len) -{ -long read; - - read =smh_read (fd, memp, len); -if (read <0 ) -return read; -if (read != len) -return -EIO ; -return 0 ; -} +#include <spl_load.h> static ulong smh_fit_read (struct spl_load_info *load,ulong file_offset,ulong size,void *buf)
@@ -40,8 +29,7 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,const char *filename =CONFIG_SPL_FS_LOAD_PAYLOAD_NAME ;int ret;long fd, len; -struct legacy_img_hdr *header = -spl_get_load_buffer (-sizeof (*header),sizeof (*header)); +struct spl_load_info load; fd =smh_open (filename,MODE_READ |MODE_BINARY );if (fd <0 ) {
@@ -56,38 +44,10 @@ static int spl_smh_load_image(struct spl_image_info *spl_image, } len = ret; - ret =smh_read_full (fd, header,sizeof (struct legacy_img_hdr )); -if (ret) { -log_debug ("could not read image header: %d\n" , ret); - goto out; - } - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.read = smh_fit_read; -spl_set_bl_len (&load,1 ); - load.priv = &fd; - - ret =spl_load_simple_fit (spl_image, &load,0 , header); - goto out; - } - - ret =spl_parse_image_header (spl_image, bootdev, header); -if (ret) { -log_debug ("failed to parse image header: %d\n" , ret); - goto out; - } - - ret =smh_seek (fd,0 ); -if (ret) { -log_debug ("could not seek to start of image: %d\n" , ret); - goto out; - } - - ret =smh_read_full (fd, (void *)spl_image->load_addr, len); + load.read = smh_fit_read; +spl_set_bl_len (&load,1 ); + load.priv = &fd; + ret =spl_load (spl_image, bootdev, &load, len,0 );if (ret)log_debug ("could not read %s: %d\n" , filename, ret); out:
include/spl_load.h +1 -0
@@ -102,6 +102,7 @@ static inline int _spl_load(struct spl_image_info *spl_image, (IS_ENABLED (CONFIG_SPL_NAND_SUPPORT ) && !IS_ENABLED (CONFIG_SPL_UBI )) + \IS_ENABLED (CONFIG_SPL_NET ) + \IS_ENABLED (CONFIG_SPL_NOR_SUPPORT ) + \ +IS_ENABLED (CONFIG_SPL_SEMIHOSTING ) + \ 0#if SPL_LOAD_USERS >1
Signature · 1 line
2.37.1
PATCH v6 23/25 spl: Convert spi to spl_load
In reply to Sean AndersonThis converts the spi load method to use spl_load. The address used for LOAD_FIT_FULL may be different, but there are no in-tree users of that config. Since payload_offs is only used without OS_BOOT, we defer its initialization.
---
Changes in v6:
- Fix soft reset after loading from SPI
Changes in v5:
- Rework to load header in spl_load
common/spl/spl_spi.c | 80 +++++++-------------------------------- include/spl_load.h | 1 + test/image/spl_load_spi.c | 1 + 3 files changed, 15 insertions(+), 67 deletions(-)
common/spl/spl_spi.c +13 -67
@@ -12,11 +12,11 @@#include <image.h> #include <imx_container.h> #include <log.h> -#include <mapmem.h> #include <spi.h> #include <spi_flash.h> #include <errno.h> #include <spl.h> +#include <spl_load.h> #include <asm/global_data.h> #include <asm/io.h> #include <dm/ofnode.h>
@@ -95,9 +95,9 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,int err =0 ;unsigned int payload_offs;struct spi_flash *flash; -struct legacy_img_hdr *header;unsigned int sf_bus =spl_spi_boot_bus ();unsigned int sf_cs =spl_spi_boot_cs (); +struct spl_load_info load;/* * Load U-Boot image from SPI flash into RAM
@@ -112,77 +112,23 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,return -ENODEV ; } +#if CONFIG_IS_ENABLED (OS_BOOT ) +if (!spl_start_uboot () && !spi_load_image_os (spl_image, bootdev, flash, header)) +return 0 ; +#endif + payload_offs =spl_spi_get_uboot_offs (flash); - - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); -if (CONFIG_IS_ENABLED (OF_REAL )) { payload_offs =ofnode_conf_read_int ("u-boot,spl-payload-offset" , payload_offs); } -#if CONFIG_IS_ENABLED (OS_BOOT ) -if (spl_start_uboot () ||spi_load_image_os (spl_image, bootdev, flash, header)) -#endif - { -/* Load u-boot, mkimage header is 64 bytes. */ - err =spi_flash_read (flash, payload_offs,sizeof (*header), - (void *)header); -if (err) { -debug ("%s: Failed to read from SPI flash (err=%d)\n" , - __func__, err); -return err; - } - -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL ) && -image_get_magic (header) ==FDT_MAGIC ) { -u32 size =roundup (fdt_totalsize (header),4 ); - - err =spi_flash_read (flash, payload_offs, - size, -map_sysmem (CONFIG_SYS_LOAD_ADDR , - size)); -if (err) -return err; - err =spl_parse_image_header (spl_image, bootdev, -phys_to_virt (CONFIG_SYS_LOAD_ADDR )); - }else if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && -image_get_magic (header) ==FDT_MAGIC ) { -struct spl_load_info load; - -debug ("Found FIT\n" ); - load.priv = flash; -spl_set_bl_len (&load,1 ); - load.read = spl_spi_fit_read; - err =spl_load_simple_fit (spl_image, &load, - payload_offs, - header); - }else if (IS_ENABLED (CONFIG_SPL_LOAD_IMX_CONTAINER ) && -valid_container_hdr ((void *)header)) { -struct spl_load_info load; - - load.priv = flash; -spl_set_bl_len (&load,1 ); - load.read = spl_spi_fit_read; - - err =spl_load_imx_container (spl_image, &load, - payload_offs); - }else { - err =spl_parse_image_header (spl_image, bootdev, header); -if (err) -return err; - err =spi_flash_read (flash, payload_offs + spl_image->offset, - spl_image->size, -map_sysmem (spl_image->load_addr, - spl_image->size)); - } -if (IS_ENABLED (CONFIG_SPI_FLASH_SOFT_RESET )) { - err =spi_nor_remove (flash); -if (err) -return err; - } - } - + load.priv = flash; +spl_set_bl_len (&load,1 ); + load.read = spl_spi_fit_read; + err =spl_load (spl_image, bootdev, &load,0 , payload_offs); +if (IS_ENABLED (CONFIG_SPI_FLASH_SOFT_RESET )) + err =spi_nor_remove (flash);return err; }/* Use priorty 1 so that boards can override this */
include/spl_load.h +1 -0
@@ -103,6 +103,7 @@ static inline int _spl_load(struct spl_image_info *spl_image,IS_ENABLED (CONFIG_SPL_NET ) + \IS_ENABLED (CONFIG_SPL_NOR_SUPPORT ) + \IS_ENABLED (CONFIG_SPL_SEMIHOSTING ) + \ +IS_ENABLED (CONFIG_SPL_SPI_LOAD ) + \ 0#if SPL_LOAD_USERS >1
test/image/spl_load_spi.c +1 -0
@@ -34,6 +34,7 @@ static int spl_test_spi(struct unit_test_state *uts, const char *test_name, spl_test_spi_write_image); }SPL_IMG_TEST (spl_test_spi,LEGACY ,DM_FLAGS ); +SPL_IMG_TEST (spl_test_spi,LEGACY_LZMA ,DM_FLAGS );SPL_IMG_TEST (spl_test_spi,IMX8 ,DM_FLAGS );SPL_IMG_TEST (spl_test_spi,FIT_INTERNAL ,DM_FLAGS );#if !IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )
Signature · 1 line
2.37.1
Re: [PATCH v6 23/25] spl: Convert spi to spl_load
Quoted 12 lines · Sean Anderson
This converts the spi load method to use
spl_load. The address used forLOAD_FIT_FULLmay be different, but there are no in-tree users of that config. Sincepayload_offsis only used withoutOS_BOOT, we defer its initialization.Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Fix soft reset after loading from SPI
Quoted 8 lines
Changes in v5:
- Rework to load header inspl_loadcommon/spl/spl_spi.c | 80 +++++++-------------------------------- include/spl_load.h | 1 + test/image/spl_load_spi.c | 1 + 3 files changed, 15 insertions(+), 67 deletions(-)
I am just amazed at how many times this FIT code got copied...there is something wrong with U-Boot's development model here.
PATCH v6 24/25 spl: spi: Consolidate spi_load_image_os into spl_spi_load_image
In reply to Sean Andersonspi_load_image_os performs almost the same steps as the non-falcon-boot path of spl_spi_load_image. The load address is different, and it also loads a device tree, but that's it. Refactor the boot process so that they can both use the same load function.
---
(no changes since v5)
Changes in v5:
- Rework to load header in spl_load
Changes in v2:
- New
common/spl/spl_spi.c | 54 ++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-)
common/spl/spl_spi.c +14 -40
@@ -21,41 +21,6 @@#include <asm/io.h> #include <dm/ofnode.h> -#if CONFIG_IS_ENABLED (OS_BOOT ) -/* -* Load the kernel, check for a valid header we can parse, and if found load -* the kernel and then device tree. -*/ -static int spi_load_image_os (struct spl_image_info *spl_image, -struct spl_boot_device *bootdev, -struct spi_flash *flash, -struct legacy_img_hdr *header) -{ -int err; - -/* Read for a header, parse or error out. */ -spi_flash_read (flash,CFG_SYS_SPI_KERNEL_OFFS ,sizeof (*header), - (void *)header); - -if (image_get_magic (header) !=IH_MAGIC ) -return -1 ; - - err =spl_parse_image_header (spl_image, bootdev, header); -if (err) -return err; - -spi_flash_read (flash,CFG_SYS_SPI_KERNEL_OFFS , - spl_image->size, (void *)spl_image->load_addr); - -/* Read device tree. */ -spi_flash_read (flash,CFG_SYS_SPI_ARGS_OFFS , -CFG_SYS_SPI_ARGS_SIZE , - (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR ); - -return 0 ; -} -#endif -static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector,ulong count,void *buf) {
@@ -112,9 +77,21 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,return -ENODEV ; } + load.priv = flash; +spl_set_bl_len (&load,1 ); + load.read = spl_spi_fit_read; +#if CONFIG_IS_ENABLED (OS_BOOT ) -if (!spl_start_uboot () && !spi_load_image_os (spl_image, bootdev, flash, header)) -return 0 ; +if (spl_start_uboot ()) { +int err =spl_load (spl_image, bootdev, &load,0 , +CFG_SYS_SPI_KERNEL_OFFS ); + +if (!err) +/* Read device tree. */ +return spi_flash_read (flash,CFG_SYS_SPI_ARGS_OFFS , +CFG_SYS_SPI_ARGS_SIZE , + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR ); + }#endif payload_offs =spl_spi_get_uboot_offs (flash);
@@ -123,9 +100,6 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, payload_offs); } - load.priv = flash; -spl_set_bl_len (&load,1 ); - load.read = spl_spi_fit_read; err =spl_load (spl_image, bootdev, &load,0 , payload_offs);if (IS_ENABLED (CONFIG_SPI_FLASH_SOFT_RESET )) err =spi_nor_remove (flash);
Signature · 1 line
2.37.1
Re: [PATCH v6 24/25] spl: spi: Consolidate spi_load_image_os into spl_spi_load_image
Quoted 11 lines · Sean Anderson
spi_load_image_osperforms almost the same steps as the non-falcon-boot path ofspl_spi_load_image. The load address is different, and it also loads a device tree, but that's it. Refactor the boot process so that they can both use the same load function.Signed-off-by Sean Anderson <[email protected]>---
(no changes since v5)
Quoted 8 lines
Changes in v5:
- Rework to load header inspl_loadChanges in v2:
- Newcommon/spl/spl_spi.c | 54 ++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-)
PATCH v6 25/25 spl: fat: Add option to disable DMA alignment
In reply to Sean AndersonIf we don't DMA-align buffers we pass to FAT, it will align them itself. This behaviour likely should be deprecated in favor of CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the meantime, don't bother aligning the buffer unless we had been doing so in the past.
---
Changes in v6:
- New
common/spl/Kconfig | 18 ++++++++++++++++-- common/spl/spl_blk_fs.c | 5 ++++- common/spl/spl_fat.c | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-)
common/spl/Kconfig +16 -2
@@ -694,13 +694,28 @@ config SPL_FS_SQUASHFS config SPL_FS_FAT bool "Support FAT filesystems" select FS_FAT - select SPL_LOAD_BLOCK help Enable support for FAT and VFAT filesystems with SPL. This permits U-Boot (or Linux in Falcon mode) to be loaded from a FAT filesystem from within SPL. Support for the underlying block device (e.g. MMC or USB) must be enabled separately. +config SPL_FS_FAT_DMA_ALIGN + bool "Use DMA-aligned buffers with FAT" + depends on SPL_FS_FAT + select SPL_LOAD_BLOCK + default y if SPL_LOAD_FIT + help + The FAT filesystem driver tries to ensure that the reads it issues to + the block subsystem use DMA-aligned buffers. If the supplied buffer is + not DMA-aligned, the FAT driver will use a bounce-buffer and read + block-by-block. This is separate from the bounce-buffer used by the + block subsystem (CONFIG_BOUNCE_BUFFER). + + Enable this config to align buffers passed to the FAT filesystem + driver. This will speed up reads, but will increase the size of U-Boot + by around 60 bytes. + config SPL_FS_LOAD_PAYLOAD_NAME string "File to load for U-Boot from the filesystem" depends on SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS || SPL_SEMIHOSTING
@@ -1282,7 +1297,6 @@ config SPL_NVME depends on BLK select FS_LOADER select SPL_BLK_FS - select SPL_LOAD_BLOCK help This option enables support for NVM Express devices. It supports basic functions of NVMe (read/write).
common/spl/spl_blk_fs.c +4 -1
@@ -82,7 +82,10 @@ int spl_blk_load_image(struct spl_image_info *spl_image, } load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); +if (IS_ENABLED (CONFIG_SPL_FS_FAT_DMA_ALIGN )) +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); +else +spl_set_bl_len (&load,1 ); load.priv = &dev;return spl_load (spl_image, bootdev, &load, filesize,0 ); }
common/spl/spl_fat.c +4 -1
@@ -86,7 +86,10 @@ int spl_load_image_fat(struct spl_image_info *spl_image, } load.read = spl_fit_read; -spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); +if (IS_ENABLED (CONFIG_SPL_FS_FAT_DMA_ALIGN )) +spl_set_bl_len (&load,ARCH_DMA_MINALIGN ); +else +spl_set_bl_len (&load,1 ); load.priv = (void *)filename; err =spl_load (spl_image, bootdev, &load, size,0 );
Signature · 1 line
2.37.1
Re: [PATCH v6 25/25] spl: fat: Add option to disable DMA alignment
Quoted 10 lines · Sean Anderson
If we don't DMA-align buffers we pass to FAT, it will align them itself. This behaviour likely should be deprecated in favor of
CONFIG_BOUNCE_BUFFER, but that's a task for another series. For the meantime, don't bother aligning the buffer unless we had been doing so in the past.Signed-off-by Sean Anderson <[email protected]>---
Quoted 8 lines
Changes in v6:
- Newcommon/spl/Kconfig | 18 ++++++++++++++++-- common/spl/spl_blk_fs.c | 5 ++++- common/spl/spl_fat.c | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-)
What you are doing is the worst thing in the world. You have been ignoring all my changes which I have been sending for one year, then you wrote me that I'm not competent to do any kind of programming, later you wrote that you would ignore all my requests and stop responding to any questions, then you have removed all my code from u-boot and showed me as the worst person in the world.
But seems that this is not enough for you. You have to continue attacking on me, and making everything even worse.
WHAT YOU WANT FROM ME NOW???? WHY YOU ARE CONTACTING ME??? IS NOT IT ENOUGH WHAT YOU HAVE TO ME?? Or you do think that I forgot what you have been doing with me last years? Speak up!
Quoted 160 lines · On Sunday 05 November 2023 21:25:38 Sean Anderson wrote:
This series adds support for loading all image types (Legacy (with and without LZMA), FIT (with and without
LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR, NET, FAT, EXT, NVMe, and semihosting load methods. It does this by introducing a helper function which handles the minutiae of invoking the proper parsing function, and reading the rest of the image.Hopefully, this will make it easier for load methods to support all image types that U-Boot supports, without having undocumented unsupported image types. I applied this to several loaders which were invoking
spl_load_simple_fitand/orspl_parse_image_header, but I did not use it with others (e.g. DFU/RAM) which had complications in the mix.This series is organized roughly into two parts. Patches up to "spl: Add generic
spl_loadfunction" are all setup or size-reduction oriented. Later patches generally convert various load functions tospl_load.bloat-o-meter results (for
CONFIG_SPLonly) at [1]. Size growth has been the bigegst challenge to preparing this series. I have used every trick I can think of to reduce bloat. Some SAMA boards no longer fit, but I have a plan to fix them [2].This is bar far the largest and most-difficult revision of this series to-date. There are probably still things which can reduce the size, but I have been working on this series for the better part of two months and I think it is a good idea to get some feedback. Because of the SAMA bloat, this series will not pass CI, so I expect to do a v7 before this is ready to apply. Feel free, however, to apply patches in the first half (especially the fixes).
This version of the series is better-tested than ever before, thanks to some new unit tests. However, things like the i.MX ROMAPI are untested. NAND should also be tested more-widely, for reasons listed in the commit message. I encourage you try this series out on your favorite board.
This series depends on [3]. (Almost passing) CI at [4].
[1] https://gist.github.com/Forty-Bot/5bfe88676dd3c2aec6ebc23abb08e06f
This includes some changes toam335x_evm_spibootandam65x_evm_r5_usbdfuwhich have since been undone.
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/[email protected]/
[4] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18447Changes in v6:
- Fix uninitialized return value when we can't get ablk_desc
- Don't close fd beforespl_load_simple_fit
- Remove NULL assignments inspl_load_info
- Remove dev fromspl_load_info
- Take advantage of bl_len's power-of-twoness
- Refactorspl_load_info->readto use units of bytes
- Remove filename fromspl_load_info
- Only supportbl_lenwhen we have to
- Removespl_nand_legacy_read
- Split off LZMA decompression into its own function
- Support testingLEGACY_LZMAfilesystem images
- Use pseudo-LTO forspl_load
- Align reads tobl_len
- AddSYS_MMCSD_RAW_MODEto help determine whetherSPL_MMCloads anything directly.
- Convert nand tospl_load
- Fix LZMA support
- Fix load address
- Fix invalid return fromspl_blk_load_image
- Fix soft reset after loading from SPI
- Explicitly initializeload_infomembers to reduce text size
- Rebase on u-boot/next
- Add option to disable DMA alignment for FATChanges in v5:
- MakeSHOW_ERRORSdepend on LIBCOMMON
- Load the header inspl_loadas well
- Don't bother trying to DMA-align the buffer, since we can't really fix it.
- Convert NVMe tospl_loadChanges in v4:
- Fix format specifiers in debug prints
- Reword/fix some of the doc comments forspl_load
- Rebase on u-boot/masterChanges in v3:
- Fix using ffs instead of fls
- Fix using not initializingbl_lenwheninfo->filenamewas NULL
- Fix failing on successChanges in v2:
- Use reverse-xmas-tree style for locals inspl_simple_read. This is not complete, since overhead depends onbl_mask.
- Convert semihosting as well
- Consolidatespi_load_image_osintospl_spi_load_imageSean Anderson (25):
spl:blk_fs: Fix uninitialized return value when we can't get a
blk_desc
arm: DisableSPL_FS_FATwhen it isn't used
spl: MakeSHOW_ERRORSdepend on LIBCOMMON
spl: semihosting: Don't close fd beforespl_load_simple_fit
spl: Remove NULL assignments inspl_load_info
spl: Remove dev fromspl_load_info
spl: Take advantage of bl_len's power-of-twoness
spl: Refactorspl_load_info->readto use units of bytes
spl: Remove filename fromspl_load_info
spl: Only supportbl_lenwhen we have to
spl: nand: Removespl_nand_legacy_read
spl: legacy: Split off LZMA decompression into its own function
test: spl: Support testingLEGACY_LZMAfilesystem images
spl: Add genericspl_loadfunction
spl: Convert ext to usespl_load
spl: Convert fat tospl_load
spl: Convert mmc tospl_load
spl: Convert nand tospl_load
spl: Convert net tospl_load
spl: Convert nor tospl_load
spl: Convert NVMe tospl_load
spl: Convert semihosting tospl_load
spl: Convert spi tospl_load
spl: spi: Consolidatespi_load_image_osintospl_spi_load_image
spl: fat: Add option to disable DMA alignmentarch/arm/mach-imx/spl_imx_romapi.c | 24 ++-- arch/arm/mach-sunxi/spl_spi_sunxi.c | 5 +- common/spl/Kconfig | 37 +++++- common/spl/spl.c | 13 +- common/spl/spl_blk_fs.c | 73 +++-------- common/spl/spl_ext.c | 36 +++--- common/spl/spl_fat.c | 62 ++++------ common/spl/spl_fit.c | 74 ++++------- common/spl/spl_imx_container.c | 55 ++++----- common/spl/spl_legacy.c | 110 ++++------------- common/spl/spl_mmc.c | 101 ++------------- common/spl/spl_nand.c | 104 ++++------------ common/spl/spl_net.c | 29 +---- common/spl/spl_nor.c | 42 ++----- common/spl/spl_ram.c | 2 +- common/spl/spl_semihosting.c | 65 ++-------- common/spl/spl_spi.c | 130 ++++--------------- common/spl/spl_ymodem.c | 4 +- configs/am335x_evm_spiboot_defconfig | 2 +- configs/am65x_evm_r5_usbdfu_defconfig | 1 - configs/xilinx_zynqmp_mini_qspi_defconfig | 3 + configs/zynq_cse_nand_defconfig | 3 + configs/zynq_cse_nor_defconfig | 3 + configs/zynq_cse_qspi_defconfig | 3 + drivers/usb/gadget/f_sdp.c | 10 +- include/spl.h | 60 +++++++-- include/spl_load.h | 144 ++++++++++++++++++++++ include/test/spl.h | 4 + test/image/Kconfig | 1 + test/image/spl_load.c | 13 +- test/image/spl_load_fs.c | 32 +++-- test/image/spl_load_nand.c | 2 + test/image/spl_load_net.c | 2 + test/image/spl_load_nor.c | 2 + test/image/spl_load_os.c | 16 ++- test/image/spl_load_spi.c | 1 + 36 files changed, 536 insertions(+), 732 deletions(-) create mode 100644 include/spl_load.hSignature · 1 line
2.37.1
Quoted 7 lines · Pali Rohár
What you are doing is the worst thing in the world. You have been ignoring all my changes which I have been sending for one year, then you wrote me that I'm not competent to do any kind of programming, later you wrote that you would ignore all my requests and stop responding to any questions, then you have removed all my code from u-boot and showed me as the worst person in the world.
Quoted 6 lines
But seems that this is not enough for you. You have to continue attacking on me, and making everything even worse.
WHAT YOU WANT FROM ME NOW???? WHY YOU ARE CONTACTING ME??? IS NOT IT ENOUGH WHAT YOU HAVE TO ME?? Or you do think that I forgot what you have been doing with me last years? Speak up!
I have created a patch for .mailmap to avoid sending Pali any further "unsolicited" mail.
[PATCH 1/1] .mailmap: map Pali Rohár
https://lists.denx.de/pipermail/u-boot/2023-November/536392.html
Best regards
Heinrich
Quoted 6 lines · On Mon, 6 Nov 2023 08:49:05 +0100 Pali Rohár <[email protected]> wrote:
What you are doing is the worst thing in the world. You have been ignoring all my changes which I have been sending for one year, then you wrote me that I'm not competent to do any kind of programming, later you wrote that you would ignore all my requests and stop responding to any questions, then you have removed all my code from u-boot and showed me as the worst person in the world.
I am sorry this happened the way it did. I personally do not think that you're not a competent programmer. On the contrary, I think that you're a very good programmer, and that what happened has more to do with an escalation of misunderstandings and relevant people being too busy at unfortunate times. This naturally led to frustrations and harsh language, which led to this unfortunate situation.
Just wanted to let you know that I am sorry about how this whole thing played out, and that I feel partially responsible for a little bit of it, since I also made you some promises ages ago which still are not fulfilled :-(
I have finally managed to recruit two newbie kernel hackers into our team. I am currently tutoring them, and one of the projects I have in the tutoring plan is getting the work you did out into the open. It will take some time, but my hopes are that it will be done.
Again, I am sorry. I hope you are doing well.
Marek