From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Huacai Chen <chenhuacai@loongson.cn>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, Xuerui Wang <kernel@xen0n.name>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
stable@vger.kernel.org,
Hongliang Wang <wanghongliang@loongson.cn>,
zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks
Date: Thu, 20 Aug 2026 20:23:59 +0800 [thread overview]
Message-ID: <fed97fbc-7d78-4509-86c2-cb302d3957db@oss.qualcomm.com> (raw)
In-Reply-To: <20260818123921.3600606-5-chenhuacai@loongson.cn>
On 8/18/2026 8:39 PM, Huacai Chen wrote:
> Our server productions (e.g. Loongson-3D6000/3E6000) can have discrete
> global physical CPU IDs while the core ID inside the packages are always
> continuous. In these cases we should use global physical CPU IDs to get
> and set frequencies.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
> drivers/cpufreq/loongson3_cpufreq.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
> index e3cd78a5ab18..c75c0e30e881 100644
> --- a/drivers/cpufreq/loongson3_cpufreq.c
> +++ b/drivers/cpufreq/loongson3_cpufreq.c
> @@ -219,38 +219,40 @@ static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 ext
>
> static unsigned int loongson3_cpufreq_get(unsigned int cpu)
> {
> - int ret;
> + int ret, core = cpu_logical_map(cpu);
>
> - ret = do_service_request(cpu, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_INFO, 0, 0);
> + ret = do_service_request(core, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_INFO, 0, 0);
As patch 5/5 changelog:
"However, IOCSR read/write can only perform on the current node, while
sometimes we want to perform on other nodes"
However, patch 4/5 starts passing the global CPU number without updating
do_service_request(), which is only changed in patch 5/5. Doesn't that
mean patch 4/5 is broken on its own?
>
> return ret * KILO;
> }
>
A separate issue, do_service_request() can return errno such as -EPERM,
it will cause .get() func return a large unsigned integer value.
> static int loongson3_cpufreq_target(struct cpufreq_policy *policy, unsigned int index)
> {
> - int ret;
> + int ret, core = cpu_logical_map(policy->cpu);
>
> - ret = do_service_request(cpu_data[policy->cpu].core,
> - FREQ_INFO_TYPE_LEVEL, CMD_SET_FREQ_INFO, index, 0);
> + ret = do_service_request(core, FREQ_INFO_TYPE_LEVEL, CMD_SET_FREQ_INFO,
> + index, 0);
>
> return (ret >= 0) ? 0 : ret;
> }
>
> static int configure_freq_table(int cpu)
> {
> - int i, ret, boost_level, max_level, freq_level;
> + int i, ret, core, boost_level, max_level, freq_level;
> struct platform_device *pdev = cpufreq_get_driver_data();
> struct loongson3_freq_data *data;
>
> if (per_cpu(freq_data, cpu))
> return 0;
>
> - ret = do_service_request(cpu, 0, CMD_GET_FREQ_LEVEL_NUM, 0, 0);
> + core = cpu_logical_map(cpu);
> +
> + ret = do_service_request(core, 0, CMD_GET_FREQ_LEVEL_NUM, 0, 0);
> if (ret < 0)
> return ret;
> max_level = ret;
>
> - ret = do_service_request(cpu, 0, CMD_GET_FREQ_BOOST_LEVEL, 0, 0);
> + ret = do_service_request(core, 0, CMD_GET_FREQ_BOOST_LEVEL, 0, 0);
> if (ret < 0)
> return ret;
> boost_level = ret;
> @@ -263,7 +265,7 @@ static int configure_freq_table(int cpu)
> data->def_freq_level = boost_level - 1;
>
> for (i = 0; i < freq_level; i++) {
> - ret = do_service_request(cpu, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_LEVEL_INFO, i, 0);
> + ret = do_service_request(core, FREQ_INFO_TYPE_FREQ, CMD_GET_FREQ_LEVEL_INFO, i, 0);
> if (ret < 0) {
> devm_kfree(&pdev->dev, data);
> return ret;
--
Thx and BRs,
Zhongqiu Han
next prev parent reply other threads:[~2026-08-20 12:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 12:39 [PATCH 0/5] cpufreq: loongson3: Fix wrong behaviors on multi-node servers Huacai Chen
2026-08-18 12:39 ` [PATCH 1/5] cpufreq: loongson3: Make this drvier depend on MACH_LOONGSON64 Huacai Chen
2026-08-20 9:23 ` Zhongqiu Han
2026-08-18 12:39 ` [PATCH 2/5] cpufreq: loongson3: Adjust the width of id and val in smc_message Huacai Chen
2026-08-20 10:03 ` Zhongqiu Han
2026-08-18 12:39 ` [PATCH 3/5] cpufreq: loongson3: Replace per-package mutex with per-node Huacai Chen
2026-08-20 11:34 ` Zhongqiu Han
2026-08-20 12:35 ` Zhongqiu Han
2026-08-21 4:54 ` Xi Ruoyao
2026-08-18 12:39 ` [PATCH 4/5] cpufreq: loongson3: Use global physical CPU ID in get/target callbacks Huacai Chen
2026-08-20 12:23 ` Zhongqiu Han [this message]
2026-08-18 12:39 ` [PATCH 5/5] cpufreq: loongson3: Replace IOCSR read/write with MMIO ones Huacai Chen
2026-08-20 12:57 ` Zhongqiu Han
2026-08-21 5:01 ` Xi Ruoyao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fed97fbc-7d78-4509-86c2-cb302d3957db@oss.qualcomm.com \
--to=zhongqiu.han@oss.qualcomm.com \
--cc=chenhuacai@kernel.org \
--cc=chenhuacai@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=wanghongliang@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox