[RFC PATCH 1/4] riscv: Optimize satp_mode data type

Christoph Hellwig hch at infradead.org
Tue Jul 5 10:26:11 PDT 2022


On Tue, Jul 05, 2022 at 06:05:20AM -0400, guoren at kernel.org wrote:
> From: Guo Ren <guoren at linux.alibaba.com>
> 
> Fixup satp_mode data type. Use ulong instead of u64 for rv32
> compatibility. Because the u64 type didn't cause any real problem, make
> it as optimized.

The changelog loooks odd, but given that CSR are Xlen sized this
is the right thing to do even without further justification.

> -extern u64 satp_mode;
> +extern ulong satp_mode;

.. but please spell out unsigned long.

>  #ifdef CONFIG_64BIT
> -u64 satp_mode __ro_after_init = !IS_ENABLED(CONFIG_XIP_KERNEL) ? SATP_MODE_57 : SATP_MODE_39;
> +ulong satp_mode __ro_after_init = !IS_ENABLED(CONFIG_XIP_KERNEL) ? SATP_MODE_57 : SATP_MODE_39;
>  #else
> -u64 satp_mode __ro_after_init = SATP_MODE_32;
> +ulong satp_mode __ro_after_init = SATP_MODE_32;
>  #endif

And maybe make this less of a mess while we're at it:

#ifdef CONFIG_32BIT
#define SATP_DEFAULT	SATP_MODE_32
#elif defined(CONFIG_XIP_KERNEL)
#define SATP_DEFAULT	SATP_MODE_39
#else
#define SATP_DEFAULT	SATP_MODE_57
#endif

unsigned long satp_mode __ro_after_init = SATP_DEFAULT;



More information about the linux-riscv mailing list