From 1e7879045f6c20f68ce2c6fcce7ec187e8844b51 Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Fri, 7 May 2021 14:40:34 +0530 Subject: [PATCH 1/9] pinctrl: single: Fix probe failure getting register area size If reg property of pinctrl-single node requires address translation then probe fails with following message: single-pinctrl pinctrl@4301c000: failed to get base register size This is because driver uses dev_read_addr_size() to get size which also tries to fetch untranslated addr and fails. Fix this by using dev_read_addr_size_index() which takes care of address translation and also makes following dev_read_addr() call redundant. This fixes Ethernet failures on TI's AM654 based EVMs due to lack of pinmux configuration. Fixes: 9fd8a430f3 ("pinctrl: single: get register area size by device API") Signed-off-by: Vignesh Raghavendra --- drivers/pinctrl/pinctrl-single.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index ebb7602dde..7af6c5f0b0 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -509,19 +509,13 @@ static int single_of_to_plat(struct udevice *dev) return -EINVAL; } - addr = dev_read_addr_size(dev, "reg", &size); + addr = dev_read_addr_size_index(dev, 0, &size); if (addr == FDT_ADDR_T_NONE) { - dev_err(dev, "failed to get base register size\n"); + dev_err(dev, "failed to get base register address\n"); return -EINVAL; } pdata->offset = size - pdata->width / BITS_PER_BYTE; - - addr = dev_read_addr(dev); - if (addr == FDT_ADDR_T_NONE) { - dev_dbg(dev, "no valid base register address\n"); - return -EINVAL; - } pdata->base = addr; ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask); From 26de4296cc20bb45eb40560b4a4a98fa90a16a28 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sat, 15 May 2021 14:13:54 -0400 Subject: [PATCH 2/9] part: Add check for NULL dev_part_str Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str. While blk_get_device_part_str handles this fine, part_get_info_by_dev_and_name does not. This fixes commands crashing when implicitly using bootdevice. The unit test has also been updated to set bootdevice to a known value and to restore it after we are done. Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions") Reported-by: Heinrich Schuchardt Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- disk/part.c | 6 +++++- test/dm/part.c | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/disk/part.c b/disk/part.c index 5e7e59cf25..086da84b7f 100644 --- a/disk/part.c +++ b/disk/part.c @@ -714,7 +714,11 @@ static int part_get_info_by_dev_and_name(const char *dev_iface, int ret; /* Separate device and partition name specification */ - part_str = strchr(dev_part_str, '#'); + if (dev_part_str) + part_str = strchr(dev_part_str, '#'); + else + part_str = NULL; + if (part_str) { dup_str = strdup(dev_part_str); dup_str[part_str - dev_part_str] = 0; diff --git a/test/dm/part.c b/test/dm/part.c index 051e9010b6..78dd8472c2 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -11,11 +11,25 @@ #include #include -static int dm_test_part(struct unit_test_state *uts) +static inline int do_test(struct unit_test_state *uts, int expected, + const char *part_str, bool whole) { - char str_disk_guid[UUID_STR_LEN + 1]; struct blk_desc *mmc_dev_desc; struct disk_partition part_info; + + ut_asserteq(expected, + part_get_info_by_dev_and_name_or_num("mmc", part_str, + &mmc_dev_desc, + &part_info, whole)); + return 0; +} + +static int dm_test_part(struct unit_test_state *uts) +{ + char *oldbootdevice; + char str_disk_guid[UUID_STR_LEN + 1]; + int ret; + struct blk_desc *mmc_dev_desc; struct disk_partition parts[2] = { { .start = 48, /* GPT data takes up the first 34 blocks or so */ @@ -38,16 +52,22 @@ static int dm_test_part(struct unit_test_state *uts) ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts, ARRAY_SIZE(parts))); -#define test(expected, part_str, whole) \ - ut_asserteq(expected, \ - part_get_info_by_dev_and_name_or_num("mmc", part_str, \ - &mmc_dev_desc, \ - &part_info, whole)) + oldbootdevice = env_get("bootdevice"); +#define test(expected, part_str, whole) do { \ + ret = do_test(uts, expected, part_str, whole); \ + if (ret) \ + goto out; \ +} while (0) + + env_set("bootdevice", NULL); + test(-ENODEV, NULL, true); test(-ENODEV, "", true); env_set("bootdevice", "0"); + test(0, NULL, true); test(0, "", true); env_set("bootdevice", "1"); + test(1, NULL, false); test(1, "", false); test(1, "-", false); env_set("bootdevice", ""); @@ -70,7 +90,10 @@ static int dm_test_part(struct unit_test_state *uts) test(-EINVAL, "1#bogus", false); test(1, "1#test1", false); test(2, "1#test2", false); + ret = 0; - return 0; +out: + env_set("bootdevice", oldbootdevice); + return ret; } DM_TEST(dm_test_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); From f6c0d365d3e8ee8e4fd3ebe2ed957c2bca9d3328 Mon Sep 17 00:00:00 2001 From: Matt Merhar Date: Mon, 17 May 2021 17:32:48 +0000 Subject: [PATCH 3/9] powerpc: fix regression in arch_initr_trap() The assembly output of the arch_initr_trap() function differed by a single byte after common.h was removed from traps.c: fff49a18 : fff49a18: 94 21 ff f0 stwu r1,-16(r1) fff49a1c: 7c 08 02 a6 mflr r0 fff49a20: 90 01 00 14 stw r0,20(r1) -fff49a24: 80 62 00 44 lwz r3,68(r2) +fff49a24: 80 62 00 38 lwz r3,56(r2) fff49a28: 4b ff 76 19 bl fff41040 fff49a2c: 80 01 00 14 lwz r0,20(r1) fff49a30: 38 60 00 00 li r3,0 fff49a34: 38 21 00 10 addi r1,r1,16 fff49a38: 7c 08 03 a6 mtlr r0 This was causing a consistent hard lockup during the MMC read / loading of the QoriQ FMan firmware on a P2041RDB board. Re-adding the header causes identical assembly to be emitted and allows the firmware loading and subsequent boot to succeed. Fixes: 401d1c4f5d ("common: Drop asm/global_data.h from common header") Signed-off-by: Matt Merhar --- arch/powerpc/lib/traps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c index c7bce82a44..ab8ca269a5 100644 --- a/arch/powerpc/lib/traps.c +++ b/arch/powerpc/lib/traps.c @@ -4,6 +4,7 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ +#include #include #include From 53ba2c21c2df142b37bb2f0d6850d79dcfd8976f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 17 May 2021 08:21:39 +0200 Subject: [PATCH 4/9] fs/squashfs: zero out unused fields in fs_dirent When reading directories the UEFI sub-system must supply file attributes and timestamps. These fields will have to be added to struct fs_dirent. SquashFS should not fill these fields with random data. Ensure that they are zeroed out. Signed-off-by: Heinrich Schuchardt Reviewed-by: Miquel Raynal --- fs/squashfs/sqfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 29805c3c6f..997be2dcf4 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -876,7 +876,7 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp) char **token_list = NULL, *path = NULL; u32 *pos_list = NULL; - dirs = malloc(sizeof(*dirs)); + dirs = calloc(1, sizeof(*dirs)); if (!dirs) return -EINVAL; From 9e8bb078859a559b17effdb21bafdb050b859b6e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 18 May 2021 00:39:39 +0200 Subject: [PATCH 5/9] fs: btrfs: Add missing cache aligned allocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The superblock buffer must be cache aligned, since it might be used in DMA context, allocate it using ALLOC_CACHE_ALIGN_BUFFER() just like it was done in btrfs_read_superblock() and read_tree_node(). This fixes this output on boot and non-working btrfs on iMX53: CACHE: Misaligned operation at range [ced299d0, ced2a9d0] Signed-off-by: Marek Vasut Cc: Marek BehĂșn Cc: Qu Wenruo Reviewed-by: Marek BehĂșn --- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c6fdec95c1..349411c3cc 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -291,7 +291,7 @@ error_out: int btrfs_read_dev_super(struct blk_desc *desc, struct disk_partition *part, struct btrfs_super_block *sb) { - char tmp[BTRFS_SUPER_INFO_SIZE]; + ALLOC_CACHE_ALIGN_BUFFER(char, tmp, BTRFS_SUPER_INFO_SIZE); struct btrfs_super_block *buf = (struct btrfs_super_block *)tmp; int ret; From ce869b55f8bebdaeed62b45d273e6133e976e8ec Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 20 May 2021 13:08:44 +0200 Subject: [PATCH 6/9] spl: Kconfig: Use tabs instead of space for alignment A lot of entries were using spaces instead of tab for alignment that's why it is good to fix it to use the same style everywhere. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- common/spl/Kconfig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index df5468f1ac..b709a05a7b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -165,7 +165,7 @@ config SPL_BOARD_INIT provided by the board. config SPL_BOOTROM_SUPPORT - bool "Support returning to the BOOTROM" + bool "Support returning to the BOOTROM" help Some platforms (e.g. the Rockchip RK3368) provide support in their ROM for loading the next boot-stage after performing basic setup @@ -707,7 +707,7 @@ config SYS_MMCSD_FS_BOOT_PARTITION default 1 help Partition on the MMC to load U-Boot from when the MMC is being - used in fs mode + used in fs mode config SPL_MMC_TINY bool "Tiny MMC framework in SPL" @@ -784,8 +784,8 @@ config SPL_NAND_SIMPLE config SPL_NAND_BASE depends on SPL_NAND_DRIVERS bool "Use Base NAND Driver" - help - Include nand_base.c in the SPL. + help + Include nand_base.c in the SPL. config SPL_NAND_IDENT depends on SPL_NAND_BASE @@ -1301,7 +1301,7 @@ config SPL_ATF_LOAD_IMAGE_V2 method, say Y. config SPL_ATF_NO_PLATFORM_PARAM - bool "Pass no platform parameter" + bool "Pass no platform parameter" depends on SPL_ATF help While we expect to call a pointer to a valid FDT (or NULL) @@ -1395,7 +1395,7 @@ config TPL_BOOTCOUNT_LIMIT For example, it may be useful to choose the device to boot. config TPL_LDSCRIPT - string "Linker script for the TPL stage" + string "Linker script for the TPL stage" depends on TPL default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64 default "arch/\$(ARCH)/cpu/u-boot-spl.lds" @@ -1409,7 +1409,7 @@ config TPL_LDSCRIPT fall back to the linker-script used for the SPL stage. config TPL_NEEDS_SEPARATE_TEXT_BASE - bool "TPL needs a separate text-base" + bool "TPL needs a separate text-base" default n depends on TPL help @@ -1418,7 +1418,7 @@ config TPL_NEEDS_SEPARATE_TEXT_BASE .text sections of the TPL stage has to be set below. config TPL_NEEDS_SEPARATE_STACK - bool "TPL needs a separate initial stack-pointer" + bool "TPL needs a separate initial stack-pointer" default n depends on TPL help @@ -1426,20 +1426,20 @@ config TPL_NEEDS_SEPARATE_STACK stack-pointer from the settings for the SPL stage. config TPL_TEXT_BASE - hex "Base address for the .text section of the TPL stage" + hex "Base address for the .text section of the TPL stage" depends on TPL_NEEDS_SEPARATE_TEXT_BASE help The base address for the .text section of the TPL stage. config TPL_MAX_SIZE - int "Maximum size (in bytes) for the TPL stage" + int "Maximum size (in bytes) for the TPL stage" default 0 depends on TPL help The maximum size (in bytes) of the TPL stage. config TPL_STACK - hex "Address of the initial stack-pointer for the TPL stage" + hex "Address of the initial stack-pointer for the TPL stage" depends on TPL_NEEDS_SEPARATE_STACK help The address of the initial stack-pointer for the TPL stage. @@ -1457,7 +1457,7 @@ config TPL_READ_ONLY device-private data. config TPL_BOOTROM_SUPPORT - bool "Support returning to the BOOTROM (from TPL)" + bool "Support returning to the BOOTROM (from TPL)" help Some platforms (e.g. the Rockchip RK3368) provide support in their ROM for loading the next boot-stage after performing basic setup From 77bfaad04836bf64c2bfccf1b9517639e9d27602 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Thu, 20 May 2021 22:09:46 +0300 Subject: [PATCH 7/9] test: Fix filesystem tests always being skipped Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") fixes an issue in the filesystem tests where the test setup may fail to mount an image and still attempt to unmount it. However, the commit unintentionally breaks the test setups in two ways. The newly created unmounted filesystem images are being immediately deleted due to some cleanup steps being misplaced into finally blocks, which makes them always run instead of only on failures. The mount calls always fail since the images never exist, causing the tests to be always skipped. This patch moves these cleanup calls into the except blocks to fix this and makes the tests run again. There are also unmount calls misplaced into finally blocks, making them run after the tests instead of before the tests. These unmount calls make the filesystem image file consistent with the changes made to it as part of the test setup, and this misplacement is making a number of tests fail unexpectedly. The unmount calls must be run before the tests use the image, meaning before the yield call and not in the finally block. They must also be run as a cleanup step when the filesystem setup fails, so they can't be placed as the final call in the try blocks since they would be skipped on such failures. For these reasons, this patch places the unmount calls both in the except blocks and the else blocks of the final setup step. This makes the unexpectedly failing tests to succeed again. Furthermore, this isolates the mount calls to their own try-except statement to avoid reintroducing the original issue of unmounting a not-mounted image while fixing the unmount misplacement. After these fixes, running "make tests" with guestmount available results in two test failures not related to the mentioned commit. If the guestmount executables are unavailable, the mounts fallback to using sudo and result in no failures. Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") Signed-off-by: Alper Nebi Yasak Acked-by: Andy Shevchenko --- test/py/tests/test_fs/conftest.py | 48 +++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index 50af9efcf7..410a675b97 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -278,14 +278,19 @@ def fs_obj_basic(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a subdirectory. check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) @@ -348,11 +353,12 @@ def fs_obj_basic(request, u_boot_config): except CalledProcessError as err: pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -394,14 +400,19 @@ def fs_obj_ext(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a test directory check_call('mkdir %s/dir1' % mount_dir, shell=True) @@ -443,11 +454,12 @@ def fs_obj_ext(request, u_boot_config): check_call('rm %s' % tmp_file, shell=True) except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -517,14 +529,19 @@ def fs_obj_unlink(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Test Case 1 & 3 check_call('mkdir %s/dir1' % mount_dir, shell=True) check_call('dd if=/dev/urandom of=%s/dir1/file1 bs=1K count=1' @@ -548,11 +565,12 @@ def fs_obj_unlink(request, u_boot_config): except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -594,14 +612,19 @@ def fs_obj_symlink(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a subdirectory. check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) @@ -625,10 +648,11 @@ def fs_obj_symlink(request, u_boot_config): except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) From b725ed50714ff817cc0d8ccbc9c3655032587382 Mon Sep 17 00:00:00 2001 From: Harm Berntsen Date: Fri, 21 May 2021 21:59:45 +0200 Subject: [PATCH 8/9] GitLab: Remove tags for sandbox_noinst tests Commit 712cc962b70d ("GitLab: Remove "tags" stanzas") removed the 'all' tag from all the jobs. The sandbox_noinst_test.py test was added in between the author date and commit date (commit 6c914e4232cd ("azure/gitlab: Add tests for sandbox_noinst")) which is probably why it still contains the tags. This commit fixes that so all jobs now don't require tags on the GitLab runners. Signed-off-by: Harm Berntsen CC: Simon Glass Acked-by: Pratyush Yadav --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e250f3654..d072e833a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -189,7 +189,6 @@ sandbox_spl test.py: <<: *buildman_and_testpy_dfn sandbox_noinst_test.py: - tags: [ 'all' ] variables: TEST_PY_BD: "sandbox_noinst" TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" From cb6c9c83e2f1cb5b96851445dbf3dea8541cb212 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sun, 23 May 2021 13:00:56 -0400 Subject: [PATCH 9/9] test: Remove duplicate macro ut_asserteq_strn is defined twice. Remove one definition. Fixes: 33d7edfd5f ("test: Add a way to check part of a console line or skip it") Signed-off-by: Sean Anderson Reviewed-by: Heinrich Schuchardt --- include/test/ut.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/include/test/ut.h b/include/test/ut.h index fbbba286ee..656e25fe57 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -177,23 +177,6 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes); } \ } -/* - * Assert that two string expressions are equal, up to length of the - * first - */ -#define ut_asserteq_strn(expr1, expr2) { \ - const char *_val1 = (expr1), *_val2 = (expr2); \ - int _len = strlen(_val1); \ - \ - if (memcmp(_val1, _val2, _len)) { \ - ut_failf(uts, __FILE__, __LINE__, __func__, \ - #expr1 " = " #expr2, \ - "Expected \"%.*s\", got \"%.*s\"", \ - _len, _val1, _len, _val2); \ - return CMD_RET_FAILURE; \ - } \ -} - /* Assert that two memory areas are equal */ #define ut_asserteq_mem(expr1, expr2, len) { \ const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \