diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2013-10-16 11:10:07 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-03-31 12:17:12 -0400 |
commit | d6d3c9afaab47418ab2d7f874fb8aeac1f067104 (patch) | |
tree | 9f3b27fad7b722ab15144e6a044c5d771d3e3d59 | |
parent | a2bec0784465d3e30eadc20b49c779fa77d42dad (diff) |
MIPS: MT: proc: Add support for printing VPE and TC ids
And there are more CPUs or configurations that want to provide special
per-CPU information in /proc/cpuinfo. So I think there needs to be a
hook mechanism, such as a notifier.
This is a first cut only; I need to think about what sort of looking
the notifier needs to have. But I'd appreciate testing on MT hardware!
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/6066/
-rw-r--r-- | arch/mips/include/asm/cpu-info.h | 21 | ||||
-rw-r--r-- | arch/mips/kernel/proc.c | 23 | ||||
-rw-r--r-- | arch/mips/kernel/smp-mt.c | 22 | ||||
-rw-r--r-- | arch/mips/kernel/smtc-proc.c | 23 |
4 files changed, 89 insertions, 0 deletions
diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h index 49953f717334..dc2135be2a3a 100644 --- a/arch/mips/include/asm/cpu-info.h +++ b/arch/mips/include/asm/cpu-info.h | |||
@@ -96,6 +96,27 @@ extern void cpu_report(void); | |||
96 | extern const char *__cpu_name[]; | 96 | extern const char *__cpu_name[]; |
97 | #define cpu_name_string() __cpu_name[smp_processor_id()] | 97 | #define cpu_name_string() __cpu_name[smp_processor_id()] |
98 | 98 | ||
99 | struct seq_file; | ||
100 | struct notifier_block; | ||
101 | |||
102 | extern int register_proc_cpuinfo_notifier(struct notifier_block *nb); | ||
103 | extern int proc_cpuinfo_notifier_call_chain(unsigned long val, void *v); | ||
104 | |||
105 | #define proc_cpuinfo_notifier(fn, pri) \ | ||
106 | ({ \ | ||
107 | static struct notifier_block fn##_nb = { \ | ||
108 | .notifier_call = fn, \ | ||
109 | .priority = pri \ | ||
110 | }; \ | ||
111 | \ | ||
112 | register_proc_cpuinfo_notifier(&fn##_nb); \ | ||
113 | }) | ||
114 | |||
115 | struct proc_cpuinfo_notifier_args { | ||
116 | struct seq_file *m; | ||
117 | unsigned long n; | ||
118 | }; | ||
119 | |||
99 | #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) | 120 | #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) |
100 | # define cpu_vpe_id(cpuinfo) ((cpuinfo)->vpe_id) | 121 | # define cpu_vpe_id(cpuinfo) ((cpuinfo)->vpe_id) |
101 | #else | 122 | #else |
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index f0df7fde37c5..e40971b51d2f 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c | |||
@@ -17,8 +17,24 @@ | |||
17 | 17 | ||
18 | unsigned int vced_count, vcei_count; | 18 | unsigned int vced_count, vcei_count; |
19 | 19 | ||
20 | /* | ||
21 | * * No lock; only written during early bootup by CPU 0. | ||
22 | * */ | ||
23 | static RAW_NOTIFIER_HEAD(proc_cpuinfo_chain); | ||
24 | |||
25 | int __ref register_proc_cpuinfo_notifier(struct notifier_block *nb) | ||
26 | { | ||
27 | return raw_notifier_chain_register(&proc_cpuinfo_chain, nb); | ||
28 | } | ||
29 | |||
30 | int proc_cpuinfo_notifier_call_chain(unsigned long val, void *v) | ||
31 | { | ||
32 | return raw_notifier_call_chain(&proc_cpuinfo_chain, val, v); | ||
33 | } | ||
34 | |||
20 | static int show_cpuinfo(struct seq_file *m, void *v) | 35 | static int show_cpuinfo(struct seq_file *m, void *v) |
21 | { | 36 | { |
37 | struct proc_cpuinfo_notifier_args proc_cpuinfo_notifier_args; | ||
22 | unsigned long n = (unsigned long) v - 1; | 38 | unsigned long n = (unsigned long) v - 1; |
23 | unsigned int version = cpu_data[n].processor_id; | 39 | unsigned int version = cpu_data[n].processor_id; |
24 | unsigned int fp_vers = cpu_data[n].fpu_id; | 40 | unsigned int fp_vers = cpu_data[n].fpu_id; |
@@ -120,6 +136,13 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
120 | cpu_has_vce ? "%u" : "not available"); | 136 | cpu_has_vce ? "%u" : "not available"); |
121 | seq_printf(m, fmt, 'D', vced_count); | 137 | seq_printf(m, fmt, 'D', vced_count); |
122 | seq_printf(m, fmt, 'I', vcei_count); | 138 | seq_printf(m, fmt, 'I', vcei_count); |
139 | |||
140 | proc_cpuinfo_notifier_args.m = m; | ||
141 | proc_cpuinfo_notifier_args.n = n; | ||
142 | |||
143 | raw_notifier_call_chain(&proc_cpuinfo_chain, 0, | ||
144 | &proc_cpuinfo_notifier_args); | ||
145 | |||
123 | seq_printf(m, "\n"); | 146 | seq_printf(m, "\n"); |
124 | 147 | ||
125 | return 0; | 148 | return 0; |
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c index 0fb8cefc9114..3378c452e5d7 100644 --- a/arch/mips/kernel/smp-mt.c +++ b/arch/mips/kernel/smp-mt.c | |||
@@ -313,3 +313,25 @@ struct plat_smp_ops vsmp_smp_ops = { | |||
313 | .smp_setup = vsmp_smp_setup, | 313 | .smp_setup = vsmp_smp_setup, |
314 | .prepare_cpus = vsmp_prepare_cpus, | 314 | .prepare_cpus = vsmp_prepare_cpus, |
315 | }; | 315 | }; |
316 | |||
317 | static int proc_cpuinfo_chain_call(struct notifier_block *nfb, | ||
318 | unsigned long action_unused, void *data) | ||
319 | { | ||
320 | struct proc_cpuinfo_notifier_args *pcn = data; | ||
321 | struct seq_file *m = pcn->m; | ||
322 | unsigned long n = pcn->n; | ||
323 | |||
324 | if (!cpu_has_mipsmt) | ||
325 | return NOTIFY_OK; | ||
326 | |||
327 | seq_printf(m, "VPE\t\t\t: %d\n", cpu_data[n].vpe_id); | ||
328 | |||
329 | return NOTIFY_OK; | ||
330 | } | ||
331 | |||
332 | static int __init proc_cpuinfo_notifier_init(void) | ||
333 | { | ||
334 | return proc_cpuinfo_notifier(proc_cpuinfo_chain_call, 0); | ||
335 | } | ||
336 | |||
337 | subsys_initcall(proc_cpuinfo_notifier_init); | ||
diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c index c10aa84c9fa9..38635a996cbf 100644 --- a/arch/mips/kernel/smtc-proc.c +++ b/arch/mips/kernel/smtc-proc.c | |||
@@ -77,3 +77,26 @@ void init_smtc_stats(void) | |||
77 | 77 | ||
78 | proc_create("smtc", 0444, NULL, &smtc_proc_fops); | 78 | proc_create("smtc", 0444, NULL, &smtc_proc_fops); |
79 | } | 79 | } |
80 | |||
81 | static int proc_cpuinfo_chain_call(struct notifier_block *nfb, | ||
82 | unsigned long action_unused, void *data) | ||
83 | { | ||
84 | struct proc_cpuinfo_notifier_args *pcn = data; | ||
85 | struct seq_file *m = pcn->m; | ||
86 | unsigned long n = pcn->n; | ||
87 | |||
88 | if (!cpu_has_mipsmt) | ||
89 | return NOTIFY_OK; | ||
90 | |||
91 | seq_printf(m, "VPE\t\t\t: %d\n", cpu_data[n].vpe_id); | ||
92 | seq_printf(m, "TC\t\t\t: %d\n", cpu_data[n].tc_id); | ||
93 | |||
94 | return NOTIFY_OK; | ||
95 | } | ||
96 | |||
97 | static int __init proc_cpuinfo_notifier_init(void) | ||
98 | { | ||
99 | return proc_cpuinfo_notifier(proc_cpuinfo_chain_call, 0); | ||
100 | } | ||
101 | |||
102 | subsys_initcall(proc_cpuinfo_notifier_init); | ||