From b142d0ac1946701f4d592869c2d81e42afe2e294 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 28 Apr 2020 21:40:13 +0200 Subject: cmd/gpt: avoid NULL check before free() free() checks if its argument is NULL. Do not duplicate this in the calling code. Signed-off-by: Heinrich Schuchardt Reviewed-by: Tom Rini --- cmd/gpt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/gpt.c b/cmd/gpt.c index b94f0051cdd..b8d11c167df 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -772,11 +772,9 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm, out: del_gpt_info(); #ifdef CONFIG_RANDOM_UUID - if (str_disk_guid) - free(str_disk_guid); + free(str_disk_guid); #endif - if (new_partitions) - free(new_partitions); + free(new_partitions); free(partitions_list); return ret; } -- cgit v1.2.3 From 5fb292f20f0d28bf916b4e480c9ab4a24713116c Mon Sep 17 00:00:00 2001 From: Ovidiu Panait Date: Mon, 20 Apr 2020 10:31:45 +0300 Subject: cmd/bedbug.c: Make bedbug_init have a return value Do this as a preparation for removing initr_bedbug wrapper from common/board_r.c. Signed-off-by: Ovidiu Panait Reviewed-by: Simon Glass --- cmd/bedbug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/bedbug.c b/cmd/bedbug.c index 9fee5288301..d3e31212eab 100644 --- a/cmd/bedbug.c +++ b/cmd/bedbug.c @@ -44,10 +44,10 @@ int bedbug_puts (const char *str) * settings. * ====================================================================== */ -void bedbug_init (void) +int bedbug_init(void) { /* -------------------------------------------------- */ - return; + return 0; } /* bedbug_init */ -- cgit v1.2.3 From b40745e5c29a45ebe7efce53a1e3ba751d0ef351 Mon Sep 17 00:00:00 2001 From: Joel Johnson Date: Sat, 25 Apr 2020 20:54:56 -0600 Subject: cmd: mvebu: bubt: fix quoted string split across lines Update quoted string alignment to address checkpatch.pl warning originally introduced in commit f60a66ef5d7d ("cmd: mvebu: bubt: show image boot device"). Signed-off-by: Joel Johnson Reviewed-by: Simon Glass --- cmd/mvebu/bubt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index dc0ce01c358..ef53153c46b 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -730,8 +730,8 @@ static int bubt_check_boot_mode(const struct bubt_dev *dst) for (int i = 0; i < ARRAY_SIZE(a38x_boot_modes); i++) { if (a38x_boot_modes[i].id == hdr->blockid) { - printf("Error: A38x image meant to be " - "booted from \"%s\", not \"%s\"!\n", + printf("Error: A38x image meant to be booted from " + "\"%s\", not \"%s\"!\n", a38x_boot_modes[i].name, dst->name); return -ENOEXEC; } -- cgit v1.2.3 From 8d99d5434b1c98c832f7a1aa0a0e0c9ab4c284a1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 30 Apr 2020 22:02:13 -0600 Subject: cmd: Add an indication of 32/64-bit to bdinfo It is useful to know what mode U-Boot is running in. Add a message at the end of the 'bdinfo' output. Suggested-by: Mark Kettenis Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Reviewed-by: Bin Meng Tested-by: Bin Meng [bmeng: change commit tag to 'cmd' as this is not x86 specific] Signed-off-by: Bin Meng --- cmd/bdinfo.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index d6a7175b379..9edcf8d74eb 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -15,6 +15,11 @@ DECLARE_GLOBAL_DATA_PTR; +__maybe_unused void print_cpu_word_size(void) +{ + printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8); +} + __maybe_unused static void print_num(const char *name, ulong value) { @@ -208,6 +213,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_baudrate(); print_num("relocaddr", gd->relocaddr); board_detail(); + print_cpu_word_size(); + return 0; } @@ -227,6 +234,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); return 0; } @@ -252,6 +260,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("fdt_blob", (ulong)gd->fdt_blob); print_num("new_fdt", (ulong)gd->new_fdt); print_num("fdt_size", (ulong)gd->fdt_size); + print_cpu_word_size(); return 0; } @@ -283,6 +292,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); return 0; } @@ -294,6 +304,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_std_bdinfo(gd->bd); print_num("relocaddr", gd->relocaddr); print_num("reloc off", gd->reloc_off); + print_cpu_word_size(); return 0; } @@ -354,6 +365,7 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, #endif if (gd->fdt_blob) print_num("fdt_blob", (ulong)gd->fdt_blob); + print_cpu_word_size(); return 0; } @@ -368,6 +380,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_bi_flash(bd); print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); + return 0; } @@ -388,6 +402,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_mhz("ethspeed", bd->bi_ethspeed); #endif print_baudrate(); + print_cpu_word_size(); return 0; } @@ -405,6 +420,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) print_num("FB base ", gd->fb_base); #endif + print_cpu_word_size(); + return 0; } @@ -419,6 +436,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_bi_dram(bd); print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); return 0; } @@ -435,6 +453,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("reloc off", gd->reloc_off); print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); return 0; } @@ -448,6 +467,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_bi_mem(bd); print_eth_ip_addr(); print_baudrate(); + print_cpu_word_size(); return 0; } -- cgit v1.2.3 From a30c72319cc1e486a680efe2d0c94d58f4957e85 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 2 May 2020 16:08:37 +0200 Subject: cmd: efidebug: simplify UEFI protocol calls We should not to refer to a function via the run-time or boot services tables if the function is exported. Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'cmd') diff --git a/cmd/efidebug.c b/cmd/efidebug.c index d4030fee645..d8a76d78a38 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -17,7 +17,6 @@ #include #define BS systab.boottime -#define RT systab.runtime /** * efi_get_device_handle_info() - get information of UEFI device @@ -69,7 +68,7 @@ static int do_efi_show_devices(cmd_tbl_t *cmdtp, int flag, u16 *dev_path_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer(ALL_HANDLES, NULL, NULL, + ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, &num, &handles)); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; @@ -86,7 +85,7 @@ static int do_efi_show_devices(cmd_tbl_t *cmdtp, int flag, } } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -148,7 +147,7 @@ static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, u16 *driver_name, *image_path_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer( + ret = EFI_CALL(efi_locate_handle_buffer( BY_PROTOCOL, &efi_guid_driver_binding_protocol, NULL, &num, &handles)); if (ret != EFI_SUCCESS) @@ -170,12 +169,12 @@ static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, else printf("%p %-20ls \n", handles[i], driver_name); - EFI_CALL(BS->free_pool(driver_name)); - EFI_CALL(BS->free_pool(image_path_text)); + efi_free_pool(driver_name); + efi_free_pool(image_path_text); } } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -321,7 +320,7 @@ static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, const char *guid_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer(ALL_HANDLES, NULL, NULL, + ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, &num, &handles)); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; @@ -355,7 +354,7 @@ static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, putc('\n'); } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -463,18 +462,17 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, int i; efi_status_t ret; - ret = EFI_CALL(BS->get_memory_map(&map_size, memmap, NULL, NULL, NULL)); + ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL); if (ret == EFI_BUFFER_TOO_SMALL) { map_size += sizeof(struct efi_mem_desc); /* for my own */ - ret = EFI_CALL(BS->allocate_pool(EFI_LOADER_DATA, - map_size, (void *)&memmap)); + ret = efi_allocate_pool(EFI_LOADER_DATA, map_size, + (void *)&memmap); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; - ret = EFI_CALL(BS->get_memory_map(&map_size, memmap, - NULL, NULL, NULL)); + ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL); } if (ret != EFI_SUCCESS) { - EFI_CALL(BS->free_pool(memmap)); + efi_free_pool(memmap); return CMD_RET_FAILURE; } @@ -501,7 +499,7 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, putc('\n'); } - EFI_CALL(BS->free_pool(memmap)); + efi_free_pool(memmap); return CMD_RET_SUCCESS; } @@ -615,7 +613,7 @@ static int do_efi_boot_add(cmd_tbl_t *cmdtp, int flag, goto out; } - ret = EFI_CALL(RT->set_variable(var_name16, &guid, + ret = EFI_CALL(efi_set_variable(var_name16, &guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -670,7 +668,7 @@ static int do_efi_boot_rm(cmd_tbl_t *cmdtp, int flag, p = var_name16; utf8_utf16_strncpy(&p, var_name, 9); - ret = EFI_CALL(RT->set_variable(var_name16, &guid, 0, 0, NULL)); + ret = EFI_CALL(efi_set_variable(var_name16, &guid, 0, 0, NULL)); if (ret) { printf("Cannot remove %ls\n", var_name16); return CMD_RET_FAILURE; @@ -864,7 +862,7 @@ static int show_efi_boot_order(void) efi_status_t ret; size = 0; - ret = EFI_CALL(RT->get_variable(L"BootOrder", &efi_global_variable_guid, + ret = EFI_CALL(efi_get_variable(L"BootOrder", &efi_global_variable_guid, NULL, &size, NULL)); if (ret != EFI_BUFFER_TOO_SMALL) { if (ret == EFI_NOT_FOUND) { @@ -975,7 +973,7 @@ static int do_efi_boot_next(cmd_tbl_t *cmdtp, int flag, guid = efi_global_variable_guid; size = sizeof(u16); - ret = EFI_CALL(RT->set_variable(L"BootNext", &guid, + ret = EFI_CALL(efi_set_variable(L"BootNext", &guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -1036,7 +1034,7 @@ static int do_efi_boot_order(cmd_tbl_t *cmdtp, int flag, } guid = efi_global_variable_guid; - ret = EFI_CALL(RT->set_variable(L"BootOrder", &guid, + ret = EFI_CALL(efi_set_variable(L"BootOrder", &guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, -- cgit v1.2.3 From c2a2123e33371b2dc3406789764996d4fa73aac3 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 28 Apr 2020 11:38:03 +0200 Subject: cmd: cache: Fix non-cached memory cachability If dcache is switched OFF to ON state and if non-cached memory is used, this non-cached memory must be re-declared as uncached to mmu each time dcache is set ON. Introduce noncached_set_region() to set this non-cached region's mmu settings. Let architecture override it by defining it as a weak function. For ARM architecture, noncached_set_region() defines all noncached region as non-cacheable. Issue found on STM32MP1 platform using dwc_eth_qos ethernet driver, when going from dcache OFF to dcache ON state, ethernet driver issued TX timeout errors when performing dhcp or ping. It can be reproduced with the following sequence: dhcp while true ; do ping 192.168.1.300 ; dcache off ; ping 192.168.1.300 ; dcache on ; done Signed-off-by: Patrice Chotard Cc: Marek Vasut Cc: Joe Hershberger Cc: Ramon Fried Cc: Stephen Warren Reviewed-by: Marek Vasut --- cmd/cache.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmd') diff --git a/cmd/cache.c b/cmd/cache.c index 27dcec09316..7678615dd83 100644 --- a/cmd/cache.c +++ b/cmd/cache.c @@ -20,6 +20,10 @@ void __weak invalidate_icache_all(void) puts("No arch specific invalidate_icache_all available!\n"); } +__weak void noncached_set_region(void) +{ +} + static int do_icache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { switch (argc) { @@ -64,6 +68,7 @@ static int do_dcache(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; case 1: dcache_enable(); + noncached_set_region(); break; case 2: flush_dcache_all(); -- cgit v1.2.3 From 5168d7a6264be30f82c1c074e43c24fcacbb4283 Mon Sep 17 00:00:00 2001 From: Thirupathaiah Annapureddy Date: Wed, 18 Mar 2020 11:38:42 -0700 Subject: menu: add support for client defined statusline function Currently displaying status line is done in a weak function menu_display_statusline(). bootmenu.c overrides the weak default function. It calls menu_default_choice() and interprets the data as struct bootmenu_entry. pxe boot also uses common menu code for pxe menus. If there is a system that enables both bootmenu and pxe, menu_display_statusline() defined in bootmenu.c will be called and it will interpret struct pxe_label as struct bootmenu_entry. This leads to data aborts and pxe menu corruptions. This patch adds support for client defined statusline function to resolve the above bug. Signed-off-by: Thirupathaiah Annapureddy --- cmd/bootmenu.c | 61 +++++++++++++++++++++++++++++---------------------------- cmd/pxe_utils.c | 2 +- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'cmd') diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 3dc2c854aca..f1562883f52 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -365,6 +365,34 @@ cleanup: return NULL; } +static void menu_display_statusline(struct menu *m) +{ + struct bootmenu_entry *entry; + struct bootmenu_data *menu; + + if (menu_default_choice(m, (void *)&entry) < 0) + return; + + menu = entry->menu; + + printf(ANSI_CURSOR_POSITION, 1, 1); + puts(ANSI_CLEAR_LINE); + printf(ANSI_CURSOR_POSITION, 2, 1); + puts(" *** U-Boot Boot Menu ***"); + puts(ANSI_CLEAR_LINE_TO_END); + printf(ANSI_CURSOR_POSITION, 3, 1); + puts(ANSI_CLEAR_LINE); + + /* First 3 lines are bootmenu header + 2 empty lines between entries */ + printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); + puts(ANSI_CLEAR_LINE); + printf(ANSI_CURSOR_POSITION, menu->count + 6, 1); + puts(" Press UP/DOWN to move, ENTER to select"); + puts(ANSI_CLEAR_LINE_TO_END); + printf(ANSI_CURSOR_POSITION, menu->count + 7, 1); + puts(ANSI_CLEAR_LINE); +} + static void bootmenu_show(int delay) { int init = 0; @@ -396,8 +424,9 @@ static void bootmenu_show(int delay) if (!bootmenu) return; - menu = menu_create(NULL, bootmenu->delay, 1, bootmenu_print_entry, - bootmenu_choice_entry, bootmenu); + menu = menu_create(NULL, bootmenu->delay, 1, menu_display_statusline, + bootmenu_print_entry, bootmenu_choice_entry, + bootmenu); if (!menu) { bootmenu_destroy(bootmenu); return; @@ -445,34 +474,6 @@ cleanup: #endif } -void menu_display_statusline(struct menu *m) -{ - struct bootmenu_entry *entry; - struct bootmenu_data *menu; - - if (menu_default_choice(m, (void *)&entry) < 0) - return; - - menu = entry->menu; - - printf(ANSI_CURSOR_POSITION, 1, 1); - puts(ANSI_CLEAR_LINE); - printf(ANSI_CURSOR_POSITION, 2, 1); - puts(" *** U-Boot Boot Menu ***"); - puts(ANSI_CLEAR_LINE_TO_END); - printf(ANSI_CURSOR_POSITION, 3, 1); - puts(ANSI_CLEAR_LINE); - - /* First 3 lines are bootmenu header + 2 empty lines between entries */ - printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); - puts(ANSI_CLEAR_LINE); - printf(ANSI_CURSOR_POSITION, menu->count + 6, 1); - puts(" Press UP/DOWN to move, ENTER to select"); - puts(ANSI_CLEAR_LINE_TO_END); - printf(ANSI_CURSOR_POSITION, menu->count + 7, 1); - puts(ANSI_CLEAR_LINE); -} - #ifdef CONFIG_AUTOBOOT_MENU_SHOW int menu_show(int bootdelay) { diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 53af04d7dc7..c244bfb10d6 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -1237,7 +1237,7 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) * Create a menu and add items for all the labels. */ m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10), - cfg->prompt, label_print, NULL, NULL); + cfg->prompt, NULL, label_print, NULL, NULL); if (!m) return NULL; -- cgit v1.2.3 From 9900e4623a9a826447b0467cabc29e09fdf29fb6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 6 May 2020 02:01:34 +0200 Subject: efi_loader: use logical and in do_env_print_efi() If we want to check if two booleans are true, we should use a logical conjunction (&&) and not a bitwise and-operator (&). Signed-off-by: Heinrich Schuchardt --- cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 837e39e0217..6f69a84feaa 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -298,7 +298,7 @@ int do_env_print_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; /* -a already specified */ - if (!default_guid & guid_any) + if (!default_guid && guid_any) return CMD_RET_USAGE; argc--; -- cgit v1.2.3 From 42a426e027df472714e8d6209cafac291935c331 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 6 May 2020 20:32:31 +0200 Subject: efi_loader: put device tree into EfiACPIReclaimMemory According to the UEFI spec ACPI tables should be placed in EfiACPIReclaimMemory. Let's do the same with the device tree. Suggested-by: Ard Biesheuvel Cc: Grant Likely Signed-off-by: Heinrich Schuchardt --- cmd/bootefi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 54b4b8f9845..06573b14e9b 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -127,13 +127,13 @@ static efi_status_t copy_fdt(void **fdtp) new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f00000 + fdt_size, 0); ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_BOOT_SERVICES_DATA, fdt_pages, + EFI_ACPI_RECLAIM_MEMORY, fdt_pages, &new_fdt_addr); if (ret != EFI_SUCCESS) { /* If we can't put it there, put it somewhere */ new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size); ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_BOOT_SERVICES_DATA, fdt_pages, + EFI_ACPI_RECLAIM_MEMORY, fdt_pages, &new_fdt_addr); if (ret != EFI_SUCCESS) { printf("ERROR: Failed to reserve space for FDT\n"); -- cgit v1.2.3 From e519f03a18464c1fe249bd7fcf7829fad31abc9a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 4 May 2020 13:54:40 +0200 Subject: cmd: mem: Remove CONFIG_SYS_MEMTEST_SCRATCH mapping There is no real need to exactly define space for saving patterns for alternate memory test. It is much easier to allocate space on the stack and use it instead of trying to find out space where pattern should be saved. For example if you want to test the whole DDR memory you can't save patter to DDR and you need to find it out. On Xilinx devices DDR or OCM addresses were chosen but that means that OCM needs to be mapped and U-Boot has access permission there. It is easier to remove this limitation and simply save it on stack because it is very clear that memory test can't rewrite U-Boot and U-Boot has also full access to memory where runs from. Signed-off-by: Michal Simek Reviewed-by: Simon Glass Reviewed-by: Stefan Roese Reviewed-by: Heiko Schocher --- cmd/mem.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'cmd') diff --git a/cmd/mem.c b/cmd/mem.c index 009b7b58f32..18f0510098b 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -25,10 +25,6 @@ DECLARE_GLOBAL_DATA_PTR; -#ifndef CONFIG_SYS_MEMTEST_SCRATCH -#define CONFIG_SYS_MEMTEST_SCRATCH 0 -#endif - static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); /* Display values from last command. @@ -922,7 +918,8 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong start, end; - vu_long *buf, *dummy; + vu_long scratch_space; + vu_long *buf, *dummy = &scratch_space; ulong iteration_limit = 0; ulong count = 0; ulong errs = 0; /* number of errors, or -1 if interrupted */ @@ -958,7 +955,6 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, start, end); buf = map_sysmem(start, end - start); - dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long)); for (iteration = 0; !iteration_limit || iteration < iteration_limit; iteration++) { @@ -988,7 +984,6 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, } unmap_sysmem((void *)buf); - unmap_sysmem((void *)dummy); if (errs == -1UL) { /* Memory test was aborted - write a newline to finish off */ -- cgit v1.2.3 From 702de89cc6a34c1c23dd3d987b0472b2cecdb63c Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Mon, 4 May 2020 15:26:21 +0200 Subject: treewide: mem: Move mtest related defines to Kconfig Move below defines which are used by mtest utility to Kconfig. CONFIG_SYS_MEMTEST_START CONFIG_SYS_MEMTEST_END Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek [trini: Fix kmcoge5ne board, re-run migration as well] Signed-off-by: Tom Rini --- cmd/Kconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 157a33081ff..f9be1988f65 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -750,6 +750,22 @@ config SYS_ALT_MEMTEST help Use a more complete alternative memory test. +config SYS_MEMTEST_START + hex "default start address for mtest" + default 0 + help + This is the default start address for mtest for simple read/write + test. If no arguments are given to mtest, default address is used + as start address. + +config SYS_MEMTEST_END + hex "default end address for mtest" + default 0x1000 + help + This is the default end address for mtest for simple read/write + test. If no arguments are given to mtest, default address is used + as end address. + endif config CMD_SHA1SUM -- cgit v1.2.3