aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/Kconfig14
-rw-r--r--arch/mips/kernel/proc.c1
-rw-r--r--arch/mips/kernel/smp-mt.c6
-rw-r--r--arch/mips/kernel/smp.c30
-rw-r--r--include/asm-mips/cpu-info.h5
-rw-r--r--include/asm-mips/smp.h3
-rw-r--r--include/asm-mips/topology.h16
7 files changed, 73 insertions, 2 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 11bc17ce0ebf..d5a89f3fdfd3 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1442,6 +1442,7 @@ config MIPS_MT_SMP
1442 select MIPS_MT 1442 select MIPS_MT
1443 select NR_CPUS_DEFAULT_2 1443 select NR_CPUS_DEFAULT_2
1444 select SMP 1444 select SMP
1445 select SYS_SUPPORTS_SCHED_SMT if SMP
1445 select SYS_SUPPORTS_SMP 1446 select SYS_SUPPORTS_SMP
1446 help 1447 help
1447 This is a kernel model which is also known a VSMP or lately 1448 This is a kernel model which is also known a VSMP or lately
@@ -1468,6 +1469,19 @@ endchoice
1468config MIPS_MT 1469config MIPS_MT
1469 bool 1470 bool
1470 1471
1472config SCHED_SMT
1473 bool "SMT (multithreading) scheduler support"
1474 depends on SYS_SUPPORTS_SCHED_SMT
1475 default n
1476 help
1477 SMT scheduler support improves the CPU scheduler's decision making
1478 when dealing with MIPS MT enabled cores at a cost of slightly
1479 increased overhead in some places. If unsure say N here.
1480
1481config SYS_SUPPORTS_SCHED_SMT
1482 bool
1483
1484
1471config SYS_SUPPORTS_MULTITHREADING 1485config SYS_SUPPORTS_MULTITHREADING
1472 bool 1486 bool
1473 1487
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index 6e6e947cce1e..34dd22838fdb 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -62,6 +62,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
62 ); 62 );
63 seq_printf(m, "shadow register sets\t: %d\n", 63 seq_printf(m, "shadow register sets\t: %d\n",
64 cpu_data[n].srsets); 64 cpu_data[n].srsets);
65 seq_printf(m, "core\t\t\t: %d\n", cpu_data[n].core);
65 66
66 sprintf(fmt, "VCE%%c exceptions\t\t: %s\n", 67 sprintf(fmt, "VCE%%c exceptions\t\t: %s\n",
67 cpu_has_vce ? "%u" : "not available"); 68 cpu_has_vce ? "%u" : "not available");
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 94e210cc6cb6..2ab0b7eeaa7e 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -22,6 +22,7 @@
22#include <linux/cpumask.h> 22#include <linux/cpumask.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/smp.h>
25 26
26#include <asm/atomic.h> 27#include <asm/atomic.h>
27#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
@@ -30,7 +31,6 @@
30#include <asm/system.h> 31#include <asm/system.h>
31#include <asm/hardirq.h> 32#include <asm/hardirq.h>
32#include <asm/mmu_context.h> 33#include <asm/mmu_context.h>
33#include <asm/smp.h>
34#include <asm/time.h> 34#include <asm/time.h>
35#include <asm/mipsregs.h> 35#include <asm/mipsregs.h>
36#include <asm/mipsmtregs.h> 36#include <asm/mipsmtregs.h>
@@ -223,6 +223,7 @@ static void __init smp_tc_init(unsigned int tc, unsigned int mvpconf0)
223void __init plat_smp_setup(void) 223void __init plat_smp_setup(void)
224{ 224{
225 unsigned int mvpconf0, ntc, tc, ncpu = 0; 225 unsigned int mvpconf0, ntc, tc, ncpu = 0;
226 unsigned int nvpe;
226 227
227#ifdef CONFIG_MIPS_MT_FPAFF 228#ifdef CONFIG_MIPS_MT_FPAFF
228 /* If we have an FPU, enroll ourselves in the FPU-full mask */ 229 /* If we have an FPU, enroll ourselves in the FPU-full mask */
@@ -242,6 +243,9 @@ void __init plat_smp_setup(void)
242 mvpconf0 = read_c0_mvpconf0(); 243 mvpconf0 = read_c0_mvpconf0();
243 ntc = (mvpconf0 & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT; 244 ntc = (mvpconf0 & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT;
244 245
246 nvpe = ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1;
247 smp_num_siblings = nvpe;
248
245 /* we'll always have more TC's than VPE's, so loop setting everything 249 /* we'll always have more TC's than VPE's, so loop setting everything
246 to a sensible state */ 250 to a sensible state */
247 for (tc = 0; tc <= ntc; tc++) { 251 for (tc = 0; tc <= ntc; tc++) {
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 63989e9df4f9..335be9bcf0dc 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -56,6 +56,34 @@ EXPORT_SYMBOL(cpu_online_map);
56extern void __init calibrate_delay(void); 56extern void __init calibrate_delay(void);
57extern void cpu_idle(void); 57extern void cpu_idle(void);
58 58
59/* Number of TCs (or siblings in Intel speak) per CPU core */
60int smp_num_siblings = 1;
61EXPORT_SYMBOL(smp_num_siblings);
62
63/* representing the TCs (or siblings in Intel speak) of each logical CPU */
64cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
65EXPORT_SYMBOL(cpu_sibling_map);
66
67/* representing cpus for which sibling maps can be computed */
68static cpumask_t cpu_sibling_setup_map;
69
70static inline void set_cpu_sibling_map(int cpu)
71{
72 int i;
73
74 cpu_set(cpu, cpu_sibling_setup_map);
75
76 if (smp_num_siblings > 1) {
77 for_each_cpu_mask(i, cpu_sibling_setup_map) {
78 if (cpu_data[cpu].core == cpu_data[i].core) {
79 cpu_set(i, cpu_sibling_map[cpu]);
80 cpu_set(cpu, cpu_sibling_map[i]);
81 }
82 }
83 } else
84 cpu_set(cpu, cpu_sibling_map[cpu]);
85}
86
59/* 87/*
60 * First C code run on the secondary CPUs after being started up by 88 * First C code run on the secondary CPUs after being started up by
61 * the master. 89 * the master.
@@ -85,6 +113,7 @@ asmlinkage __cpuinit void start_secondary(void)
85 cpu_data[cpu].udelay_val = loops_per_jiffy; 113 cpu_data[cpu].udelay_val = loops_per_jiffy;
86 114
87 prom_smp_finish(); 115 prom_smp_finish();
116 set_cpu_sibling_map(cpu);
88 117
89 cpu_set(cpu, cpu_callin_map); 118 cpu_set(cpu, cpu_callin_map);
90 119
@@ -258,6 +287,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
258 init_new_context(current, &init_mm); 287 init_new_context(current, &init_mm);
259 current_thread_info()->cpu = 0; 288 current_thread_info()->cpu = 0;
260 plat_prepare_cpus(max_cpus); 289 plat_prepare_cpus(max_cpus);
290 set_cpu_sibling_map(0);
261#ifndef CONFIG_HOTPLUG_CPU 291#ifndef CONFIG_HOTPLUG_CPU
262 cpu_present_map = cpu_possible_map; 292 cpu_present_map = cpu_possible_map;
263#endif 293#endif
diff --git a/include/asm-mips/cpu-info.h b/include/asm-mips/cpu-info.h
index ed5c02c6afbb..0c5a358863f3 100644
--- a/include/asm-mips/cpu-info.h
+++ b/include/asm-mips/cpu-info.h
@@ -55,6 +55,7 @@ struct cpuinfo_mips {
55 struct cache_desc scache; /* Secondary cache */ 55 struct cache_desc scache; /* Secondary cache */
56 struct cache_desc tcache; /* Tertiary/split secondary cache */ 56 struct cache_desc tcache; /* Tertiary/split secondary cache */
57 int srsets; /* Shadow register sets */ 57 int srsets; /* Shadow register sets */
58 int core; /* physical core number */
58#if defined(CONFIG_MIPS_MT_SMTC) 59#if defined(CONFIG_MIPS_MT_SMTC)
59 /* 60 /*
60 * In the MIPS MT "SMTC" model, each TC is considered 61 * In the MIPS MT "SMTC" model, each TC is considered
@@ -63,8 +64,10 @@ struct cpuinfo_mips {
63 * to all TCs within the same VPE. 64 * to all TCs within the same VPE.
64 */ 65 */
65 int vpe_id; /* Virtual Processor number */ 66 int vpe_id; /* Virtual Processor number */
66 int tc_id; /* Thread Context number */
67#endif /* CONFIG_MIPS_MT */ 67#endif /* CONFIG_MIPS_MT */
68#ifdef CONFIG_MIPS_MT_SMTC
69 int tc_id; /* Thread Context number */
70#endif
68 void *data; /* Additional data */ 71 void *data; /* Additional data */
69} __attribute__((aligned(SMP_CACHE_BYTES))); 72} __attribute__((aligned(SMP_CACHE_BYTES)));
70 73
diff --git a/include/asm-mips/smp.h b/include/asm-mips/smp.h
index dc770025a9b0..23265879cee9 100644
--- a/include/asm-mips/smp.h
+++ b/include/asm-mips/smp.h
@@ -20,6 +20,9 @@
20#include <linux/cpumask.h> 20#include <linux/cpumask.h>
21#include <asm/atomic.h> 21#include <asm/atomic.h>
22 22
23extern int smp_num_siblings;
24extern cpumask_t cpu_sibling_map[];
25
23#define raw_smp_processor_id() (current_thread_info()->cpu) 26#define raw_smp_processor_id() (current_thread_info()->cpu)
24 27
25/* Map from cpu id to sequential logical cpu number. This will only 28/* Map from cpu id to sequential logical cpu number. This will only
diff --git a/include/asm-mips/topology.h b/include/asm-mips/topology.h
index 0440fb9f2180..259145e07e97 100644
--- a/include/asm-mips/topology.h
+++ b/include/asm-mips/topology.h
@@ -1 +1,17 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_TOPOLOGY_H
9#define __ASM_TOPOLOGY_H
10
1#include <topology.h> 11#include <topology.h>
12
13#ifdef CONFIG_SMP
14#define smt_capable() (smp_num_siblings > 1)
15#endif
16
17#endif /* __ASM_TOPOLOGY_H */