blob: 0e2887b6d09e2e8cb578ff8d9f50df7c2f4de94d [file] [log] [blame]
Martin Schwidefsky395d31d2008-12-25 13:39:50 +01001/*
2 * arch/s390/kernel/processor.c
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 */
7
8#define KMSG_COMPONENT "cpu"
9#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/smp.h>
14#include <linux/seq_file.h>
15#include <linux/delay.h>
Heiko Carstens19726ce2011-01-05 12:48:17 +010016#include <linux/cpu.h>
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010017#include <asm/elf.h>
18#include <asm/lowcore.h>
19#include <asm/param.h>
20
Martin Schwidefsky94038a92010-05-17 10:00:00 +020021static DEFINE_PER_CPU(struct cpuid, cpu_id);
22
23/*
24 * cpu_init - initializes state that is per-CPU.
25 */
26void __cpuinit cpu_init(void)
27{
Heiko Carstens00082042012-07-13 15:45:33 +020028 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
Heiko Carstens50bb1f72012-07-13 16:12:04 +020029 struct cpuid *id = &__get_cpu_var(cpu_id);
Martin Schwidefsky94038a92010-05-17 10:00:00 +020030
31 get_cpu_id(id);
32 atomic_inc(&init_mm.mm_count);
33 current->active_mm = &init_mm;
34 BUG_ON(current->mm);
35 enter_lazy_tlb(&init_mm, current);
Heiko Carstens00082042012-07-13 15:45:33 +020036 memset(idle, 0, sizeof(*idle));
Martin Schwidefsky94038a92010-05-17 10:00:00 +020037}
38
39/*
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010040 * show_cpuinfo - Get information on one CPU for use by procfs.
41 */
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010042static int show_cpuinfo(struct seq_file *m, void *v)
43{
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020044 static const char *hwcap_str[10] = {
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010045 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020046 "edat", "etf3eh", "highgprs"
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010047 };
Martin Schwidefsky7b468482009-03-26 15:24:42 +010048 unsigned long n = (unsigned long) v - 1;
49 int i;
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010050
Martin Schwidefsky7b468482009-03-26 15:24:42 +010051 if (!n) {
Heiko Carstens8e102302011-01-05 12:48:18 +010052 s390_adjust_jiffies();
Martin Schwidefsky7b468482009-03-26 15:24:42 +010053 seq_printf(m, "vendor_id : IBM/S390\n"
54 "# processors : %i\n"
55 "bogomips per cpu: %lu.%02lu\n",
56 num_online_cpus(), loops_per_jiffy/(500000/HZ),
57 (loops_per_jiffy/(5000/HZ))%100);
58 seq_puts(m, "features\t: ");
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020059 for (i = 0; i < 10; i++)
Martin Schwidefsky7b468482009-03-26 15:24:42 +010060 if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
61 seq_printf(m, "%s ", hwcap_str[i]);
62 seq_puts(m, "\n");
63 }
Heiko Carstens19726ce2011-01-05 12:48:17 +010064 get_online_cpus();
Martin Schwidefsky7b468482009-03-26 15:24:42 +010065 if (cpu_online(n)) {
Martin Schwidefsky94038a92010-05-17 10:00:00 +020066 struct cpuid *id = &per_cpu(cpu_id, n);
Martin Schwidefsky7b468482009-03-26 15:24:42 +010067 seq_printf(m, "processor %li: "
68 "version = %02X, "
69 "identification = %06X, "
70 "machine = %04X\n",
Martin Schwidefsky94038a92010-05-17 10:00:00 +020071 n, id->version, id->ident, id->machine);
Martin Schwidefsky7b468482009-03-26 15:24:42 +010072 }
Heiko Carstens19726ce2011-01-05 12:48:17 +010073 put_online_cpus();
Martin Schwidefsky7b468482009-03-26 15:24:42 +010074 return 0;
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010075}
76
77static void *c_start(struct seq_file *m, loff_t *pos)
78{
Martin Schwidefskydd4a5a32011-10-30 15:16:05 +010079 return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010080}
81
82static void *c_next(struct seq_file *m, void *v, loff_t *pos)
83{
84 ++*pos;
85 return c_start(m, pos);
86}
87
88static void c_stop(struct seq_file *m, void *v)
89{
90}
91
92const struct seq_operations cpuinfo_op = {
93 .start = c_start,
94 .next = c_next,
95 .stop = c_stop,
96 .show = show_cpuinfo,
97};
98