mbox series

[v3,0/3] Add RISC-V 32 NOMMU support

Message ID 20230301002657.352637-1-Mr.Bossman075@gmail.com (mailing list archive)
Headers show
Series Add RISC-V 32 NOMMU support | expand

Message

Jesse T March 1, 2023, 12:26 a.m. UTC
This patch-set aims to add NOMMU support to RV32.
Many people want to build simple emulators or HDL
models of RISC-V this patch makes it possible to
run linux on them.

Yimin Gu is the original author of this set.
Submitted here:
https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html

Though Jesse T rewrote the Dconf.

The new set:
https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
---
V1->V2:
 - Add Conor's clock patch for implicit div64
 - Fix typo in commit title 3/3
 - Fix typo in commit description 2/3
V2->V3
 - Change from defconfig file to a PHONY config
---

Conor Dooley (1):
  clk: k210: remove an implicit 64-bit division

Jesse Taube (1):
  riscv: configs: Add nommu PHONY defconfig for RV32

Yimin Gu (1):
  riscv: Kconfig: Allow RV32 to build with no MMU

 arch/riscv/Kconfig     | 5 ++---
 arch/riscv/Makefile    | 4 ++++
 drivers/clk/clk-k210.c | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

Comments

Randy Dunlap March 1, 2023, 4:07 a.m. UTC | #1
Hi--

On 2/28/23 16:26, Jesse Taube wrote:
> This patch-set aims to add NOMMU support to RV32.
> Many people want to build simple emulators or HDL
> models of RISC-V this patch makes it possible to
> run linux on them.
> 
> Yimin Gu is the original author of this set.
> Submitted here:
> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
> 
> Though Jesse T rewrote the Dconf.

Dconf?

> 
> The new set:
> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
> ---
> V1->V2:
>  - Add Conor's clock patch for implicit div64
>  - Fix typo in commit title 3/3
>  - Fix typo in commit description 2/3
> V2->V3
>  - Change from defconfig file to a PHONY config
> ---

Is this 'rv32_nommu_virt_defconfig' target the only build target
that is supported?

I ask because I applied the 3 patches and did 25 randconfig builds.
5 of them failed the same way:

riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'

because
# CONFIG_COMMON_CLK_K210 is not set


Maybe SOC_CANAAN needs some more selects for required code?

> Conor Dooley (1):
>   clk: k210: remove an implicit 64-bit division
> 
> Jesse Taube (1):
>   riscv: configs: Add nommu PHONY defconfig for RV32
> 
> Yimin Gu (1):
>   riscv: Kconfig: Allow RV32 to build with no MMU
> 
>  arch/riscv/Kconfig     | 5 ++---
>  arch/riscv/Makefile    | 4 ++++
>  drivers/clk/clk-k210.c | 2 +-
>  3 files changed, 7 insertions(+), 4 deletions(-)
>
Damien Le Moal March 1, 2023, 4:42 a.m. UTC | #2
On 3/1/23 13:07, Randy Dunlap wrote:
> Hi--
> 
> On 2/28/23 16:26, Jesse Taube wrote:
>> This patch-set aims to add NOMMU support to RV32.
>> Many people want to build simple emulators or HDL
>> models of RISC-V this patch makes it possible to
>> run linux on them.
>>
>> Yimin Gu is the original author of this set.
>> Submitted here:
>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>
>> Though Jesse T rewrote the Dconf.
> 
> Dconf?
> 
>>
>> The new set:
>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>> ---
>> V1->V2:
>>  - Add Conor's clock patch for implicit div64
>>  - Fix typo in commit title 3/3
>>  - Fix typo in commit description 2/3
>> V2->V3
>>  - Change from defconfig file to a PHONY config
>> ---
> 
> Is this 'rv32_nommu_virt_defconfig' target the only build target
> that is supported?
> 
> I ask because I applied the 3 patches and did 25 randconfig builds.
> 5 of them failed the same way:
> 
> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'

Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
compile test with rv32 (or any arch), that driver provides the
k210_clk_early_init() function which is called very early in the boot process
from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
problem may be there. Probably should be disabled for rv32 if no SoC need that
sort of early init call.

> 
> because
> # CONFIG_COMMON_CLK_K210 is not set
> 
> 
> Maybe SOC_CANAAN needs some more selects for required code?
> 
>> Conor Dooley (1):
>>   clk: k210: remove an implicit 64-bit division
>>
>> Jesse Taube (1):
>>   riscv: configs: Add nommu PHONY defconfig for RV32
>>
>> Yimin Gu (1):
>>   riscv: Kconfig: Allow RV32 to build with no MMU
>>
>>  arch/riscv/Kconfig     | 5 ++---
>>  arch/riscv/Makefile    | 4 ++++
>>  drivers/clk/clk-k210.c | 2 +-
>>  3 files changed, 7 insertions(+), 4 deletions(-)
>>
>
Jesse T March 8, 2023, 1:26 a.m. UTC | #3
On 2/28/23 23:42, Damien Le Moal wrote:
> On 3/1/23 13:07, Randy Dunlap wrote:
>> Hi--
>>
>> On 2/28/23 16:26, Jesse Taube wrote:
>>> This patch-set aims to add NOMMU support to RV32.
>>> Many people want to build simple emulators or HDL
>>> models of RISC-V this patch makes it possible to
>>> run linux on them.
>>>
>>> Yimin Gu is the original author of this set.
>>> Submitted here:
>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>
>>> Though Jesse T rewrote the Dconf.
>>
>> Dconf?
>>
>>>
>>> The new set:
>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>> ---
>>> V1->V2:
>>>   - Add Conor's clock patch for implicit div64
>>>   - Fix typo in commit title 3/3
>>>   - Fix typo in commit description 2/3
>>> V2->V3
>>>   - Change from defconfig file to a PHONY config
>>> ---
>>
>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>> that is supported?
>>
>> I ask because I applied the 3 patches and did 25 randconfig builds.
>> 5 of them failed the same way:
>>
>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
I can not recreate this error.
can you send me the .config you used.

Thanks,
Jesse Taube
> 
> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
> compile test with rv32 (or any arch), that driver provides the
> k210_clk_early_init() function which is called very early in the boot process
> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
> problem may be there. Probably should be disabled for rv32 if no SoC need that
> sort of early init call.
> 
>>
>> because
>> # CONFIG_COMMON_CLK_K210 is not set
>>
>>
>> Maybe SOC_CANAAN needs some more selects for required code?
>>
>>> Conor Dooley (1):
>>>    clk: k210: remove an implicit 64-bit division
>>>
>>> Jesse Taube (1):
>>>    riscv: configs: Add nommu PHONY defconfig for RV32
>>>
>>> Yimin Gu (1):
>>>    riscv: Kconfig: Allow RV32 to build with no MMU
>>>
>>>   arch/riscv/Kconfig     | 5 ++---
>>>   arch/riscv/Makefile    | 4 ++++
>>>   drivers/clk/clk-k210.c | 2 +-
>>>   3 files changed, 7 insertions(+), 4 deletions(-)
>>>
>>
>
Randy Dunlap March 8, 2023, 2:16 a.m. UTC | #4
Hi--

On 3/7/23 17:26, Jesse Taube wrote:
> 
> 
> On 2/28/23 23:42, Damien Le Moal wrote:
>> On 3/1/23 13:07, Randy Dunlap wrote:
>>> Hi--
>>>
>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>> This patch-set aims to add NOMMU support to RV32.
>>>> Many people want to build simple emulators or HDL
>>>> models of RISC-V this patch makes it possible to
>>>> run linux on them.
>>>>
>>>> Yimin Gu is the original author of this set.
>>>> Submitted here:
>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>
>>>> Though Jesse T rewrote the Dconf.
>>>
>>> Dconf?
>>>
>>>>
>>>> The new set:
>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>> ---
>>>> V1->V2:
>>>>   - Add Conor's clock patch for implicit div64
>>>>   - Fix typo in commit title 3/3
>>>>   - Fix typo in commit description 2/3
>>>> V2->V3
>>>>   - Change from defconfig file to a PHONY config
>>>> ---
>>>
>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>> that is supported?
>>>
>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>> 5 of them failed the same way:
>>>
>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
> I can not recreate this error.
> can you send me the .config you used.
> 
> Thanks,
> Jesse Taube

Sure, it's attached.

>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>> compile test with rv32 (or any arch), that driver provides the
>> k210_clk_early_init() function which is called very early in the boot process
>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>> sort of early init call.
>>
>>>
>>> because
>>> # CONFIG_COMMON_CLK_K210 is not set
>>>
>>>
>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>
>>>> Conor Dooley (1):
>>>>    clk: k210: remove an implicit 64-bit division
>>>>
>>>> Jesse Taube (1):
>>>>    riscv: configs: Add nommu PHONY defconfig for RV32
>>>>
>>>> Yimin Gu (1):
>>>>    riscv: Kconfig: Allow RV32 to build with no MMU
>>>>
>>>>   arch/riscv/Kconfig     | 5 ++---
>>>>   arch/riscv/Makefile    | 4 ++++
>>>>   drivers/clk/clk-k210.c | 2 +-
>>>>   3 files changed, 7 insertions(+), 4 deletions(-)
>>>>
>>>
>>
Jesse T March 8, 2023, 2:30 a.m. UTC | #5
On 3/7/23 21:16, Randy Dunlap wrote:
> Hi--
> 
> On 3/7/23 17:26, Jesse Taube wrote:
>>
>>
>> On 2/28/23 23:42, Damien Le Moal wrote:
>>> On 3/1/23 13:07, Randy Dunlap wrote:
>>>> Hi--
>>>>
>>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>>> This patch-set aims to add NOMMU support to RV32.
>>>>> Many people want to build simple emulators or HDL
>>>>> models of RISC-V this patch makes it possible to
>>>>> run linux on them.
>>>>>
>>>>> Yimin Gu is the original author of this set.
>>>>> Submitted here:
>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>>
>>>>> Though Jesse T rewrote the Dconf.
>>>>
>>>> Dconf?
>>>>
>>>>>
>>>>> The new set:
>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>>> ---
>>>>> V1->V2:
>>>>>    - Add Conor's clock patch for implicit div64
>>>>>    - Fix typo in commit title 3/3
>>>>>    - Fix typo in commit description 2/3
>>>>> V2->V3
>>>>>    - Change from defconfig file to a PHONY config
>>>>> ---
>>>>
>>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>>> that is supported?
>>>>
>>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>>> 5 of them failed the same way:
>>>>
>>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
>> I can not recreate this error.
>> can you send me the .config you used.
>>
>> Thanks,
>> Jesse Taube
> 
> Sure, it's attached.

Hmmm, it links fine for me.

objdump -x vmlinux | grep k210_clk_early_init
81e40124 g     F .init.text     00000088 k210_clk_early_init

gcc version 11.3.0 (Buildroot 2022.11-361-g1be0d438f7)
GNU assembler version 2.38 (riscv32-buildroot-linux-uclibc)
GNU ld (GNU Binutils) 2.38

what gcc version are you using?

Thanks,
Jesse Taube

> 
>>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>>> compile test with rv32 (or any arch), that driver provides the
>>> k210_clk_early_init() function which is called very early in the boot process
>>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>>> sort of early init call.
>>>
>>>>
>>>> because
>>>> # CONFIG_COMMON_CLK_K210 is not set
>>>>
>>>>
>>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>>
>>>>> Conor Dooley (1):
>>>>>     clk: k210: remove an implicit 64-bit division
>>>>>
>>>>> Jesse Taube (1):
>>>>>     riscv: configs: Add nommu PHONY defconfig for RV32
>>>>>
>>>>> Yimin Gu (1):
>>>>>     riscv: Kconfig: Allow RV32 to build with no MMU
>>>>>
>>>>>    arch/riscv/Kconfig     | 5 ++---
>>>>>    arch/riscv/Makefile    | 4 ++++
>>>>>    drivers/clk/clk-k210.c | 2 +-
>>>>>    3 files changed, 7 insertions(+), 4 deletions(-)
>>>>>
>>>>
>>>
>
Randy Dunlap March 8, 2023, 2:33 a.m. UTC | #6
On 3/7/23 18:30, Jesse Taube wrote:
> 
> 
> On 3/7/23 21:16, Randy Dunlap wrote:
>> Hi--
>>
>> On 3/7/23 17:26, Jesse Taube wrote:
>>>
>>>
>>> On 2/28/23 23:42, Damien Le Moal wrote:
>>>> On 3/1/23 13:07, Randy Dunlap wrote:
>>>>> Hi--
>>>>>
>>>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>>>> This patch-set aims to add NOMMU support to RV32.
>>>>>> Many people want to build simple emulators or HDL
>>>>>> models of RISC-V this patch makes it possible to
>>>>>> run linux on them.
>>>>>>
>>>>>> Yimin Gu is the original author of this set.
>>>>>> Submitted here:
>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>>>
>>>>>> Though Jesse T rewrote the Dconf.
>>>>>
>>>>> Dconf?
>>>>>
>>>>>>
>>>>>> The new set:
>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>>>> ---
>>>>>> V1->V2:
>>>>>>    - Add Conor's clock patch for implicit div64
>>>>>>    - Fix typo in commit title 3/3
>>>>>>    - Fix typo in commit description 2/3
>>>>>> V2->V3
>>>>>>    - Change from defconfig file to a PHONY config
>>>>>> ---
>>>>>
>>>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>>>> that is supported?
>>>>>
>>>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>>>> 5 of them failed the same way:
>>>>>
>>>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
>>> I can not recreate this error.
>>> can you send me the .config you used.
>>>
>>> Thanks,
>>> Jesse Taube
>>
>> Sure, it's attached.
> 
> Hmmm, it links fine for me.
> 
> objdump -x vmlinux | grep k210_clk_early_init
> 81e40124 g     F .init.text     00000088 k210_clk_early_init
> 
> gcc version 11.3.0 (Buildroot 2022.11-361-g1be0d438f7)
> GNU assembler version 2.38 (riscv32-buildroot-linux-uclibc)
> GNU ld (GNU Binutils) 2.38
> 
> what gcc version are you using?


gcc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]
from opensuse Tumbleweed.

I'll try it on a current tree...

>>
>>>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>>>> compile test with rv32 (or any arch), that driver provides the
>>>> k210_clk_early_init() function which is called very early in the boot process
>>>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>>>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>>>> sort of early init call.
>>>>
>>>>>
>>>>> because
>>>>> # CONFIG_COMMON_CLK_K210 is not set
>>>>>
>>>>>
>>>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>>>
>>>>>> Conor Dooley (1):
>>>>>>     clk: k210: remove an implicit 64-bit division
>>>>>>
>>>>>> Jesse Taube (1):
>>>>>>     riscv: configs: Add nommu PHONY defconfig for RV32
>>>>>>
>>>>>> Yimin Gu (1):
>>>>>>     riscv: Kconfig: Allow RV32 to build with no MMU
>>>>>>
>>>>>>    arch/riscv/Kconfig     | 5 ++---
>>>>>>    arch/riscv/Makefile    | 4 ++++
>>>>>>    drivers/clk/clk-k210.c | 2 +-
>>>>>>    3 files changed, 7 insertions(+), 4 deletions(-)
>>>>>>
>>>>>
>>>>
>>
Randy Dunlap March 8, 2023, 2:51 a.m. UTC | #7
On 3/7/23 18:33, Randy Dunlap wrote:
> 
> 
> On 3/7/23 18:30, Jesse Taube wrote:
>>
>>
>> On 3/7/23 21:16, Randy Dunlap wrote:
>>> Hi--
>>>
>>> On 3/7/23 17:26, Jesse Taube wrote:
>>>>
>>>>
>>>> On 2/28/23 23:42, Damien Le Moal wrote:
>>>>> On 3/1/23 13:07, Randy Dunlap wrote:
>>>>>> Hi--
>>>>>>
>>>>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>>>>> This patch-set aims to add NOMMU support to RV32.
>>>>>>> Many people want to build simple emulators or HDL
>>>>>>> models of RISC-V this patch makes it possible to
>>>>>>> run linux on them.
>>>>>>>
>>>>>>> Yimin Gu is the original author of this set.
>>>>>>> Submitted here:
>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>>>>
>>>>>>> Though Jesse T rewrote the Dconf.
>>>>>>
>>>>>> Dconf?
>>>>>>
>>>>>>>
>>>>>>> The new set:
>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>>>>> ---
>>>>>>> V1->V2:
>>>>>>>    - Add Conor's clock patch for implicit div64
>>>>>>>    - Fix typo in commit title 3/3
>>>>>>>    - Fix typo in commit description 2/3
>>>>>>> V2->V3
>>>>>>>    - Change from defconfig file to a PHONY config
>>>>>>> ---
>>>>>>
>>>>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>>>>> that is supported?
>>>>>>
>>>>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>>>>> 5 of them failed the same way:
>>>>>>
>>>>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>>>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
>>>> I can not recreate this error.
>>>> can you send me the .config you used.
>>>>
>>>> Thanks,
>>>> Jesse Taube
>>>
>>> Sure, it's attached.
>>
>> Hmmm, it links fine for me.
>>
>> objdump -x vmlinux | grep k210_clk_early_init
>> 81e40124 g     F .init.text     00000088 k210_clk_early_init
>>
>> gcc version 11.3.0 (Buildroot 2022.11-361-g1be0d438f7)
>> GNU assembler version 2.38 (riscv32-buildroot-linux-uclibc)
>> GNU ld (GNU Binutils) 2.38
>>
>> what gcc version are you using?
> 
> 
> gcc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]
> from opensuse Tumbleweed.
> 
> I'll try it on a current tree...

OK, I don't know how it happened. I cannot reproduce it now.
The failing .config files has CONFIG_MMU is not set (for RV32I), which
appears to be impossible.

Sorry to bother you.

Thanks.

>>>
>>>>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>>>>> compile test with rv32 (or any arch), that driver provides the
>>>>> k210_clk_early_init() function which is called very early in the boot process
>>>>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>>>>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>>>>> sort of early init call.
>>>>>
>>>>>>
>>>>>> because
>>>>>> # CONFIG_COMMON_CLK_K210 is not set
>>>>>>
>>>>>>
>>>>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>>>>
>>>>>>> Conor Dooley (1):
>>>>>>>     clk: k210: remove an implicit 64-bit division
>>>>>>>
>>>>>>> Jesse Taube (1):
>>>>>>>     riscv: configs: Add nommu PHONY defconfig for RV32
>>>>>>>
>>>>>>> Yimin Gu (1):
>>>>>>>     riscv: Kconfig: Allow RV32 to build with no MMU
>>>>>>>
>>>>>>>    arch/riscv/Kconfig     | 5 ++---
>>>>>>>    arch/riscv/Makefile    | 4 ++++
>>>>>>>    drivers/clk/clk-k210.c | 2 +-
>>>>>>>    3 files changed, 7 insertions(+), 4 deletions(-)
>>>>>>>
>>>>>>
>>>>>
>>>
>
Jesse T March 8, 2023, 2:54 a.m. UTC | #8
On 3/7/23 21:51, Randy Dunlap wrote:
> 
> 
> On 3/7/23 18:33, Randy Dunlap wrote:
>>
>>
>> On 3/7/23 18:30, Jesse Taube wrote:
>>>
>>>
>>> On 3/7/23 21:16, Randy Dunlap wrote:
>>>> Hi--
>>>>
>>>> On 3/7/23 17:26, Jesse Taube wrote:
>>>>>
>>>>>
>>>>> On 2/28/23 23:42, Damien Le Moal wrote:
>>>>>> On 3/1/23 13:07, Randy Dunlap wrote:
>>>>>>> Hi--
>>>>>>>
>>>>>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>>>>>> This patch-set aims to add NOMMU support to RV32.
>>>>>>>> Many people want to build simple emulators or HDL
>>>>>>>> models of RISC-V this patch makes it possible to
>>>>>>>> run linux on them.
>>>>>>>>
>>>>>>>> Yimin Gu is the original author of this set.
>>>>>>>> Submitted here:
>>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>>>>>
>>>>>>>> Though Jesse T rewrote the Dconf.
>>>>>>>
>>>>>>> Dconf?
>>>>>>>
>>>>>>>>
>>>>>>>> The new set:
>>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>>>>>> ---
>>>>>>>> V1->V2:
>>>>>>>>     - Add Conor's clock patch for implicit div64
>>>>>>>>     - Fix typo in commit title 3/3
>>>>>>>>     - Fix typo in commit description 2/3
>>>>>>>> V2->V3
>>>>>>>>     - Change from defconfig file to a PHONY config
>>>>>>>> ---
>>>>>>>
>>>>>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>>>>>> that is supported?
>>>>>>>
>>>>>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>>>>>> 5 of them failed the same way:
>>>>>>>
>>>>>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>>>>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
>>>>> I can not recreate this error.
>>>>> can you send me the .config you used.
>>>>>
>>>>> Thanks,
>>>>> Jesse Taube
>>>>
>>>> Sure, it's attached.
>>>
>>> Hmmm, it links fine for me.
>>>
>>> objdump -x vmlinux | grep k210_clk_early_init
>>> 81e40124 g     F .init.text     00000088 k210_clk_early_init
>>>
>>> gcc version 11.3.0 (Buildroot 2022.11-361-g1be0d438f7)
>>> GNU assembler version 2.38 (riscv32-buildroot-linux-uclibc)
>>> GNU ld (GNU Binutils) 2.38
>>>
>>> what gcc version are you using?
>>
>>
>> gcc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]
>> from opensuse Tumbleweed.
>>
>> I'll try it on a current tree...
> 
> OK, I don't know how it happened. I cannot reproduce it now.
> The failing .config files has CONFIG_MMU is not set (for RV32I), which
> appears to be impossible.
These patches add `CONFIG_MMU is not set` (for RV32I).
But no worries it seems to be a non issue  now.

Your thoughts Damien?

Thanks,
Jesse Taube
> 
> Sorry to bother you.
> 
> Thanks.
> 
>>>>
>>>>>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>>>>>> compile test with rv32 (or any arch), that driver provides the
>>>>>> k210_clk_early_init() function which is called very early in the boot process
>>>>>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>>>>>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>>>>>> sort of early init call.
>>>>>>
>>>>>>>
>>>>>>> because
>>>>>>> # CONFIG_COMMON_CLK_K210 is not set
>>>>>>>
>>>>>>>
>>>>>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>>>>>
>>>>>>>> Conor Dooley (1):
>>>>>>>>      clk: k210: remove an implicit 64-bit division
>>>>>>>>
>>>>>>>> Jesse Taube (1):
>>>>>>>>      riscv: configs: Add nommu PHONY defconfig for RV32
>>>>>>>>
>>>>>>>> Yimin Gu (1):
>>>>>>>>      riscv: Kconfig: Allow RV32 to build with no MMU
>>>>>>>>
>>>>>>>>     arch/riscv/Kconfig     | 5 ++---
>>>>>>>>     arch/riscv/Makefile    | 4 ++++
>>>>>>>>     drivers/clk/clk-k210.c | 2 +-
>>>>>>>>     3 files changed, 7 insertions(+), 4 deletions(-)
>>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>
>
Randy Dunlap March 8, 2023, 3:23 a.m. UTC | #9
On 3/7/23 18:54, Jesse Taube wrote:
> 
> 
> On 3/7/23 21:51, Randy Dunlap wrote:
>>
>>
>> On 3/7/23 18:33, Randy Dunlap wrote:
>>>
>>>
>>> On 3/7/23 18:30, Jesse Taube wrote:
>>>>
>>>>
>>>> On 3/7/23 21:16, Randy Dunlap wrote:
>>>>> Hi--
>>>>>
>>>>> On 3/7/23 17:26, Jesse Taube wrote:
>>>>>>
>>>>>>
>>>>>> On 2/28/23 23:42, Damien Le Moal wrote:
>>>>>>> On 3/1/23 13:07, Randy Dunlap wrote:
>>>>>>>> Hi--
>>>>>>>>
>>>>>>>> On 2/28/23 16:26, Jesse Taube wrote:
>>>>>>>>> This patch-set aims to add NOMMU support to RV32.
>>>>>>>>> Many people want to build simple emulators or HDL
>>>>>>>>> models of RISC-V this patch makes it possible to
>>>>>>>>> run linux on them.
>>>>>>>>>
>>>>>>>>> Yimin Gu is the original author of this set.
>>>>>>>>> Submitted here:
>>>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
>>>>>>>>>
>>>>>>>>> Though Jesse T rewrote the Dconf.
>>>>>>>>
>>>>>>>> Dconf?
>>>>>>>>
>>>>>>>>>
>>>>>>>>> The new set:
>>>>>>>>> https://lists.buildroot.org/pipermail/buildroot/2022-December/658258.html
>>>>>>>>> ---
>>>>>>>>> V1->V2:
>>>>>>>>>     - Add Conor's clock patch for implicit div64
>>>>>>>>>     - Fix typo in commit title 3/3
>>>>>>>>>     - Fix typo in commit description 2/3
>>>>>>>>> V2->V3
>>>>>>>>>     - Change from defconfig file to a PHONY config
>>>>>>>>> ---
>>>>>>>>
>>>>>>>> Is this 'rv32_nommu_virt_defconfig' target the only build target
>>>>>>>> that is supported?
>>>>>>>>
>>>>>>>> I ask because I applied the 3 patches and did 25 randconfig builds.
>>>>>>>> 5 of them failed the same way:
>>>>>>>>
>>>>>>>> riscv32-linux-ld: drivers/soc/canaan/k210-sysctl.o: in function `k210_soc_early_init':
>>>>>>>> k210-sysctl.c:(.init.text+0x78): undefined reference to `k210_clk_early_init'
>>>>>> I can not recreate this error.
>>>>>> can you send me the .config you used.
>>>>>>
>>>>>> Thanks,
>>>>>> Jesse Taube
>>>>>
>>>>> Sure, it's attached.
>>>>
>>>> Hmmm, it links fine for me.
>>>>
>>>> objdump -x vmlinux | grep k210_clk_early_init
>>>> 81e40124 g     F .init.text     00000088 k210_clk_early_init
>>>>
>>>> gcc version 11.3.0 (Buildroot 2022.11-361-g1be0d438f7)
>>>> GNU assembler version 2.38 (riscv32-buildroot-linux-uclibc)
>>>> GNU ld (GNU Binutils) 2.38
>>>>
>>>> what gcc version are you using?
>>>
>>>
>>> gcc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]
>>> from opensuse Tumbleweed.
>>>
>>> I'll try it on a current tree...
>>
>> OK, I don't know how it happened. I cannot reproduce it now.
>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>> appears to be impossible.
> These patches add `CONFIG_MMU is not set` (for RV32I).
> But no worries it seems to be a non issue  now.
> 
> Your thoughts Damien?
> 

Thanks for reminding me.

With these 3 patches applied to linux-next-20230307,
I still get this build error.


> Thanks,
> Jesse Taube
>>
>> Sorry to bother you.
>>
>> Thanks.
>>
>>>>>
>>>>>>> Arg. Forgot about that. k210 is rv64 only and while the clk driver could still
>>>>>>> compile test with rv32 (or any arch), that driver provides the
>>>>>>> k210_clk_early_init() function which is called very early in the boot process
>>>>>>> from k210_soc_early_init(), which is an SOC_EARLY_INIT_DECLARE() call. The
>>>>>>> problem may be there. Probably should be disabled for rv32 if no SoC need that
>>>>>>> sort of early init call.
>>>>>>>
>>>>>>>>
>>>>>>>> because
>>>>>>>> # CONFIG_COMMON_CLK_K210 is not set
>>>>>>>>
>>>>>>>>
>>>>>>>> Maybe SOC_CANAAN needs some more selects for required code?
>>>>>>>>
>>>>>>>>> Conor Dooley (1):
>>>>>>>>>      clk: k210: remove an implicit 64-bit division
>>>>>>>>>
>>>>>>>>> Jesse Taube (1):
>>>>>>>>>      riscv: configs: Add nommu PHONY defconfig for RV32
>>>>>>>>>
>>>>>>>>> Yimin Gu (1):
>>>>>>>>>      riscv: Kconfig: Allow RV32 to build with no MMU
>>>>>>>>>
>>>>>>>>>     arch/riscv/Kconfig     | 5 ++---
>>>>>>>>>     arch/riscv/Makefile    | 4 ++++
>>>>>>>>>     drivers/clk/clk-k210.c | 2 +-
>>>>>>>>>     3 files changed, 7 insertions(+), 4 deletions(-)
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>
>>
Damien Le Moal March 8, 2023, 3:42 a.m. UTC | #10
On 3/8/23 12:23, Randy Dunlap wrote:
>>> OK, I don't know how it happened. I cannot reproduce it now.
>>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>>> appears to be impossible.
>> These patches add `CONFIG_MMU is not set` (for RV32I).
>> But no worries it seems to be a non issue  now.
>>
>> Your thoughts Damien?
>>
> 
> Thanks for reminding me.
> 
> With these 3 patches applied to linux-next-20230307,
> I still get this build error.

Does this help ?

diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
index 2527cf5757ec..7796c5f1d109 100644
--- a/drivers/soc/canaan/Kconfig
+++ b/drivers/soc/canaan/Kconfig
@@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
        bool "Canaan Kendryte K210 SoC system controller"
        depends on RISCV && SOC_CANAAN && OF
        default SOC_CANAAN
-        select PM
-        select MFD_SYSCON
+       select COMMON_CLK_K210
+       select PM
+       select MFD_SYSCON
        help
          Canaan Kendryte K210 SoC system controller driver.

(just noticed that there are whitespace errors here...)

Note that both the sysctl and clk driver depend on RISCV. I think these should
probably also depend on 64BIT, and eventually add a "|| COMPILE_TEST" as well.
So something like this:

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index b6c5bf69a2b2..657a36d2640d 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -431,7 +431,7 @@ config COMMON_CLK_FIXED_MMIO

 config COMMON_CLK_K210
        bool "Clock driver for the Canaan Kendryte K210 SoC"
-       depends on OF && RISCV && SOC_CANAAN
+       depends on OF && RISCV && SOC_CANAAN && (64BIT || COMPILE_TEST)
        default SOC_CANAAN
        help
          Support for the Canaan Kendryte K210 RISC-V SoC clocks.
diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
index 2527cf5757ec..1745a614d2a7 100644
--- a/drivers/soc/canaan/Kconfig
+++ b/drivers/soc/canaan/Kconfig
@@ -2,9 +2,10 @@

 config SOC_K210_SYSCTL
        bool "Canaan Kendryte K210 SoC system controller"
-       depends on RISCV && SOC_CANAAN && OF
+       depends on RISCV && SOC_CANAAN && OF && (64BIT || COMPILE_TEST)
        default SOC_CANAAN
-        select PM
-        select MFD_SYSCON
+       select COMMON_CLK_K210
+       select PM
+       select MFD_SYSCON
        help
          Canaan Kendryte K210 SoC system controller driver.

COMPILE_TEST is optional though, but I do not see any reason why not eventhough
in practice these drivers will likely never end up in 32-bits SoC.
Jesse T March 8, 2023, 3:46 a.m. UTC | #11
On 3/7/23 22:42, Damien Le Moal wrote:
> On 3/8/23 12:23, Randy Dunlap wrote:
>>>> OK, I don't know how it happened. I cannot reproduce it now.
>>>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>>>> appears to be impossible.
>>> These patches add `CONFIG_MMU is not set` (for RV32I).
>>> But no worries it seems to be a non issue  now.
>>>
>>> Your thoughts Damien?
>>>
>>
>> Thanks for reminding me.
>>
>> With these 3 patches applied to linux-next-20230307,
>> I still get this build error.
> 
> Does this help ?
> 
> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
> index 2527cf5757ec..7796c5f1d109 100644
> --- a/drivers/soc/canaan/Kconfig
> +++ b/drivers/soc/canaan/Kconfig
> @@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
>          bool "Canaan Kendryte K210 SoC system controller"
>          depends on RISCV && SOC_CANAAN && OF
>          default SOC_CANAAN
> -        select PM
> -        select MFD_SYSCON
> +       select COMMON_CLK_K210
> +       select PM
> +       select MFD_SYSCON
>          help
>            Canaan Kendryte K210 SoC system controller driver.
> 
> (just noticed that there are whitespace errors here...)
> 
> Note that both the sysctl and clk driver depend on RISCV. I think these should
> probably also depend on 64BIT, and eventually add a "|| COMPILE_TEST" as well.
> So something like this:
> 
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index b6c5bf69a2b2..657a36d2640d 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -431,7 +431,7 @@ config COMMON_CLK_FIXED_MMIO
> 
>   config COMMON_CLK_K210
>          bool "Clock driver for the Canaan Kendryte K210 SoC"
> -       depends on OF && RISCV && SOC_CANAAN
> +       depends on OF && RISCV && SOC_CANAAN && (64BIT || COMPILE_TEST)
>          default SOC_CANAAN
>          help
>            Support for the Canaan Kendryte K210 RISC-V SoC clocks.
> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
> index 2527cf5757ec..1745a614d2a7 100644
> --- a/drivers/soc/canaan/Kconfig
> +++ b/drivers/soc/canaan/Kconfig
> @@ -2,9 +2,10 @@
> 
>   config SOC_K210_SYSCTL
>          bool "Canaan Kendryte K210 SoC system controller"
> -       depends on RISCV && SOC_CANAAN && OF
> +       depends on RISCV && SOC_CANAAN && OF && (64BIT || COMPILE_TEST)
>          default SOC_CANAAN
> -        select PM
> -        select MFD_SYSCON
> +       select COMMON_CLK_K210
> +       select PM
> +       select MFD_SYSCON
>          help
>            Canaan Kendryte K210 SoC system controller driver.
> 
> COMPILE_TEST is optional though, but I do not see any reason why not eventhough
> in practice these drivers will likely never end up in 32-bits SoC.
> 
> 

Oh thanks I was in the in the midst of making a similar patch.
Do you want to submit it or shall I. Also thanks for the help with this, 
was using tag 6.2.
Randy Dunlap March 8, 2023, 3:51 a.m. UTC | #12
On 3/7/23 19:42, Damien Le Moal wrote:
> On 3/8/23 12:23, Randy Dunlap wrote:
>>>> OK, I don't know how it happened. I cannot reproduce it now.
>>>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>>>> appears to be impossible.
>>> These patches add `CONFIG_MMU is not set` (for RV32I).
>>> But no worries it seems to be a non issue  now.
>>>
>>> Your thoughts Damien?
>>>
>>
>> Thanks for reminding me.
>>
>> With these 3 patches applied to linux-next-20230307,
>> I still get this build error.
> 
> Does this help ?
> 
> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
> index 2527cf5757ec..7796c5f1d109 100644
> --- a/drivers/soc/canaan/Kconfig
> +++ b/drivers/soc/canaan/Kconfig
> @@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
>         bool "Canaan Kendryte K210 SoC system controller"
>         depends on RISCV && SOC_CANAAN && OF
>         default SOC_CANAAN
> -        select PM
> -        select MFD_SYSCON
> +       select COMMON_CLK_K210
> +       select PM
> +       select MFD_SYSCON
>         help
>           Canaan Kendryte K210 SoC system controller driver.
> 
> (just noticed that there are whitespace errors here...)

Yes, this patch allows it to build cleanly.
Thanks.

I didn't test any of the below changes.

> Note that both the sysctl and clk driver depend on RISCV. I think these should
> probably also depend on 64BIT, and eventually add a "|| COMPILE_TEST" as well.
> So something like this:
> 
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index b6c5bf69a2b2..657a36d2640d 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -431,7 +431,7 @@ config COMMON_CLK_FIXED_MMIO
> 
>  config COMMON_CLK_K210
>         bool "Clock driver for the Canaan Kendryte K210 SoC"
> -       depends on OF && RISCV && SOC_CANAAN
> +       depends on OF && RISCV && SOC_CANAAN && (64BIT || COMPILE_TEST)
>         default SOC_CANAAN
>         help
>           Support for the Canaan Kendryte K210 RISC-V SoC clocks.
> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
> index 2527cf5757ec..1745a614d2a7 100644
> --- a/drivers/soc/canaan/Kconfig
> +++ b/drivers/soc/canaan/Kconfig
> @@ -2,9 +2,10 @@
> 
>  config SOC_K210_SYSCTL
>         bool "Canaan Kendryte K210 SoC system controller"
> -       depends on RISCV && SOC_CANAAN && OF
> +       depends on RISCV && SOC_CANAAN && OF && (64BIT || COMPILE_TEST)
>         default SOC_CANAAN
> -        select PM
> -        select MFD_SYSCON
> +       select COMMON_CLK_K210
> +       select PM
> +       select MFD_SYSCON
>         help
>           Canaan Kendryte K210 SoC system controller driver.
> 
> COMPILE_TEST is optional though, but I do not see any reason why not eventhough
> in practice these drivers will likely never end up in 32-bits SoC.
> 
>
Damien Le Moal March 8, 2023, 4:11 a.m. UTC | #13
On 3/8/23 12:46, Jesse Taube wrote:
> 
> 
> On 3/7/23 22:42, Damien Le Moal wrote:
>> On 3/8/23 12:23, Randy Dunlap wrote:
>>>>> OK, I don't know how it happened. I cannot reproduce it now.
>>>>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>>>>> appears to be impossible.
>>>> These patches add `CONFIG_MMU is not set` (for RV32I).
>>>> But no worries it seems to be a non issue  now.
>>>>
>>>> Your thoughts Damien?
>>>>
>>>
>>> Thanks for reminding me.
>>>
>>> With these 3 patches applied to linux-next-20230307,
>>> I still get this build error.
>>
>> Does this help ?
>>
>> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
>> index 2527cf5757ec..7796c5f1d109 100644
>> --- a/drivers/soc/canaan/Kconfig
>> +++ b/drivers/soc/canaan/Kconfig
>> @@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
>>          bool "Canaan Kendryte K210 SoC system controller"
>>          depends on RISCV && SOC_CANAAN && OF
>>          default SOC_CANAAN
>> -        select PM
>> -        select MFD_SYSCON
>> +       select COMMON_CLK_K210
>> +       select PM
>> +       select MFD_SYSCON
>>          help
>>            Canaan Kendryte K210 SoC system controller driver.
>>
>> (just noticed that there are whitespace errors here...)
>>
>> Note that both the sysctl and clk driver depend on RISCV. I think these should
>> probably also depend on 64BIT, and eventually add a "|| COMPILE_TEST" as well.
>> So something like this:
>>
>> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
>> index b6c5bf69a2b2..657a36d2640d 100644
>> --- a/drivers/clk/Kconfig
>> +++ b/drivers/clk/Kconfig
>> @@ -431,7 +431,7 @@ config COMMON_CLK_FIXED_MMIO
>>
>>   config COMMON_CLK_K210
>>          bool "Clock driver for the Canaan Kendryte K210 SoC"
>> -       depends on OF && RISCV && SOC_CANAAN
>> +       depends on OF && RISCV && SOC_CANAAN && (64BIT || COMPILE_TEST)
>>          default SOC_CANAAN
>>          help
>>            Support for the Canaan Kendryte K210 RISC-V SoC clocks.
>> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
>> index 2527cf5757ec..1745a614d2a7 100644
>> --- a/drivers/soc/canaan/Kconfig
>> +++ b/drivers/soc/canaan/Kconfig
>> @@ -2,9 +2,10 @@
>>
>>   config SOC_K210_SYSCTL
>>          bool "Canaan Kendryte K210 SoC system controller"
>> -       depends on RISCV && SOC_CANAAN && OF
>> +       depends on RISCV && SOC_CANAAN && OF && (64BIT || COMPILE_TEST)
>>          default SOC_CANAAN
>> -        select PM
>> -        select MFD_SYSCON
>> +       select COMMON_CLK_K210
>> +       select PM
>> +       select MFD_SYSCON
>>          help
>>            Canaan Kendryte K210 SoC system controller driver.
>>
>> COMPILE_TEST is optional though, but I do not see any reason why not eventhough
>> in practice these drivers will likely never end up in 32-bits SoC.
>>
>>
> 
> Oh thanks I was in the in the midst of making a similar patch.
> Do you want to submit it or shall I. Also thanks for the help with this, 
> was using tag 6.2.

I am busy with other stuff and do not have time to properly test this. So please
feel free to go ahead and send something fully tested.
Jesse T March 14, 2023, 6:35 p.m. UTC | #14
On 3/7/23 23:11, Damien Le Moal wrote:
> On 3/8/23 12:46, Jesse Taube wrote:
>>
>>
>> On 3/7/23 22:42, Damien Le Moal wrote:
>>> On 3/8/23 12:23, Randy Dunlap wrote:
>>>>>> OK, I don't know how it happened. I cannot reproduce it now.
>>>>>> The failing .config files has CONFIG_MMU is not set (for RV32I), which
>>>>>> appears to be impossible.
>>>>> These patches add `CONFIG_MMU is not set` (for RV32I).
>>>>> But no worries it seems to be a non issue  now.
>>>>>
>>>>> Your thoughts Damien?
>>>>>
>>>>
>>>> Thanks for reminding me.
>>>>
>>>> With these 3 patches applied to linux-next-20230307,
>>>> I still get this build error.
>>>
>>> Does this help ?
>>>
>>> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
>>> index 2527cf5757ec..7796c5f1d109 100644
>>> --- a/drivers/soc/canaan/Kconfig
>>> +++ b/drivers/soc/canaan/Kconfig
>>> @@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
>>>           bool "Canaan Kendryte K210 SoC system controller"
>>>           depends on RISCV && SOC_CANAAN && OF
>>>           default SOC_CANAAN
>>> -        select PM
>>> -        select MFD_SYSCON
>>> +       select COMMON_CLK_K210

Ok so this has nothing to do with my patch-set actually and will happen 
on 64BIT as well.
the commit that brought in this bug is:

RISC-V: stop directly selecting drivers for SOC_CANAAN 
3af577f9826fdddefac42b35fc5eb3912c5b7d85

I have tested the patches Damien here they work on 64BIT and 32BIT.
The change to drivers/clk/Kconfig is not strictly necessary but makes 
scene. I don't think they need to be tested on 32bit so we can omit 
COMPILE_TEST.

If needed i can submit the patches, which I will author under Damien.

As far as I can see there is nothing holding back this set as the issue 
found has no relation to this set.

Thanks,
Jesse Taube

>>> +       select PM
>>> +       select MFD_SYSCON
>>>           help
>>>             Canaan Kendryte K210 SoC system controller driver.
>>>
>>> (just noticed that there are whitespace errors here...)
>>>
>>> Note that both the sysctl and clk driver depend on RISCV. I think these should
>>> probably also depend on 64BIT, and eventually add a "|| COMPILE_TEST" as well.
>>> So something like this:
>>>
>>> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
>>> index b6c5bf69a2b2..657a36d2640d 100644
>>> --- a/drivers/clk/Kconfig
>>> +++ b/drivers/clk/Kconfig
>>> @@ -431,7 +431,7 @@ config COMMON_CLK_FIXED_MMIO
>>>
>>>    config COMMON_CLK_K210
>>>           bool "Clock driver for the Canaan Kendryte K210 SoC"
>>> -       depends on OF && RISCV && SOC_CANAAN
>>> +       depends on OF && RISCV && SOC_CANAAN && (64BIT || COMPILE_TEST)
>>>           default SOC_CANAAN
>>>           help
>>>             Support for the Canaan Kendryte K210 RISC-V SoC clocks.
>>> diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
>>> index 2527cf5757ec..1745a614d2a7 100644
>>> --- a/drivers/soc/canaan/Kconfig
>>> +++ b/drivers/soc/canaan/Kconfig
>>> @@ -2,9 +2,10 @@
>>>
>>>    config SOC_K210_SYSCTL
>>>           bool "Canaan Kendryte K210 SoC system controller"
>>> -       depends on RISCV && SOC_CANAAN && OF
>>> +       depends on RISCV && SOC_CANAAN && OF && (64BIT || COMPILE_TEST)
>>>           default SOC_CANAAN
>>> -        select PM
>>> -        select MFD_SYSCON
>>> +       select COMMON_CLK_K210
>>> +       select PM
>>> +       select MFD_SYSCON
>>>           help
>>>             Canaan Kendryte K210 SoC system controller driver.
>>>
>>> COMPILE_TEST is optional though, but I do not see any reason why not eventhough
>>> in practice these drivers will likely never end up in 32-bits SoC.
>>>
>>>
>>
>> Oh thanks I was in the in the midst of making a similar patch.
>> Do you want to submit it or shall I. Also thanks for the help with this,
>> was using tag 6.2.
> 
> I am busy with other stuff and do not have time to properly test this. So please
> feel free to go ahead and send something fully tested.
>
Conor Dooley March 14, 2023, 7:16 p.m. UTC | #15
On Tue, Mar 14, 2023 at 02:35:39PM -0400, Jesse Taube wrote:
> 
> 
> On 3/7/23 23:11, Damien Le Moal wrote:
> > On 3/8/23 12:46, Jesse Taube wrote:
> > > 
> > > 
> > > On 3/7/23 22:42, Damien Le Moal wrote:
> > > > On 3/8/23 12:23, Randy Dunlap wrote:
> > > > > > > OK, I don't know how it happened. I cannot reproduce it now.
> > > > > > > The failing .config files has CONFIG_MMU is not set (for RV32I), which
> > > > > > > appears to be impossible.
> > > > > > These patches add `CONFIG_MMU is not set` (for RV32I).
> > > > > > But no worries it seems to be a non issue  now.
> > > > > > 
> > > > > > Your thoughts Damien?
> > > > > > 
> > > > > 
> > > > > Thanks for reminding me.
> > > > > 
> > > > > With these 3 patches applied to linux-next-20230307,
> > > > > I still get this build error.
> > > > 
> > > > Does this help ?
> > > > 
> > > > diff --git a/drivers/soc/canaan/Kconfig b/drivers/soc/canaan/Kconfig
> > > > index 2527cf5757ec..7796c5f1d109 100644
> > > > --- a/drivers/soc/canaan/Kconfig
> > > > +++ b/drivers/soc/canaan/Kconfig
> > > > @@ -4,7 +4,8 @@ config SOC_K210_SYSCTL
> > > >           bool "Canaan Kendryte K210 SoC system controller"
> > > >           depends on RISCV && SOC_CANAAN && OF
> > > >           default SOC_CANAAN
> > > > -        select PM
> > > > -        select MFD_SYSCON
> > > > +       select COMMON_CLK_K210

Ideally this would be depends on, rather than select, so that we avoid
selecting user visible symbols like that.

> Ok so this has nothing to do with my patch-set actually and will happen on
> 64BIT as well.
> the commit that brought in this bug is:
> 
> RISC-V: stop directly selecting drivers for SOC_CANAAN
> 3af577f9826fdddefac42b35fc5eb3912c5b7d85

Ah right, because the select in Kconfig.socs enforced that if the
conditions were correct for the system controller driver to be enabled,
the clock driver would always be present.
In converting the select in kconfig.socs to a default "on location", I
preserved the default behaviour but not the dependency.

> I have tested the patches Damien here they work on 64BIT and 32BIT.
> The change to drivers/clk/Kconfig is not strictly necessary but makes scene.
> I don't think they need to be tested on 32bit so we can omit COMPILE_TEST.
> 
> If needed i can submit the patches, which I will author under Damien.

It probably does need fixing to satisfy the randconfigs, submit away!

> As far as I can see there is nothing holding back this set as the issue
> found has no relation to this set.

Yup. You're currently in the queue on patchwork.
Conor Dooley March 25, 2023, 11:57 a.m. UTC | #16
On Tue, Feb 28, 2023 at 07:26:54PM -0500, Jesse Taube wrote:
> This patch-set aims to add NOMMU support to RV32.
> Many people want to build simple emulators or HDL
> models of RISC-V this patch makes it possible to
> run linux on them.

> Jesse Taube (1):
>   riscv: configs: Add nommu PHONY defconfig for RV32
> Yimin Gu (1):
>   riscv: Kconfig: Allow RV32 to build with no MMU

For these two:
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

I'll add an rv32 nommu build to the patchwork CI once this lands I
suppose!

Thanks,
Conor.
Palmer Dabbelt March 28, 2023, 6:50 p.m. UTC | #17
On Tue, 28 Feb 2023 19:26:54 -0500, Jesse Taube wrote:
> This patch-set aims to add NOMMU support to RV32.
> Many people want to build simple emulators or HDL
> models of RISC-V this patch makes it possible to
> run linux on them.
> 
> Yimin Gu is the original author of this set.
> Submitted here:
> https://lists.buildroot.org/pipermail/buildroot/2022-November/656134.html
> 
> [...]

Applied, thanks!

[2/3] riscv: Kconfig: Allow RV32 to build with no MMU
      https://git.kernel.org/palmer/c/b5e2c507b06c
[3/3] riscv: configs: Add nommu PHONY defconfig for RV32
      https://git.kernel.org/palmer/c/77c0c966719f

Best regards,