Skip to contentSkip to conversation

adjust cpufreq uses of LOONGSON_CHIPCFG

PATCH In review Alexandre Oliva 4 participants 5 messages Jan 18, 2020 – Jan 22, 2020

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

PATCH 1/1 adjust cpufreq uses of LOONGSON_CHIPCFG

The post-fork cleanup of loongson2ef from loongson64 changed LOONGSON_CHIPCFG from a single-argument functional macro to a non-functional macro with an mmio address in loongson2ef, but loongson2_cpufreq still uses the notation of a functional macro call expecting it to be an lvalue. Fixed based on loongson_suspend_enter.

---
 drivers/cpufreq/loongson2_cpufreq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +5 -3
index 84f0eee..ace2d46 100644
@@ -144,9 +144,11 @@ static void loongson2_cpu_wait(void)
 	u32 cpu_freq;
 
 	spin_lock_irqsave(&loongson2_wait_lock, flags);
-	cpu_freq = LOONGSON_CHIPCFG(0);
-	LOONGSON_CHIPCFG(0) &= ~0x7;	/* Put CPU into wait mode */
-	LOONGSON_CHIPCFG(0) = cpu_freq;	/* Restore CPU state */
+	cpu_freq = readl(LOONGSON_CHIPCFG);
+	/* Put CPU into wait mode */
+	writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
+	/* Restore CPU state */
+	writel(cpu_freq, LOONGSON_CHIPCFG);
 	spin_unlock_irqrestore(&loongson2_wait_lock, flags);
 	local_irq_enable();
 }
Signature · 8 lines
2.7.4


-- 
Alexandre Oliva, freedom fighter   he/him   https://FSFLA.org/blogs/lxo
Free Software Evangelist           Stallman was right, but he's left :(
GNU Toolchain Engineer    FSMatrix: It was he who freed the first of us
FSF & FSFLA board member                The Savior shall return (true);
#1 lore raw

Hi Alexandre,

Quoted 11 lines · Alexandre Oliva

The post-fork cleanup of loongson2ef from loongson64 changed LOONGSON_CHIPCFG from a single-argument functional macro to a non-functional macro with an mmio address in loongson2ef, but loongson2_cpufreq still uses the notation of a functional macro call expecting it to be an lvalue. Fixed based on loongson_suspend_enter.

This patch looks good to me, but you need to copy the cpufreq maintainers:

$ ./scripts/get_maintainer.pl -f drivers/cpufreq/loongson2_cpufreq.c
Jiaxun Yang <[email protected]> (maintainer:MIPS/LOONGSON2EF ARCHITECTURE)
"Rafael J. Wysocki" <[email protected]> (maintainer:CPU FREQUENCY SCALING FRAMEWORK)
Viresh Kumar <[email protected]> (maintainer:CPU FREQUENCY SCALING FRAMEWORK)
[email protected] (open list:MIPS/LOONGSON2EF ARCHITECTURE)
[email protected] (open list:CPU FREQUENCY SCALING FRAMEWORK)
[email protected] (open list)

I've CC'd them now, but they might want the patch resending.

Thanks,
Paul

Quoted 32 lines
---
 drivers/cpufreq/loongson2_cpufreq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +5 -3
index 84f0eee..ace2d46 100644
@@ -144,9 +144,11 @@ static void loongson2_cpu_wait(void)
 	u32 cpu_freq;
 
 	spin_lock_irqsave(&loongson2_wait_lock, flags);
-	cpu_freq = LOONGSON_CHIPCFG(0);
-	LOONGSON_CHIPCFG(0) &= ~0x7;	/* Put CPU into wait mode */
-	LOONGSON_CHIPCFG(0) = cpu_freq;	/* Restore CPU state */
+	cpu_freq = readl(LOONGSON_CHIPCFG);
+	/* Put CPU into wait mode */
+	writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
+	/* Restore CPU state */
+	writel(cpu_freq, LOONGSON_CHIPCFG);
 	spin_unlock_irqrestore(&loongson2_wait_lock, flags);
 	local_irq_enable();
 }
Signature · 8 lines
2.7.4


-- 
Alexandre Oliva, freedom fighter   he/him   https://FSFLA.org/blogs/lxo
Free Software Evangelist           Stallman was right, but he's left :(
GNU Toolchain Engineer    FSMatrix: It was he who freed the first of us
FSF & FSFLA board member                The Savior shall return (true);
maintainer Acked-by
#2 lore raw
Quoted 42 lines · Paul Burton

Hi Alexandre,

Quoted 11 lines · Alexandre Oliva

The post-fork cleanup of loongson2ef from loongson64 changed LOONGSON_CHIPCFG from a single-argument functional macro to a non-functional macro with an mmio address in loongson2ef, but loongson2_cpufreq still uses the notation of a functional macro call expecting it to be an lvalue. Fixed based on loongson_suspend_enter.

This patch looks good to me, but you need to copy the cpufreq maintainers:

$ ./scripts/get_maintainer.pl -f drivers/cpufreq/loongson2_cpufreq.c
Jiaxun Yang <[email protected]> (maintainer:MIPS/LOONGSON2EF ARCHITECTURE)
"Rafael J. Wysocki" <[email protected]> (maintainer:CPU FREQUENCY SCALING FRAMEWORK)
Viresh Kumar <[email protected]> (maintainer:CPU FREQUENCY SCALING FRAMEWORK)
[email protected] (open list:MIPS/LOONGSON2EF ARCHITECTURE)
[email protected] (open list:CPU FREQUENCY SCALING FRAMEWORK)
[email protected] (open list)

I've CC'd them now, but they might want the patch resending.

Thanks,
Paul

Quoted 11 lines
---
 drivers/cpufreq/loongson2_cpufreq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +0 -0
index 84f0eee..ace2d46 100644
@@ -144,9 +144,11 @@ static void loongson2_cpu_wait(void)
 	u32 cpu_freq;
 
Quoted 12 lines

drivers/cpufreq/loongson2_cpufreq.c static void loongson2_cpu_wait(void) · line 154

Quoted 12 lines
drivers/cpufreq/loongson2_cpufreq.c +5 -3
 	spin_lock_irqsave(&loongson2_wait_lock, flags);
-	cpu_freq = LOONGSON_CHIPCFG(0);
-	LOONGSON_CHIPCFG(0) &= ~0x7;	/* Put CPU into wait mode */
-	LOONGSON_CHIPCFG(0) = cpu_freq;	/* Restore CPU state */
+	cpu_freq = readl(LOONGSON_CHIPCFG);
+	/* Put CPU into wait mode */
+	writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
+	/* Restore CPU state */
+	writel(cpu_freq, LOONGSON_CHIPCFG);
 	spin_unlock_irqrestore(&loongson2_wait_lock, flags);
 	local_irq_enable();
 }

Please resend it and add my

Signature · 1 line
viresh
#3 lore raw

PATCH 1/1 adjust cpufreq uses of LOONGSON_CHIPCFG

The post-fork cleanup of loongson2ef from loongson64 changed LOONGSON_CHIPCFG from a single-argument functional macro to a non-functional macro with an mmio address in loongson2ef, but loongson2_cpufreq still uses the notation of a functional macro call expecting it to be an lvalue. Fixed based on loongson_suspend_enter.

---
 drivers/cpufreq/loongson2_cpufreq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +5 -3
index 84f0eee..ace2d46 100644
@@ -144,9 +144,11 @@ static void loongson2_cpu_wait(void)
 	u32 cpu_freq;
 
 	spin_lock_irqsave(&loongson2_wait_lock, flags);
-	cpu_freq = LOONGSON_CHIPCFG(0);
-	LOONGSON_CHIPCFG(0) &= ~0x7;	/* Put CPU into wait mode */
-	LOONGSON_CHIPCFG(0) = cpu_freq;	/* Restore CPU state */
+	cpu_freq = readl(LOONGSON_CHIPCFG);
+	/* Put CPU into wait mode */
+	writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
+	/* Restore CPU state */
+	writel(cpu_freq, LOONGSON_CHIPCFG);
 	spin_unlock_irqrestore(&loongson2_wait_lock, flags);
 	local_irq_enable();
 }
Signature · 7 lines
2.7.4

-- 
Alexandre Oliva, freedom fighter   he/him   https://FSFLA.org/blogs/lxo
Free Software Evangelist           Stallman was right, but he's left :(
GNU Toolchain Engineer    FSMatrix: It was he who freed the first of us
FSF & FSFLA board member                The Savior shall return (true);
#4 lore raw
Quoted 7 lines · Alexandre Oliva

The post-fork cleanup of loongson2ef from loongson64 changed LOONGSON_CHIPCFG from a single-argument functional macro to a non-functional macro with an mmio address in loongson2ef, but loongson2_cpufreq still uses the notation of a functional macro call expecting it to be an lvalue. Fixed based on loongson_suspend_enter.

Quoted 5 lines

Queued up as 5.6 material under modified subject ("cpufreq:
loongson2_cpufreq: adjust cpufreq uses of LOONGSON_CHIPCFG"), thanks!

Quoted 31 lines
---
 drivers/cpufreq/loongson2_cpufreq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +5 -4
index 84f0eee..ace2d46 100644
@@ -144,9 +144,11 @@ static void loongson2_cpu_wait(void)
        u32 cpu_freq;
 
        spin_lock_irqsave(&loongson2_wait_lock, flags);
-       cpu_freq = LOONGSON_CHIPCFG(0);
-       LOONGSON_CHIPCFG(0) &= ~0x7;    /* Put CPU into wait mode */
-       LOONGSON_CHIPCFG(0) = cpu_freq; /* Restore CPU state */
+       cpu_freq = readl(LOONGSON_CHIPCFG);
+       /* Put CPU into wait mode */
+       writel(readl(LOONGSON_CHIPCFG) & ~0x7, LOONGSON_CHIPCFG);
+       /* Restore CPU state */
+       writel(cpu_freq, LOONGSON_CHIPCFG);
        spin_unlock_irqrestore(&loongson2_wait_lock, flags);
        local_irq_enable();
 }
--

2.7.4

--
Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo
Free Software Evangelist Stallman was right, but he's left :(
GNU Toolchain Engineer FSMatrix: It was he who freed the first of us
FSF & FSFLA board member The Savior shall return (true);