[PATCH] riscv: Use asm-generic for {read,write}{bwlq} and their relaxed variant

Jisheng Zhang jszhang at kernel.org
Mon Nov 27 07:57:09 PST 2023


On Mon, Nov 27, 2023 at 10:39:16AM +0000, Conor Dooley wrote:
> On Thu, Nov 23, 2023 at 10:20:03PM +0800, Jisheng Zhang wrote:
> > The asm-generic implementation is functionally identical to the riscv
> > version.
> > 
> > Signed-off-by: Jisheng Zhang <jszhang at kernel.org>
> 
> This fails to build for nommu:
>   /tmp/tmp.ojumpiEgOt/arch/riscv/include/asm/timex.h:20:16: error: implicit declaration of function 'readq_relaxed' [-Werror=implicit-function-declaration]
>   /tmp/tmp.ojumpiEgOt/include/asm-generic/io.h:342:23: error: conflicting types for 'readq_relaxed'; have 'u64(const volatile void *)' {aka 'long long unsigned int(const volatile void *)'}
> 
>   Cheers,
>   Conor.

Hi,

Thanks for the report. I can reproduce the build error locally.
The problem is readl_relaxed usage in timex.h.

If include <asm/io.h> in timex.h, then we will meet issues which is
fixed by commit 0c3ac289.

If not include <asm/io.h>, then the readl_relaxed readq_relaxed
are not explictly declared as reported here.

I have two solutions:

solA: use __raw_readl and __raw_readq in timex, since I found other
architectures use the raw asm instructions for get_cycles()

solB: remove clint_time_val and export a function in timer-clint.c as below:
get_clint_cycles()
{
	readl_relaxed(clint_time_val);
}

then
#define get_cycles get_clint_cycles

Both solutions can solve the issues. which one is better?

Thanks in advance




More information about the linux-riscv mailing list