[PATCH v3] riscv: use generic relaxed MMIO accessors

Arnd Bergmann arnd at arndb.de
Thu Sep 24 07:51:42 PDT 2026


On Wed, Sep 23, 2026, at 03:39, Qingfang Deng wrote:
> The relaxed MMIO accessors duplicate the generic implementation, as noted
> by their FIXME comment. Remove those definitions and their empty barrier
> hooks so asm-generic/io.h supplies them through the existing asm/io.h
> include path.

This seems fine.

> The M-mode timer uses the lightweight asm/mmio.h header before the
> generic relaxed accessors are available. Use readl_cpu() and readq_cpu()
> there, which perform the same accesses and endian conversion as the
> existing relaxed accessors.
>
> @@ -17,18 +17,18 @@ typedef unsigned long cycles_t;
>  #ifdef CONFIG_64BIT
>  static inline cycles_t get_cycles(void)
>  {
> -	return readq_relaxed(clint_time_val);
> +	return readq_cpu(clint_time_val);
>  }
>  #else /* !CONFIG_64BIT */
>  static inline u32 get_cycles(void)
>  {
> -	return readl_relaxed(((u32 __iomem *)clint_time_val));
> +	return readl_cpu(((u32 __iomem *)clint_time_val));
>  }
>  #define get_cycles get_cycles

I don't understand this bit: Why should these not keep using the
portable accessors? As far as I can tell, the readl_cpu() helpers
are just an implementation detail in riscv and could be removed
along with the custom readl_relaxed() variant, but with your
patch that becomes harder.

     Arnd



More information about the linux-riscv mailing list