Re: [PATCH V3 2/2] cpufreq: Add Loongson-3 CPUFreq driver support
From: Huacai Chen
Date: Mon Aug 26 2024 - 10:40:18 EST
Hi, Ruoyao,
On Fri, Aug 23, 2024 at 2:34 PM Xi Ruoyao <xry111@xxxxxxxxxxx> wrote:
>
> On Fri, 2024-07-05 at 14:06 +0800, Huacai Chen wrote:
> > Some of LoongArch processors (Loongson-3 series) support DVFS, their
> > IOCSR.FEATURES has IOCSRF_FREQSCALE set. And they has a micro-core in
> > the package called SMC (System Management Controller), which can be
> > used to detect temperature, control fans, scale frequency and voltage,
> > etc.
> >
> > The Loongson-3 CPUFreq driver is very simple now, it communicate with
> > SMC, get DVFS info, set target frequency from CPUFreq core, and so on.
> >
> > There is a command list to interact with SMC, widely-used commands in
> > the CPUFreq driver include:
> >
> > CMD_GET_VERSION: Get SMC firmware version.
> >
> > CMD_GET_FEATURE: Get enabled SMC features.
> >
> > CMD_SET_FEATURE: Enable SMC features, such as basic DVFS, BOOST.
> >
> > CMD_GET_FREQ_LEVEL_NUM: Get the number of all frequency levels.
> >
> > CMD_GET_FREQ_BOOST_LEVEL: Get the first boost frequency level.
> >
> > CMD_GET_FREQ_LEVEL_INFO: Get the detail info of a frequency level.
> >
> > CMD_GET_FREQ_INFO: Get the current frequency.
> >
> > CMD_SET_FREQ_INFO: Set the target frequency.
> >
> > In future we will add automatic frequency scaling, which is similar to
> > Intel's HWP (HardWare P-State).
> >
> > Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
> > Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx
>
> Hi Huacai,
>
> I got some error with the driver enabled:
>
> [ 6.650403] BUG: using smp_processor_id() in preemptible [00000000] code: (udev-worker)/208
> [ 6.658719] caller is loongson3_cpufreq_probe+0x5c/0x250 [loongson3_cpufreq]
>
> and the driver failed to probe.
>
> It seems the caller of smp_processor_id is actually do_service_request,
> which is inlined into loongson3_cpufreq_probe.
Emm, it seems we should use raw_smp_processor_id() instead of
smp_processor_id(), but I don't know why we haven't met this problem.
Huacai
>
> The .config file is attached.
>
> --
> Xi Ruoyao <xry111@xxxxxxxxxxx>
> School of Aerospace Science and Technology, Xidian University