2020-05-11 02:21:45

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 00/10] riscv: make riscv build happier

When add RISCV arch to huawei build test, there are some build
issue, let's fix them to make riscv build happier :)

Those patches is rebased on next-20200508.

Kefeng Wang (10):
riscv: Fix unmet direct dependencies built based on SOC_VIRT
riscv: stacktrace: Fix undefined reference to `walk_stackframe'
riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if
NOMMU
riscv: Fix print_vm_layout build error if NOMMU
riscv: Disable ARCH_HAS_DEBUG_WX if NOMMU
riscv: Disable ARCH_HAS_DEBUG_VIRTUAL if NOMMU
riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU
riscv: pgtable: Fix __kernel_map_pages build error if NOMMU
timer-riscv: Fix undefined riscv_time_val
riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id'

arch/riscv/Kconfig | 5 +++--
arch/riscv/Kconfig.socs | 17 +++++++++--------
arch/riscv/include/asm/mmio.h | 2 ++
arch/riscv/include/asm/mmiowb.h | 1 +
arch/riscv/include/asm/pgtable.h | 3 +++
arch/riscv/kernel/stacktrace.c | 2 +-
arch/riscv/mm/init.c | 2 +-
drivers/clocksource/timer-riscv.c | 1 +
8 files changed, 21 insertions(+), 12 deletions(-)

--
2.26.2


2020-05-11 02:22:43

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 02/10] riscv: stacktrace: Fix undefined reference to `walk_stackframe'

Drop static declaration to fix following build error if FRAME_POINTER disabled,
riscv64-linux-ld: arch/riscv/kernel/perf_callchain.o: in function `.L0':
perf_callchain.c:(.text+0x2b8): undefined reference to `walk_stackframe'

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/kernel/stacktrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 38141a3c70f7..595342910c3f 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -65,7 +65,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,

#else /* !CONFIG_FRAME_POINTER */

-static void notrace walk_stackframe(struct task_struct *task,
+void notrace walk_stackframe(struct task_struct *task,
struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg)
{
unsigned long sp, pc;
--
2.26.2

2020-05-11 02:25:37

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 07/10] riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU

HUGETLBFS only used when MMU enabled, add the dependence.

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 494e670520ae..d0010ed8e0f4 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -138,6 +138,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
def_bool y

config SYS_SUPPORTS_HUGETLBFS
+ depends on MMU
def_bool y

config STACKTRACE_SUPPORT
--
2.26.2

2020-05-11 02:25:40

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 10/10] riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id'

In file included from ./../include/linux/compiler_types.h:68,
from <command-line>:
../include/asm-generic/mmiowb.h: In function ‘mmiowb_set_pending’:
../include/asm-generic/percpu.h:34:38: error: implicit declaration of function ‘smp_processor_id’; did you mean ‘raw_smp_processor_id’? [-Werror=implicit-function-declaration]
#define my_cpu_offset per_cpu_offset(smp_processor_id())
^~~~~~~~~~~~~~~~
../include/linux/compiler-gcc.h:58:26: note: in definition of macro ‘RELOC_HIDE’
(typeof(ptr)) (__ptr + (off)); \
^~~
../include/linux/percpu-defs.h:249:2: note: in expansion of macro ‘SHIFT_PERCPU_PTR’
SHIFT_PERCPU_PTR(ptr, my_cpu_offset); \
^~~~~~~~~~~~~~~~
../include/asm-generic/percpu.h:34:23: note: in expansion of macro ‘per_cpu_offset’
#define my_cpu_offset per_cpu_offset(smp_processor_id())
^~~~~~~~~~~~~~
../include/linux/percpu-defs.h:249:24: note: in expansion of macro ‘my_cpu_offset’
SHIFT_PERCPU_PTR(ptr, my_cpu_offset); \
^~~~~~~~~~~~~
../include/asm-generic/mmiowb.h:30:26: note: in expansion of macro ‘this_cpu_ptr’
#define __mmiowb_state() this_cpu_ptr(&__mmiowb_state)
^~~~~~~~~~~~
../include/asm-generic/mmiowb.h:37:28: note: in expansion of macro ‘__mmiowb_state’
struct mmiowb_state *ms = __mmiowb_state();
^~~~~~~~~~~~~~

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/include/asm/mmiowb.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/asm/mmiowb.h b/arch/riscv/include/asm/mmiowb.h
index bb4091ff4a21..0b2333e71fdc 100644
--- a/arch/riscv/include/asm/mmiowb.h
+++ b/arch/riscv/include/asm/mmiowb.h
@@ -9,6 +9,7 @@
*/
#define mmiowb() __asm__ __volatile__ ("fence o,w" : : : "memory");

+#include <linux/smp.h>
#include <asm-generic/mmiowb.h>

#endif /* _ASM_RISCV_MMIOWB_H */
--
2.26.2

2020-05-11 02:26:07

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
drivers/clocksource/timer-riscv.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index c4f15c4068c0..071b8c144027 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -19,6 +19,7 @@

u64 __iomem *riscv_time_cmp;
u64 __iomem *riscv_time_val;
+EXPORT_SYMBOL(riscv_time_val);

static inline void mmio_set_timer(u64 val)
{
--
2.26.2

2020-05-11 02:27:07

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 04/10] riscv: Fix print_vm_layout build error if NOMMU

arch/riscv/mm/init.c: In function ‘print_vm_layout’:
arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in this function);
arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this function);

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index dfcaebc3928f..58c39c44b9c9 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -49,7 +49,7 @@ static void setup_zero_page(void)
memset((void *)empty_zero_page, 0, PAGE_SIZE);
}

-#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(DEBUG_VM)
static inline void print_mlk(char *name, unsigned long b, unsigned long t)
{
pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld kB)\n", name, b, t,
--
2.26.2

2020-05-11 02:27:33

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH 06/10] riscv: Disable ARCH_HAS_DEBUG_VIRTUAL if NOMMU

DEBUG_VIRTUAL should only used when MMU enabled, add the dependence.

Signed-off-by: Kefeng Wang <[email protected]>
---
arch/riscv/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 7da0a36a8df0..494e670520ae 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -53,7 +53,7 @@ config RISCV
select GENERIC_ARCH_TOPOLOGY if SMP
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_MMIOWB
- select ARCH_HAS_DEBUG_VIRTUAL
+ select ARCH_HAS_DEBUG_VIRTUAL if MMU
select HAVE_EBPF_JIT if MMU
select EDAC_SUPPORT
select ARCH_HAS_GIGANTIC_PAGE
--
2.26.2

2020-05-13 21:16:31

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 07/10] riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU

On Sun, 10 May 2020 19:19:58 PDT (-0700), [email protected] wrote:
> HUGETLBFS only used when MMU enabled, add the dependence.
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> arch/riscv/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 494e670520ae..d0010ed8e0f4 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -138,6 +138,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
> def_bool y
>
> config SYS_SUPPORTS_HUGETLBFS
> + depends on MMU
> def_bool y

I don't think this is the right way to do this: there's nothing specific to the
RISC-V implementation that makes HUGETLBFS depend on MMU. That said, SH
appears to do it this way so I'm OK taking this for now.

>
> config STACKTRACE_SUPPORT

2020-05-13 21:16:34

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected] wrote:
> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> drivers/clocksource/timer-riscv.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
> index c4f15c4068c0..071b8c144027 100644
> --- a/drivers/clocksource/timer-riscv.c
> +++ b/drivers/clocksource/timer-riscv.c
> @@ -19,6 +19,7 @@
>
> u64 __iomem *riscv_time_cmp;
> u64 __iomem *riscv_time_val;
> +EXPORT_SYMBOL(riscv_time_val);
>
> static inline void mmio_set_timer(u64 val)
> {

Reviewed-by: Palmer Dabbelt <[email protected]>
Acked-by: Palmer Dabbelt <[email protected]>

Adding the clocksource maintainers. Let me know if you want this through my
tree, I'm assuming you want it through your tree.

Thanks!

2020-05-13 21:17:15

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 00/10] riscv: make riscv build happier

On Sun, 10 May 2020 19:19:51 PDT (-0700), [email protected] wrote:
> When add RISCV arch to huawei build test, there are some build
> issue, let's fix them to make riscv build happier :)
>
> Those patches is rebased on next-20200508.
>
> Kefeng Wang (10):
> riscv: Fix unmet direct dependencies built based on SOC_VIRT
> riscv: stacktrace: Fix undefined reference to `walk_stackframe'
> riscv: Add pgprot_writecombine/device and PAGE_SHARED defination if
> NOMMU
> riscv: Fix print_vm_layout build error if NOMMU
> riscv: Disable ARCH_HAS_DEBUG_WX if NOMMU
> riscv: Disable ARCH_HAS_DEBUG_VIRTUAL if NOMMU
> riscv: Make SYS_SUPPORTS_HUGETLBFS depends on MMU
> riscv: pgtable: Fix __kernel_map_pages build error if NOMMU
> timer-riscv: Fix undefined riscv_time_val
> riscv: mmiowb: Fix implicit declaration of function 'smp_processor_id'
>
> arch/riscv/Kconfig | 5 +++--
> arch/riscv/Kconfig.socs | 17 +++++++++--------
> arch/riscv/include/asm/mmio.h | 2 ++
> arch/riscv/include/asm/mmiowb.h | 1 +
> arch/riscv/include/asm/pgtable.h | 3 +++
> arch/riscv/kernel/stacktrace.c | 2 +-
> arch/riscv/mm/init.c | 2 +-
> drivers/clocksource/timer-riscv.c | 1 +
> 8 files changed, 21 insertions(+), 12 deletions(-)

Unless I said otherwise in the patch reviews, these are all on fixes.

Thanks!

2020-05-14 10:14:41

by Alexandre Ghiti

[permalink] [raw]
Subject: Re: [PATCH 04/10] riscv: Fix print_vm_layout build error if NOMMU

Hi,

On 5/10/20 10:19 PM, Kefeng Wang wrote:
> arch/riscv/mm/init.c: In function ‘print_vm_layout’:
> arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in this function);
> arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
> arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
> arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
> arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
> arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this function);
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> arch/riscv/mm/init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index dfcaebc3928f..58c39c44b9c9 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -49,7 +49,7 @@ static void setup_zero_page(void)
> memset((void *)empty_zero_page, 0, PAGE_SIZE);
> }
>
> -#ifdef CONFIG_DEBUG_VM
> +#if defined(CONFIG_MMU) && defined(DEBUG_VM)


Shouldn't it be CONFIG_DEBUG_VM ?


> static inline void print_mlk(char *name, unsigned long b, unsigned long t)
> {
> pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld kB)\n", name, b, t,


Alex

2020-05-14 11:46:59

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 04/10] riscv: Fix print_vm_layout build error if NOMMU


On 2020/5/14 18:10, Alex Ghiti wrote:
> Hi,
>
> On 5/10/20 10:19 PM, Kefeng Wang wrote:
>> arch/riscv/mm/init.c: In function ‘print_vm_layout’:
>> arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first
>> use in this function);
>> arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
>> arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
>> arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
>> arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
>> arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first
>> use in this function);
>>
>> Reported-by: Hulk Robot <[email protected]>
>> Signed-off-by: Kefeng Wang <[email protected]>
>> ---
>>   arch/riscv/mm/init.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index dfcaebc3928f..58c39c44b9c9 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -49,7 +49,7 @@ static void setup_zero_page(void)
>>       memset((void *)empty_zero_page, 0, PAGE_SIZE);
>>   }
>>   -#ifdef CONFIG_DEBUG_VM
>> +#if defined(CONFIG_MMU) && defined(DEBUG_VM)
>
>
> Shouldn't it be CONFIG_DEBUG_VM ?
oops, should be CONFIG_DEBUG_VM, will send v2, thanks.
>
>
>>   static inline void print_mlk(char *name, unsigned long b, unsigned
>> long t)
>>   {
>>       pr_notice("%12s : 0x%08lx - 0x%08lx   (%4ld kB)\n", name, b, t,
>
>
> Alex
>
>
> .
>

2020-05-14 11:52:17

by Kefeng Wang

[permalink] [raw]
Subject: [PATCH v2] riscv: Fix print_vm_layout build error if NOMMU

arch/riscv/mm/init.c: In function ‘print_vm_layout’:
arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in this function);
arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this function);

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Kefeng Wang <[email protected]>
---
v2:
- Should CONFIG_DEBUG_VM instead of DEBUG_VM
- Based on riscv fixes branch

arch/riscv/mm/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 27a334106708..736de6c8739f 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -47,7 +47,7 @@ static void setup_zero_page(void)
memset((void *)empty_zero_page, 0, PAGE_SIZE);
}

-#ifdef CONFIG_DEBUG_VM
+#if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM)
static inline void print_mlk(char *name, unsigned long b, unsigned long t)
{
pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld kB)\n", name, b, t,
--
2.26.2

2020-05-18 14:11:28

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

On 13/05/2020 23:14, Palmer Dabbelt wrote:
> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected] wrote:
>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>
>> Reported-by: Hulk Robot <[email protected]>
>> Signed-off-by: Kefeng Wang <[email protected]>
>> ---
>>  drivers/clocksource/timer-riscv.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/clocksource/timer-riscv.c
>> b/drivers/clocksource/timer-riscv.c
>> index c4f15c4068c0..071b8c144027 100644
>> --- a/drivers/clocksource/timer-riscv.c
>> +++ b/drivers/clocksource/timer-riscv.c
>> @@ -19,6 +19,7 @@
>>
>>  u64 __iomem *riscv_time_cmp;
>>  u64 __iomem *riscv_time_val;
>> +EXPORT_SYMBOL(riscv_time_val);
>>
>>  static inline void mmio_set_timer(u64 val)
>>  {
>
> Reviewed-by: Palmer Dabbelt <[email protected]>
> Acked-by: Palmer Dabbelt <[email protected]>
>
> Adding the clocksource maintainers.  Let me know if you want this
> through my
> tree, I'm assuming you want it through your tree.

How can we end up by an export symbol here ?!


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

2020-05-18 15:45:31

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val


On 2020/5/18 22:09, Daniel Lezcano wrote:
> On 13/05/2020 23:14, Palmer Dabbelt wrote:
>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected] wrote:
>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>>
>>> Reported-by: Hulk Robot <[email protected]>
>>> Signed-off-by: Kefeng Wang <[email protected]>
>>> ---
>>>  drivers/clocksource/timer-riscv.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/clocksource/timer-riscv.c
>>> b/drivers/clocksource/timer-riscv.c
>>> index c4f15c4068c0..071b8c144027 100644
>>> --- a/drivers/clocksource/timer-riscv.c
>>> +++ b/drivers/clocksource/timer-riscv.c
>>> @@ -19,6 +19,7 @@
>>>
>>>  u64 __iomem *riscv_time_cmp;
>>>  u64 __iomem *riscv_time_val;
>>> +EXPORT_SYMBOL(riscv_time_val);
>>>
>>>  static inline void mmio_set_timer(u64 val)
>>>  {
>> Reviewed-by: Palmer Dabbelt <[email protected]>
>> Acked-by: Palmer Dabbelt <[email protected]>
>>
>> Adding the clocksource maintainers.  Let me know if you want this
>> through my
>> tree, I'm assuming you want it through your tree.
> How can we end up by an export symbol here ?!

Hi Danile,

Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
is not,

see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
registers"

thanks.

>
>

2020-05-18 20:28:15

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val


Hi Kefeng,

On 18/05/2020 17:40, Kefeng Wang wrote:
>
> On 2020/5/18 22:09, Daniel Lezcano wrote:
>> On 13/05/2020 23:14, Palmer Dabbelt wrote:
>>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected]
>>> wrote:
>>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>>>
>>>> Reported-by: Hulk Robot <[email protected]>
>>>> Signed-off-by: Kefeng Wang <[email protected]>
>>>> ---
>>>>   drivers/clocksource/timer-riscv.c | 1 +
>>>>   1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/drivers/clocksource/timer-riscv.c
>>>> b/drivers/clocksource/timer-riscv.c
>>>> index c4f15c4068c0..071b8c144027 100644
>>>> --- a/drivers/clocksource/timer-riscv.c
>>>> +++ b/drivers/clocksource/timer-riscv.c
>>>> @@ -19,6 +19,7 @@
>>>>
>>>>   u64 __iomem *riscv_time_cmp;
>>>>   u64 __iomem *riscv_time_val;
>>>> +EXPORT_SYMBOL(riscv_time_val);
>>>>
>>>>   static inline void mmio_set_timer(u64 val)
>>>>   {
>>> Reviewed-by: Palmer Dabbelt <[email protected]>
>>> Acked-by: Palmer Dabbelt <[email protected]>
>>>
>>> Adding the clocksource maintainers.  Let me know if you want this
>>> through my
>>> tree, I'm assuming you want it through your tree.
>> How can we end up by an export symbol here ?!
>
> Hi Danile,

s/Danile/Daniel/

> Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
> is not,
>
> see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
> registers"

Thanks for the pointer.

The question still remains, how do we end up with this EXPORT_SYMBOL?

There is something wrong if the fix is an EXPORT_SYMBOL for a global
variable.



--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

2020-05-19 12:43:49

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val


On 2020/5/19 4:23, Daniel Lezcano wrote:
> Hi Kefeng,
>
> On 18/05/2020 17:40, Kefeng Wang wrote:
>> On 2020/5/18 22:09, Daniel Lezcano wrote:
>>> On 13/05/2020 23:14, Palmer Dabbelt wrote:
>>>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected]
>>>> wrote:
>>>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>>>>
>>>>> Reported-by: Hulk Robot <[email protected]>
>>>>> Signed-off-by: Kefeng Wang <[email protected]>
>>>>> ---
>>>>>   drivers/clocksource/timer-riscv.c | 1 +
>>>>>   1 file changed, 1 insertion(+)
>>>>>
>>>>> diff --git a/drivers/clocksource/timer-riscv.c
>>>>> b/drivers/clocksource/timer-riscv.c
>>>>> index c4f15c4068c0..071b8c144027 100644
>>>>> --- a/drivers/clocksource/timer-riscv.c
>>>>> +++ b/drivers/clocksource/timer-riscv.c
>>>>> @@ -19,6 +19,7 @@
>>>>>
>>>>>   u64 __iomem *riscv_time_cmp;
>>>>>   u64 __iomem *riscv_time_val;
>>>>> +EXPORT_SYMBOL(riscv_time_val);
>>>>>
>>>>>   static inline void mmio_set_timer(u64 val)
>>>>>   {
>>>> Reviewed-by: Palmer Dabbelt <[email protected]>
>>>> Acked-by: Palmer Dabbelt <[email protected]>
>>>>
>>>> Adding the clocksource maintainers.  Let me know if you want this
>>>> through my
>>>> tree, I'm assuming you want it through your tree.
>>> How can we end up by an export symbol here ?!
>> Hi Danile,
> s/Danile/Daniel/
Sorry for typing error.
>
>> Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
>> is not,
>>
>> see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
>> registers"
> Thanks for the pointer.
>
> The question still remains, how do we end up with this EXPORT_SYMBOL?
>
> There is something wrong if the fix is an EXPORT_SYMBOL for a global
> variable.

Not very clear, there are some global variable( eg, acpi_disabled,
memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that
export riscv_time_val is wrong way?



>
>
>

2020-05-19 13:53:02

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

On 19/05/2020 14:39, Kefeng Wang wrote:
>
> On 2020/5/19 4:23, Daniel Lezcano wrote:
>> Hi Kefeng,
>>
>> On 18/05/2020 17:40, Kefeng Wang wrote:
>>> On 2020/5/18 22:09, Daniel Lezcano wrote:
>>>> On 13/05/2020 23:14, Palmer Dabbelt wrote:
>>>>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected]
>>>>> wrote:
>>>>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>>>>>
>>>>>> Reported-by: Hulk Robot <[email protected]>
>>>>>> Signed-off-by: Kefeng Wang <[email protected]>
>>>>>> ---
>>>>>>    drivers/clocksource/timer-riscv.c | 1 +
>>>>>>    1 file changed, 1 insertion(+)
>>>>>>
>>>>>> diff --git a/drivers/clocksource/timer-riscv.c
>>>>>> b/drivers/clocksource/timer-riscv.c
>>>>>> index c4f15c4068c0..071b8c144027 100644
>>>>>> --- a/drivers/clocksource/timer-riscv.c
>>>>>> +++ b/drivers/clocksource/timer-riscv.c
>>>>>> @@ -19,6 +19,7 @@
>>>>>>
>>>>>>    u64 __iomem *riscv_time_cmp;
>>>>>>    u64 __iomem *riscv_time_val;
>>>>>> +EXPORT_SYMBOL(riscv_time_val);
>>>>>>
>>>>>>    static inline void mmio_set_timer(u64 val)
>>>>>>    {
>>>>> Reviewed-by: Palmer Dabbelt <[email protected]>
>>>>> Acked-by: Palmer Dabbelt <[email protected]>
>>>>>
>>>>> Adding the clocksource maintainers.  Let me know if you want this
>>>>> through my
>>>>> tree, I'm assuming you want it through your tree.
>>>> How can we end up by an export symbol here ?!
>>> Hi Danile,
>> s/Danile/Daniel/
> Sorry for typing error.
>>
>>> Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
>>> is not,
>>>
>>> see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
>>> registers"
>> Thanks for the pointer.
>>
>> The question still remains, how do we end up with this EXPORT_SYMBOL?
>>
>> There is something wrong if the fix is an EXPORT_SYMBOL for a global
>> variable.
>
> Not very clear, there are some global variable( eg, acpi_disabled,
> memstart_addr in arm64,) is exported by EXPORT_SYMBOL,  do you mean that
> export riscv_time_val is wrong way?

I do not maintain acpi neither arm64.mm.

AFAICT, riscv_time_val is globally declared in
drivers/clocksource/timer-riscv.c

The driver does not use this variable at all. Then there is a readl on
it in the header file arch/riscv/include/asm/timex.h

And finally it is initialized in arch/riscv/kernel/clint.c

Same thing for riscv_time_cmp.

The correct fix is to initialize the variables in the place where they
belong to (drivers/clocksource/timer-riscv.c), create a function to read
their content and export-symbol-gpl the function.


--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

2020-05-20 01:16:57

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val

On Tue, May 19, 2020 at 7:21 PM Daniel Lezcano
<[email protected]> wrote:
>
> On 19/05/2020 14:39, Kefeng Wang wrote:
> >
> > On 2020/5/19 4:23, Daniel Lezcano wrote:
> >> Hi Kefeng,
> >>
> >> On 18/05/2020 17:40, Kefeng Wang wrote:
> >>> On 2020/5/18 22:09, Daniel Lezcano wrote:
> >>>> On 13/05/2020 23:14, Palmer Dabbelt wrote:
> >>>>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected]
> >>>>> wrote:
> >>>>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
> >>>>>>
> >>>>>> Reported-by: Hulk Robot <[email protected]>
> >>>>>> Signed-off-by: Kefeng Wang <[email protected]>
> >>>>>> ---
> >>>>>> drivers/clocksource/timer-riscv.c | 1 +
> >>>>>> 1 file changed, 1 insertion(+)
> >>>>>>
> >>>>>> diff --git a/drivers/clocksource/timer-riscv.c
> >>>>>> b/drivers/clocksource/timer-riscv.c
> >>>>>> index c4f15c4068c0..071b8c144027 100644
> >>>>>> --- a/drivers/clocksource/timer-riscv.c
> >>>>>> +++ b/drivers/clocksource/timer-riscv.c
> >>>>>> @@ -19,6 +19,7 @@
> >>>>>>
> >>>>>> u64 __iomem *riscv_time_cmp;
> >>>>>> u64 __iomem *riscv_time_val;
> >>>>>> +EXPORT_SYMBOL(riscv_time_val);
> >>>>>>
> >>>>>> static inline void mmio_set_timer(u64 val)
> >>>>>> {
> >>>>> Reviewed-by: Palmer Dabbelt <[email protected]>
> >>>>> Acked-by: Palmer Dabbelt <[email protected]>
> >>>>>
> >>>>> Adding the clocksource maintainers. Let me know if you want this
> >>>>> through my
> >>>>> tree, I'm assuming you want it through your tree.
> >>>> How can we end up by an export symbol here ?!
> >>> Hi Danile,
> >> s/Danile/Daniel/
> > Sorry for typing error.
> >>
> >>> Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
> >>> is not,
> >>>
> >>> see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
> >>> registers"
> >> Thanks for the pointer.
> >>
> >> The question still remains, how do we end up with this EXPORT_SYMBOL?
> >>
> >> There is something wrong if the fix is an EXPORT_SYMBOL for a global
> >> variable.
> >
> > Not very clear, there are some global variable( eg, acpi_disabled,
> > memstart_addr in arm64,) is exported by EXPORT_SYMBOL, do you mean that
> > export riscv_time_val is wrong way?
>
> I do not maintain acpi neither arm64.mm.
>
> AFAICT, riscv_time_val is globally declared in
> drivers/clocksource/timer-riscv.c
>
> The driver does not use this variable at all. Then there is a readl on
> it in the header file arch/riscv/include/asm/timex.h
>
> And finally it is initialized in arch/riscv/kernel/clint.c
>
> Same thing for riscv_time_cmp.
>
> The correct fix is to initialize the variables in the place where they
> belong to (drivers/clocksource/timer-riscv.c), create a function to read
> their content and export-symbol-gpl the function.

I agree with Daniel. Exporting riscv_time_val is a temporary fix.

The problem is timer-riscv.c is pretty convoluted right now. It is
implementing two different clocksources and clockevents in one-place.

I think we need two separate drivers for RISC-V world.

1. timer-riscv: This for regular S-mode kernel with MMU. The clocksource
will use TIME CSR and the clockevent device will use SBI calls.

2. timer-clint: This for M-mode kernel without MMU (or NoMMU kernel).
The clocksource will use MMIO counter for clocksource and the
clockevent device will use MMIO compare registers.

I will send a patch to have a separate timer-clint driver under
drivers/clocksource. (@Daniel, I hope you will be fine with this?)

Regards,
Anup

>
>
> --
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

2020-05-20 03:02:30

by Kefeng Wang

[permalink] [raw]
Subject: Re: [PATCH 09/10] timer-riscv: Fix undefined riscv_time_val


On 2020/5/20 9:14, Anup Patel wrote:
> On Tue, May 19, 2020 at 7:21 PM Daniel Lezcano
> <[email protected]> wrote:
>> On 19/05/2020 14:39, Kefeng Wang wrote:
>>> On 2020/5/19 4:23, Daniel Lezcano wrote:
>>>> Hi Kefeng,
>>>>
>>>> On 18/05/2020 17:40, Kefeng Wang wrote:
>>>>> On 2020/5/18 22:09, Daniel Lezcano wrote:
>>>>>> On 13/05/2020 23:14, Palmer Dabbelt wrote:
>>>>>>> On Sun, 10 May 2020 19:20:00 PDT (-0700), [email protected]
>>>>>>> wrote:
>>>>>>>> ERROR: modpost: "riscv_time_val" [crypto/tcrypt.ko] undefined!
>>>>>>>>
>>>>>>>> Reported-by: Hulk Robot <[email protected]>
>>>>>>>> Signed-off-by: Kefeng Wang <[email protected]>
>>>>>>>> ---
>>>>>>>> drivers/clocksource/timer-riscv.c | 1 +
>>>>>>>> 1 file changed, 1 insertion(+)
>>>>>>>>
>>>>>>>> diff --git a/drivers/clocksource/timer-riscv.c
>>>>>>>> b/drivers/clocksource/timer-riscv.c
>>>>>>>> index c4f15c4068c0..071b8c144027 100644
>>>>>>>> --- a/drivers/clocksource/timer-riscv.c
>>>>>>>> +++ b/drivers/clocksource/timer-riscv.c
>>>>>>>> @@ -19,6 +19,7 @@
>>>>>>>>
>>>>>>>> u64 __iomem *riscv_time_cmp;
>>>>>>>> u64 __iomem *riscv_time_val;
>>>>>>>> +EXPORT_SYMBOL(riscv_time_val);
>>>>>>>>
>>>>>>>> static inline void mmio_set_timer(u64 val)
>>>>>>>> {
>>>>>>> Reviewed-by: Palmer Dabbelt <[email protected]>
>>>>>>> Acked-by: Palmer Dabbelt <[email protected]>
>>>>>>>
>>>>>>> Adding the clocksource maintainers. Let me know if you want this
>>>>>>> through my
>>>>>>> tree, I'm assuming you want it through your tree.
>>>>>> How can we end up by an export symbol here ?!
>>>>> Hi Danile,
>>>> s/Danile/Daniel/
>>> Sorry for typing error.
>>>>> Found this build error when CONFIG_RISCV_M_MODE=y and CONFIG_RISCV_SBI
>>>>> is not,
>>>>>
>>>>> see patch "4f9bbcefa142 riscv: add support for MMIO access to the timer
>>>>> registers"
>>>> Thanks for the pointer.
>>>>
>>>> The question still remains, how do we end up with this EXPORT_SYMBOL?
>>>>
>>>> There is something wrong if the fix is an EXPORT_SYMBOL for a global
>>>> variable.
>>> Not very clear, there are some global variable( eg, acpi_disabled,
>>> memstart_addr in arm64,) is exported by EXPORT_SYMBOL, do you mean that
>>> export riscv_time_val is wrong way?
>> I do not maintain acpi neither arm64.mm.
>>
>> AFAICT, riscv_time_val is globally declared in
>> drivers/clocksource/timer-riscv.c
>>
>> The driver does not use this variable at all. Then there is a readl on
>> it in the header file arch/riscv/include/asm/timex.h
>>
>> And finally it is initialized in arch/riscv/kernel/clint.c
>>
>> Same thing for riscv_time_cmp.
>>
>> The correct fix is to initialize the variables in the place where they
>> belong to (drivers/clocksource/timer-riscv.c), create a function to read
>> their content and export-symbol-gpl the function.

ok, it's better.  thanks for your explanation.


> I agree with Daniel. Exporting riscv_time_val is a temporary fix.

yes.  it's only for build,  let's wait for Anup's patch.

>
> The problem is timer-riscv.c is pretty convoluted right now. It is
> implementing two different clocksources and clockevents in one-place.
>
> I think we need two separate drivers for RISC-V world.
>
> 1. timer-riscv: This for regular S-mode kernel with MMU. The clocksource
> will use TIME CSR and the clockevent device will use SBI calls.
>
> 2. timer-clint: This for M-mode kernel without MMU (or NoMMU kernel).
> The clocksource will use MMIO counter for clocksource and the
> clockevent device will use MMIO compare registers.
>
> I will send a patch to have a separate timer-clint driver under
> drivers/clocksource. (@Daniel, I hope you will be fine with this?)
> Regards,
> Anup
>
>>
>> --
>> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>>
>> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
>> <http://twitter.com/#!/linaroorg> Twitter |
>> <http://www.linaro.org/linaro-blog/> Blog
> .
>

2020-05-20 22:54:20

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH v2] riscv: Fix print_vm_layout build error if NOMMU

On Thu, 14 May 2020 04:53:35 PDT (-0700), [email protected] wrote:
> arch/riscv/mm/init.c: In function ‘print_vm_layout’:
> arch/riscv/mm/init.c:68:37: error: ‘FIXADDR_START’ undeclared (first use in this function);
> arch/riscv/mm/init.c:69:20: error: ‘FIXADDR_TOP’ undeclared
> arch/riscv/mm/init.c:70:37: error: ‘PCI_IO_START’ undeclared
> arch/riscv/mm/init.c:71:20: error: ‘PCI_IO_END’ undeclared
> arch/riscv/mm/init.c:72:38: error: ‘VMEMMAP_START’ undeclared
> arch/riscv/mm/init.c:73:20: error: ‘VMEMMAP_END’ undeclared (first use in this function);
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Kefeng Wang <[email protected]>
> ---
> v2:
> - Should CONFIG_DEBUG_VM instead of DEBUG_VM
> - Based on riscv fixes branch
>
> arch/riscv/mm/init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 27a334106708..736de6c8739f 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -47,7 +47,7 @@ static void setup_zero_page(void)
> memset((void *)empty_zero_page, 0, PAGE_SIZE);
> }
>
> -#ifdef CONFIG_DEBUG_VM
> +#if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM)
> static inline void print_mlk(char *name, unsigned long b, unsigned long t)
> {
> pr_notice("%12s : 0x%08lx - 0x%08lx (%4ld kB)\n", name, b, t,

Thanks, this is on fixes.