RISC-V AX25-AE350 support SPL
cover RISC-V AX25-AE350 support SPL
From: Rick Chen <[email protected]>
This series add support for SPL to AX25-AE350.
U-Boot SPL can boots from RAM or ROM and jump to OPenSbi(FW_DYNAMIC firmware) and U-Boot proper from RAM or MMC devices.
Also fix some bugs for andes plic driver and improve cache configurations for SPL.
Following are the booting messages on AE350 four cores SMP platform:
U-Boot 2019.10-00602-g693b70f (Oct 23 2019 - 16:32:19 +0800)
DRAM: 1 GiB
U-Boot SPL 2019.10-00601-g04f8f09-dirty (Oct 24 2019 - 10:46:49 +0800) Trying to boot from RAM
OpenSBI v0.4-32-g98ee15c (Sep 17 2019 10:41:30)
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|Platform Name : Andes AE350
Platform HART Features : RV64ACIMSUX
Platform Max HARTs : 4
Current Hart : 0
Firmware Base : 0x0
Firmware Size : 80 KB
Runtime SBI Version : 0.1
PMP0: 0x0000000000000000-0x000000000001ffff (A)
PMP1: 0x0000000000000000-0x00000001ffffffff (A,R,W,X)
U-Boot 2019.10-00601-g04f8f09-dirty (Oct 24 2019 - 10:46:49 +0800)
DRAM: 1 GiB Flash: 64 MiB MMC: mmc at f0e00000: 0 Loading Environment from SPI Flash... SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB OK In: serial at f0300000 Out: serial at f0300000 Err: serial at f0300000 Net: no alias for ethernet0
Warning: mac at e0100000 (eth0) using random MAC address - 06:2b:40:2d:38:d1
eth0: mac at e0100000
Hit any key to stop autoboot: 0
6455 bytes read in 30 ms (210 KiB/s)
20421684 bytes read in 8614 ms (2.3 MiB/s)
## Booting kernel from Legacy Image at 00600000 ...
Image Name:
Image Type: RISC-V Linux Kernel Image (uncompressed)
Data Size: 20421620 Bytes = 19.5 MiB
Load Address: 00200000
Entry Point: 00200000
Verifying Checksum ... OK
## Flattened Device Tree blob at 20000000
Booting using the fdt blob at 0x20000000
Loading Kernel Image
Loading Device Tree to 000000001effb000, end 000000001efff936 ... OK
Starting kernel ...
OF: fdt: Ignoring memory range 0x0 - 0x200000
Linux version 4.17.0-00253-g49136e10bcb2 (sqa at atcsqa07) (gcc version 7.3.0 (2019-04-06_nds64le-linux-glibc-v5_experimental)) #1 SMP PREEMPT Sat Apr 6 23:41:49 CST 2019 bootconsole [early0] enabled
Initial ramdisk at: 0x (ptrval) (13665712 bytes)
Zone ranges:
DMA32 [mem 0x0000000000200000-0x000000003fffffff]
Normal empty
Movable zone start for each node
Early memory node ranges
node 0: [mem 0x0000000000200000-0x000000003fffffff]
Initmem setup node 0 [mem 0x0000000000200000-0x000000003fffffff]
software IO TLB [mem 0x3b1f8000-0x3f1f8000] (64MB) mapped at [ (ptrval)- (ptrval)]elf_platform is rv64i2p0m2p0a2p0c2p0xv5-0p0
compatible privileged spec version 1.10
percpu: Embedded 16 pages/cpu @ (ptrval) s28184 r8192 d29160 u65536
Built 1 zonelists, mobility grouping on. Total pages: 258055
Kernel command line: console=ttyS0,38400n8 debug loglevel=7log_buf_len individual max cpu contribution: 4096 byteslog_buf_len total cpu_extra contributions: 12288 byteslog_buf_len min size: 16384 byteslog_buf_len: 32768 bytes
early log buf free: 14608(89%)
Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
Sorting __ex_table...
Memory: 944428K/1046528K available (3979K kernel code, 246K rwdata, 1490K rodata, 13523K init, 688K bss, 102100K reserved, 0K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Preemptible hierarchical RCU implementation.
Tasks RCU enabled.NR_IRQS: 72, nr_irqs: 72, preallocated irqs: 0
riscv,cpu_intc,0: 64 local interrupts mapped
riscv,cpu_intc,1: 64 local interrupts mapped
riscv,cpu_intc,2: 64 local interrupts mapped
riscv,cpu_intc,3: 64 local interrupts mapped
riscv,plic0,e4000000: mapped 71 interrupts to 8/8 handlers
clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1bacf917bf, max_idle_ns: 881590412290 nssched_clock: 64 bits@60MHz, resolution 16ns, wraps every 4398046511098ns
Console: colour dummy device 40x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 120.00 BogoMIPS (lpj=600000)pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU0: online
CPU2: online
CPU3: online
smp: Brought up 1 node, 4 CPUs
...
...
...
Rick Chen (8):
riscv: ax25: add SPL support
riscv: ax25-ae350: add SPL configuration
riscv: ax25-ae350: Use generic memory size setup
riscv: andes_plic: Fix some wrong configurations
riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
spl: cache: Allow cache drivers in SPL
riscv: Fix clear bss loop in the start-up code
riscv: dts: Support four cores SMP
arch/riscv/cpu/ax25/Kconfig | 4 ++- arch/riscv/cpu/ax25/cache.c | 60 +++++++++++++++++++++++++-------- arch/riscv/cpu/start.S | 4 +-- arch/riscv/dts/ae350_32.dts | 51 ++++++++++++++++++++++++++-- arch/riscv/dts/ae350_64.dts | 51 ++++++++++++++++++++++++++-- arch/riscv/lib/andes_plic.c | 11 +++--- board/AndesTech/ax25-ae350/Kconfig | 10 ++++++ board/AndesTech/ax25-ae350/MAINTAINERS | 4 +++ board/AndesTech/ax25-ae350/ax25-ae350.c | 48 +++++++++++++++----------- common/spl/Kconfig | 7 ++++ configs/ae350_rv32_spl_defconfig | 37 ++++++++++++++++++++ configs/ae350_rv32_spl_xip_defconfig | 39 +++++++++++++++++++++ configs/ae350_rv64_spl_defconfig | 38 +++++++++++++++++++++ configs/ae350_rv64_spl_xip_defconfig | 40 ++++++++++++++++++++++ drivers/Makefile | 1 + include/configs/ax25-ae350.h | 17 ++++++++++ 16 files changed, 376 insertions(+), 46 deletions(-) create mode 100644 configs/ae350_rv32_spl_defconfig create mode 100644 configs/ae350_rv32_spl_xip_defconfig create mode 100644 configs/ae350_rv64_spl_defconfig create mode 100644 configs/ae350_rv64_spl_xip_defconfig
Signature · 1 line
2.7.4
PATCH 1/8 riscv: ax25: add SPL support
From: Rick Chen <[email protected]>
The U-Boot SPL will boot in M mode and load the FIT image which include OpenSbi and U-Boot proper images. After loading progress, it will jump to OpenSbi first and then U-Boot proper which will run in S mode.
--- arch/riscv/cpu/ax25/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/cpu/ax25/Kconfig +3 -1
@@ -6,7 +6,9 @@ config RISCV_NDS imply RISCV_TIMER imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) - imply V5L2_CACHE + imply SPL_CPU_SUPPORT + imply SPL_OPENSBI + imply SPL_LOAD_FIT help Run U-Boot on AndeStar V5 platforms and use some specific features which are provided by Andes Technology AndeStar V5 families.
Signature · 1 line
2.7.4
PATCH 1/8 riscv: ax25: add SPL support
Hi Rick,
Quoted 5 lines · Andes
From: Rick Chen <[email protected]>
The U-Boot SPL will boot in M mode and load the FIT image which include OpenSbi and U-Boot proper
nits: OpenSBI
Quoted 2 lines
images. After loading progress, it will jump to OpenSbi first and then U-Boot proper which will
ditto
Quoted 14 lines
run in S mode.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/riscv/cpu/ax25/Kconfig +0
-0
arch/riscv/cpu/ax25/Kconfig config RISCV_NDS · line 9
Quoted 4 lines
arch/riscv/cpu/ax25/Kconfig +0
-1@@ -6,7 +6,9 @@ config RISCV_NDS imply RISCV_TIMER imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) - imply V5L2_CACHE
Why this is removed?
arch/riscv/cpu/ax25/Kconfig config RISCV_NDS
Quoted 7 lines
arch/riscv/cpu/ax25/Kconfig +3
-1+ imply SPL_CPU_SUPPORT + imply SPL_OPENSBI + imply SPL_LOAD_FIT help Run U-Boot on AndeStar V5 platforms and use some specific features which are provided by Andes Technology AndeStar V5 families. --
Regards,
Bin
PATCH 1/8 riscv: ax25: add SPL support
Hi Bin
Quoted 11 lines
Hi Rick,
Quoted 5 lines · Andes
From: Rick Chen <[email protected]>
The U-Boot SPL will boot in M mode and load the FIT image which include OpenSbi and U-Boot proper
nits: OpenSBI
OK
Quoted 5 lines
Quoted 3 lines
images. After loading progress, it will jump to OpenSbi first and then U-Boot proper which will
ditto
OK
Quoted 10 lines
Quoted 10 lines
run in S mode.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 11 lines
arch/riscv/cpu/ax25/Kconfig config RISCV_NDS · line 9
Quoted 9 lines
arch/riscv/cpu/ax25/Kconfig +0
-1@@ -6,7 +6,9 @@ config RISCV_NDS imply RISCV_TIMER imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) - imply V5L2_CACHEWhy this is removed?
Without CACHE_SUPPORT, the compiling will fail while enable V5l2_CACHE. That is why I remove it. I hope it can be enable manually. Because it will enlarge U-Boot SPL size.
Thanks
Rick
Quoted 11 lines
arch/riscv/cpu/ax25/Kconfig config RISCV_NDS
Quoted 8 lines
arch/riscv/cpu/ax25/Kconfig +3
-1+ imply SPL_CPU_SUPPORT + imply SPL_OPENSBI + imply SPL_LOAD_FIT help Run U-Boot on AndeStar V5 platforms and use some specific features which are provided by Andes Technology AndeStar V5 families. --Regards,
Bin
PATCH 1/8 riscv: ax25: add SPL support
Hi Rick,
Quoted 47 lines · Rick Chen
Hi Bin
Quoted 11 lines
Hi Rick,
Quoted 5 lines · Andes
From: Rick Chen <[email protected]>
The U-Boot SPL will boot in M mode and load the FIT image which include OpenSbi and U-Boot proper
nits: OpenSBI
OK
Quoted 5 lines
Quoted 3 lines
images. After loading progress, it will jump to OpenSbi first and then U-Boot proper which will
ditto
OK
Quoted 10 lines
Quoted 10 lines
run in S mode.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 11 lines
arch/riscv/cpu/ax25/Kconfig config RISCV_NDS · line 9
Quoted 9 lines
arch/riscv/cpu/ax25/Kconfig +0
-1@@ -6,7 +6,9 @@ config RISCV_NDS imply RISCV_TIMER imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) - imply V5L2_CACHEWhy this is removed?
Quoted 4 lines
Without
CACHE_SUPPORT, the compiling will fail while enableV5l2_CACHE. That is why I remove it. I hope it can be enable manually. Because it will enlarge U-Boot SPL size.
Could you please describe it in the commit message?
Regards,
Bin
PATCH 1/8 riscv: ax25: add SPL support
Hi Bin
Quoted 51 lines
Hi Rick,
Quoted 47 lines · Rick Chen
Hi Bin
Quoted 11 lines
Hi Rick,
Quoted 5 lines · Andes
From: Rick Chen <[email protected]>
The U-Boot SPL will boot in M mode and load the FIT image which include OpenSbi and U-Boot proper
nits: OpenSBI
OK
Quoted 5 lines
Quoted 3 lines
images. After loading progress, it will jump to OpenSbi first and then U-Boot proper which will
ditto
OK
Quoted 21 lines
Quoted 15 lines
run in S mode.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/riscv/cpu/ax25/Kconfig +0
-0arch/riscv/cpu/ax25/Kconfig config RISCV_NDS · line 9
Quoted 4 lines
arch/riscv/cpu/ax25/Kconfig +0
-1@@ -6,7 +6,9 @@ config RISCV_NDS imply RISCV_TIMER imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) - imply V5L2_CACHEWhy this is removed?
Quoted 6 lines
Quoted 4 lines
Without
CACHE_SUPPORT, the compiling will fail while enableV5l2_CACHE. That is why I remove it. I hope it can be enable manually. Because it will enlarge U-Boot SPL size.Could you please describe it in the commit message?
OK. I will add it.
Thanks
Rick
Quoted 3 lines
Regards,
Bin
PATCH 2/8 riscv: ax25-ae350: add SPL configuration
In reply to AndesFrom: Rick Chen <[email protected]>
This patch provides four configurations
which can support U-Boot SPL to boot from
RAM or FLASH and then boot FIT image
including OpenSBI FW_DYNAMIC firmware
and U-Boot proper images from RAM or
MMC boot devices.
With ae350_rv[32|64]_spl_defconfigs:
U-Boot SPL will be loaded by gdb or FSBL
and runs in RAM in machine mode and then
load FIT image from RAM device on AE350.
With ae350_rv[32|64]_spl_xip_defconfigs:
U-Boot SPL can be burned into SPI flash
and run in flash in machine mode and then
load FIT image from SPI flash or MMC device
on AE350.
--- board/AndesTech/ax25-ae350/Kconfig | 10 +++++++++ board/AndesTech/ax25-ae350/MAINTAINERS | 4 ++++ board/AndesTech/ax25-ae350/ax25-ae350.c | 27 ++++++++++++++++++++++ configs/ae350_rv32_spl_defconfig | 37 ++++++++++++++++++++++++++++++ configs/ae350_rv32_spl_xip_defconfig | 39 ++++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_defconfig | 38 +++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_xip_defconfig | 40 +++++++++++++++++++++++++++++++++ include/configs/ax25-ae350.h | 17 ++++++++++++++ 8 files changed, 212 insertions(+) create mode 100644 configs/ae350_rv32_spl_defconfig create mode 100644 configs/ae350_rv32_spl_xip_defconfig create mode 100644 configs/ae350_rv64_spl_defconfig create mode 100644 configs/ae350_rv64_spl_xip_defconfig
board/AndesTech/ax25-ae350/Kconfig +10 -0
@@ -21,9 +21,19 @@ config ENV_SIZE config ENV_OFFSET default 0x140000 if ENV_IS_IN_SPI_FLASH +config SPL_TEXT_BASE + default 0x00000000 + +config SPL_OPENSBI_LOAD_ADDR + default 0x01000000 + config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select RISCV_NDS + select SUPPORT_SPL + imply SYS_NS16550 imply SMP + imply SPL_RAM_SUPPORT + imply SPL_RAM_DEVICE endif
board/AndesTech/ax25-ae350/MAINTAINERS +4 -0
@@ -7,3 +7,7 @@ F: configs/ae350_rv32_defconfig F: configs/ae350_rv64_defconfig F: configs/ae350_rv32_xip_defconfig F: configs/ae350_rv64_xip_defconfig +F: configs/ae350_rv32_spl_defconfig +F: configs/ae350_rv64_spl_defconfig +F: configs/ae350_rv32_spl_xip_defconfig +F: configs/ae350_rv64_spl_xip_defconfig
board/AndesTech/ax25-ae350/ax25-ae350.c +27 -0
@@ -12,6 +12,7 @@#include <faraday/ftsmc020.h> #include <fdtdec.h> #include <dm.h> +#include <spl.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -110,3 +111,29 @@ int board_early_init_f(void)return 0 ; }#endif + +#ifdef CONFIG_SPL +void board_boot_order (u32 *spl_boot_list) +{ +u8 i; + u32 boot_devices[] = { +#ifdef CONFIG_SPL_RAM_SUPPORT + BOOT_DEVICE_RAM, +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT + BOOT_DEVICE_MMC1, +#endif + }; + +for (i =0 ; i <ARRAY_SIZE (boot_devices); i++) + spl_boot_list[i] = boot_devices[i]; +} +#endif + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match (const char *name) +{ +/* boot using first FIT config */ +return 0 ; +} +#endif
configs/ae350_rv32_spl_defconfig new file +37 -0
@@ -0,0 +1,37 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=y
configs/ae350_rv32_spl_xip_defconfig new file +39 -0
@@ -0,0 +1,39 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=y
configs/ae350_rv64_spl_defconfig new file +38 -0
@@ -0,0 +1,38 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=y
configs/ae350_rv64_spl_xip_defconfig new file +40 -0
@@ -0,0 +1,40 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=y
include/configs/ax25-ae350.h +17 -0
@@ -7,6 +7,23 @@#ifndef __CONFIG_H#define __CONFIG_H +#ifdef CONFIG_SPL +#define CONFIG_SPL_MAX_SIZE 0x00100000 +#define CONFIG_SPL_BSS_START_ADDR 0x04000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00100000 + +#ifndef CONFIG_XIP +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x00200000 +#else +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x80010000 +#endif + +#ifdef CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.itb" +#endif +#endif +/* * CPU and Board Configuration Options */
Signature · 1 line
2.7.4
PATCH 2/8 riscv: ax25-ae350: add SPL configuration
Hi Rick,
Quoted 16 lines · Andes
From: Rick Chen <[email protected]>
This patch provides four configurations
which can support U-Boot SPL to boot from
RAM or FLASH and then boot FIT image
including OpenSBIFW_DYNAMICfirmware
and U-Boot proper images from RAM or
MMC boot devices.With ae350_rv[32|64]_spl_defconfigs:
U-Boot SPL will be loaded by gdb or FSBL
and runs in RAM in machine mode and then
load FIT image from RAM device on AE350.
Quoted 7 lines
With ae350_rv[32|64]_spl_xip_defconfigs:
U-Boot SPL can be burned into SPI flash
and run in flash in machine mode and then
load FIT image from SPI flash or MMC device
on AE350.
Could you please rewrite the commit message so that every line has about 70 characters?
Quoted 27 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- board/AndesTech/ax25-ae350/Kconfig | 10 +++++++++ board/AndesTech/ax25-ae350/MAINTAINERS | 4 ++++ board/AndesTech/ax25-ae350/ax25-ae350.c | 27 ++++++++++++++++++++++ configs/ae350_rv32_spl_defconfig | 37 ++++++++++++++++++++++++++++++ configs/ae350_rv32_spl_xip_defconfig | 39 ++++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_defconfig | 38 +++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_xip_defconfig | 40 +++++++++++++++++++++++++++++++++ include/configs/ax25-ae350.h | 17 ++++++++++++++ 8 files changed, 212 insertions(+) create mode 100644 configs/ae350_rv32_spl_defconfig create mode 100644 configs/ae350_rv32_spl_xip_defconfig create mode 100644 configs/ae350_rv64_spl_defconfig create mode 100644 configs/ae350_rv64_spl_xip_defconfigboard/AndesTech/ax25-ae350/Kconfig +1
-0@@ -21,9 +21,19 @@ config ENV_SIZE config ENV_OFFSET default 0x140000 if ENV_IS_IN_SPI_FLASH +config SPL_TEXT_BASE
board/AndesTech/ax25-ae350/Kconfig config ENV_SIZE · line 34
Quoted 10 lines
board/AndesTech/ax25-ae350/Kconfig +7
-0+ default 0x00000000 + +config SPL_OPENSBI_LOAD_ADDR + default 0x01000000 + config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select RISCV_NDS + select SUPPORT_SPL + imply SYS_NS16550
Is there any 16550 on the AX25 boards? If not, please remove. If yes, this should be a separate patch with DTS changes.
Quoted 10 lines
board/AndesTech/ax25-ae350/Kconfig +2
-0imply SMP + imply SPL_RAM_SUPPORT + imply SPL_RAM_DEVICE endifboard/AndesTech/ax25-ae350/MAINTAINERS +0
-0
board/AndesTech/ax25-ae350/MAINTAINERS F: configs/ae350_rv32_defconfig · line 13
Quoted 7 lines
board/AndesTech/ax25-ae350/MAINTAINERS +4
-0@@ -7,3 +7,7 @@ F: configs/ae350_rv32_defconfig F: configs/ae350_rv64_defconfig F: configs/ae350_rv32_xip_defconfig F: configs/ae350_rv64_xip_defconfig +F: configs/ae350_rv32_spl_defconfig +F: configs/ae350_rv64_spl_defconfig +F: configs/ae350_rv32_spl_xip_defconfig +F: configs/ae350_rv64_spl_xip_defconfig
Could you please update the doc/board/AndesTech/ax25-ae350.rst to add descriptions about all these different configurations of the same board?
Quoted 239 lines
board/AndesTech/ax25-ae350/ax25-ae350.c +27
-0@@ -12,6 +12,7 @@#include <faraday/ftsmc020.h> #include <fdtdec.h> #include <dm.h> +#include <spl.h> DECLARE_GLOBAL_DATA_PTR ;@@ -110,3 +111,29 @@ int board_early_init_f(void)return 0 ; }#endif + +#ifdef CONFIG_SPL +void board_boot_order (u32 *spl_boot_list) +{ +u8 i; + u32 boot_devices[] = { +#ifdef CONFIG_SPL_RAM_SUPPORT + BOOT_DEVICE_RAM, +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT + BOOT_DEVICE_MMC1, +#endif + }; + +for (i =0 ; i <ARRAY_SIZE (boot_devices); i++) + spl_boot_list[i] = boot_devices[i]; +} +#endif + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match (const char *name) +{ +/* boot using first FIT config */ +return 0 ; +} +#endif configs/ae350_rv32_spl_defconfig new file +37
-0@@ -0,0 +1,37 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv32_spl_xip_defconfig new file +39
-0@@ -0,0 +1,39 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv64_spl_defconfig new file +38
-0@@ -0,0 +1,38 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv64_spl_xip_defconfig new file +40
-0@@ -0,0 +1,40 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yinclude/configs/ax25-ae350.h +11
-0@@ -7,6 +7,23 @@#ifndef __CONFIG_H#define __CONFIG_H +#ifdef CONFIG_SPL +#define CONFIG_SPL_MAX_SIZE 0x00100000 +#define CONFIG_SPL_BSS_START_ADDR 0x04000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00100000 + +#ifndef CONFIG_XIP +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x00200000 +#else +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x80010000 +#endif +
include/configs/ax25-ae350.h
Quoted 10 lines
include/configs/ax25-ae350.h +6
-1+#ifdef CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.itb" +#endif +#endif +/* * CPU and Board Configuration Options */ --
Regards,
Bin
PATCH 2/8 riscv: ax25-ae350: add SPL configuration
Hi Bin
Quoted 21 lines
Hi Rick,
Quoted 18 lines · Andes
From: Rick Chen <[email protected]>
This patch provides four configurations
which can support U-Boot SPL to boot from
RAM or FLASH and then boot FIT image
including OpenSBIFW_DYNAMICfirmware
and U-Boot proper images from RAM or
MMC boot devices.With ae350_rv[32|64]_spl_defconfigs:
U-Boot SPL will be loaded by gdb or FSBL
and runs in RAM in machine mode and then
load FIT image from RAM device on AE350.With ae350_rv[32|64]_spl_xip_defconfigs:
Quoted 8 lines
Quoted 5 lines
U-Boot SPL can be burned into SPI flash
and run in flash in machine mode and then
load FIT image from SPI flash or MMC device
on AE350.Could you please rewrite the commit message so that every line has about 70 characters?
OK. I will rewrite it.
Quoted 27 lines
Quoted 27 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- board/AndesTech/ax25-ae350/Kconfig | 10 +++++++++ board/AndesTech/ax25-ae350/MAINTAINERS | 4 ++++ board/AndesTech/ax25-ae350/ax25-ae350.c | 27 ++++++++++++++++++++++ configs/ae350_rv32_spl_defconfig | 37 ++++++++++++++++++++++++++++++ configs/ae350_rv32_spl_xip_defconfig | 39 ++++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_defconfig | 38 +++++++++++++++++++++++++++++++ configs/ae350_rv64_spl_xip_defconfig | 40 +++++++++++++++++++++++++++++++++ include/configs/ax25-ae350.h | 17 ++++++++++++++ 8 files changed, 212 insertions(+) create mode 100644 configs/ae350_rv32_spl_defconfig create mode 100644 configs/ae350_rv32_spl_xip_defconfig create mode 100644 configs/ae350_rv64_spl_defconfig create mode 100644 configs/ae350_rv64_spl_xip_defconfigboard/AndesTech/ax25-ae350/Kconfig +0
-0@@ -21,9 +21,19 @@ config ENV_SIZE config ENV_OFFSET default 0x140000 if ENV_IS_IN_SPI_FLASH
Quoted 14 lines
board/AndesTech/ax25-ae350/Kconfig config ENV_SIZE · line 34
Quoted 11 lines
board/AndesTech/ax25-ae350/Kconfig +8
-0+config SPL_TEXT_BASE + default 0x00000000 + +config SPL_OPENSBI_LOAD_ADDR + default 0x01000000 + config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select RISCV_NDS + select SUPPORT_SPL + imply SYS_NS16550Is there any 16550 on the AX25 boards? If not, please remove. If yes, this should be a separate patch with DTS changes.
Yes, it needs SYS_NS16550, but it has been declared in ae350_XXX_defconfig. It is duplicate declaration here. I will remove it.
Quoted 14 lines
Quoted 14 lines
board/AndesTech/ax25-ae350/Kconfig +2
-0imply SMP + imply SPL_RAM_SUPPORT + imply SPL_RAM_DEVICE endifboard/AndesTech/ax25-ae350/MAINTAINERS +0
-0@@ -7,3 +7,7 @@ F: configs/ae350_rv32_defconfig F: configs/ae350_rv64_defconfig F: configs/ae350_rv32_xip_defconfig F: configs/ae350_rv64_xip_defconfig
Quoted 8 lines
board/AndesTech/ax25-ae350/MAINTAINERS F: configs/ae350_rv32_defconfig · line 13
Quoted 4 lines
board/AndesTech/ax25-ae350/MAINTAINERS +4
-0+F: configs/ae350_rv32_spl_defconfig +F: configs/ae350_rv64_spl_defconfig +F: configs/ae350_rv32_spl_xip_defconfig +F: configs/ae350_rv64_spl_xip_defconfigCould you please update the
doc/board/AndesTech/ax25-ae350.rstto add descriptions about all these different configurations of the same board?
OK. I will update doc/board/AndesTech/ax25-ae350.rst.
Thanks
Rick
Quoted 253 lines
Quoted 240 lines
board/AndesTech/ax25-ae350/ax25-ae350.c +27
-0@@ -12,6 +12,7 @@#include <faraday/ftsmc020.h> #include <fdtdec.h> #include <dm.h> +#include <spl.h> DECLARE_GLOBAL_DATA_PTR ;@@ -110,3 +111,29 @@ int board_early_init_f(void)return 0 ; }#endif + +#ifdef CONFIG_SPL +void board_boot_order (u32 *spl_boot_list) +{ +u8 i; + u32 boot_devices[] = { +#ifdef CONFIG_SPL_RAM_SUPPORT + BOOT_DEVICE_RAM, +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT + BOOT_DEVICE_MMC1, +#endif + }; + +for (i =0 ; i <ARRAY_SIZE (boot_devices); i++) + spl_boot_list[i] = boot_devices[i]; +} +#endif + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match (const char *name) +{ +/* boot using first FIT config */ +return 0 ; +} +#endif configs/ae350_rv32_spl_defconfig new file +37
-0@@ -0,0 +1,37 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv32_spl_xip_defconfig new file +39
-0@@ -0,0 +1,39 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv64_spl_defconfig new file +38
-0@@ -0,0 +1,38 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_PRIOR_STAGE=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yconfigs/ae350_rv64_spl_xip_defconfig new file +40
-0@@ -0,0 +1,40 @@ +CONFIG_RISCV=y +CONFIG_SPL=y +CONFIG_RISCV_SMODE=y +CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SYS_TEXT_BASE=0x01200000 +CONFIG_NR_DRAM_BANKS=2 +CONFIG_TARGET_AX25_AE350=y +CONFIG_ARCH_RV64I=y +CONFIG_XIP=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SYS_PROMPT="RISC-V # " +CONFIG_CMD_IMLS=y +CONFIG_CMD_MMC=y +CONFIG_CMD_SF=y +CONFIG_CMD_SF_TEST=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_BOOTP_PREFER_SERVERIP=y +CONFIG_CMD_CACHE=y +CONFIG_OF_BOARD=y +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_MMC=y +CONFIG_FTSDC010=y +CONFIG_FTSDC010_SDIO=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_FLASH_CFI_DRIVER=y +CONFIG_CFI_FLASH=y +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y +CONFIG_SYS_FLASH_CFI=y +CONFIG_SPI_FLASH=y +CONFIG_SF_DEFAULT_MODE=0x0 +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_FTMAC100=y +CONFIG_BAUDRATE=38400 +CONFIG_SYS_NS16550=y +CONFIG_SPI=y +CONFIG_ATCSPI200_SPI=yinclude/configs/ax25-ae350.h +11
-0@@ -7,6 +7,23 @@#ifndef __CONFIG_H#define __CONFIG_H +#ifdef CONFIG_SPL +#define CONFIG_SPL_MAX_SIZE 0x00100000 +#define CONFIG_SPL_BSS_START_ADDR 0x04000000 +#define CONFIG_SPL_BSS_MAX_SIZE 0x00100000 + +#ifndef CONFIG_XIP +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x00200000 +#else +#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x80010000 +#endif +include/configs/ax25-ae350.h
Quoted 10 lines
include/configs/ax25-ae350.h +6
-1+#ifdef CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.itb" +#endif +#endif +/* * CPU and Board Configuration Options */ --Regards,
Bin
PATCH 3/8 riscv: ax25-ae350: Use generic memory size setup
In reply to AndesFrom: Rick Chen <[email protected]>
To get memory size from device tree instead of get_ram_size(). This can avoid memory access fault in U-Boot proper after PMP configurations in OpenSbi.
--- board/AndesTech/ax25-ae350/ax25-ae350.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
board/AndesTech/ax25-ae350/ax25-ae350.c +2 -19
@@ -30,29 +30,12 @@ int board_init(void)int dram_init (void ) { -unsigned long sdram_base =PHYS_SDRAM_0 ; -unsigned long expected_size =PHYS_SDRAM_0_SIZE +PHYS_SDRAM_1_SIZE ; -unsigned long actual_size; - - actual_size =get_ram_size ((void *)sdram_base, expected_size); - gd->ram_size = actual_size; - -if (expected_size != actual_size) { -printf ("Warning: Only %lu of %lu MiB SDRAM is working\n" , - actual_size >>20 , expected_size >>20 ); - } - -return 0 ; +return fdtdec_setup_mem_size_base (); }int dram_init_banksize (void ) { - gd->bd->bi_dram[0 ].start =PHYS_SDRAM_0 ; - gd->bd->bi_dram[0 ].size =PHYS_SDRAM_0_SIZE ; - gd->bd->bi_dram[1 ].start =PHYS_SDRAM_1 ; - gd->bd->bi_dram[1 ].size =PHYS_SDRAM_1_SIZE ; - -return 0 ; +return fdtdec_setup_memory_banksize (); }#if defined(CONFIG_FTMAC100 ) && !defined(CONFIG_DM_ETH )
Signature · 1 line
2.7.4
PATCH 3/8 riscv: ax25-ae350: Use generic memory size setup
Hi Rick,
Quoted 5 lines · Andes
From: Rick Chen <[email protected]>
To get memory size from device tree instead of
get_ram_size(). This can avoid memory access fault
Could you please explain a little more about why get_ram_size() causes PMP access fault?
Quoted 9 lines
in U-Boot proper after PMP configurations in OpenSbi.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- board/AndesTech/ax25-ae350/ax25-ae350.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
Regards,
Bin
PATCH 3/8 riscv: ax25-ae350: Use generic memory size setup
Hi Bin
Bin Meng <[email protected]> 於 2019年10月29日 週二 下午10:42寫道:
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 7 lines
Quoted 4 lines
From: Rick Chen <[email protected]>
To get memory size from device tree instead of
get_ram_size(). This can avoid memory access faultCould you please explain a little more about why
get_ram_size()causes PMP access fault?
OpenSBI will configure pmpcfg and pmpaddr for memory protection in specific range.
When get_ram_size() try to store or load memory address, it will appear access fault exception.
Thanks
Rick
Quoted 13 lines
Quoted 10 lines
in U-Boot proper after PMP configurations in OpenSbi.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- board/AndesTech/ax25-ae350/ax25-ae350.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
In reply to AndesFrom: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/riscv/lib/andes_plic.c +7 -4
@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */
@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en; en =ENABLE_HART_IPI >> hart;writel (en, (void __iomem *)ENABLE_REG (gd->arch.plic, hart));
@@ -94,10 +94,13 @@ static int init_plic(void)int riscv_send_ipi (int hart) { +unsigned int ipi; +PLIC_BASE_GET (); -writel (SEND_IPI_TO_HART (hart), - (void __iomem *)PENDING_REG (gd->arch.plic, gd->arch.boot_hart)); + ipi = (SEND_IPI_TO_HART (hart) << (8 * gd->arch.boot_hart)); +writel (ipi, (void __iomem *)PENDING_REG (gd->arch.plic, + gd->arch.boot_hart));return 0 ; }
Signature · 1 line
2.7.4
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Rick,
Quoted 7 lines · Andes
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Quoted 5 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
So does this mean there is a bug in OpenSBI too?
Quoted 5 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
Quoted 21 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */
arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;
Is this for some compiler warning fix?
Quoted 10 lines
arch/riscv/lib/andes_plic.c +2
-0en =ENABLE_HART_IPI >> hart;writel (en, (void __iomem *)ENABLE_REG (gd->arch.plic, hart));@@ -94,10 +94,13 @@ static int init_plic(void)int riscv_send_ipi (int hart) { +unsigned int ipi; +PLIC_BASE_GET ();
arch/riscv/lib/andes_plic.c static int init_plic(void)
Quoted 10 lines
arch/riscv/lib/andes_plic.c +3
-3-writel (SEND_IPI_TO_HART (hart), - (void __iomem *)PENDING_REG (gd->arch.plic, gd->arch.boot_hart)); + ipi = (SEND_IPI_TO_HART (hart) << (8 * gd->arch.boot_hart)); +writel (ipi, (void __iomem *)PENDING_REG (gd->arch.plic, + gd->arch.boot_hart));return 0 ; } --
Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 8 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI. But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ @@ -46,7 +46,7 @@ static int init_plic(void);
Quoted 6 lines
arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 4 lines
arch/riscv/lib/andes_plic.c +1
-1static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
No, it is not a warning fix. It is a bug fix.
I hope en can be 0x0000000080808080 instead of 0xffffffff80808080, or it will cause IPI sending errors.
Thanks
Rick
Quoted 24 lines
Quoted 11 lines
arch/riscv/lib/andes_plic.c +2
-0en =ENABLE_HART_IPI >> hart;writel (en, (void __iomem *)ENABLE_REG (gd->arch.plic, hart));@@ -94,10 +94,13 @@ static int init_plic(void)int riscv_send_ipi (int hart) { +unsigned int ipi; +PLIC_BASE_GET ();arch/riscv/lib/andes_plic.c static int init_plic(void)
Quoted 10 lines
arch/riscv/lib/andes_plic.c +3
-3-writel (SEND_IPI_TO_HART (hart), - (void __iomem *)PENDING_REG (gd->arch.plic, gd->arch.boot_hart)); + ipi = (SEND_IPI_TO_HART (hart) << (8 * gd->arch.boot_hart)); +writel (ipi, (void __iomem *)PENDING_REG (gd->arch.plic, + gd->arch.boot_hart));return 0 ; } --Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Quoted 49 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ @@ -46,7 +46,7 @@ static int init_plic(void);Quoted 6 lines
arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 4 lines
arch/riscv/lib/andes_plic.c +1
-1static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,
But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Quoted 2 lines
or it will cause IPI sending errors.
Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54
Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
Quoted 49 lines
Quoted 49 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }
Would you mind sharing what you get after running this on your x86_64 (if you have one) computer? Really appreiciate that.
The almost identical episode is in the patch, specifically,
Quoted 7 lines
en =
ENABLE_HART_IPI>> hartQuoted 2 lines
or it will cause IPI sending errors.
Regards,
Bin
Best,
Alan
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Alan,
Quoted 43 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Quoted 7 lines
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.
This is true only for the very first a few instructions when OpenSBI boots. Later OpenSBI main initialization does not require hart to be zero.
Quoted 68 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
Quoted 49 lines
Quoted 49 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }
Quoted 5 lines
Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hart
Yes, this is a bug. But I was confused by Rick's comments as he was using a 64-bit number as int is never to be a 64-bit for both 32-bit and 64-bit.
Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 126 lines · Bin Meng
Hi Alan,
Quoted 43 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Quoted 7 lines
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.This is true only for the very first a few instructions when OpenSBI boots. Later OpenSBI main initialization does not require hart to be zero.
Quoted 68 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
Quoted 49 lines
Quoted 49 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }
Quoted 7 lines
Quoted 5 lines
Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hartYes, this is a bug. ...
Wait, what do you mean but "this"? What is a bug here?
If you want to be helpful, please also be specific or anyone else reviewing this patch will be confused.
Quoted 3 lines
... But I was confused by Rick's comments as he was
using a 64-bit number as int is never to be a 64-bit for both 32-bit and 64-bit.
It was just an example. Nothing to do with bit width, but just a sign- extension issue.
Quoted 3 lines
Regards,
Bin
Thanks,
Alan
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Alan,
Quoted 132 lines · Alan Kao
Quoted 129 lines · Bin Meng
Hi Alan,
Quoted 43 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Quoted 7 lines
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.This is true only for the very first a few instructions when OpenSBI boots. Later OpenSBI main initialization does not require hart to be zero.
Quoted 71 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
Quoted 49 lines
Quoted 49 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hartYes, this is a bug. ...
Wait, what do you mean but "this"? What is a bug here?
The bug you mentioned.
Quoted 2 lines
If you want to be helpful, please also be specific or anyone else reviewing this patch will be confused.
It's just the explanation that Rick gave confuses people like me.
Quoted 7 lines
Quoted 4 lines
... But I was confused by Rick's comments as he was
using a 64-bit number as int is never to be a 64-bit for both 32-bit and 64-bit.It was just an example. Nothing to do with bit width, but just a sign- extension issue.
Regards,
Bin
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
In reply to Alan KaoQuoted 46 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54
Quoted 6 lines
Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for FW_DYNAMIC.
I will try to fix this in OpenSBI but we might end-up having boot_lottery.
Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hart
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
or it will cause IPI sending errors.
Regards,
BinBest,
Alan
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 52 lines · Anup Patel
Quoted 50 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.
Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"
Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Regards,
Anup
Quoted 84 lines
Quoted 73 lines
Quoted 51 lines
Quoted 51 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hartQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
or it will cause IPI sending errors.
Regards,
BinBest,
AlanRegards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 60 lines · Anup Patel
Quoted 58 lines · Alan Kao
Quoted 46 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Quoted 6 lines
Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.
Quoted 9 lines
Quoted 1 line
I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
OK
Thanks
Rick
Quoted 87 lines
Regards,
AnupQuoted 84 lines
Quoted 73 lines
Quoted 51 lines
Quoted 51 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 5 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
Please consider the following simple program:
Quoted 7 lines
#define MASK
0x80808080int main(){ int en; en = MASK; printf("%x, shifted %x\n", en, en >> 1); return 0; }Would you mind sharing what you get after running this on your
x86_64(if you have one) computer? Really appreiciate that.The almost identical episode is in the patch, specifically,
Quoted 1 line
en =
ENABLE_HART_IPI>> hartQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
or it will cause IPI sending errors.
Regards,
BinBest,
AlanRegards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 61 lines
Quoted 61 lines · Anup Patel
Quoted 59 lines · Alan Kao
Quoted 46 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Quoted 6 lines
Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.
Quoted 8 lines
Quoted 7 lines
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?
Thanks
Rick
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 67 lines · Rick Chen
Hi Anup
Quoted 64 lines
Quoted 64 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?
You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
Regards,
Anup
Quoted 3 lines
Thanks
Rick
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do _relocate_copy_to_lower which will copy data from 0x1000000 to 0x0.
And it will corrupt U-Boot SPL.
Thanks
Rick
Quoted 7 lines
Regards,
AnupQuoted 3 lines
Thanks
Rick
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 89 lines · Rick Chen
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)
Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.
The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the FW_TEXT_START before entering C code. This helps us load OpenSBI firmwares anywhere in RAM.
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI FW_DYNAMIC and U-Boot SPL are linked to address same address 0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBI FW_DYNAMIC and U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 103 lines · Anup Patel
Quoted 89 lines · Rick Chen
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.
Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.
I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in arch/riscv/lib/spl.c)
The real issue is FW_TEXT_START being same as U-Boot SPL TEXT_START.
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL TEXT_START would be convenient since this series is under review. Thoughts ?
Regards,
Anup
Quoted 3 lines
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 120 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)
Quoted 5 lines
The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?
Yes.
I know it can avoid corrupting issue with changing U-Boot SPL TEXT_START not equal to OpenSBI TEXT base.
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to _wait_relocate_copy_done
It will be convenient to change U-Boot SPL text base currently.
Thanks
Rick
Quoted 7 lines
Regards,
AnupQuoted 3 lines
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 125 lines · Rick Chen
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 13 lines
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.
Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.
I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 5 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_done
Overall it's a good suggestion but we cannot use a2 register because this will break FW_JUMP and FW_PAYLOAD. Instead, we should pass preferred boot HART id in struct fw_dynamic_info.
I have a patch for this in preferred_boot_hart_v1 branch of
https://github.com/avpatel/opensbi.git
Can you try OpenSBI from above branch ?
You will have to update the "struct fw_dynamic_info" passed to OpenSBI by U-Boot SPL.
Meanwhile, I will try above patch on QEMU and SiFive Unleashed.
Quoted 2 lines
It will be convenient to change U-Boot SPL text base currently.
Let's fix this correctly now itself.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 137 lines · Rick Chen
Quoted 125 lines
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 30 lines · Bin Meng
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.Quoted 7 lines
Quoted 4 lines
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.
Sorry, what I want to say shall be a3.
Quoted 8 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.
Main hart will pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6, _wait_relocate_copy_done
change to
bne a3, a6, _wait_relocate_copy_done
before this commit 98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lottery
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Thanks
Rick
Quoted 10 lines
Meanwhile, I will try above patch on QEMU and SiFive Unleashed.
Quoted 2 lines
It will be convenient to change U-Boot SPL text base currently.
Let's fix this correctly now itself.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 155 lines · Rick Chen
Hi Anup
Quoted 137 lines · Rick Chen
Quoted 125 lines
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
Quoted 37 lines · Bin Meng
Hi Rick,
On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi Bin
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it a limitation.
This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 4 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.git
Quoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.
That's wrong in U-Boot SPL.
All HARTs have to follow FW_DYNAMIC protocol and pass "struct fw_dynamic_info" pointer in 'a2' register.
Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lottery
What about FW_JUMP and FW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.
Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct fw_dynamic_info" for this so that we can maintain backward compatibility as well.
Please make sure that U-Boot SPL passes "struct fw_dynamic_info" pointer in 'a2' register for all HARTs.
Quoted 4 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Let's fix this in the right way from start itself.
Regards,
Anup
Quoted 14 lines
Thanks
RickQuoted 10 lines
Meanwhile, I will try above patch on QEMU and SiFive Unleashed.
Quoted 2 lines
It will be convenient to change U-Boot SPL text base currently.
Let's fix this correctly now itself.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 194 lines · Anup Patel
Quoted 155 lines · Rick Chen
Hi Anup
Quoted 137 lines · Rick Chen
Quoted 125 lines
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 52 lines · Alan Kao
Quoted 50 lines
Hi Bin,
Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi Bin
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.Quoted 7 lines
Quoted 2 lines
So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation in OpenSBI for
FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having
boot_lottery.I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 4 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 1 line
Quoted 8 lines
Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Let's fix this in the right way from start itself.
I double checked spl_invoke_opensbi() and it is doing the right thing by passing "struct fw_dyanmic_info" pointer in 'a2' register. (Refer, common/spl/spl_opensbi.c)
Not sure, why it is not passing 'a2' register correctly for you ??
Regards,
Anup
Quoted 18 lines
Regards,
AnupQuoted 14 lines
Thanks
RickQuoted 10 lines
Meanwhile, I will try above patch on QEMU and SiFive Unleashed.
Quoted 2 lines
It will be convenient to change U-Boot SPL text base currently.
Let's fix this correctly now itself.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 203 lines · Anup Patel
Quoted 201 lines · Rick Chen
Quoted 155 lines
Hi Anup
Quoted 137 lines · Rick Chen
Quoted 125 lines
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
Quoted 59 lines · Alan Kao
Hi Bin,
Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi Bin
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 4 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 4 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass struct fw_dyanmic_info in a2 to OpenSBI.
Thanks for your corrections
Regards,
Rick
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 212 lines · Rick Chen
Hi Anup
Quoted 209 lines · Anup Patel
Quoted 194 lines · Rick Chen
Quoted 155 lines
Hi Anup
Quoted 137 lines · Rick Chen
Quoted 125 lines
Hi Anup
Quoted 122 lines · Anup Patel
Quoted 103 lines · Rick Chen
Quoted 89 lines
Hi Anup
Quoted 75 lines · Rick Chen
Quoted 73 lines
Hi Anup
Quoted 69 lines
Quoted 68 lines · Anup Patel
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,
Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi Bin
Hi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 4 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 1 line
Quoted 8 lines
Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)
Quoted 7 lines
Quoted 2 lines
Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
common/spl/spl_opensbi.c +1 -0
@@ -69,6 +69,7 @@ void spl_invoke_opensbi(struct spl_image_info *spl_image) opensbi_info.next_addr = uboot_entry; opensbi_info.next_mode =FW_DYNAMIC_INFO_NEXT_MODE_S ; opensbi_info.options =SBI_SCRATCH_NO_BOOT_PRINTS ; + opensbi_info.boot_hart = gd->arch.boot_hart; opensbi_entry = (void (*)(ulong ,ulong ,ulong ))spl_image->entry_point;invalidate_icache_all ();
include/opensbi.h +3 -1
@@ -11,7 +11,7 @@#define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f/** Maximum supported info version */ -#define FW_DYNAMIC_INFO_VERSION 0x1 +#define FW_DYNAMIC_INFO_VERSION 0x2/** Possible next mode values */ #define FW_DYNAMIC_INFO_NEXT_MODE_U 0x0
@@ -35,6 +35,8 @@ struct fw_dynamic_info {unsigned long next_mode;/** Options for OpenSBI library */ unsigned long options; +/** Preferred boot HART id */ + unsigned long boot_hart; } __packed;#endif
Regards,
Anup
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 78 lines
Hi Anup
Quoted 65 lines · Rick Chen
Quoted 64 lines
Hi Anup
Quoted 61 lines
On Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.
Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
Regards,
Lukas
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 211 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 78 lines
Hi Anup
Quoted 65 lines · Rick Chen
Quoted 64 lines
Hi Anup
On Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
Quoted 6 lines
Quoted 2 lines
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding hart_mask in fw_dynamic_info, I think the issue will be the size of the hart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bit hart_mask to be not sufficient for all HARTs.
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in fw_base.S which will add to the boot-time as well.
I still think the root cause of the issue is that TEXT_START of U-Boot SPL and OpenSBI FW_DYNAMIC is same. Maybe we can insist SOC vendors to not use same TEXT_START ?
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 236 lines
Quoted 211 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 78 lines
Hi Anup
Quoted 71 lines · Rick Chen
Hi Anup
On Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.
Quoted 6 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?
I have try your changes about boot_hart for U-Boot SPL with OpenSBI, preferred_boot_hart_v2 branch
It still encounter some booting problems. I try to find out the root cause but in vain.
I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting progress will be pass.
Thanks
Rick
Quoted 3 lines
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 247 lines · Rick Chen
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 236 lines
Quoted 211 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 85 lines
Hi Anup
On Tue, Nov 5, 2019 at 7:19 AM Rick Chen <[email protected]> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart.
The hart 1 will receive ipi and come into OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Quoted 6 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?
Quoted 8 lines
I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting progress will be pass.
No problem, it will be your decision to go with different TEXT_BASE for AndesTech platform.
We will keep the "boot_hart" field in OpenSBI for U-Boot SPL on QEMU and I will wait for Lukas to add more checks and small delay in U-Boot SPL (like he mentioned).
Thanks,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Anup
Quoted 254 lines · Rick Chen
Quoted 252 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 236 lines
Quoted 211 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 99 lines · Rick Chen
Hi Anup
On Tue, Nov 5, 2019 at 7:19 AM Rick Chen <[email protected]> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart.
The hart 1 will receive ipi and come into OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI FW_DYNAMIC and U-Boot SPL are linked to
address same address 0x0. This means secondary HARTs cannot safely
wait while primary HART enters OpenSBI. You should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and U-Boot proper are
loaded in RAM by primary HART. All your HARTs should jump to OpenSBI
at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Quoted 6 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.
Quoted 6 lines
Quoted 3 lines
I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting progress will be pass.No problem, it will be your decision to go with different
TEXT_BASEfor AndesTech platform.
You misunderstand my intention
It is just a temporary solution for debugging.
I prefer U-Boot SPL text base can be sync with you finally.
Quoted 4 lines
We will keep the "
boot_hart" field in OpenSBI for U-Boot SPL on QEMU and I will wait for Lukas to add more checks and small delay in U-Boot SPL (like he mentioned).
I am happy to hear that. :)
Thanks
Rick
Quoted 3 lines
Thanks,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 261 lines · Rick Chen
Hi Anup
Quoted 258 lines · Rick Chen
Quoted 255 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 236 lines
Quoted 211 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <[email protected]> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <[email protected]> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart.
The hart 1 will receive ipi and come into OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI FW_DYNAMIC and U-Boot SPL are linked to
address same address 0x0. This means secondary HARTs cannot safely
wait while primary HART enters OpenSBI. You should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and U-Boot proper are
loaded in RAM by primary HART. All your HARTs should jump to OpenSBI
at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-Boot SPL TEXT_START.
Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Quoted 6 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting progress will be pass.
Quoted 6 lines
Quoted 2 lines
No problem, it will be your decision to go with different
TEXT_BASEfor AndesTech platform.You misunderstand my intention
It is just a temporary solution for debugging.
I prefer U-Boot SPL text base can be sync with you finally.
No worries, we are on same page here. If we get U-Boot SPL -> OpenSBI boot-flow stable on AndesTech platform then it will make things easy for SiFive Unleashed as well.
If possible please try your patches on-top-of Lukas's changes. I am sure this will help you achieve 100% reliability.
Quoted 7 lines
Quoted 5 lines
We will keep the "
boot_hart" field in OpenSBI for U-Boot SPL on QEMU and I will wait for Lukas to add more checks and small delay in U-Boot SPL (like he mentioned).I am happy to hear that. :)
Cool.
Best Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
In reply to Rick ChenQuoted 346 lines · Rick Chen
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 217 lines · Rick Chen
Hi Anup
Quoted 201 lines
Quoted 183 lines · Rick Chen
Hi Anup
Quoted 172 lines
Quoted 149 lines · Anup Patel
Quoted 137 lines · Rick Chen
Hi Anup
On Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to theFW_TEXT_STARTbefore entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.Quoted 12 lines
In your case, both OpenSBI
FW_DYNAMICand U-
Boot SPL are linked to
address same address0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBIFW_DYNAMICand
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)Quoted 8 lines
The real issue is
FW_TEXT_STARTbeing same as U-
Boot SPLTEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPLTEXT_STARTwould be
convenient since this series
is under review. Thoughts ?Quoted 4 lines
Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 7 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneQuoted 5 lines
Overall it's a good suggestion but we cannot use a2 register because this
will breakFW_JUMPandFW_PAYLOAD. Instead, we should pass preferred
boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 6 lines
I have a patch for this in
preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
Quoted 8 lines
Quoted 3 lines
You will have to update the "struct
fw_dynamic_info" passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just
have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.
Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Quoted 10 lines
I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting
progress will be pass.Thanks
RickQuoted 2 lines
Regards,
Anup
Signature · 2 lines
Regards, Atish
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Atish
Quoted 358 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 217 lines · Rick Chen
Hi Anup
Quoted 201 lines
Quoted 183 lines · Rick Chen
Hi Anup
Quoted 172 lines
Quoted 161 lines · Anup Patel
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)Quoted 8 lines
The real issue is
FW_TEXT_STARTbeing same as U-
Boot SPLTEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPLTEXT_STARTwould be
convenient since this series
is under review. Thoughts ?Quoted 4 lines
Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 7 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneQuoted 5 lines
Overall it's a good suggestion but we cannot use a2 register because this
will breakFW_JUMPandFW_PAYLOAD. Instead, we should pass preferred
boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 6 lines
I have a patch for this in
preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
Quoted 8 lines
Quoted 3 lines
You will have to update the "struct
fw_dynamic_info" passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just
have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.
Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit 831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in struct fw_dynamic_info
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
Thanks
Rick
Quoted 15 lines
Quoted 11 lines
I am very agree with options of Lukas.
After modifying U-Boot SPL text base not equal to zero and the booting
progress will be pass.Thanks
RickQuoted 2 lines
Regards,
Anup--
Regards,
Atish
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Atish
Quoted 368 lines
Hi Atish
Quoted 358 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 217 lines · Rick Chen
Hi Anup
Quoted 201 lines
Quoted 183 lines · Rick Chen
Hi Anup
Quoted 180 lines
On Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Quoted 4 lines
Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 7 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneQuoted 5 lines
Overall it's a good suggestion but we cannot use a2 register because this
will breakFW_JUMPandFW_PAYLOAD. Instead, we should pass preferred
boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 6 lines
I have a patch for this in
preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
Quoted 8 lines
Quoted 3 lines
You will have to update the "struct
fw_dynamic_info" passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just
have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Quoted 7 lines
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoIt fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
case 1 (fail)
hb *0x1000000
Thread 2 hit Breakpoint 3, 0x0000000001000000 in ?? () (gdb) info threads
Id Target Id Frame 1 Thread 1 (hart 1) 0x0000000001000000 in ?? () * 2 Thread 2 (hart 2) 0x0000000001000000 in ?? () 3 Thread 3 (hart 3) secondary_hart_loop () at arch/riscv/cpu/start.S:416 4 Thread 4 (hart 4) secondary_hart_loop () at arch/riscv/cpu/start.S:416
(gdb) p/x gd->arch.boot_hart
$3 = 0x1
main hart is hart 1 in U-Boot SPL, hart 1 have arrived OpenSBI, but hart 3, 4 still run in U-Boot SPL
c
U-Boot console print message
U-Boot SPL 2019.10-00603-g850848e-dirty (Nov 08 2019 - 14:37:54 +0800) Trying to boot from RAM
U-Boot 2019.10-00603-g850848e-dirty (Nov 08 2019 - 14:37:54 +0800)
DRAM: 1 GiB
Flash:
<== hang here
Thanks
Rick
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 217 lines · Rick Chen
Hi Anup
Quoted 201 lines
Quoted 187 lines · Rick Chen
Hi Anup
On Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 7 lines
With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneQuoted 5 lines
Overall it's a good suggestion but we cannot use a2 register because this
will breakFW_JUMPandFW_PAYLOAD. Instead, we should pass preferred
boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 6 lines
I have a patch for this in
preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
Quoted 8 lines
Quoted 3 lines
You will have to update the "struct
fw_dynamic_info" passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just
have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_info
Quoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hart
Thanks,
Lukas
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Lukas
Quoted 384 lines
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 217 lines · Rick Chen
Hi Anup
Quoted 206 lines
On Wed, Nov 6, 2019 at 2:51 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running
on QEMU as well.With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2
register because this
will break FW_JUMP and FW_PAYLOAD. Instead, we should
pass preferred
boot HART id in struct fw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 6 lines
I have a patch for this in preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
Quoted 8 lines
Quoted 3 lines
You will have to update the "struct fw_dynamic_info"
passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just
have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoQuoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Quoted 6 lines
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hart
I have try this patch, but it seems can not guarantee main hart to be the last hart while leaving U-Boot SPL.
Even the main hart have checked all harts have received the IPI, but it still have opportunities to arrive OpenSBI before other harts.
Thanks
Rick
Quoted 3 lines
Thanks,
Lukas
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Rick,
Quoted 389 lines · Rick Chen
Hi Lukas
Quoted 387 lines
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 267 lines · Anup Patel
Quoted 225 lines · Rick Chen
Hi Anup
On Wed, Nov 6, 2019 at 2:51 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running
on QEMU as well.With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2
register because this
will break FW_JUMP and FW_PAYLOAD. Instead, we should
pass preferred
boot HART id in struct fw_dynamic_info.Sorry, what I want to say shall be a3.
I have a patch for this in preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
You will have to update the "struct fw_dynamic_info"
passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "fw_dynamic_info" to OpenSBI
by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info"
to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 9 lines
So if U-Boot SPL can pass main hart information via a3,
OpenSBI just
have the following change
blt zero, a6, _wait_relocate_copy_done
change to
bne a3, a6, _wait_relocate_copy_done
before this commit
98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing
value in a3 for these firmwares because these are not booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not
pass anything in 'a3' register.We should definitely use "struct
fw_dynamic_info" for this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.Quoted 5 lines
But after this commit 98f4a, main hart become chosen
from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not
overlap with
OpenSBI text start. :)Quoted 6 lines
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoQuoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
Quoted 8 lines
Quoted 2 lines
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hartI have try this patch, but it seems can not guarantee main hart to be the last hart while leaving U-Boot SPL.
Even the main hart have checked all harts have received the IPI, but it still have opportunities to arrive OpenSBI before other harts.
Thanks for testing! Can you try again with the same branch? I added another patch so that clearing the IPI is the very last thing before jumping to the SMP function.
If that does not help, we'll have to add a delay in spl_invoke_opensbi() to delay the main hart.
Thanks,
Lukas
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Hi Lukas
Quoted 402 lines
Hi Rick,
Quoted 389 lines · Rick Chen
Hi Lukas
Quoted 387 lines
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 276 lines
Quoted 273 lines · Anup Patel
On Thu, Nov 7, 2019 at 7:04 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:51 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running
on QEMU as well.With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2
register because this
will break FW_JUMP and FW_PAYLOAD. Instead, we should
pass preferred
boot HART id in struct fw_dynamic_info.Sorry, what I want to say shall be a3.
I have a patch for this in preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
You will have to update the "struct fw_dynamic_info"
passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "fw_dynamic_info" to OpenSBI
by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info"
to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow FW_DYNAMIC protocol and pass
"struct fw_dynamic_info" pointer in 'a2' register.So if U-Boot SPL can pass main hart information via a3,
OpenSBI just
have the following change
blt zero, a6, _wait_relocate_copy_done
change to
bne a3, a6, _wait_relocate_copy_done
before this commit
98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about FW_JUMP and FW_PAYLOAD? We have no way of
passing
value in a3 for these firmwares because these are not
booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support
which does not
pass anything in 'a3' register.We should definitely use "struct fw_dynamic_info" for
this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.But after this commit 98f4a, main hart become chosen
from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not
overlap with
OpenSBI text start. :)Like I mentioned, we have this issue for U-Boot SPL on
QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on
QEMU.Let's fix this in the right way from start itself.
Quoted 9 lines
I double checked
spl_invoke_opensbi()and it is doing the right thing
by passing "structfw_dyanmic_info" pointer in 'a2' register.
(Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoQuoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
Quoted 8 lines
Quoted 2 lines
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hartI have try this patch, but it seems can not guarantee main hart to be the last hart while leaving U-Boot SPL.
Even the main hart have checked all harts have received the IPI, but it still have opportunities to arrive OpenSBI before other harts.
Quoted 5 lines
Thanks for testing! Can you try again with the same branch? I added another patch so that clearing the IPI is the very last thing before jumping to the SMP function.
If that does not help, we'll have to add a delay inspl_invoke_opensbi()to delay the main hart.
Thanks for your patch, it indeed solve the problem almost. It always pass the booting verification under free running, I try many times and can not hit the failure case.
But if I do something with GDB, E.g
Set a break in 0x6c2 (c.jalr s2) in handle_ipi() and then delete the break and free run after it hit this break
then it will hit the failure case as below:
-----------------------------
U-Boot SPL fail print message
-----------------------------
U-Boot SPL 2020.01-rc1-08573-gc42669d-dirty (Nov 13 2019 - 10:31:12 +0800) Trying to boot from RAMboot_hart 0
U-Boot 2020.01-rc1-08573-gc42669d-dirty (Nov 13 2019 - 10:31:12 +0800)
DRAM: 1 GiB
Flash:
---------------
gdb information
---------------
Thread 4 hit Breakpoint 3, 0x00000000000006c2 in handle_ipi (hart=3)
at arch/riscv/lib/smp.c:110
110 smp_function(hart, gd->arch.ipi[hart].arg0,
gd->arch.ipi[hart].arg1);
(gdb) inf othreads
Undefined info command: "othreads". Try "help info". (gdb) info threads
Id Target Id Frame
1 Thread 1 (hart 1) 0x000000000122a8f8 in ?? ()
2 Thread 2 (hart 2) 0x00000000000006c2 in handle_ipi (hart=1)
at arch/riscv/lib/smp.c:110
3 Thread 3 (hart 3) 0x00000000000006c2 in handle_ipi (hart=2)
at arch/riscv/lib/smp.c:110
* 4 Thread 4 (hart 4) 0x00000000000006c2 in handle_ipi (hart=3)
at arch/riscv/lib/smp.c:110(gdb) d
Delete all breakpoints? (y or n) y
(gdb) c
Continuing.
----------handle_ipi
----------
0000000000000678 <handle_ipi>:
678: 479d c.li a5,7
67a: 04a7e663 bltu a5,a0,6c6 <handle_ipi+0x4e>
67e: 6a1042ef jal t0,551e <__riscv_save_2>
682: 842a c.mv s0,a0
684: 0330000f fence rw,rw
688: 44e1 c.li s1,24
68a: 029504b3 mul s1,a0,s1
68e: 003487b3 add a5,s1,gp
692: 1507b903 ld s2,336(a5)
696: d57ff0ef jal ra,3ec <invalidate_icache_all>
69a: 0004051b sext.w a0,s0
69e: e4bff0ef jal ra,4e8 <riscv_clear_ipi>
6a2: c911 c.beqz a0,6b6 <handle_ipi+0x3e>
6a4: 85a2 c.mv a1,s0
6a6: 00005517 auipc a0,0x5
6aa: 36250513 addi a0,a0,866 # 5a08 <_ctype+0x440>
6ae: 3f8030ef jal ra,3aa6 <printf>
6b2: 6a50406f j 5556 <__riscv_restore_2>
6b6: 948e c.add s1,gp
6b8: 1604b603 ld a2,352(s1)
6bc: 1584b583 ld a1,344(s1)
6c0: 8522 c.mv a0,s0
6c2: 9902 c.jalr s2
6c4: b7fd c.j 6b2 <handle_ipi+0x3a>
6c6: 8082 c.jr raMaybe it is a little picky and fussy, what I try to say is that someone maybe can not understand why the main hart shall be the last hart when leaving U-Boot SPL when they review this part. I think the better way shall be that make sure all harts are there before relocation in OpenSBI (You mentioned it before)
Thanks for your sharing this way to avoid this problem again. It really provide me another way to work around in current status. I will keep trying it's robustness and reliability under free running.
Thanks
Rick
Quoted 3 lines
Thanks,
Lukas
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 412 lines · Rick Chen
Hi Lukas
Quoted 402 lines
Hi Rick,
Quoted 389 lines · Rick Chen
Hi Lukas
Quoted 387 lines
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupQuoted 285 lines
On Thu, Nov 7, 2019 at 10:45 AM Anup Patel <
anup at brainfault.org> wrote:
On Thu, Nov 7, 2019 at 7:04 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:51 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running
on QEMU as well.With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2
register because this
will break FW_JUMP and FW_PAYLOAD. Instead, we should
pass preferred
boot HART id in struct fw_dynamic_info.Sorry, what I want to say shall be a3.
I have a patch for this in preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
You will have to update the "struct fw_dynamic_info"
passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "fw_dynamic_info" to OpenSBI
by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info"
to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow FW_DYNAMIC protocol and pass
"struct fw_dynamic_info" pointer in 'a2' register.So if U-Boot SPL can pass main hart information via a3,
OpenSBI just
have the following change
blt zero, a6, _wait_relocate_copy_done
change to
bne a3, a6, _wait_relocate_copy_done
before this commit
98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about FW_JUMP and FW_PAYLOAD? We have no way of
passing
value in a3 for these firmwares because these are not
booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support
which does not
pass anything in 'a3' register.We should definitely use "struct fw_dynamic_info" for
this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.But after this commit 98f4a, main hart become chosen
from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not
overlap with
OpenSBI text start. :)Like I mentioned, we have this issue for U-Boot SPL on
QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on
QEMU.Let's fix this in the right way from start itself.
I double checked spl_invoke_opensbi() and it is doing the
right thing
by passing "struct fw_dyanmic_info" pointer in 'a2'
register.
(Refer, common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for
you ??Yes, you are right. I reply too quickly. Other harts will pass struct
fw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoQuoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
Quoted 8 lines
Quoted 2 lines
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hartI have try this patch, but it seems can not guarantee main hart to be the last hart while leaving U-Boot SPL.
Even the main hart have checked all harts have received the IPI, but it still have opportunities to arrive OpenSBI before other harts.Quoted 5 lines
Thanks for testing! Can you try again with the same branch? I added another patch so that clearing the IPI is the very last thing before jumping to the SMP function.
If that does not help, we'll have to add a delay inspl_invoke_opensbi()to delay the main hart.
Quoted 8 lines
Thanks for your patch, it indeed solve the problem almost. It always pass the booting verification under free running, I try many times and can not hit the failure case.
But if I do something with GDB, E.g
Set a break in0x6c2(c.jalr s2) inhandle_ipi()and then delete the break and free run after it hit this break
then it will hit the failure case as below:
The current booting mechanism where all HARTs jump to each booting stage (including Linux) at the same time is very fragile.
Attaching a debugger at boot-time will certainly break current way of booting all HARTs because we are holding a particular HART in debug state. I am not sure if we can handle the debugger case in software but in real-world deployments debugger won't be present so maybe we can ignore this case.
The SBI v0.2 HSM extension will make things better. It would be even better if HW designers provide explicit HW mechanism to power-on/off HARTs at run-time.
Regards,
Anup
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 410 lines · Anup Patel
Quoted 409 lines · Rick Chen
Hi Lukas
Quoted 406 lines
Hi Rick,
Quoted 389 lines · Rick Chen
Hi Lukas
Quoted 387 lines
Hi Rick,
Quoted 372 lines · Rick Chen
Hi Atish
Quoted 370 lines
Hi Atish
Quoted 357 lines · Rick Chen
Quoted 346 lines
Hi Anup & Lukas
Anup Patel <[email protected]> 於 2019年11月7日 週四 下午6:44寫道:
Quoted 343 lines
Quoted 308 lines · Lukas
Quoted 294 lines · Anup Patel
On Thu, Nov 7, 2019 at 11:40 AM Rick Chen <[email protected]
Quoted 293 lines
wrote:
Hi AnupOn Thu, Nov 7, 2019 at 10:45 AM Anup Patel <
anup at brainfault.org> wrote:
On Thu, Nov 7, 2019 at 7:04 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:51 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Wed, Nov 6, 2019 at 2:18 PM Anup Patel <
anup at brainfault.org> wrote:
On Wed, Nov 6, 2019 at 12:14 PM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Tue, Nov 5, 2019 at 7:19 AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup
Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM
Alan Kao <[email protected]>
wrote:
Hi Bin,Thanks for the critics. Comments
below.
On Wed, Oct 30, 2019 at
06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50
AM Rick Chen <
rickchen36 at gmail.com> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at
2:18 PM Andes <
uboot at andestech.com> wrote:
From: Rick Chen <
rick at andestech.com>It will work fine due to
hart 0 always will be
main
hart coincidentally. When
develop SPL flow, I try
to
force other harts to be
main hart. And it will go
wrong in sending IPI
flow. So fix it.Fix what? Does this commit
contain 2 fixes, or just 1
fix?Yes, it include two fixs. But
they will cause one negative
result
that only hart 0 can send ipi
to other harts.Having this fix, any hart
can be main hart in U-
Boot SPL
theoretically, but it
still fail somewhere.
After dig in
and found there is an
assumption that hart 0
shall be
main hart in OpenSbi.So does this mean there is
a bug in OpenSBI too?I am not sure if it is a bug.
Maybe it is a compatible
issue.
There is a limitation that
only hart 0 can be main hart
in OpenSBI.I don't think OpenSBI has such
limitation.Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs
of the initialization are the
1. get hart ID.
2. determine which route to take
based on their ID respectively.So, I do think OpenSBI has this
signature, if you are not willing
to call it
a limitation.This dependency on hart id #0 was
not there until we added self-
relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI
but we might end-up having
boot_lottery.I have send a patch to fix this
OpenSBI:
"[PATCH] firmware: Introduce
relocation lottery"Can you try above patch and see if
that helps ?It will be great if you can provide
Tested-by to my patch as well.I can not find this patch in mailing
list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed
multiple times.I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0
play as main hart.
The hart 1 will receive ipi and come into
OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still
run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower
which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares
ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering
C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the
U-Boot SPL is running.In your case, both OpenSBI FW_DYNAMIC and U-
Boot SPL are linked to
address same address 0x0. This means secondary
HARTs cannot safely
wait while primary HART enters OpenSBI. You
should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and
U-Boot proper are
loaded in RAM by primary HART. All your HARTs
should jump to OpenSBI
at the same time after everything is loaded in
RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART
jump to OpenSBI and primary
HART jumps to OpenSBI at the end.
(Refer, jump_to_image_no_args() in
arch/riscv/lib/spl.c)The real issue is FW_TEXT_START being same as U-
Boot SPL TEXT_START.If possible please change TEXT base for U-Boot
SPL or OpenSBI. I think
changing U-Boot SPL TEXT_START would be
convenient since this series
is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with
changing U-Boot SPL
TEXT_START not equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running
on QEMU as well.With the following changes, U-Boot SPL text base
can equal to OpenSBI text base
1 U-Boot pass main hart information (a2) when
jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart,
other harts go to
_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2
register because this
will break FW_JUMP and FW_PAYLOAD. Instead, we should
pass preferred
boot HART id in struct fw_dynamic_info.Sorry, what I want to say shall be a3.
I have a patch for this in preferred_boot_hart_v1
branch of
https://github.com/avpatel/opensbi.gitCan you try OpenSBI from above branch ?
You will have to update the "struct fw_dynamic_info"
passed to
OpenSBI by U-Boot SPL.Main hart will pass struct "fw_dynamic_info" to OpenSBI
by U-Boot SPL.
But other harts will NOT pass struct "fw_dynamic_info"
to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow FW_DYNAMIC protocol and pass
"struct fw_dynamic_info" pointer in 'a2' register.So if U-Boot SPL can pass main hart information via a3,
OpenSBI just
have the following change
blt zero, a6, _wait_relocate_copy_done
change to
bne a3, a6, _wait_relocate_copy_done
before this commit
98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about FW_JUMP and FW_PAYLOAD? We have no way of
passing
value in a3 for these firmwares because these are not
booted by U-Boot
SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support
which does not
pass anything in 'a3' register.We should definitely use "struct fw_dynamic_info" for
this so that we can
maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info"
pointer in 'a2' register for all HARTs.But after this commit 98f4a, main hart become chosen
from lottery mechanism.
Maybe I will prefer to change U-Boot SPL text base not
overlap with
OpenSBI text start. :)Like I mentioned, we have this issue for U-Boot SPL on
QEMU as well. It's
just that most of us did not notice it for U-Boot SPL on
QEMU.Let's fix this in the right way from start itself.
I double checked spl_invoke_opensbi() and it is doing the
right thing
by passing "struct fw_dyanmic_info" pointer in 'a2'
register.
(Refer, common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for
you ??Yes, you are right. I reply too quickly.
Other harts will pass struct fw_dyanmic_info in a2 to
OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I
had to add a short delay between sending the IPIs to trigger the problem.Quoted 12 lines
We might still run into problems however. Right now, we are assuming
that the main hart is the last one to enter OpenSBI. If this is not the
case (some delay when handling the IPI), we will have the same problem
again. To fix this we could pass the hart mask, containing all harts
that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so
this might not be needed.I agree that we might still run into this issue if primary HART enters
OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the
size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait- loop
infw_base.Swhich will add to the boot-time as well.Quoted 9 lines
Quoted 3 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?I have try your changes about
boot_hartfor U-Boot SPL with OpenSBI,preferred_boot_hart_v2branch
It still encounter some booting problems. I try to find out the root cause but in vain.Quoted 6 lines
Just wanted to make sure that you have tried this patch.
http://lists.infradead.org/pipermail/opensbi/2019-November/000672.html
We should investigate the issue why it did not work for you if this patch did not work for you.
Yes, I try with this
commit831aa3c1ad2546a2b35ddf5b1aa0ce91cdc7fe89
firmware: Add preferred boot HART field in structfw_dynamic_infoQuoted 7 lines
Quoted 3 lines
It fail randomly yesterday, but this morning I try several times it will pass. I will keep trying.
I have figure out one fail case which is belong to main hart of U-Boot SPL is not the last hart while entering OpenSBI
Can you try this branch [1]? It includes a quick implementation of the changes a mentioned yesterday, where the main hart waits until all harts have received the IPI.
Quoted 8 lines
Quoted 2 lines
[1]:
https://github.com/lukasauer/u-boot/commits/riscv-opensbi-boot-hartI have try this patch, but it seems can not guarantee main hart to be the last hart while leaving U-Boot SPL.
Even the main hart have checked all harts have received the IPI, but it still have opportunities to arrive OpenSBI before other harts.Thanks for testing! Can you try again with the same branch? I added another patch so that clearing the IPI is the very last thing before jumping to the SMP function.
If that does not help, we'll have to add a delay inspl_invoke_opensbi()to delay the main hart.
Quoted 4 lines
Quoted 4 lines
Thanks for your patch, it indeed solve the problem almost. It always pass the booting verification under free running, I try many times and can not hit the failure case.
Thanks for testing the changes again, Rick. I will try to clean them up and submit them soon.
Quoted 14 lines
Quoted 4 lines
But if I do something with GDB, E.g
Set a break in0x6c2(c.jalr s2) inhandle_ipi()and then delete the break and free run after it hit this break
then it will hit the failure case as below:The current booting mechanism where all HARTs jump to each booting stage (including Linux) at the same time is very fragile.
Attaching a debugger at boot-time will certainly break current way of booting all HARTs because we are holding a particular HART in debug state. I am not sure if we can handle the debugger case in software but in real-world deployments debugger won't be present so maybe we can ignore this case.
Quoted 4 lines
The SBI v0.2 HSM extension will make things better. It would be even better if HW designers provide explicit HW mechanism to power-on/off HARTs at run-time.
I agree with you, Anup. The debugger should not be attached in real- world scenarios. Even if it is, it is likely for debugging something in U-Boot proper or SPL and not the part where we are jumping to OpenSBI, so we should not typically run into any issues here. In addition, the recommended way of using SPL should be with separate text bases for U-Boot SPL and OpenSBI. In this setup we don't run into this problem. All in all, I think the current solution is robust enough.
I will also make sure to add a comment on why it is important that the main hart enters OpenSBI last. This way the problem is documented and people looking at the code will be aware of it.
Thanks,
Lukas
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
In reply to Anup PatelQuoted 220 lines · Anup Patel
Quoted 210 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 78 lines
Hi Anup
Quoted 71 lines · Rick Chen
Hi Anup
On Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(98f4a208995b027662a7b04a25e4fa5df5f3eefe)Quoted 7 lines
The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart. The hart 1 will receive ipi and come into OpenSBI(0x1000000) from U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL. Then hart 1 will do_relocate_copy_to_lowerwhich will copy data from0x1000000to0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
Quoted 8 lines
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
You are right, I don't think we will ever see this on real hardware. I can add a check to ensure all harts have processed the IPI before jumping to OpenSBI on the main hart. A simple delay is probably already sufficient however.
Quoted 9 lines
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.
I agree, it's best to keep everything simple here.
Quoted 4 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?
That is definitely the best solution. I am not familiar with the details of the Andes platform, so unsure if that would work on it. On the SiFive Unleashed board this will be possible as soon as we have a working DRAM driver. U-Boot SPL could then run from L2 scratchpad memory instead of DRAM.
Regards,
Lukas
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 227 lines · Lukas
Quoted 225 lines · Anup Patel
Quoted 210 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 91 lines · Rick Chen
Quoted 85 lines
Hi Anup
On Tue, Nov 5, 2019 at 7:19 AM Rick Chen <[email protected]> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart.
The hart 1 will receive ipi and come into OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware are moved to the
FW_TEXT_STARTbefore entering C code. This helps us load OpenSBI firmwares anywhere in RAM.Quoted 8 lines
However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI
FW_DYNAMICand U-Boot SPL are linked to address same address0x0. This means secondary HARTs cannot safely wait while primary HART enters OpenSBI. You should hold secondary HARTs in U-Boot SPL only till OpenSBIFW_DYNAMICand U-Boot proper are loaded in RAM by primary HART. All your HARTs should jump to OpenSBI at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Quoted 8 lines
Quoted 3 lines
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
You are right, I don't think we will ever see this on real hardware. I can add a check to ensure all harts have processed the IPI before jumping to OpenSBI on the main hart. A simple delay is probably already sufficient however.
Yes, please change spl_opensbi like you described.
Maybe also add some comments about the issues we discussed here.
Quoted 7 lines
Quoted 7 lines
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.
Quoted 5 lines
Quoted 3 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I agree, it's best to keep everything simple here.
Cool, I guess we are in-sync.
Quoted 11 lines
Quoted 5 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?That is definitely the best solution. I am not familiar with the details of the Andes platform, so unsure if that would work on it. On the SiFive Unleashed board this will be possible as soon as we have a working DRAM driver. U-Boot SPL could then run from L2 scratchpad memory instead of DRAM.
Yes, this won't be a problem on SiFive Unleashed.
Regards,
Anup
Auer
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
Quoted 232 lines · Anup Patel
Quoted 230 lines · Lukas
Quoted 228 lines · Anup Patel
Quoted 210 lines · Lukas
Quoted 197 lines · Anup Patel
Quoted 196 lines · Rick Chen
Hi Anup
Quoted 182 lines · Anup Patel
Quoted 181 lines · Rick Chen
Quoted 138 lines
Hi Anup
Quoted 122 lines · Rick Chen
Quoted 111 lines
Hi Anup
Quoted 109 lines · Anup Patel
Quoted 99 lines · Rick Chen
Hi Anup
On Tue, Nov 5, 2019 at 7:19 AM Rick Chen <[email protected]> wrote:
Hi AnupOn Thu, Oct 31, 2019 at 1:42 PM Anup Patel <[email protected]> wrote:
On Thu, Oct 31, 2019 at 6:30 AM Alan Kao <[email protected]> wrote:
Hi Bin,Thanks for the critics. Comments below.
On Wed, Oct 30, 2019 at 06:38:00PM +0800, Bin Meng wrote:
Hi Rick,On Wed, Oct 30, 2019 at 10:50 AM Rick Chen <[email protected]> wrote:
Hi BinHi Rick,
On Fri, Oct 25, 2019 at 2:18 PM Andes <[email protected]> wrote:
From: Rick Chen <[email protected]>It will work fine due to hart 0 always will be main
hart coincidentally. When develop SPL flow, I try to
force other harts to be main hart. And it will go
wrong in sending IPI flow. So fix it.Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result
that only hart 0 can send ipi to other harts.Having this fix, any hart can be main hart in U-Boot SPL
theoretically, but it still fail somewhere. After dig in
and found there is an assumption that hart 0 shall be
main hart in OpenSbi.So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue.
There is a limitation that only hart 0 can be main hart in OpenSBI.I don't think OpenSBI has such limitation.
Please check the source.
https://github.com/riscv/opensbi/blob/master/firmware/fw_base.S#L54Apparently, the FIRST TWO LINEs of the initialization are the
1. get hart ID.
2. determine which route to take based on their ID respectively.So, I do think OpenSBI has this signature, if you are not willing to call it
a limitation.This dependency on hart id #0 was not there until we added self-relocation
in OpenSBI for FW_DYNAMIC.I will try to fix this in OpenSBI but we might end-up having boot_lottery.
I have send a patch to fix this OpenSBI:
"[PATCH] firmware: Introduce relocation lottery"Can you try above patch and see if that helps ?
It will be great if you can provide Tested-by to my patch as well.
I can not find this patch in mailing list.
Can you provide a hyperlink ?You can try latest riscv/opensbi master.
I have tested the patch on SiFive Unleashed multiple times.
I have tried this patch, but it fail
firmware: Introduce relocation lottery(
98f4a208995b027662a7b04a25e4fa5df5f3eefe)The scenario was as below:
There are 4 harts run in U-Boot SPL, hart 0 play as main hart.
The hart 1 will receive ipi and come into OpenSBI(0x1000000) from
U-Boot SPL(0x0), meanwhile hart 0,2,3 still run in U-Boot SPL.
Then hart 1 will do _relocate_copy_to_lower which will copy data from
0x1000000 to 0x0.
And it will corrupt U-Boot SPL.The self-relocation in OpenSBI firmwares ensures that OpenSBI firmware
are moved to the FW_TEXT_START before entering C code. This helps
us load OpenSBI firmwares anywhere in RAM.However, OpenSBI firmwares don't know where the U-Boot SPL is running.
In your case, both OpenSBI FW_DYNAMIC and U-Boot SPL are linked to
address same address 0x0. This means secondary HARTs cannot safely
wait while primary HART enters OpenSBI. You should hold secondary HARTs
in U-Boot SPL only till OpenSBI FW_DYNAMIC and U-Boot proper are
loaded in RAM by primary HART. All your HARTs should jump to OpenSBI
at the same time after everything is loaded in RAM.I see the issue now.
The U-Boot SPL is first letting secondary HART jump to OpenSBI and primary HART jumps to OpenSBI at the end.
(Refer,jump_to_image_no_args()inarch/riscv/lib/spl.c)The real issue is
FW_TEXT_STARTbeing same as U-Boot SPLTEXT_START.Quoted 7 lines
Quoted 3 lines
If possible please change TEXT base for U-Boot SPL or OpenSBI. I think changing U-Boot SPL
TEXT_STARTwould be convenient since this series is under review. Thoughts ?Yes.
I know it can avoid corrupting issue with changing U-Boot SPLTEXT_STARTnot equal to OpenSBI TEXT base.I think this issue will be seen on U-Boot SPL running on QEMU as well.
Quoted 8 lines
Quoted 4 lines
With the following changes, U-Boot SPL text base can equal to OpenSBI text base 1 U-Boot pass main hart information (a2) when jumping to OpenSBI
2 OpenSBI pick up $a2 to keep playing as main hart, other harts go to_wait_relocate_copy_doneOverall it's a good suggestion but we cannot use a2 register because this will break
FW_JUMPandFW_PAYLOAD. Instead, we should pass preferred boot HART id in structfw_dynamic_info.Sorry, what I want to say shall be a3.
Quoted 3 lines
I have a patch for this in
preferred_boot_hart_v1branch of
https://github.com/avpatel/opensbi.gitQuoted 7 lines
Quoted 4 lines
Can you try OpenSBI from above branch ?
You will have to update the "struct
fw_dynamic_info" passed to OpenSBI by U-Boot SPL.Main hart will pass struct "
fw_dynamic_info" to OpenSBI by U-Boot SPL. But other harts will NOT pass struct "fw_dynamic_info" to OpenSBI by U-Boot SPL.That's wrong in U-Boot SPL.
All HARTs have to follow
FW_DYNAMICprotocol and pass "structfw_dynamic_info" pointer in 'a2' register.Quoted 8 lines
So if U-Boot SPL can pass main hart information via a3, OpenSBI just have the following change
blt zero, a6,_wait_relocate_copy_done
change to
bne a3, a6,_wait_relocate_copy_done
before this commit98f4a208995b027662a7b04a25e4fa5df5f3eefe
firmware: Introduce relocation lotteryWhat about
FW_JUMPandFW_PAYLOAD? We have no way of passing value in a3 for these firmwares because these are not booted by U-Boot SPL.Also, U-Boot-2019.10 already uses U-Boot SPL support which does not pass anything in 'a3' register.
We should definitely use "struct
fw_dynamic_info" for this so that we can maintain backward compatibility as well.Please make sure that U-Boot SPL passes "struct
fw_dynamic_info" pointer in 'a2' register for all HARTs.Quoted 3 lines
But after this commit 98f4a, main hart become chosen from lottery mechanism. Maybe I will prefer to change U-Boot SPL text base not overlap with OpenSBI text start. :)
Like I mentioned, we have this issue for U-Boot SPL on QEMU as well. It's just that most of us did not notice it for U-Boot SPL on QEMU.
Quoted 8 lines
Quoted 1 line
Let's fix this in the right way from start itself.
I double checked
spl_invoke_opensbi()and it is doing the right thing by passing "structfw_dyanmic_info" pointer in 'a2' register. (Refer,common/spl/spl_opensbi.c)Not sure, why it is not passing 'a2' register correctly for you ??
Yes, you are right. I reply too quickly.
Other harts will pass structfw_dyanmic_infoin a2 to OpenSBI.Quoted 7 lines
Quoted 1 line
Thanks for your corrections
No problem, I am happy to help.
BTW, I tried to play around with U-Boot SPL on QEMU.
Maybe below changes can help you...
Thanks for looking into this issue! I successfully tested it on QEMU, I had to add a short delay between sending the IPIs to trigger the problem.
Quoted 7 lines
We might still run into problems however. Right now, we are assuming that the main hart is the last one to enter OpenSBI. If this is not the case (some delay when handling the IPI), we will have the same problem again. To fix this we could pass the hart mask, containing all harts that have entered U-Boot, to OpenSBI and wait for all harts to be running in OpenSBI. I am not sure how realistic this scenario is, so this might not be needed.
I agree that we might still run into this issue if primary HART enters OpenSBI before secondary HARTs. I think this situation can only happen on QEMU where each CPU is a thread running on host but very unlikely/impossible on real HW.
Maybe a delay on primary HART in U-Boot SPL after SMP calls to secondary HARTs and before jumping to OpenSBI ?
Quoted 8 lines
Quoted 4 lines
You are right, I don't think we will ever see this on real hardware. I can add a check to ensure all harts have processed the IPI before jumping to OpenSBI on the main hart. A simple delay is probably already sufficient however.
Yes, please change
spl_opensbilike you described.Maybe also add some comments about the issues we discussed here.
Good idea, I will add the changes and describe the issue in a comment.
Regards,
Lukas
Quoted 30 lines
Quoted 7 lines
Quoted 7 lines
Regarding
hart_maskinfw_dynamic_info, I think the issue will be the size of thehart_mask. It is possible in-future SOC vendors come-up with SOC having huge number of HARTs OR SOC with discontinuous HART IDs which can cause a 64bithart_maskto be not sufficient for all HARTs.Quoted 5 lines
Quoted 3 lines
Also, waiting for all HARTs to enter OpenSBI will be one more wait-loop in
fw_base.Swhich will add to the boot-time as well.I agree, it's best to keep everything simple here.
Cool, I guess we are in-sync.
Quoted 10 lines
Quoted 4 lines
I still think the root cause of the issue is that
TEXT_STARTof U-Boot SPL and OpenSBIFW_DYNAMICis same. Maybe we can insist SOC vendors to not use sameTEXT_START?That is definitely the best solution. I am not familiar with the details of the Andes platform, so unsure if that would work on it. On the SiFive Unleashed board this will be possible as soon as we have a working DRAM driver. U-Boot SPL could then run from L2 scratchpad memory instead of DRAM.
Yes, this won't be a problem on SiFive Unleashed.
Regards,
Anup
PATCH 4/8 riscv: andes_plic: Fix some wrong configurations
In reply to Bin MengHi Bin
Quoted 31 lines
Hi Rick,
Quoted 27 lines · Rick Chen
Hi Bin
Quoted 5 lines
Hi Rick,
Quoted 1 line · Andes
Quoted 8 lines
Quoted 6 lines
From: Rick Chen <[email protected]>
It will work fine due to hart 0 always will be main hart coincidentally. When develop SPL flow, I try to force other harts to be main hart. And it will go wrong in sending IPI flow. So fix it.
Fix what? Does this commit contain 2 fixes, or just 1 fix?
Yes, it include two fixs. But they will cause one negative result that only hart 0 can send ipi to other harts.
Quoted 7 lines
Quoted 6 lines
Having this fix, any hart can be main hart in U-Boot SPL theoretically, but it still fail somewhere. After dig in and found there is an assumption that hart 0 shall be main hart in OpenSbi.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So does this mean there is a bug in OpenSBI too?
I am not sure if it is a bug. Maybe it is a compatible issue. There is a limitation that only hart 0 can be main hart in OpenSBI.
I don't think OpenSBI has such limitation.
OK.
But there is a hint in OpenSBI indeed.
Maybe it is just different interpretation each other.
/*
* Jump to warm-boot if this is not the first core booting,
* that is, for mhartid != 0
*/
Quoted 50 lines
Quoted 50 lines
But any hart can be main hart in U-Boot.
In general case, hart 0 will be main and it is fine when U-Boot jump ot OpenSBI. But if we force hart 1 to be main hart, when hart 0 jump to OPenSBI from U-Boot, It will do relocation flow in OpenSBI which willcorrupt U-Boot SPL, but hart 0 still in U-Boot SPL.
Quoted 9 lines
Quoted 6 lines
After some work-arounds, it can pass the verifications that any hart can be main hart and boots U-Boot SPL -> OpenSbi -> U-Boot proper -> Linux Kernel successfully.
It's a bit hard for me to understand what was described here in the commit message. Maybe you need rewrite something.
OK. I will rewrite this commit message.
Quoted 29 lines
Quoted 22 lines
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/lib/andes_plic.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/riscv/lib/andes_plic.c +1
-1@@ -19,7 +19,7 @@#include <cpu.h> /* pending register */ -#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + (hart) * 8) +#define PENDING_REG (base, hart) ((ulong)(base) + 0x1000 + ((hart) / 4) * 4)/* enable register */ #define ENABLE_REG (base, hart) ((ulong)(base) + 0x2000 + (hart) * 0x80)/* claim register */ arch/riscv/lib/andes_plic.c static int init_plic(void); · line 49
Quoted 5 lines
arch/riscv/lib/andes_plic.c +1
-1@@ -46,7 +46,7 @@ static int init_plic(void);static int enable_ipi (int hart) { -int en; +unsigned int en;Is this for some compiler warning fix?
Quoted 4 lines
Quoted 2 lines
No, it is not a warning fix. It is a bug fix.
I hope en can be0x0000000080808080instead of0xffffffff80808080,But it is int, which is only 32-bit. The example you gave was a 64-bit number.
The verification runs on RV64, so it is a 64-bit number example.
Thanks
Rick
Quoted 6 lines
Quoted 3 lines
or it will cause IPI sending errors.
Regards,
Bin
PATCH 5/8 riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
In reply to AndesFrom: Rick Chen <[email protected]>
The mcache_ctl csr only can be manipulated in M mode. Add SPL_RISCV_MMODE for U-Boot SPL to control cache operation.
--- arch/riscv/cpu/ax25/cache.c | 60 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-)
arch/riscv/cpu/ax25/cache.c +46 -14
@@ -11,18 +11,46 @@#include <asm/csr.h> #ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )/* mcctlcommand */ #define CCTL_REG_MCCTLCOMMAND_NUM 0x7cc/* D-cache operation */ #define CCTL_L1D_WBINVAL_ALL 6#endif +#endif + +#ifdef CONFIG_V5L2_CACHE +static void _cache_enable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_enable (dev); +} + +static void _cache_disable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_disable (dev); +} +#endif void flush_dcache_all (void ) { +#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL );#endif +#endif +#endif }void flush_dcache_range (unsigned long start,unsigned long end)
@@ -39,6 +67,7 @@ void icache_enable(void) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x1\n\t"
@@ -46,12 +75,14 @@ void icache_enable(void) );#endif #endif +#endif }void icache_disable (void ) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("fence.i\n\t" "csrr t1, mcache_ctl\n\t"
@@ -60,24 +91,23 @@ void icache_disable(void) );#endif #endif +#endif }void dcache_enable (void ) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_enable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_enable (); +#endif #endif #endif }
@@ -86,19 +116,17 @@ void dcache_disable(void) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL ); asmvolatile ("csrr t1, mcache_ctl\n\t" "andi t0, t1, ~0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_disable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_disable (); +#endif #endif #endif }
@@ -108,6 +136,7 @@ int icache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x01\n\t"
@@ -116,6 +145,7 @@ int icache_status(void) : "memory" );#endif +#endif return ret; }
@@ -125,6 +155,7 @@ int dcache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x02\n\t"
@@ -133,6 +164,7 @@ int dcache_status(void) : "memory" );#endif +#endif return ret; }
Signature · 1 line
2.7.4
PATCH 5/8 riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
Hi Rick,
Quoted 19 lines · Andes
From: Rick Chen <[email protected]>
The
mcache_ctlcsr only can be manipulated in M mode. AddSPL_RISCV_MMODEfor U-Boot SPL to control cache operation.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/cache.c | 60 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-)arch/riscv/cpu/ax25/cache.c +0
-0
arch/riscv/cpu/ax25/cache.c line 14
Quoted 4 lines
arch/riscv/cpu/ax25/cache.c +1
-0@@ -11,18 +11,46 @@#include <asm/csr.h> #ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )
Use CONFIG_IS_ENABLED(RISCV_MMODE)
Quoted 55 lines
arch/riscv/cpu/ax25/cache.c +29
-0/* mcctlcommand */ #define CCTL_REG_MCCTLCOMMAND_NUM 0x7cc/* D-cache operation */ #define CCTL_L1D_WBINVAL_ALL 6#endif +#endif + +#ifdef CONFIG_V5L2_CACHE +static void _cache_enable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_enable (dev); +} + +static void _cache_disable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_disable (dev); +} +#endif void flush_dcache_all (void ) { +#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL );#endif +#endif +#endif }void flush_dcache_range (unsigned long start,unsigned long end)@@ -39,6 +67,7 @@ void icache_enable(void) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x1\n\t"@@ -46,12 +75,14 @@ void icache_enable(void) );#endif #endif +#endif
arch/riscv/cpu/ax25/cache.c void icache_enable(void) · line 88
Quoted 10 lines
arch/riscv/cpu/ax25/cache.c +1
-0}void icache_disable (void ) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("fence.i\n\t" "csrr t1, mcache_ctl\n\t"
Could you please add a patch to replace the CSR name with CSR number? This way an upstream GCC to build this code without any issue.
Quoted 81 lines
arch/riscv/cpu/ax25/cache.c +14
-14@@ -60,24 +91,23 @@ void icache_disable(void) );#endif #endif +#endif }void dcache_enable (void ) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_enable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_enable (); +#endif #endif #endif }@@ -86,19 +116,17 @@ void dcache_disable(void) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL ); asmvolatile ("csrr t1, mcache_ctl\n\t" "andi t0, t1, ~0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_disable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_disable (); +#endif #endif #endif }@@ -108,6 +136,7 @@ int icache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x01\n\t"@@ -116,6 +145,7 @@ int icache_status(void) : "memory" );#endif +#endif return ret; }@@ -125,6 +155,7 @@ int dcache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x02\n\t"
arch/riscv/cpu/ax25/cache.c int dcache_status(void)
Quoted 8 lines
arch/riscv/cpu/ax25/cache.c +1
-1@@ -133,6 +164,7 @@ int dcache_status(void) : "memory" );#endif +#endif return ret; } --
Regards,
Bin
PATCH 5/8 riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
Hi Bin
Quoted 87 lines
Hi Rick,
Quoted 19 lines · Andes
From: Rick Chen <[email protected]>
The
mcache_ctlcsr only can be manipulated in M mode. AddSPL_RISCV_MMODEfor U-Boot SPL to control cache operation.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/cache.c | 60 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-)arch/riscv/cpu/ax25/cache.c +0
-0arch/riscv/cpu/ax25/cache.c line 14
Quoted 4 lines
arch/riscv/cpu/ax25/cache.c +1
-0@@ -11,18 +11,46 @@#include <asm/csr.h> #ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )Use
CONFIG_IS_ENABLED(RISCV_MMODE)Quoted 57 lines
arch/riscv/cpu/ax25/cache.c +29
-0/* mcctlcommand */ #define CCTL_REG_MCCTLCOMMAND_NUM 0x7cc/* D-cache operation */ #define CCTL_L1D_WBINVAL_ALL 6#endif +#endif + +#ifdef CONFIG_V5L2_CACHE +static void _cache_enable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_enable (dev); +} + +static void _cache_disable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_disable (dev); +} +#endif void flush_dcache_all (void ) { +#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL );#endif +#endif +#endif }void flush_dcache_range (unsigned long start,unsigned long end)@@ -39,6 +67,7 @@ void icache_enable(void) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x1\n\t"@@ -46,12 +75,14 @@ void icache_enable(void) );#endif #endif +#endif }
Quoted 11 lines
arch/riscv/cpu/ax25/cache.c void icache_enable(void) · line 88
Quoted 8 lines
arch/riscv/cpu/ax25/cache.c +1
-0void icache_disable (void ) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("fence.i\n\t" "csrr t1, mcache_ctl\n\t"Could you please add a patch to replace the CSR name with CSR number? This way an upstream GCC to build this code without any issue.
Thanks for your suggestions.
But I prefer not modify it in this patchs for SPL.
I will send another patch to modify as your suggestions.
Thanks
Rick
Quoted 93 lines
Quoted 82 lines
arch/riscv/cpu/ax25/cache.c +14
-14@@ -60,24 +91,23 @@ void icache_disable(void) );#endif #endif +#endif }void dcache_enable (void ) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_enable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_enable (); +#endif #endif #endif }@@ -86,19 +116,17 @@ void dcache_disable(void) {#if !CONFIG_IS_ENABLED (SYS_DCACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE -struct udevice *dev =NULL ; - +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL ); asmvolatile ("csrr t1, mcache_ctl\n\t" "andi t0, t1, ~0x2\n\t" "csrw mcache_ctl, t0\n\t" ); - -uclass_find_first_device (UCLASS_CACHE , &dev); - -if (dev) -cache_disable (dev); +#endif +#ifdef CONFIG_V5L2_CACHE +_cache_disable (); +#endif #endif #endif }@@ -108,6 +136,7 @@ int icache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x01\n\t"@@ -116,6 +145,7 @@ int icache_status(void) : "memory" );#endif +#endif return ret; }@@ -125,6 +155,7 @@ int dcache_status(void)int ret =0 ;#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "andi %0, t1, 0x02\n\t"arch/riscv/cpu/ax25/cache.c int dcache_status(void)
Quoted 8 lines
arch/riscv/cpu/ax25/cache.c +1
-1@@ -133,6 +164,7 @@ int dcache_status(void) : "memory" );#endif +#endif return ret; } --Regards,
Bin
PATCH 5/8 riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
Hi Rick,
Quoted 102 lines · Rick Chen
Hi Bin
Quoted 87 lines
Hi Rick,
Quoted 19 lines · Andes
From: Rick Chen <[email protected]>
The
mcache_ctlcsr only can be manipulated in M mode. AddSPL_RISCV_MMODEfor U-Boot SPL to control cache operation.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/ax25/cache.c | 60 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-)arch/riscv/cpu/ax25/cache.c +0
-0arch/riscv/cpu/ax25/cache.c line 14
Quoted 4 lines
arch/riscv/cpu/ax25/cache.c +1
-0@@ -11,18 +11,46 @@#include <asm/csr.h> #ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )Use
CONFIG_IS_ENABLED(RISCV_MMODE)Quoted 57 lines
arch/riscv/cpu/ax25/cache.c +29
-0/* mcctlcommand */ #define CCTL_REG_MCCTLCOMMAND_NUM 0x7cc/* D-cache operation */ #define CCTL_L1D_WBINVAL_ALL 6#endif +#endif + +#ifdef CONFIG_V5L2_CACHE +static void _cache_enable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_enable (dev); +} + +static void _cache_disable (void ) +{ +struct udevice *dev =NULL ; + +uclass_find_first_device (UCLASS_CACHE , &dev); + +if (dev) +cache_disable (dev); +} +#endif void flush_dcache_all (void ) { +#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE )csr_write (CCTL_REG_MCCTLCOMMAND_NUM ,CCTL_L1D_WBINVAL_ALL );#endif +#endif +#endif }void flush_dcache_range (unsigned long start,unsigned long end)@@ -39,6 +67,7 @@ void icache_enable(void) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("csrr t1, mcache_ctl\n\t" "ori t0, t1, 0x1\n\t"@@ -46,12 +75,14 @@ void icache_enable(void) );#endif #endif +#endif }Quoted 11 lines
arch/riscv/cpu/ax25/cache.c void icache_enable(void) · line 88
Quoted 8 lines
arch/riscv/cpu/ax25/cache.c +1
-0void icache_disable (void ) {#if !CONFIG_IS_ENABLED (SYS_ICACHE_OFF )#ifdef CONFIG_RISCV_NDS_CACHE +#if defined(CONFIG_RISCV_MMODE ) || defined(CONFIG_SPL_RISCV_MMODE ) asmvolatile ("fence.i\n\t" "csrr t1, mcache_ctl\n\t"Could you please add a patch to replace the CSR name with CSR number? This way an upstream GCC to build this code without any issue.
Quoted 3 lines
Thanks for your suggestions.
But I prefer not modify it in this patchs for SPL.
Yes, I was saying an additional patch. Definitely not this patch.
Quoted 1 line
I will send another patch to modify as your suggestions.
Regards,
Bin
PATCH 6/8 spl: cache: Allow cache drivers in SPL
In reply to AndesFrom: Rick Chen <[email protected]>
When ax25-ae350 try to enable v5l2 cache driver in SPL configuration, it need this option for cache support in SPL.
--- common/spl/Kconfig | 7 +++++++ drivers/Makefile | 1 + 2 files changed, 8 insertions(+)
common/spl/Kconfig +7 -0
@@ -456,6 +456,13 @@ config SPL_CRYPTO_SUPPORT this option to build the drivers in drivers/crypto as part of an SPL build. +config SPL_CACHE_SUPPORT + bool "Support CACHE drivers" + help + Enable CACHE drivers in SPL. These drivers can store data so that + future requests for that data can be served faster. Enable this option + to build the drivers in drivers/cache as part of an SPL build. + config SPL_HASH_SUPPORT bool "Support hashing drivers" select SHA1
drivers/Makefile +1 -0
@@ -33,6 +33,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ +obj-$(CONFIG_SPL_CACHE_SUPPORT) += cache/ obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
Signature · 1 line
2.7.4
PATCH 6/8 spl: cache: Allow cache drivers in SPL
Hi Rick,
Quoted 20 lines · Andes
From: Rick Chen <[email protected]>
When ax25-ae350 try to enable v5l2 cache driver in SPL configuration, it need this option for cache support in SPL.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- common/spl/Kconfig | 7 +++++++ drivers/Makefile | 1 + 2 files changed, 8 insertions(+)common/spl/Kconfig +0
-0
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 459
Quoted 4 lines
common/spl/Kconfig +1
-0@@ -456,6 +456,13 @@ config SPL_CRYPTO_SUPPORT this option to build the drivers in drivers/crypto as part of an SPL build. +config SPL_CACHE_SUPPORT
nits: please insert this option per alphabetical order, so it should come before SPL_CPU
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 463
Quoted 4 lines
common/spl/Kconfig +4
-0+ bool "Support CACHE drivers" + help + Enable CACHE drivers in SPL. These drivers can store data so that + future requests for that data can be served faster. Enable this option
The description here "store data so that ..." does not apply to cache drivers
Quoted 10 lines
common/spl/Kconfig +2
-0+ to build the drivers in drivers/cache as part of an SPL build. + config SPL_HASH_SUPPORT bool "Support hashing drivers" select SHA1drivers/Makefile +0
-0
drivers/Makefile ifdef CONFIG_SPL_BUILD · line 36
Quoted 4 lines
drivers/Makefile +1
-0@@ -33,6 +33,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ +obj-$(CONFIG_SPL_CACHE_SUPPORT) += cache/
ditto
drivers/Makefile ifdef CONFIG_SPL_BUILD
Quoted 4 lines
drivers/Makefile +0
-1obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/ --
Regards,
Bin
PATCH 6/8 spl: cache: Allow cache drivers in SPL
Hi Bin
Quoted 27 lines
Hi Rick,
Quoted 23 lines · Andes
From: Rick Chen <[email protected]>
When ax25-ae350 try to enable v5l2 cache driver in SPL configuration, it need this option for cache support in SPL.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- common/spl/Kconfig | 7 +++++++ drivers/Makefile | 1 + 2 files changed, 8 insertions(+)common/spl/Kconfig +0
-0@@ -456,6 +456,13 @@ config SPL_CRYPTO_SUPPORT this option to build the drivers in drivers/crypto as part of an SPL build.
Quoted 4 lines
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 459
Quoted 1 line
common/spl/Kconfig +1
-0+config SPL_CACHE_SUPPORTnits: please insert this option per alphabetical order, so it should come before
SPL_CPU
OK
Quoted 7 lines
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 463
Quoted 5 lines
common/spl/Kconfig +4
-0+ bool "Support CACHE drivers" + help + Enable CACHE drivers in SPL. These drivers can store data so that + future requests for that data can be served faster. Enable this optionThe description here "store data so that ..." does not apply to cache drivers
Do you have any suggestions about how to describe it more precisely ?
Thanks
Rick
Quoted 17 lines
Quoted 11 lines
common/spl/Kconfig +2
-0+ to build the drivers in drivers/cache as part of an SPL build. + config SPL_HASH_SUPPORT bool "Support hashing drivers" select SHA1drivers/Makefile +0
-0drivers/Makefile ifdef CONFIG_SPL_BUILD · line 36
Quoted 4 lines
drivers/Makefile +1
-0@@ -33,6 +33,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ +obj-$(CONFIG_SPL_CACHE_SUPPORT) += cache/ditto
OK
Quoted 8 lines
drivers/Makefile ifdef CONFIG_SPL_BUILD
Quoted 5 lines
drivers/Makefile +0
-1obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/ --Regards,
Bin
PATCH 6/8 spl: cache: Allow cache drivers in SPL
Hi Rick,
Quoted 38 lines · Rick Chen
Hi Bin
Quoted 27 lines
Hi Rick,
Quoted 23 lines · Andes
From: Rick Chen <[email protected]>
When ax25-ae350 try to enable v5l2 cache driver in SPL configuration, it need this option for cache support in SPL.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- common/spl/Kconfig | 7 +++++++ drivers/Makefile | 1 + 2 files changed, 8 insertions(+)common/spl/Kconfig +0
-0@@ -456,6 +456,13 @@ config SPL_CRYPTO_SUPPORT this option to build the drivers in drivers/crypto as part of an SPL build.Quoted 4 lines
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 459
Quoted 1 line
common/spl/Kconfig +1
-0+config SPL_CACHE_SUPPORTnits: please insert this option per alphabetical order, so it should come before
SPL_CPUOK
Quoted 1 line
Quoted 9 lines
Quoted 6 lines
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 463
Quoted 4 lines
common/spl/Kconfig +4
-0+ bool "Support CACHE drivers" + help + Enable CACHE drivers in SPL. These drivers can store data so that + future requests for that data can be served faster. Enable this optionThe description here "store data so that ..." does not apply to cache drivers
Do you have any suggestions about how to describe it more precisely ?
The descriptions says drivers can store data, but cache driver does not store data at all. I think you enabled it just for boot time performance?
Regards,
Bin
PATCH 6/8 spl: cache: Allow cache drivers in SPL
Hi Bin
Bin Meng <[email protected]> 於 2019年10月31日 週四 上午11:02寫道:
Quoted 47 lines
Hi Rick,
Quoted 43 lines · Rick Chen
Hi Bin
Quoted 27 lines
Hi Rick,
Quoted 23 lines · Andes
From: Rick Chen <[email protected]>
When ax25-ae350 try to enable v5l2 cache driver in SPL configuration, it need this option for cache support in SPL.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- common/spl/Kconfig | 7 +++++++ drivers/Makefile | 1 + 2 files changed, 8 insertions(+)common/spl/Kconfig +0
-0@@ -456,6 +456,13 @@ config SPL_CRYPTO_SUPPORT this option to build the drivers in drivers/crypto as part of an SPL build.Quoted 4 lines
common/spl/Kconfig config SPL_CRYPTO_SUPPORT · line 459
Quoted 1 line
common/spl/Kconfig +1
-0+config SPL_CACHE_SUPPORTnits: please insert this option per alphabetical order, so it should come before
SPL_CPUOK
Quoted 6 lines
Quoted 5 lines
common/spl/Kconfig +4
-0+ bool "Support CACHE drivers" + help + Enable CACHE drivers in SPL. These drivers can store data so that + future requests for that data can be served faster. Enable this option
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
The description here "store data so that ..." does not apply to cache drivers
Do you have any suggestions about how to describe it more precisely ?
The descriptions says drivers can store data, but cache driver does not store data at all. I think you enabled it just for boot time performance?
Yes, so the description mention about "served faster", it can represent improve boot time performance widely.
Maybe you think store data is that kind of store data in flash. Cache will store data in it, so CPU can execute more faster.
Quoted 3 lines
Regards,
Bin
PATCH 7/8 riscv: Fix clear bss loop in the start-up code
In reply to AndesFrom: Rick Chen <[email protected]>
For RV64, it will use sd instruction to clear t0 register, and the increament will be 8 bytes. So if the difference between__bss_strat and __bss_end was not 8 bytes aligned, the clear bss loop will overflow and acks like system hang.
--- arch/riscv/cpu/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/cpu/start.S +2 -2
@@ -174,7 +174,7 @@ spl_clear_bss: spl_clear_bss_loop: SREG zero, 0(t0) addi t0, t0, REGBYTES - bne t0, t1, spl_clear_bss_loop + blt t0, t1, spl_clear_bss_loop spl_stack_gd_setup: jal spl_relocate_stack_gd
@@ -324,7 +324,7 @@ clear_bss: clbss_l: SREG zero, 0(t0) /* clear loop... */ addi t0, t0, REGBYTES - bne t0, t1, clbss_l + blt t0, t1, clbss_l relocate_secondary_harts: #ifdef CONFIG_SMP
Signature · 1 line
2.7.4
PATCH 7/8 riscv: Fix clear bss loop in the start-up code
Hi Rick,
Quoted 21 lines · Andes
From: Rick Chen <[email protected]>
For RV64, it will use sd instruction to clear t0 register, and the increament will be 8 bytes. So if the difference
between__bss_stratand__bss_endwas not 8 bytes aligned, the clear bss loop will overflow and acks like system hang.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/riscv/cpu/start.S +0
-0
arch/riscv/cpu/start.S spl_clear_bss: · line 177
Quoted 5 lines
arch/riscv/cpu/start.S +1
-1@@ -174,7 +174,7 @@ spl_clear_bss: spl_clear_bss_loop: SREG zero, 0(t0) addi t0, t0, REGBYTES - bne t0, t1, spl_clear_bss_loop + blt t0, t1, spl_clear_bss_loop
This leaves bss section not completely zeroed.
arch/riscv/cpu/start.S clear_bss:
Quoted 13 lines
arch/riscv/cpu/start.S +1
-2spl_stack_gd_setup: jal spl_relocate_stack_gd@@ -324,7 +324,7 @@ clear_bss: clbss_l: SREG zero, 0(t0) /* clear loop... */ addi t0, t0, REGBYTES - bne t0, t1, clbss_l + blt t0, t1, clbss_l relocate_secondary_harts: #ifdef CONFIG_SMP --
Regards,
Bin
PATCH 7/8 riscv: Fix clear bss loop in the start-up code
Hi Bin
Quoted 20 lines
Hi Rick,
Quoted 16 lines · Andes
From: Rick Chen <[email protected]>
For RV64, it will use sd instruction to clear t0 register, and the increament will be 8 bytes. So if the difference
between__bss_stratand__bss_endwas not 8 bytes aligned, the clear bss loop will overflow and acks like system hang.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 12 lines
arch/riscv/cpu/start.S spl_clear_bss: · line 177
Quoted 10 lines
arch/riscv/cpu/start.S +1
-1@@ -174,7 +174,7 @@ spl_clear_bss: spl_clear_bss_loop: SREG zero, 0(t0) addi t0, t0, REGBYTES - bne t0, t1, spl_clear_bss_loop + blt t0, t1, spl_clear_bss_loopThis leaves bss section not completely zeroed.
I don't think this will clear bss section incompletely. Can you check it again ?
Or explain more details why you think so ?
Thanks
Rick
Quoted 17 lines
Quoted 5 lines
arch/riscv/cpu/start.S +0
-0spl_stack_gd_setup: jal spl_relocate_stack_gdarch/riscv/cpu/start.S clear_bss:
Quoted 9 lines
arch/riscv/cpu/start.S +1
-2@@ -324,7 +324,7 @@ clear_bss: clbss_l: SREG zero, 0(t0) /* clear loop... */ addi t0, t0, REGBYTES - bne t0, t1, clbss_l + blt t0, t1, clbss_l relocate_secondary_harts: #ifdef CONFIG_SMP --Regards,
Bin
PATCH 7/8 riscv: Fix clear bss loop in the start-up code
Hi Rick,
Quoted 36 lines · Rick Chen
Hi Bin
Quoted 20 lines
Hi Rick,
Quoted 16 lines · Andes
From: Rick Chen <[email protected]>
For RV64, it will use sd instruction to clear t0 register, and the increament will be 8 bytes. So if the difference
between__bss_stratand__bss_endwas not 8 bytes aligned, the clear bss loop will overflow and acks like system hang.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Quoted 12 lines
arch/riscv/cpu/start.S spl_clear_bss: · line 177
Quoted 10 lines
arch/riscv/cpu/start.S +1
-1@@ -174,7 +174,7 @@ spl_clear_bss: spl_clear_bss_loop: SREG zero, 0(t0) addi t0, t0, REGBYTES - bne t0, t1, spl_clear_bss_loop + blt t0, t1, spl_clear_bss_loopThis leaves bss section not completely zeroed.
Quoted 4 lines
I don't think this will clear bss section incompletely. Can you check it again ?
Or explain more details why you think so ?
Sorry I meant to say the other way around. This incorrectly clear the last a few bytes that are less than REGBYTES to zero.
Regards,
Bin
PATCH 7/8 riscv: Fix clear bss loop in the start-up code
Hi Bin
Quoted 40 lines
Hi Rick,
Quoted 36 lines · Rick Chen
Hi Bin
Quoted 32 lines
Hi Rick,
Quoted 21 lines · Andes
From: Rick Chen <[email protected]>
For RV64, it will use sd instruction to clear t0 register, and the increament will be 8 bytes. So if the difference
between__bss_stratand__bss_endwas not 8 bytes aligned, the clear bss loop will overflow and acks like system hang.Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/cpu/start.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/riscv/cpu/start.S +0
-0arch/riscv/cpu/start.S spl_clear_bss: · line 177
Quoted 5 lines
arch/riscv/cpu/start.S +1
-1@@ -174,7 +174,7 @@ spl_clear_bss: spl_clear_bss_loop: SREG zero, 0(t0) addi t0, t0, REGBYTES - bne t0, t1, spl_clear_bss_loop + blt t0, t1, spl_clear_bss_loopThis leaves bss section not completely zeroed.
Quoted 8 lines
Quoted 4 lines
I don't think this will clear bss section incompletely. Can you check it again ?
Or explain more details why you think so ?Sorry I meant to say the other way around. This incorrectly clear the last a few bytes that are less than REGBYTES to zero.
OK . I will also modify as ALIGN(8) in ld to avoid this boundary exceeding.
Thanks
Rick
Quoted 2 lines
Regards,
Bin
PATCH 8/8 riscv: dts: Support four cores SMP
In reply to AndesFrom: Rick Chen <[email protected]>
Add CPU2 and CPU3 informations in cpus node to support four cores SMP booting.
--- arch/riscv/dts/ae350_32.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- arch/riscv/dts/ae350_64.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 6 deletions(-)
arch/riscv/dts/ae350_32.dts +48 -3
@@ -62,6 +62,48 @@ compatible = "riscv,cpu-intc"; }; }; + CPU2: cpu at 2 { + device_type = "cpu"; + reg = <2>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU2_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; + CPU3: cpu at 3 { + device_type = "cpu"; + reg = <3>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU3_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; }; L2: l2-cache at e0500000 {
@@ -94,7 +136,8 @@ interrupt-controller; reg = <0xe4000000 0x2000000>; riscv,ndev=<71>; - interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>; + interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9 + &CPU2_intc 11 &CPU2_intc 9 &CPU3_intc 11 &CPU3_intc 9>; }; plic1: interrupt-controller at e6400000 {
@@ -104,12 +147,14 @@ interrupt-controller; reg = <0xe6400000 0x400000>; riscv,ndev=<2>; - interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>; + interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3 + &CPU2_intc 3 &CPU3_intc 3>; }; plmt0 at e6000000 { compatible = "riscv,plmt0"; - interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>; + interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7 + &CPU2_intc 7 &CPU3_intc 7>; reg = <0xe6000000 0x100000>; }; };
arch/riscv/dts/ae350_64.dts +48 -3
73 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 8/8 riscv: dts: Support four cores SMP
Hi Rick,
Quoted 4 lines · Andes
From: Rick Chen <[email protected]>
Add CPU2 and CPU3 informations in cpus node
nits: information
Quoted 64 lines
to support four cores SMP booting.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/dts/ae350_32.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- arch/riscv/dts/ae350_64.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 6 deletions(-)arch/riscv/dts/ae350_32.dts +42
-0@@ -62,6 +62,48 @@ compatible = "riscv,cpu-intc"; }; }; + CPU2: cpu at 2 { + device_type = "cpu"; + reg = <2>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU2_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; + CPU3: cpu at 3 { + device_type = "cpu"; + reg = <3>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU3_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; }; L2: l2-cache at e0500000 {
arch/riscv/dts/ae350_32.dts line 140
Quoted 6 lines
arch/riscv/dts/ae350_32.dts +2
-1@@ -94,7 +136,8 @@ interrupt-controller; reg = <0xe4000000 0x2000000>; riscv,ndev=<71>; - interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>; + interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9 + &CPU2_intc 11 &CPU2_intc 9 &CPU3_intc 11 &CPU3_intc 9>;
The indentation looks wrong.
Quoted 10 lines
arch/riscv/dts/ae350_32.dts +2
-1}; plic1: interrupt-controller at e6400000 {@@ -104,12 +147,14 @@ interrupt-controller; reg = <0xe6400000 0x400000>; riscv,ndev=<2>; - interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>; + interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3 + &CPU2_intc 3 &CPU3_intc 3>;
arch/riscv/dts/ae350_32.dts line 160
Quoted 10 lines
arch/riscv/dts/ae350_32.dts +2
-1}; plmt0 at e6000000 { compatible = "riscv,plmt0"; - interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>; + interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7 + &CPU2_intc 7 &CPU3_intc 7>; reg = <0xe6000000 0x100000>; }; };
[snip]
Regards,
Bin
PATCH 8/8 riscv: dts: Support four cores SMP
Hi Bin
Quoted 10 lines
Hi Rick,
Quoted 4 lines · Andes
From: Rick Chen <[email protected]>
Add CPU2 and CPU3 informations in cpus node
nits: information
OK
Quoted 63 lines
Quoted 63 lines
to support four cores SMP booting.
Signed-off-by Rick Chen <[email protected]>Cc KC Lin <[email protected]>Cc Alan Kao <[email protected]>--- arch/riscv/dts/ae350_32.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- arch/riscv/dts/ae350_64.dts | 51 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 6 deletions(-)arch/riscv/dts/ae350_32.dts +42
-0@@ -62,6 +62,48 @@ compatible = "riscv,cpu-intc"; }; }; + CPU2: cpu at 2 { + device_type = "cpu"; + reg = <2>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU2_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; + CPU3: cpu at 3 { + device_type = "cpu"; + reg = <3>; + status = "okay"; + compatible = "riscv"; + riscv,isa = "rv32imafdc"; + riscv,priv-major = <1>; + riscv,priv-minor = <10>; + mmu-type = "riscv,sv32"; + clock-frequency = <60000000>; + i-cache-size = <0x8000>; + i-cache-line-size = <32>; + d-cache-size = <0x8000>; + d-cache-line-size = <32>; + next-level-cache = <&L2>; + CPU3_intc: interrupt-controller { + #interrupt-cells = <1>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + }; + }; };
Quoted 10 lines
arch/riscv/dts/ae350_32.dts line 140
Quoted 8 lines
arch/riscv/dts/ae350_32.dts +2
-1L2: l2-cache at e0500000 {@@ -94,7 +136,8 @@ interrupt-controller; reg = <0xe4000000 0x2000000>; riscv,ndev=<71>; - interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9>; + interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9 &CPU1_intc 11 &CPU1_intc 9 + &CPU2_intc 11 &CPU2_intc 9 &CPU3_intc 11 &CPU3_intc 9>;The indentation looks wrong.
OK. I will fix it.
Thanks
Rick
Quoted 26 lines
Quoted 11 lines
arch/riscv/dts/ae350_32.dts +2
-1}; plic1: interrupt-controller at e6400000 {@@ -104,12 +147,14 @@ interrupt-controller; reg = <0xe6400000 0x400000>; riscv,ndev=<2>; - interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3>; + interrupts-extended = <&CPU0_intc 3 &CPU1_intc 3 + &CPU2_intc 3 &CPU3_intc 3>;arch/riscv/dts/ae350_32.dts line 160
Quoted 10 lines
arch/riscv/dts/ae350_32.dts +2
-1}; plmt0 at e6000000 { compatible = "riscv,plmt0"; - interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7>; + interrupts-extended = <&CPU0_intc 7 &CPU1_intc 7 + &CPU2_intc 7 &CPU3_intc 7>; reg = <0xe6000000 0x100000>; }; };[snip]
Regards,
Bin