Skip to contentSkip to conversation

MIPS: Move CPU topology macros to topology.h

PATCH Superseded Huacai Chen 4 participants 9 messages Aug 8, 2014 – Aug 25, 2014 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 MIPS: Move CPU topology macros to topology.h

This fix macros redefinition problems for Netlogic.

Cc Jayachandran C. <[email protected]>
---
 arch/mips/include/asm/smp.h      |    5 -----
 arch/mips/include/asm/topology.h |   13 +++++++++++++
 2 files changed, 13 insertions(+), 5 deletions(-)
arch/mips/include/asm/smp.h +0 -5
index 1e0f20a..eacf865 100644
@@ -37,11 +37,6 @@ extern int __cpu_logical_map[NR_CPUS];
 
 #define NO_PROC_ID	(-1)
 
-#define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
-#define topology_core_id(cpu)			(cpu_data[cpu].core)
-#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
-#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
-
 #define SMP_RESCHEDULE_YOURSELF 0x1	/* XXX braindead */
 #define SMP_CALL_FUNCTION	0x2
 /* Octeon - Tell another core to flush its icache */
arch/mips/include/asm/topology.h +13 -0
index 20ea485..2a0f04b 100644
@@ -10,4 +10,17 @@
 
 #include <topology.h>
 
+#ifndef topology_physical_package_id
+#define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
+#endif
+#ifndef topology_core_id
+#define topology_core_id(cpu)			(cpu_data[cpu].core)
+#endif
+#ifndef topology_core_cpumask
+#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
+#endif
+#ifndef topology_thread_cpumask
+#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
+#endif
+
 #endif /* __ASM_TOPOLOGY_H */
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 2/2 MIPS: Loongson: Fix COP2 usage for preemptible kernel

In preemptible kernel, only TIF_USEDFPU flag is reliable to distinguish whether _init_fpu()/_restore_fp() is needed. Because the value of the CP0_Status.CU1 isn't changed during preemption.

---
 arch/mips/loongson/loongson-3/cop2-ex.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/loongson/loongson-3/cop2-ex.c +4 -4
index 9182e8d..c1e9503 100644
@@ -22,13 +22,13 @@
 static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
 	void *data)
 {
-	int fpu_enabled;
+	int fpu_owned;
 	int fr = !test_thread_flag(TIF_32BIT_FPREGS);
 
 	switch (action) {
 	case CU2_EXCEPTION:
 		preempt_disable();
-		fpu_enabled = read_c0_status() & ST0_CU1;
+		fpu_owned = __is_fpu_owner();
 		if (!fr)
 			set_c0_status(ST0_CU1 | ST0_CU2);
 		else
@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
 			KSTK_STATUS(current) |= ST0_FR;
 		else
 			KSTK_STATUS(current) &= ~ST0_FR;
-		/* If FPU is enabled, we needn't init or restore fp */
-		if(!fpu_enabled) {
+		/* If FPU is owned, we needn't init or restore fp */
+		if(!fpu_owned) {
 			set_thread_flag(TIF_USEDFPU);
 			if (!used_math()) {
 				_init_fpu();
Signature · 1 line
1.7.7.3
#2 lore raw

Re: [PATCH 2/2] MIPS: Loongson: Fix COP2 usage for preemptible kernel

Hello.

Quoted 13 lines · Huacai Chen

In preemptible kernel, only TIF_USEDFPU flag is reliable to distinguish whether _init_fpu()/_restore_fp() is needed. Because the value of the CP0_Status.CU1 isn't changed during preemption.

---
  arch/mips/loongson/loongson-3/cop2-ex.c |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
arch/mips/loongson/loongson-3/cop2-ex.c +0 -0
index 9182e8d..c1e9503 100644

[...]

arch/mips/loongson/loongson-3/cop2-ex.c static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action, · line 43

Quoted 8 lines
arch/mips/loongson/loongson-3/cop2-ex.c +2 -2
@@ -39,8 +39,8 @@ static int loongson_cu2_call(struct notifier_block *nfb, unsigned long action,
  			KSTK_STATUS(current) |= ST0_FR;
  		else
  			KSTK_STATUS(current) &= ~ST0_FR;
-		/* If FPU is enabled, we needn't init or restore fp */
-		if(!fpu_enabled) {
+		/* If FPU is owned, we needn't init or restore fp */
+		if(!fpu_owned) {

Space is needed after *if*, high time to fix this.

WBR, Sergei

#4 lore raw
Quoted 4 lines · Ralf Baechle

Jayachandran,

could you convert the netlogic platforms to use this scheme, too? We then could drop the #ifdefs introduced by this patch.

The same sequence is used by ip27 platform as well, so I think the ifndef may still be needed. This is the same ifndef pattern we use for all our mach-generic/*.h vs. mach-<platform>/*.h

On second thought, I am not sure if the changes in Huacai's patch has to be in asm/topology.h, probably this has to be in mach-generic/topology.h

JC.

#5 lore raw

Hi, Ralf,

Why this patch hasn't applied?

Huacai

Quoted 16 lines · Jayachandran C.
Quoted 4 lines · Ralf Baechle

Jayachandran,

could you convert the netlogic platforms to use this scheme, too? We then could drop the #ifdefs introduced by this patch.

The same sequence is used by ip27 platform as well, so I think the ifndef may still be needed. This is the same ifndef pattern we use for all our mach-generic/*.h vs. mach-<platform>/*.h

On second thought, I am not sure if the changes in Huacai's patch has to be in asm/topology.h, probably this has to be in mach-generic/topology.h

JC.

#6 lore raw

PATCH 1/2 MIPS: Netlogic: Use MIPS topology.h

commit bda4584cd943 ("MIPS: Support CPU topology files in sysfs") added topology related macros for all MIPS platforms. This causes compile failure for Netlogic platforms with errors like:

arch/mips/include/asm/mach-netlogic/topology.h:14:0: error: "topology_physical_package_id" redefined [-Werror]

Fix this by dropping Netlogic specific topology.h and setting up package field in cpu data.

---
[Resending this, looks like linux-mips.org is down]

 arch/mips/include/asm/mach-netlogic/topology.h |   22 ----------------------
 arch/mips/netlogic/common/smp.c                |    1 +
 2 files changed, 1 insertion(+), 22 deletions(-)
 delete mode 100644 arch/mips/include/asm/mach-netlogic/topology.h
arch/mips/include/asm/mach-netlogic/topology.h deleted +0 -22
deleted file mode 100644
index ceeb1f5..0000000
@@ -1,22 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2013 Broadcom Corporation
- */
-#ifndef _ASM_MACH_NETLOGIC_TOPOLOGY_H
-#define _ASM_MACH_NETLOGIC_TOPOLOGY_H
-
-#include <asm/mach-netlogic/multi-node.h>
-
-#ifdef CONFIG_SMP
-#define topology_physical_package_id(cpu)	cpu_to_node(cpu)
-#define topology_core_id(cpu)	(cpu_logical_map(cpu) / NLM_THREADS_PER_CORE)
-#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
-#define topology_core_cpumask(cpu)	cpumask_of_node(cpu_to_node(cpu))
-#endif
-
-#include <asm-generic/topology.h>
-
-#endif /* _ASM_MACH_NETLOGIC_TOPOLOGY_H */
arch/mips/netlogic/common/smp.c +1 -0
index 4fde7ac..f23fe22 100644
@@ -120,6 +120,7 @@ static void nlm_init_secondary(void)
 
 	hwtid = hard_smp_processor_id();
 	current_cpu_data.core = hwtid / NLM_THREADS_PER_CORE;
+	current_cpu_data.package = nlm_cpuid_to_node(hwtid);
 	nlm_percpu_init(hwtid);
 	nlm_smp_irq_init(hwtid);
 }
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 2/2 MIPS: Move topology macros to topology.h

commit bda4584cd943 ("MIPS: Support CPU topology files in sysfs") added MIPS topology related macros to asm/smp.h. Move these to asm/topology.h.

---
[Resending this, looks like linux-mips.org is down]

 arch/mips/include/asm/smp.h      |    5 -----
 arch/mips/include/asm/topology.h |    5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)
arch/mips/include/asm/smp.h +0 -5
index 1e0f20a..eacf865 100644
@@ -37,11 +37,6 @@ extern int __cpu_logical_map[NR_CPUS];
 
 #define NO_PROC_ID	(-1)
 
-#define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
-#define topology_core_id(cpu)			(cpu_data[cpu].core)
-#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
-#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
-
 #define SMP_RESCHEDULE_YOURSELF 0x1	/* XXX braindead */
 #define SMP_CALL_FUNCTION	0x2
 /* Octeon - Tell another core to flush its icache */
arch/mips/include/asm/topology.h +5 -0
index 20ea485..e012429 100644
@@ -10,4 +10,9 @@
 
 #include <topology.h>
 
+#define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
+#define topology_core_id(cpu)			(cpu_data[cpu].core)
+#define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
+#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
+
 #endif /* __ASM_TOPOLOGY_H */
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH 1/2] MIPS: Netlogic: Use MIPS topology.h

In reply to Jayachandran C
Quoted 8 lines · Jayachandran C

commit bda4584cd943 ("MIPS: Support CPU topology files in sysfs") added topology related macros for all MIPS platforms. This causes compile failure for Netlogic platforms with errors like:

arch/mips/include/asm/mach-netlogic/topology.h:14:0: error: "topology_physical_package_id" redefined [-Werror]

Fix this by dropping Netlogic specific topology.h and setting up package field in cpu data.

I've already applied Guenter Roeck's patch
https://patchwork.linux-mips.org/patch/7513/ as commit bbbf6d8768f5cac3523c408917083a111b1f3ffe [MIPS: Netlogic: Use MIPS topology.h] and the pull request for that one is out to Linus.

So if you think your solution is nicer, please send a followup patch,

Quoted 3 lines

---
[Resending this, looks like linux-mips.org is down]

Ironically the announcement of the new system also got affected by the email woes and only went out after resending it ... By now things should be all back to normal and I can't believe how much faster some operations such as git push have become!

Ralf