mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
@ 2024-08-28  6:24 Huacai Chen
  2024-08-28 11:59 ` Xi Ruoyao
  2024-09-03  9:01 ` Viresh Kumar
  0 siblings, 2 replies; 6+ messages in thread
From: Huacai Chen @ 2024-08-28  6:24 UTC (permalink / raw)
  To: Rafael J . Wysocki, Viresh Kumar, Huacai Chen
  Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang,
	Huacai Chen, Xi Ruoyao, Binbin Zhou

Use raw_smp_processor_id() instead of plain smp_processor_id() in
do_service_request(), otherwise we may get some errors with the driver
enabled:

 BUG: using smp_processor_id() in preemptible [00000000] code: (udev-worker)/208
 caller is loongson3_cpufreq_probe+0x5c/0x250 [loongson3_cpufreq]

Reported-by: Xi Ruoyao <xry111@xry111.site>
Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 drivers/cpufreq/loongson3_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/loongson3_cpufreq.c b/drivers/cpufreq/loongson3_cpufreq.c
index 5f79b6de127c..6b5e6798d9a2 100644
--- a/drivers/cpufreq/loongson3_cpufreq.c
+++ b/drivers/cpufreq/loongson3_cpufreq.c
@@ -176,7 +176,7 @@ static DEFINE_PER_CPU(struct loongson3_freq_data *, freq_data);
 static inline int do_service_request(u32 id, u32 info, u32 cmd, u32 val, u32 extra)
 {
 	int retries;
-	unsigned int cpu = smp_processor_id();
+	unsigned int cpu = raw_smp_processor_id();
 	unsigned int package = cpu_data[cpu].package;
 	union smc_message msg, last;
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
  2024-08-28  6:24 [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request() Huacai Chen
@ 2024-08-28 11:59 ` Xi Ruoyao
  2024-08-28 13:55   ` Huacai Chen
  2024-09-03  9:01 ` Viresh Kumar
  1 sibling, 1 reply; 6+ messages in thread
From: Xi Ruoyao @ 2024-08-28 11:59 UTC (permalink / raw)
  To: Huacai Chen, Rafael J . Wysocki, Viresh Kumar, Huacai Chen
  Cc: loongarch, linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang, Binbin Zhou

On Wed, 2024-08-28 at 14:24 +0800, Huacai Chen wrote:
> Use raw_smp_processor_id() instead of plain smp_processor_id() in
> do_service_request(), otherwise we may get some errors with the driver
> enabled:
> 
>  BUG: using smp_processor_id() in preemptible [00000000] code: (udev-
> worker)/208
>  caller is loongson3_cpufreq_probe+0x5c/0x250 [loongson3_cpufreq]
> 
> Reported-by: Xi Ruoyao <xry111@xry111.site>
> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>

Tested-by: Xi Ruoyao <xry111@xry111.site>

After this patch the BUG() message is gone, but I still get

[    6.610357] loongson3_cpufreq loongson3_cpufreq: probe with driver loongson3_cpufreq failed with error -1

-1 is EPERM and there are several "return -EPERM;" in the code.  Not
sure which one.

Do I need to modify some firmware setting to make it work?

FWIW I'm building it as a module.  Should I try building it as a part of
vmlinux?

> ---
>  drivers/cpufreq/loongson3_cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/loongson3_cpufreq.c
> b/drivers/cpufreq/loongson3_cpufreq.c
> index 5f79b6de127c..6b5e6798d9a2 100644
> --- a/drivers/cpufreq/loongson3_cpufreq.c
> +++ b/drivers/cpufreq/loongson3_cpufreq.c
> @@ -176,7 +176,7 @@ static DEFINE_PER_CPU(struct loongson3_freq_data
> *, freq_data);
>  static inline int do_service_request(u32 id, u32 info, u32 cmd, u32
> val, u32 extra)
>  {
>  	int retries;
> -	unsigned int cpu = smp_processor_id();
> +	unsigned int cpu = raw_smp_processor_id();
>  	unsigned int package = cpu_data[cpu].package;
>  	union smc_message msg, last;
>  

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
  2024-08-28 11:59 ` Xi Ruoyao
@ 2024-08-28 13:55   ` Huacai Chen
  2024-08-29  7:33     ` Xi Ruoyao
  0 siblings, 1 reply; 6+ messages in thread
From: Huacai Chen @ 2024-08-28 13:55 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: Huacai Chen, Rafael J . Wysocki, Viresh Kumar, loongarch,
	linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang, Binbin Zhou

On Wed, Aug 28, 2024 at 7:59 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Wed, 2024-08-28 at 14:24 +0800, Huacai Chen wrote:
> > Use raw_smp_processor_id() instead of plain smp_processor_id() in
> > do_service_request(), otherwise we may get some errors with the driver
> > enabled:
> >
> >  BUG: using smp_processor_id() in preemptible [00000000] code: (udev-
> > worker)/208
> >  caller is loongson3_cpufreq_probe+0x5c/0x250 [loongson3_cpufreq]
> >
> > Reported-by: Xi Ruoyao <xry111@xry111.site>
> > Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>
> Tested-by: Xi Ruoyao <xry111@xry111.site>
>
> After this patch the BUG() message is gone, but I still get
>
> [    6.610357] loongson3_cpufreq loongson3_cpufreq: probe with driver loongson3_cpufreq failed with error -1
>
> -1 is EPERM and there are several "return -EPERM;" in the code.  Not
> sure which one.
>
> Do I need to modify some firmware setting to make it work?
You should update your firmware.

>
> FWIW I'm building it as a module.  Should I try building it as a part of
> vmlinux?
No need.

Huacai

>
> > ---
> >  drivers/cpufreq/loongson3_cpufreq.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/loongson3_cpufreq.c
> > b/drivers/cpufreq/loongson3_cpufreq.c
> > index 5f79b6de127c..6b5e6798d9a2 100644
> > --- a/drivers/cpufreq/loongson3_cpufreq.c
> > +++ b/drivers/cpufreq/loongson3_cpufreq.c
> > @@ -176,7 +176,7 @@ static DEFINE_PER_CPU(struct loongson3_freq_data
> > *, freq_data);
> >  static inline int do_service_request(u32 id, u32 info, u32 cmd, u32
> > val, u32 extra)
> >  {
> >       int retries;
> > -     unsigned int cpu = smp_processor_id();
> > +     unsigned int cpu = raw_smp_processor_id();
> >       unsigned int package = cpu_data[cpu].package;
> >       union smc_message msg, last;
> >
>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
  2024-08-28 13:55   ` Huacai Chen
@ 2024-08-29  7:33     ` Xi Ruoyao
  2024-08-29  8:34       ` Huacai Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Xi Ruoyao @ 2024-08-29  7:33 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, Rafael J . Wysocki, Viresh Kumar, loongarch,
	linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang, Binbin Zhou

On Wed, 2024-08-28 at 21:55 +0800, Huacai Chen wrote:
> > Do I need to modify some firmware setting to make it work?
> You should update your firmware.

I've already updated to UDK2018-3A6000-
7A2000_EVB_V4.0.05756_prestable2405_0523dbg.fd on a XA61200 before
trying CPUFreq.

And I also tried enabling DVFS in the firmware setting, and disabling
the overclocking.  Both didn't work.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
  2024-08-29  7:33     ` Xi Ruoyao
@ 2024-08-29  8:34       ` Huacai Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Huacai Chen @ 2024-08-29  8:34 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: Huacai Chen, Rafael J . Wysocki, Viresh Kumar, loongarch,
	linux-pm, linux-kernel, Xuerui Wang, Jiaxun Yang, Binbin Zhou

On Thu, Aug 29, 2024 at 3:33 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Wed, 2024-08-28 at 21:55 +0800, Huacai Chen wrote:
> > > Do I need to modify some firmware setting to make it work?
> > You should update your firmware.
>
> I've already updated to UDK2018-3A6000-
> 7A2000_EVB_V4.0.05756_prestable2405_0523dbg.fd on a XA61200 before
> trying CPUFreq.
>
> And I also tried enabling DVFS in the firmware setting, and disabling
> the overclocking.  Both didn't work.
Hmm, current firmware with DVFS can only cooperate with the old
CPUFreq driver in old-world kernels. New firmware which can cooperate
with the upstream CPUFreq driver hasn't been released yet.

Huacai

>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request()
  2024-08-28  6:24 [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request() Huacai Chen
  2024-08-28 11:59 ` Xi Ruoyao
@ 2024-09-03  9:01 ` Viresh Kumar
  1 sibling, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2024-09-03  9:01 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Rafael J . Wysocki, Huacai Chen, loongarch, linux-pm,
	linux-kernel, Xuerui Wang, Jiaxun Yang, Xi Ruoyao, Binbin Zhou

On 28-08-24, 14:24, Huacai Chen wrote:
> Use raw_smp_processor_id() instead of plain smp_processor_id() in
> do_service_request(), otherwise we may get some errors with the driver
> enabled:
> 
>  BUG: using smp_processor_id() in preemptible [00000000] code: (udev-worker)/208
>  caller is loongson3_cpufreq_probe+0x5c/0x250 [loongson3_cpufreq]
> 
> Reported-by: Xi Ruoyao <xry111@xry111.site>
> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  drivers/cpufreq/loongson3_cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-03  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-28  6:24 [PATCH] cpufreq: loongson3: Use raw_smp_processor_id() in do_service_request() Huacai Chen
2024-08-28 11:59 ` Xi Ruoyao
2024-08-28 13:55   ` Huacai Chen
2024-08-29  7:33     ` Xi Ruoyao
2024-08-29  8:34       ` Huacai Chen
2024-09-03  9:01 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®