Re: [PATCH 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones

Xi Ruoyao <[email protected]>
Newsgroups org.kernel.vger.linux-pm,dev.linux.lists.loongarch,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>

在 2026/8/18 20:39, Huacai Chen 写道:
> Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple
> nodes in one package and SMC mailboxes are also per-node. However, IOCSR
> read/write can only perform on the current node, while sometimes we want
> to perform on other nodes (e.g. when switch governor, the get and target
> callbacks are not run on target core). So replace IOCSR read/write with
> MMIO ones.
> 
> Cc: [email protected]
> Signed-off-by: Huacai Chen <[email protected]>
> ---
>   drivers/cpufreq/loongson3_cpufreq.c | 31 ++++++++++++++++++++++-------
>   1 file changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
> index c75c0e30e881..e5062cd62390 100644
> --- a/drivers/cpufreq/loongson3_cpufreq.c
> +++ b/drivers/cpufreq/loongson3_cpufreq.c
> @@ -164,6 +164,12 @@ union smc_message {
>   
>   #define FREQ_MAX_LEVEL			16
>   
> +#define MMIO_SMCMBX(node) \
> +	((void __iomem *)(IO_BASE | (u64)(node) << NODE_ADDRSPACE_SHIFT | LOONGSON_REG_BASE | LOONGARCH_IOCSR_SMCMBX))

NODE_ADDRSPACE_SHIFT is defined in numa.h so that file needs to be 
included, to avoid a build failure when NUMA is disabled (if NUMA is 
enabled, numa.h happens to be pulled in via some other headers).

Also I'd suggest to use nid_to_addrbase(node) instead of hard coding the 
shift for better readability.

With the changes:

Tested-by: Xi Ruoyao <[email protected]> # on XA61200
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.