Re: [PATCH 3/5] cpufreq: loongson3: Replace per-package mutex with per-node
Zhongqiu Han <[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]> |
On 8/18/2026 8:39 PM, Huacai Chen wrote: > Our server productions (e.g. Loongson-3D6000/3E6000) can have multiple > nodes in one package and SMC mailboxes are also per-node. So replace the > per-package mutex with per-node one. > > Cc: [email protected] > Signed-off-by: Hongliang Wang <[email protected]> > Signed-off-by: Huacai Chen <[email protected]> > --- > drivers/cpufreq/loongson3_cpufreq.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c > index 630f679aa739..e3cd78a5ab18 100644 > --- a/drivers/cpufreq/loongson3_cpufreq.c > +++ b/drivers/cpufreq/loongson3_cpufreq.c > @@ -169,7 +169,7 @@ struct loongson3_freq_data { > struct cpufreq_frequency_table table[]; > }; > > -static struct mutex cpufreq_mutex[MAX_PACKAGES]; > +static struct mutex cpufreq_mutex[MAX_NUMNODES]; > static struct cpufreq_driver loongson3_cpufreq_driver; > static DEFINE_PER_CPU(struct loongson3_freq_data *, freq_data); > > @@ -177,14 +177,14 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext > { > int retries; > unsigned int cpu = raw_smp_processor_id(); > - unsigned int package = cpu_data[cpu].package; > + unsigned int nid = cpu_to_node(cpu); > union smc_message msg, last; > > - mutex_lock(&cpufreq_mutex[package]); > + mutex_lock(&cpufreq_mutex[nid]); > > last.value = iocsr_read32(LOONGARCH_IOCSR_SMCMBX); > if (!last.complete) { > - mutex_unlock(&cpufreq_mutex[package]); > + mutex_unlock(&cpufreq_mutex[nid]); > return -EPERM; > } > > @@ -208,11 +208,11 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext > } > > if (!msg.complete || msg.cmd != CMD_OK) { > - mutex_unlock(&cpufreq_mutex[package]); > + mutex_unlock(&cpufreq_mutex[nid]); > return -EPERM; > } > > - mutex_unlock(&cpufreq_mutex[package]); > + mutex_unlock(&cpufreq_mutex[nid]); An optimization independent of this patch: considering to use guard(mutex)(xxx.lock) > > return msg.val; > } > @@ -337,7 +337,7 @@ static int loongson3_cpufreq_probe(struct platform_device *pdev) > { > int i, ret; > > - for (i = 0; i < MAX_PACKAGES; i++) { > + for (i = 0; i < MAX_NUMNODES; i++) { > ret = devm_mutex_init(&pdev->dev, &cpufreq_mutex[i]); > if (ret) > return ret; -- Thx and BRs, Zhongqiu Han