riscv: enable multi-range memory layout
PATCH 1/1 riscv: enable multi-range memory layout
In order to enable PCIe passthrough on qemu riscv, the physical memory range between 3GB and 4GB is reserved. Therefore if guest has 4GB ram, two ranges are created as [2G, 3G) and [4G, 7G), currently u-boot sets ram_top to 4G - 1 if the gd->ram_top is above 4G in board_get_usable_ram_top(), but that address is not backed by ram. This patch selects the lowest range instead.
--- arch/riscv/cpu/generic/dram.c | 2 +- configs/qemu-riscv64_smode_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/riscv/cpu/generic/dram.c +1 -1
@@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR;int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +return fdtdec_setup_mem_size_base_lowest (); }int dram_init_banksize (void )
configs/qemu-riscv64_smode_defconfig +1 -1
@@ -1,6 +1,6 @@ CONFIG_RISCV=y CONFIG_SYS_MALLOC_LEN=0x800000 -CONFIG_NR_DRAM_BANKS=1 +CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 CONFIG_ENV_SIZE=0x20000
Signature · 1 line
2.34.1
Quoted 7 lines · Fei Wu
In order to enable PCIe passthrough on qemu riscv, the physical memory range between 3GB and 4GB is reserved. Therefore if guest has 4GB ram, two ranges are created as [2G, 3G) and [4G, 7G), currently u-boot sets
ram_topto 4G - 1 if thegd->ram_topis above 4G inboard_get_usable_ram_top(), but that address is not backed by ram. This patch selects the lowest range instead.
I think multi-range memory layout is a common requirement, PCIe passthrough happens to be the first one to require it. Could anyone please take a look at this patch and give your comments?
Thanks,
Fei.
Quoted 31 lines
Signed-off-by Fei Wu <[email protected]>--- arch/riscv/cpu/generic/dram.c | 2 +- configs/qemu-riscv64_smode_defconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/riscv/cpu/generic/dram.c +1
-1@@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR;int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +return fdtdec_setup_mem_size_base_lowest (); }int dram_init_banksize (void )configs/qemu-riscv64_smode_defconfig +1
-1@@ -1,6 +1,6 @@ CONFIG_RISCV=y CONFIG_SYS_MALLOC_LEN=0x800000 -CONFIG_NR_DRAM_BANKS=1 +CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 CONFIG_ENV_SIZE=0x20000
Am 13. September 2023 04:23:14 MESZ schrieb "Wu, Fei" <[email protected]>:
Quoted 8 lines · Fei Wu
Quoted 7 lines
In order to enable PCIe passthrough on qemu riscv, the physical memory range between 3GB and 4GB is reserved. Therefore if guest has 4GB ram, two ranges are created as [2G, 3G) and [4G, 7G), currently u-boot sets
ram_topto 4G - 1 if thegd->ram_topis above 4G inboard_get_usable_ram_top(), but that address is not backed by ram. This patch selects the lowest range instead.
Quoted 11 lines
I think multi-range memory layout is a common requirement, PCIe passthrough happens to be the first one to require it. Could anyone please take a look at this patch and give your comments?
Thanks,
Fei.Quoted 4 lines
Signed-off-by Fei Wu <[email protected]>--- arch/riscv/cpu/generic/dram.c | 2 +- configs/qemu-riscv64_smode_defconfig | 2 +-
We should consider all riscv64 defconfigs.
Best regards
Heinrich
Quoted 28 lines
Quoted 27 lines
2 files changed, 2 insertions(+), 2 deletions(-)arch/riscv/cpu/generic/dram.c +1
-1@@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR;int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +return fdtdec_setup_mem_size_base_lowest (); }int dram_init_banksize (void )configs/qemu-riscv64_smode_defconfig +1
-1@@ -1,6 +1,6 @@ CONFIG_RISCV=y CONFIG_SYS_MALLOC_LEN=0x800000 -CONFIG_NR_DRAM_BANKS=1 +CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 CONFIG_ENV_SIZE=0x20000
Quoted 18 lines · Heinrich Schuchardt
Am 13. September 2023 04:23:14 MESZ schrieb "Wu, Fei" <[email protected]>:
Quoted 15 lines · Fei Wu
Quoted 7 lines
In order to enable PCIe passthrough on qemu riscv, the physical memory range between 3GB and 4GB is reserved. Therefore if guest has 4GB ram, two ranges are created as [2G, 3G) and [4G, 7G), currently u-boot sets
ram_topto 4G - 1 if thegd->ram_topis above 4G inboard_get_usable_ram_top(), but that address is not backed by ram. This patch selects the lowest range instead.I think multi-range memory layout is a common requirement, PCIe passthrough happens to be the first one to require it. Could anyone please take a look at this patch and give your comments?
Thanks,
Fei.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Fei Wu <[email protected]>--- arch/riscv/cpu/generic/dram.c | 2 +- configs/qemu-riscv64_smode_defconfig | 2 +-We should consider all riscv64 defconfigs.
OK. I will update qemu-riscv64_defconfig, qemu-riscv64_smode_defconfig and qemu-riscv64_spl_defconfig.
Thanks,
Fei.
Quoted 32 lines
Best regards
Heinrich
Quoted 28 lines
Quoted 27 lines
2 files changed, 2 insertions(+), 2 deletions(-)arch/riscv/cpu/generic/dram.c +1
-1@@ -13,7 +13,7 @@ DECLARE_GLOBAL_DATA_PTR;int dram_init (void ) { -return fdtdec_setup_mem_size_base (); +return fdtdec_setup_mem_size_base_lowest (); }int dram_init_banksize (void )configs/qemu-riscv64_smode_defconfig +1
-1@@ -1,6 +1,6 @@ CONFIG_RISCV=y CONFIG_SYS_MALLOC_LEN=0x800000 -CONFIG_NR_DRAM_BANKS=1 +CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 CONFIG_ENV_SIZE=0x20000