Skip to contentSkip to conversation

MIPS: Fix build for LTS kernel caused by backporting lpj adjustment

PATCH In review Huacai Chen 5 participants 7 messages Jul 16, 2020 – Jul 20, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Fix build for LTS kernel caused by backporting lpj adjustment

Commit ed26aacfb5f71eecb20a ("mips: Add udelay lpj numbers adjustment") has backported to 4.4~5.4, but the "struct cpufreq_freqs" (and also the cpufreq notifier machanism) of 4.4~4.19 are different from the upstream kernel. These differences cause build errors, and this patch can fix the build.

Cc Serge Semin <[email protected]>
Cc Stable <[email protected]> # 4.4/4.9/4.14/4.19
---
 arch/mips/kernel/time.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
arch/mips/kernel/time.c +4 -9
index b7f7e08..b15ee12 100644
@@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq;
 static int cpufreq_callback(struct notifier_block *nb,
 			    unsigned long val, void *data)
 {
-	struct cpufreq_freqs *freq = data;
-	struct cpumask *cpus = freq->policy->cpus;
-	unsigned long lpj;
 	int cpu;
+	struct cpufreq_freqs *freq = data;
 
 	/*
 	 * Skip lpj numbers adjustment if the CPU-freq transition is safe for
@@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb,
 		}
 	}
 
+	cpu = freq->cpu;
 	/*
 	 * Adjust global lpj variable and per-CPU udelay_val number in
 	 * accordance with the new CPU frequency.
@@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb,
 						glb_lpj_ref_freq,
 						freq->new);
 
-		for_each_cpu(cpu, cpus) {
-			lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
-					    per_cpu(pcp_lpj_ref_freq, cpu),
-					    freq->new);
-			cpu_data[cpu].udelay_val = (unsigned int)lpj;
-		}
+		cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
+					   per_cpu(pcp_lpj_ref_freq, cpu), freq->new);
 	}
 
 	return NOTIFY_OK;
Signature · 1 line
2.7.0
#1 lore raw

Hi, Serge,

Could you please have a look at this patch?

Huacai

Quoted 56 lines · Huacai Chen

Commit ed26aacfb5f71eecb20a ("mips: Add udelay lpj numbers adjustment") has backported to 4.4~5.4, but the "struct cpufreq_freqs" (and also the cpufreq notifier machanism) of 4.4~4.19 are different from the upstream kernel. These differences cause build errors, and this patch can fix the build.

Cc Serge Semin <[email protected]>
Cc Stable <[email protected]> # 4.4/4.9/4.14/4.19
---
 arch/mips/kernel/time.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
arch/mips/kernel/time.c +4 -10
index b7f7e08..b15ee12 100644
@@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq;
 static int cpufreq_callback(struct notifier_block *nb,
                            unsigned long val, void *data)
 {
-       struct cpufreq_freqs *freq = data;
-       struct cpumask *cpus = freq->policy->cpus;
-       unsigned long lpj;
        int cpu;
+       struct cpufreq_freqs *freq = data;
 
        /*
         * Skip lpj numbers adjustment if the CPU-freq transition is safe for
@@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb,
                }
        }
 
+       cpu = freq->cpu;
        /*
         * Adjust global lpj variable and per-CPU udelay_val number in
         * accordance with the new CPU frequency.
@@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb,
                                                glb_lpj_ref_freq,
                                                freq->new);
 
-               for_each_cpu(cpu, cpus) {
-                       lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
-                                           per_cpu(pcp_lpj_ref_freq, cpu),
-                                           freq->new);
-                       cpu_data[cpu].udelay_val = (unsigned int)lpj;
-               }
+               cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
+                                          per_cpu(pcp_lpj_ref_freq, cpu), freq->new);
        }
 
        return NOTIFY_OK;
--

2.7.0

#2 lore raw
Quoted 3 lines · Huacai Chen

Hi, Serge,

Could you please have a look at this patch?

+ Gregkh

This is urgent for next stable release, please take a look.

Thanks

Quoted 59 lines

Huacai

Quoted 55 lines · Huacai Chen

Commit ed26aacfb5f71eecb20a ("mips: Add udelay lpj numbers adjustment") has backported to 4.4~5.4, but the "struct cpufreq_freqs" (and also the cpufreq notifier machanism) of 4.4~4.19 are different from the upstream kernel. These differences cause build errors, and this patch can fix the build.

Cc Serge Semin <[email protected]>
Cc Stable <[email protected]> # 4.4/4.9/4.14/4.19
---
  arch/mips/kernel/time.c | 13 ++++---------
  1 file changed, 4 insertions(+), 9 deletions(-)
arch/mips/kernel/time.c +4 -10
index b7f7e08..b15ee12 100644
@@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq;
  static int cpufreq_callback(struct notifier_block *nb,
                             unsigned long val, void *data)
  {
-       struct cpufreq_freqs *freq = data;
-       struct cpumask *cpus = freq->policy->cpus;
-       unsigned long lpj;
         int cpu;
+       struct cpufreq_freqs *freq = data;
 
         /*
          * Skip lpj numbers adjustment if the CPU-freq transition is safe for
@@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb,
                 }
         }
 
+       cpu = freq->cpu;
         /*
          * Adjust global lpj variable and per-CPU udelay_val number in
          * accordance with the new CPU frequency.
@@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb,
                                                 glb_lpj_ref_freq,
                                                 freq->new);
 
-               for_each_cpu(cpu, cpus) {
-                       lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
-                                           per_cpu(pcp_lpj_ref_freq, cpu),
-                                           freq->new);
-                       cpu_data[cpu].udelay_val = (unsigned int)lpj;
-               }
+               cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
+                                          per_cpu(pcp_lpj_ref_freq, cpu), freq->new);
         }
 
         return NOTIFY_OK;
--

2.7.0

maintainer
#3 lore raw
Quoted 10 lines · Jiaxun Yang
Quoted 3 lines · Huacai Chen

Hi, Serge,

Could you please have a look at this patch?

+ Gregkh

This is urgent for next stable release, please take a look.

Relax, it was only sent 3 days ago, we will get to this...

Also, why was this not caught by any of the testing systems that we have? That might be good to determine so we don't mess up again in the future.

thanks,

greg k-h

#4 lore raw

Hi, Greg,

Quoted 11 lines · Greg KH
Quoted 9 lines · Jiaxun Yang
Quoted 3 lines · Huacai Chen

Hi, Serge,

Could you please have a look at this patch?

+ Gregkh

Quoted 7 lines
Quoted 1 line

This is urgent for next stable release, please take a look.

Relax, it was only sent 3 days ago, we will get to this...

Also, why was this not caught by any of the testing systems that we have? That might be good to determine so we don't mess up again in the future.

I think that is because CPUFREQ is disabled by default on MIPS.

Huacai

Quoted 4 lines

thanks,

greg k-h

#5 lore raw
Quoted 13 lines · Huacai Chen

Hi, Greg,

Quoted 10 lines · Greg KH
Quoted 8 lines · Jiaxun Yang
Quoted 3 lines · Huacai Chen

Hi, Serge,

Could you please have a look at this patch?

+ Gregkh

This is urgent for next stable release, please take a look.

Relax, it was only sent 3 days ago, we will get to this...

Ahh, sorry for the rush~

Quoted 5 lines
Quoted 4 lines

Also, why was this not caught by any of the testing systems that we have? That might be good to determine so we don't mess up again in the future.

I think that is because CPUFREQ is disabled by default on MIPS.

Yeah, I'm working with kernel-ci to get more config covered.

Thanks.

- Jiaxun

Quoted 6 lines

Huacai

Quoted 3 lines

thanks,

greg k-h

Reviewed-by on v1 1/1
#6 lore raw
In reply to Huacai Chen

Hello Huacai,

Thanks for the fix. The patch looks good to me except a small cleanup comment.

Quoted 18 lines · Huacai Chen

Commit ed26aacfb5f71eecb20a ("mips: Add udelay lpj numbers adjustment") has backported to 4.4~5.4, but the "struct cpufreq_freqs" (and also the cpufreq notifier machanism) of 4.4~4.19 are different from the upstream kernel. These differences cause build errors, and this patch can fix the build.

Cc Serge Semin <[email protected]>
Cc Stable <[email protected]> # 4.4/4.9/4.14/4.19
---
 arch/mips/kernel/time.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
arch/mips/kernel/time.c +0 -0
index b7f7e08..b15ee12 100644

arch/mips/kernel/time.c static unsigned long glb_lpj_ref_freq; · line 44

Quoted 8 lines
arch/mips/kernel/time.c +1 -3
@@ -40,10 +40,8 @@ static unsigned long glb_lpj_ref_freq;
 static int cpufreq_callback(struct notifier_block *nb,
 			    unsigned long val, void *data)
 {
-	struct cpufreq_freqs *freq = data;
-	struct cpumask *cpus = freq->policy->cpus;
-	unsigned long lpj;
 	int cpu;
+	struct cpufreq_freqs *freq = data;

Why do you want to rearrange the cpu and freq variables declarations? IMO the order should be left as before since the change doesn't really make the code looking or working any better. If so the change is unneeded. Moreover reverse xmas tree-like variables declaration looks neater than any other.

After fixing that feel free to add

-Sergey

Quoted 29 lines
arch/mips/kernel/time.c +3 -6
 	/*
 	 * Skip lpj numbers adjustment if the CPU-freq transition is safe for
@@ -64,6 +62,7 @@ static int cpufreq_callback(struct notifier_block *nb,
 		}
 	}
 
+	cpu = freq->cpu;
 	/*
 	 * Adjust global lpj variable and per-CPU udelay_val number in
 	 * accordance with the new CPU frequency.
@@ -74,12 +73,8 @@ static int cpufreq_callback(struct notifier_block *nb,
 						glb_lpj_ref_freq,
 						freq->new);
 
-		for_each_cpu(cpu, cpus) {
-			lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
-					    per_cpu(pcp_lpj_ref_freq, cpu),
-					    freq->new);
-			cpu_data[cpu].udelay_val = (unsigned int)lpj;
-		}
+		cpu_data[cpu].udelay_val = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
+					   per_cpu(pcp_lpj_ref_freq, cpu), freq->new);
 	}
 
 	return NOTIFY_OK;
Signature · 1 line
2.7.0