public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] riscv: enable multi-range memory layout
@ 2023-09-05 10:09 Fei Wu
  2023-09-13  2:23 ` Wu, Fei
  0 siblings, 1 reply; 4+ messages in thread
From: Fei Wu @ 2023-09-05 10:09 UTC (permalink / raw)
  To: rick, ycliang, bmeng.cn, sjg, fei2.wu, pali, u-boot,
	andrei.warkentin, sunilvl, xypron.glpk

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.

Signed-off-by: Fei Wu <fei2.wu@intel.com>
---
 arch/riscv/cpu/generic/dram.c        | 2 +-
 configs/qemu-riscv64_smode_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
index 44e11bd56c..fb53a57b4e 100644
--- a/arch/riscv/cpu/generic/dram.c
+++ b/arch/riscv/cpu/generic/dram.c
@@ -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)
diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
index 1d0f021ade..de08a49dab 100644
--- a/configs/qemu-riscv64_smode_defconfig
+++ b/configs/qemu-riscv64_smode_defconfig
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: enable multi-range memory layout
  2023-09-05 10:09 [PATCH] riscv: enable multi-range memory layout Fei Wu
@ 2023-09-13  2:23 ` Wu, Fei
  2023-09-13  5:05   ` Heinrich Schuchardt
  0 siblings, 1 reply; 4+ messages in thread
From: Wu, Fei @ 2023-09-13  2:23 UTC (permalink / raw)
  To: rick, ycliang, bmeng.cn, sjg, pali, u-boot, andrei.warkentin,
	sunilvl, xypron.glpk

On 9/5/2023 6:09 PM, Fei Wu wrote:
> 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.
> 
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.

> Signed-off-by: Fei Wu <fei2.wu@intel.com>
> ---
>  arch/riscv/cpu/generic/dram.c        | 2 +-
>  configs/qemu-riscv64_smode_defconfig | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
> index 44e11bd56c..fb53a57b4e 100644
> --- a/arch/riscv/cpu/generic/dram.c
> +++ b/arch/riscv/cpu/generic/dram.c
> @@ -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)
> diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
> index 1d0f021ade..de08a49dab 100644
> --- a/configs/qemu-riscv64_smode_defconfig
> +++ b/configs/qemu-riscv64_smode_defconfig
> @@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: enable multi-range memory layout
  2023-09-13  2:23 ` Wu, Fei
@ 2023-09-13  5:05   ` Heinrich Schuchardt
  2023-09-13  5:59     ` Wu, Fei
  0 siblings, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2023-09-13  5:05 UTC (permalink / raw)
  To: Wu, Fei, rick, ycliang, bmeng.cn, sjg, pali, u-boot,
	andrei.warkentin, sunilvl



Am 13. September 2023 04:23:14 MESZ schrieb "Wu, Fei" <fei2.wu@intel.com>:
>On 9/5/2023 6:09 PM, Fei Wu wrote:
>> 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.
>> 
>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.
>
>> Signed-off-by: Fei Wu <fei2.wu@intel.com>
>> ---
>>  arch/riscv/cpu/generic/dram.c        | 2 +-
>>  configs/qemu-riscv64_smode_defconfig | 2 +-

We should consider all riscv64 defconfigs.

Best regards

Heinrich

>>  2 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
>> index 44e11bd56c..fb53a57b4e 100644
>> --- a/arch/riscv/cpu/generic/dram.c
>> +++ b/arch/riscv/cpu/generic/dram.c
>> @@ -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)
>> diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
>> index 1d0f021ade..de08a49dab 100644
>> --- a/configs/qemu-riscv64_smode_defconfig
>> +++ b/configs/qemu-riscv64_smode_defconfig
>> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: enable multi-range memory layout
  2023-09-13  5:05   ` Heinrich Schuchardt
@ 2023-09-13  5:59     ` Wu, Fei
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Fei @ 2023-09-13  5:59 UTC (permalink / raw)
  To: Heinrich Schuchardt, rick, ycliang, bmeng.cn, sjg, pali, u-boot,
	andrei.warkentin, sunilvl

On 9/13/2023 1:05 PM, Heinrich Schuchardt wrote:
> 
> 
> Am 13. September 2023 04:23:14 MESZ schrieb "Wu, Fei" <fei2.wu@intel.com>:
>> On 9/5/2023 6:09 PM, Fei Wu wrote:
>>> 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.
>>>
>> 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.
>>
>>> Signed-off-by: Fei Wu <fei2.wu@intel.com>
>>> ---
>>>  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.

> Best regards
> 
> Heinrich
> 
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
>>> index 44e11bd56c..fb53a57b4e 100644
>>> --- a/arch/riscv/cpu/generic/dram.c
>>> +++ b/arch/riscv/cpu/generic/dram.c
>>> @@ -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)
>>> diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
>>> index 1d0f021ade..de08a49dab 100644
>>> --- a/configs/qemu-riscv64_smode_defconfig
>>> +++ b/configs/qemu-riscv64_smode_defconfig
>>> @@ -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
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-13  6:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-05 10:09 [PATCH] riscv: enable multi-range memory layout Fei Wu
2023-09-13  2:23 ` Wu, Fei
2023-09-13  5:05   ` Heinrich Schuchardt
2023-09-13  5:59     ` Wu, Fei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox