Re: [PATCH 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones
From: Xi Ruoyao
Date: Fri Aug 21 2026 - 01:02:05 EST
在 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: stable@xxxxxxxxxxxxxxx
Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
---
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 <xry111@xxxxxxxxxxx> # on XA61200