From 5e0404ff85fca50b5ac41bf08bbe46e6de4903e7 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 27 Aug 2019 11:54:31 -0600 Subject: [PATCH 1/9] board_f: fix noncached reservation calculation The current code in reserve_noncached() has two issues: 1) The first update of gd->start_addr_sp always rounds down to a section start. However, the equivalent calculation in cache.c:noncached_init() always first rounds up to a section start, then subtracts a section size. These two calculations differ if the initial value is already rounded to section alignment. 2) The second update of gd->start_addr_sp subtracts exactly CONFIG_SYS_NONCACHED_MEMORY, whereas the equivalent calculation in cache.c:noncached_init() rounds the noncached size up to section alignment before subtracting it. The two calculations differ if the noncached region size is not a multiple of the MMU section size. In practice, one/both of those issues causes a practical problem on Jetson TX1; U-Boot triggers a synchronous abort during initialization, likely due to overlapping use of some memory region. This change fixes both these issues by duplicating the exact calculations from noncached_init() into reserve_noncached(). However, this fix assumes that gd->start_addr_sp on entry to reserve_noncached() exactly matches mem_malloc_start on entry to noncached_init(). I haven't traced the code to see whether it absolutely guarantees this in all (or indeed any!) cases. Consequently, I added some comments in the hope that this condition will continue to be true. Fixes: 5f7adb5b1c02 ("board_f: reserve noncached space below malloc area") Cc: Vikas Manocha Signed-off-by: Stephen Warren --- arch/arm/lib/cache.c | 1 + common/board_f.c | 15 ++++++++++++--- common/board_r.c | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index 449544d11c..463d283cb7 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -77,6 +77,7 @@ void noncached_init(void) phys_addr_t start, end; size_t size; + /* If this calculation changes, update board_f.c:reserve_noncached() */ end = ALIGN(mem_malloc_start, MMU_SECTION_SIZE) - MMU_SECTION_SIZE; size = ALIGN(CONFIG_SYS_NONCACHED_MEMORY, MMU_SECTION_SIZE); start = end - size; diff --git a/common/board_f.c b/common/board_f.c index 6867abc8e6..591f18f391 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -470,9 +470,18 @@ static int reserve_uboot(void) #ifdef CONFIG_SYS_NONCACHED_MEMORY static int reserve_noncached(void) { - /* round down to SECTION SIZE (typicaly 1MB) limit */ - gd->start_addr_sp &= ~(MMU_SECTION_SIZE - 1); - gd->start_addr_sp -= CONFIG_SYS_NONCACHED_MEMORY; + /* + * The value of gd->start_addr_sp must match the value of malloc_start + * calculated in boatrd_f.c:initr_malloc(), which is passed to + * board_r.c:mem_malloc_init() and then used by + * cache.c:noncached_init() + * + * These calculations must match the code in cache.c:noncached_init() + */ + gd->start_addr_sp = ALIGN(gd->start_addr_sp, MMU_SECTION_SIZE) - + MMU_SECTION_SIZE; + gd->start_addr_sp -= ALIGN(CONFIG_SYS_NONCACHED_MEMORY, + MMU_SECTION_SIZE); debug("Reserving %dM for noncached_alloc() at: %08lx\n", CONFIG_SYS_NONCACHED_MEMORY >> 20, gd->start_addr_sp); diff --git a/common/board_r.c b/common/board_r.c index b7f68bba4a..d6fb5047a2 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -247,6 +247,10 @@ static int initr_malloc(void) gd->malloc_ptr / 1024); #endif /* The malloc area is immediately below the monitor copy in DRAM */ + /* + * This value MUST match the value of gd->start_addr_sp in board_f.c: + * reserve_noncached(). + */ malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN; mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN), TOTAL_MALLOC_LEN); From 1ce884797cb382c26afce8a62e4cc790dba6bb24 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Tue, 27 Aug 2019 15:32:18 +0800 Subject: [PATCH 2/9] Revert "blk: Invalidate block cache when switching hwpart" This reverts commit 0ebe112d09b48230ba4be833cd3504b06997d9a4. Most block devices have only one hwpart. Multiple hwparts only found used by eMMC devices in u-boot. The mmc driver do blk_dselect_hwpart() at the beginning of mmc_bread() which causes block cache being invalidated too frequently and makes block cache useless. So it's not a good idea to put blkcache_invalidate() in the common functions. It should be called inside mmc_select_hwpart(). Signed-off-by: Weijie Gao Tested-by: Felix Brack --- drivers/block/blk-uclass.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index c23b6682a6..baaf431e5e 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -208,11 +208,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart) if (ret) return ret; - ret = blk_select_hwpart(dev, hwpart); - if (!ret) - blkcache_invalidate(if_type, devnum); - - return ret; + return blk_select_hwpart(dev, hwpart); } int blk_list_part(enum if_type if_type) @@ -352,13 +348,7 @@ int blk_select_hwpart(struct udevice *dev, int hwpart) int blk_dselect_hwpart(struct blk_desc *desc, int hwpart) { - int ret; - - ret = blk_select_hwpart(desc->bdev, hwpart); - if (!ret) - blkcache_invalidate(desc->if_type, desc->devnum); - - return ret; + return blk_select_hwpart(desc->bdev, hwpart); } int blk_first_device(int if_type, struct udevice **devp) From 47b7fa30c419896a9ecd0ab957dad55d61310e08 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Tue, 27 Aug 2019 15:32:19 +0800 Subject: [PATCH 3/9] mmc: invalidate block cache after hwpart switched successfully eMMC device has multiple hw partitions both address from zero. However the mmc driver lacks block cache invalidation for switch hwpart. This causes a problem that data of current hw partition is cached before switching to another hw partition. And the following read operation of the latter hw partition will get wrong data when reading from the addresses that have been cached previously. To solve this problem, invalidate block cache after a successful mmc_switch_part() operation. Signed-off-by: Weijie Gao Tested-by: Felix Brack --- drivers/mmc/mmc-uclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 551007905c..2b146ea43c 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -360,6 +360,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) struct udevice *mmc_dev = dev_get_parent(bdev); struct mmc *mmc = mmc_get_mmc_dev(mmc_dev); struct blk_desc *desc = dev_get_uclass_platdata(bdev); + int ret; if (desc->hwpart == hwpart) return 0; @@ -367,7 +368,11 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) if (mmc->part_config == MMCPART_NOAVAILABLE) return -EMEDIUMTYPE; - return mmc_switch_part(mmc, hwpart); + ret = mmc_switch_part(mmc, hwpart); + if (!ret) + blkcache_invalidate(desc->if_type, desc->devnum); + + return ret; } static int mmc_blk_probe(struct udevice *dev) From 940dd143469102868fa604a9e84c2004c41352b1 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Tue, 27 Aug 2019 15:32:20 +0800 Subject: [PATCH 4/9] configs: enable CONFIG_BLOCK_CACHE for mt7623n_bpir2 This patch enables CONFIG_BLOCK_CACHE for mt7623n_bpir2. Signed-off-by: Weijie Gao --- configs/mt7623n_bpir2_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig index ae8209831b..f79850f849 100644 --- a/configs/mt7623n_bpir2_defconfig +++ b/configs/mt7623n_bpir2_defconfig @@ -31,7 +31,6 @@ CONFIG_ENV_IS_IN_MMC=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_REGMAP=y CONFIG_SYSCON=y -# CONFIG_BLOCK_CACHE is not set CONFIG_CLK=y CONFIG_DM_MMC=y # CONFIG_MMC_QUIRKS is not set From 27351ca804680ae5e1a531bae727f749f88f3e7b Mon Sep 17 00:00:00 2001 From: Suniel Mahesh Date: Tue, 27 Aug 2019 13:27:56 +0530 Subject: [PATCH 5/9] Makefile: clean build generated SPL binary for TI AM65x TI AM65x platforms (evm and HS) generate an SPL image 'tispl.bin*' and there is no rule for cleanup. Added entry for cleanup in clean target. Signed-off-by: Suniel Mahesh --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 76f9a7275b..0570d02e5d 100644 --- a/Makefile +++ b/Makefile @@ -1852,7 +1852,7 @@ clean: $(clean-dirs) -o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \ -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \ -type f -print | xargs rm -f \ - bl31.c bl31.elf bl31_*.bin image.map + bl31.c bl31.elf bl31_*.bin image.map tispl.bin* # mrproper - Delete all generated files, including .config # From 40a13173b5d461bd43184dc1478d3a0f5becf55f Mon Sep 17 00:00:00 2001 From: Suniel Mahesh Date: Thu, 29 Aug 2019 19:08:59 +0530 Subject: [PATCH 6/9] arm: omap2: am43xx: Enable CONFIG_DM_USB Enable CONFIG_DM_USB to remove compile warning for am43xx based targets: ===================== WARNING ====================== This board does not use CONFIG_DM_USB. Please update the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info. ==================================================== Signed-off-by: Suniel Mahesh --- configs/am43xx_evm_qspiboot_defconfig | 1 + configs/am43xx_evm_rtconly_defconfig | 1 + configs/am43xx_hs_evm_defconfig | 1 + 3 files changed, 3 insertions(+) diff --git a/configs/am43xx_evm_qspiboot_defconfig b/configs/am43xx_evm_qspiboot_defconfig index 06268ba909..b1bf67002b 100644 --- a/configs/am43xx_evm_qspiboot_defconfig +++ b/configs/am43xx_evm_qspiboot_defconfig @@ -50,6 +50,7 @@ CONFIG_SYS_NS16550=y CONFIG_SPI=y CONFIG_TI_QSPI=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/am43xx_evm_rtconly_defconfig b/configs/am43xx_evm_rtconly_defconfig index caf761b565..3064f3198d 100644 --- a/configs/am43xx_evm_rtconly_defconfig +++ b/configs/am43xx_evm_rtconly_defconfig @@ -49,6 +49,7 @@ CONFIG_TI_QSPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig index d634ab1450..8be210293c 100644 --- a/configs/am43xx_hs_evm_defconfig +++ b/configs/am43xx_hs_evm_defconfig @@ -59,6 +59,7 @@ CONFIG_TI_QSPI=y CONFIG_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_DWC3=y From 3c7166dbb464a65d9822cfee7c233a7d8c1a9672 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 22 Aug 2019 21:58:26 +0200 Subject: [PATCH 7/9] siemens: avoid out of bound access char num[1]; sprintf(num, "%d", i); leads to a buffer overrun. Simplify the overly complex coding. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Acked-by: Heiko Schocher --- board/siemens/common/board.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c index 676935a843..75462d1c34 100644 --- a/board/siemens/common/board.c +++ b/board/siemens/common/board.c @@ -189,14 +189,11 @@ void set_env_gpios(unsigned char state) { char *ptr_env; char str_tmp[5]; /* must contain "ledX"*/ - char num[1]; unsigned char i, idx, pos1, pos2, ccount; unsigned char gpio_n, gpio_s0, gpio_s1; for (i = 0; i < MAX_NR_LEDS; i++) { - strcpy(str_tmp, "led"); - sprintf(num, "%d", i); - strcat(str_tmp, num); + sprintf(str_tmp, "led%d", i); /* If env var is not found we stop */ ptr_env = env_get(str_tmp); From 296439e0b1670217f07d00bcd5d60be00b9bca70 Mon Sep 17 00:00:00 2001 From: Ryan Harkin Date: Tue, 27 Aug 2019 11:56:49 +0100 Subject: [PATCH 8/9] Revert "vexpress64: fvp dram: add DRAM configuration" This reverts commit fc04b923541d984b1544056fd3bfa8129d4e5aac where the FVP DRAM configuration was added. Signed-off-by: Ryan Harkin Acked-by: Linus Walleij Acked-by: Sudeep Holla --- arch/arm/Kconfig | 10 ------- board/armltd/vexpress64/Kconfig | 2 +- board/armltd/vexpress64/MAINTAINERS | 5 ---- configs/vexpress_aemv8a_dram_defconfig | 39 -------------------------- include/configs/vexpress_aemv8a.h | 17 ++--------- 5 files changed, 3 insertions(+), 70 deletions(-) delete mode 100644 configs/vexpress_aemv8a_dram_defconfig diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 37b2585f56..3b0e315061 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1066,16 +1066,6 @@ config TARGET_VEXPRESS64_BASE_FVP select PL01X_SERIAL select SEMIHOSTING -config TARGET_VEXPRESS64_BASE_FVP_DRAM - bool "Support Versatile Express ARMv8a FVP BASE model booting from DRAM" - select ARM64 - select PL01X_SERIAL - help - This target is derived from TARGET_VEXPRESS64_BASE_FVP and over-rides - the default config to allow the user to load the images directly into - DRAM using model parameters rather than by using semi-hosting to load - the files from the host filesystem. - config TARGET_VEXPRESS64_JUNO bool "Support Versatile Express Juno Development Platform" select ARM64 diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig index e05f353b80..9014418433 100644 --- a/board/armltd/vexpress64/Kconfig +++ b/board/armltd/vexpress64/Kconfig @@ -1,4 +1,4 @@ -if TARGET_VEXPRESS64_BASE_FVP || TARGET_VEXPRESS64_JUNO || TARGET_VEXPRESS64_BASE_FVP_DRAM +if TARGET_VEXPRESS64_BASE_FVP || TARGET_VEXPRESS64_JUNO config SYS_BOARD default "vexpress64" diff --git a/board/armltd/vexpress64/MAINTAINERS b/board/armltd/vexpress64/MAINTAINERS index 15b0a08646..0ba044d7ff 100644 --- a/board/armltd/vexpress64/MAINTAINERS +++ b/board/armltd/vexpress64/MAINTAINERS @@ -10,11 +10,6 @@ M: Linus Walleij S: Maintained F: configs/vexpress_aemv8a_semi_defconfig -VEXPRESS_AEMV8A_DRAM BOARD -M: Ryan Harkin -S: Maintained -F: configs/vexpress_aemv8a_dram_defconfig - JUNO DEVELOPMENT PLATFORM BOARD M: Linus Walleij S: Maintained diff --git a/configs/vexpress_aemv8a_dram_defconfig b/configs/vexpress_aemv8a_dram_defconfig deleted file mode 100644 index 51860da387..0000000000 --- a/configs/vexpress_aemv8a_dram_defconfig +++ /dev/null @@ -1,39 +0,0 @@ -CONFIG_ARM=y -CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM=y -CONFIG_SYS_TEXT_BASE=0x88000000 -CONFIG_SYS_MALLOC_F_LEN=0x2000 -CONFIG_NR_DRAM_BANKS=1 -CONFIG_IDENT_STRING=" vexpress_aemv8a" -CONFIG_DISTRO_DEFAULTS=y -CONFIG_BOOTDELAY=1 -CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 debug user_debug=31 androidboot.hardware=fvpbase root=/dev/vda2 rw rootwait loglevel=9" -# CONFIG_USE_BOOTCOMMAND is not set -# CONFIG_DISPLAY_CPUINFO is not set -# CONFIG_DISPLAY_BOARDINFO is not set -CONFIG_SYS_PROMPT="VExpress64# " -# CONFIG_CMD_CONSOLE is not set -# CONFIG_CMD_XIMG is not set -# CONFIG_CMD_EDITENV is not set -CONFIG_CMD_MEMTEST=y -CONFIG_CMD_ARMFLASH=y -# CONFIG_CMD_LOADS is not set -# CONFIG_CMD_ITEST is not set -# CONFIG_CMD_SETEXPR is not set -# CONFIG_CMD_NFS is not set -CONFIG_CMD_CACHE=y -# CONFIG_CMD_MISC is not set -CONFIG_CMD_UBI=y -# CONFIG_ISO_PARTITION is not set -# CONFIG_EFI_PARTITION is not set -CONFIG_ENV_IS_IN_FLASH=y -CONFIG_DM=y -# CONFIG_MMC is not set -CONFIG_MTD_NOR_FLASH=y -CONFIG_MTD_DEVICE=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_PROTECTION=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_DM_SERIAL=y -CONFIG_OF_LIBFDT=y diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 9746470552..b2c14f9e10 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -16,8 +16,7 @@ #define CONFIG_REMAKE_ELF /* Link Definitions */ -#if defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) || \ - defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM) +#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP /* ATF loads u-boot here for BASE_FVP model */ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x03f00000) #elif CONFIG_TARGET_VEXPRESS64_JUNO @@ -83,8 +82,7 @@ #define GICR_BASE (0x2f100000) #else -#if defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) || \ - defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM) +#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP #define GICD_BASE (0x2f000000) #define GICC_BASE (0x2c000000) #elif CONFIG_TARGET_VEXPRESS64_JUNO @@ -191,17 +189,6 @@ "booti $kernel_addr - $fdt_addr" -#elif CONFIG_TARGET_VEXPRESS64_BASE_FVP_DRAM -#define CONFIG_EXTRA_ENV_SETTINGS \ - "kernel_addr=0x80080000\0" \ - "initrd_addr=0x84000000\0" \ - "fdt_addr=0x83000000\0" \ - "fdt_high=0xffffffffffffffff\0" \ - "initrd_high=0xffffffffffffffff\0" - -#define CONFIG_BOOTCOMMAND "booti $kernel_addr $initrd_addr $fdt_addr" - - #endif /* Monitor Command Prompt */ From 47e8ee6b39a47dc0bbde43049dc83dbc48dcdb56 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 28 Aug 2019 11:00:46 +0000 Subject: [PATCH 9/9] Makefile: fix newline escaping for CONFIG_DEFAULT_ENV_FILE I wanted this to be compatible with mkenvimage, including the ability to embed newlines in variables by escaping them. But I failed to check that it works more than once. Fixes: f3d8f7dd73a (Allow providing default environment from file) Signed-off-by: Rasmus Villemoes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0570d02e5d..c02accfc26 100644 --- a/Makefile +++ b/Makefile @@ -1700,7 +1700,7 @@ define filechk_defaultenv.h (grep -v '^#' | \ grep -v '^$$' | \ tr '\n' '\0' | \ - sed -e 's/\\\x0/\n/' | \ + sed -e 's/\\\x0/\n/g' | \ xxd -i ; echo ", 0x00" ; ) endef