[U-Boot] [PATCH 0/5] ARM: uniphier: some more UniPhier updates for v2016.07-rc2

Masahiro Yamada (5): ARM: uniphier: check return code of setenv() ARM: uniphier: do not overwrite fdt_file environment ARM: uniphier: do not overwrite bootmode environment ARM: uniphier: do not erase when updating U-Boot image in eMMC device ARM: uniphier: insert dsb barrier to ensure the visibility
arch/arm/mach-uniphier/arm64/smp_kick_cpus.c | 4 ++-- arch/arm/mach-uniphier/board_late_init.c | 28 +++++++++++++++++++++------- include/configs/uniphier.h | 1 - 3 files changed, 23 insertions(+), 10 deletions(-)

Because setenv() may fail, it is better to check its return code.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/board_late_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c index 845f047..d9eeacb 100644 --- a/arch/arm/mach-uniphier/board_late_init.c +++ b/arch/arm/mach-uniphier/board_late_init.c @@ -56,9 +56,7 @@ static int uniphier_set_fdt_file(void)
strncat(dtb_name, ".dtb", buf_len);
- setenv("fdt_file", dtb_name); - - return 0; + return setenv("fdt_file", dtb_name); }
int board_late_init(void)

This code auto-detects the best-match FDT file name, but it should respect the user's choice if "fdt_file" environment is found in a saved set of environments.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/board_late_init.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c index d9eeacb..a454126 100644 --- a/arch/arm/mach-uniphier/board_late_init.c +++ b/arch/arm/mach-uniphier/board_late_init.c @@ -39,6 +39,9 @@ static int uniphier_set_fdt_file(void) int buf_len = 256; int ret;
+ if (getenv("fdt_file")) + return 0; /* do nothing if it is already set */ + ret = fdt_get_string(gd->fdt_blob, 0, "compatible", &compat); if (ret) return -EINVAL;

This code auto-detects the boot mode, but it should respect the user's choice if "bootmode" environment is found in a saved set of environments.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/board_late_init.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c index a454126..b3fe016 100644 --- a/arch/arm/mach-uniphier/board_late_init.c +++ b/arch/arm/mach-uniphier/board_late_init.c @@ -62,33 +62,46 @@ static int uniphier_set_fdt_file(void) return setenv("fdt_file", dtb_name); }
+static int uniphier_set_bootmode(const char *bootmode) +{ + if (getenv("bootmode")) + return 0; /* do nothing if it is already set */ + + return setenv("bootenv", bootmode); +} + int board_late_init(void) { + const char *bootmode; + puts("MODE: ");
switch (spl_boot_device_raw()) { case BOOT_DEVICE_MMC1: printf("eMMC Boot\n"); - setenv("bootmode", "emmcboot"); + bootmode = "emmcboot"; break; case BOOT_DEVICE_NAND: printf("NAND Boot\n"); - setenv("bootmode", "nandboot"); nand_denali_wp_disable(); + bootmode = "nandboot"; break; case BOOT_DEVICE_NOR: printf("NOR Boot\n"); - setenv("bootmode", "norboot"); + bootmode = "norboot"; break; case BOOT_DEVICE_USB: printf("USB Boot\n"); - setenv("bootmode", "usbboot"); + bootmode = "usbboot"; break; default: printf("Unknown\n"); - break; + return; }
+ if (uniphier_set_bootmode(bootmode)) + printf("bootmode environment was not set correctly\n"); + if (uniphier_set_fdt_file()) printf("fdt_file environment was not set correctly\n");

Unlike NAND, eMMC can be re-written without erasing.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
include/configs/uniphier.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 10fd8c2..7d8a206 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -245,7 +245,6 @@ "tftpboot $tmp_addr u-boot.bin\0" \ "emmcupdate=mmcsetn &&" \ "mmc partconf $mmc_first_dev 0 1 1 &&" \ - "mmc erase 0 800 &&" \ "tftpboot u-boot-spl.bin &&" \ "mmc write $loadaddr 0 80 &&" \ "tftpboot u-boot.bin &&" \

I noticed secondary CPUs sometimes fail to wake up, and the root cause seems that the "sev" instruction is sent before the preceding register write access is observed by the secondary CPUs.
The read-back of the accessed register cannot guarantee the order. This commit uses "dsb sy" barrier to ensure the order between the write access to UNIPHIER_SMPCTRL_ROM_RSV0 and the "sev" instruction.
Signed-off-by: Masahiro Yamada yamada.masahiro@socionext.com ---
arch/arm/mach-uniphier/arm64/smp_kick_cpus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-uniphier/arm64/smp_kick_cpus.c b/arch/arm/mach-uniphier/arm64/smp_kick_cpus.c index 64412e0..3b75eaa 100644 --- a/arch/arm/mach-uniphier/arm64/smp_kick_cpus.c +++ b/arch/arm/mach-uniphier/arm64/smp_kick_cpus.c @@ -21,11 +21,11 @@ void uniphier_smp_kick_all_cpus(void) rom_boot_rsv0 = map_sysmem(UNIPHIER_SMPCTRL_ROM_RSV0, SZ_8);
writeq((u64)uniphier_secondary_startup, rom_boot_rsv0); - readq(rom_boot_rsv0); /* relax */
unmap_sysmem(rom_boot_rsv0);
uniphier_smp_setup();
- asm("sev"); /* Bring up all secondary CPUs from Boot ROM into U-Boot */ + asm("dsb sy\n" /* Ensure the visibility of ROM_RSV0 write */ + "sev"); /* Bring up all secondary CPUs from Boot ROM into U-Boot */ }

2016-06-07 21:03 GMT+09:00 Masahiro Yamada yamada.masahiro@socionext.com:
Masahiro Yamada (5): ARM: uniphier: check return code of setenv() ARM: uniphier: do not overwrite fdt_file environment ARM: uniphier: do not overwrite bootmode environment ARM: uniphier: do not erase when updating U-Boot image in eMMC device ARM: uniphier: insert dsb barrier to ensure the visibility
Series, applied to u-boot-uniphier/master except 3/5, 5/5.
participants (1)
-
Masahiro Yamada