blob: eeb651b48db3063d18d9bf04d2173ef5883c3a21 [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>
16
17#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{
28 struct cpuid *id = &per_cpu(cpu_id, smp_processor_id());
29
30 get_cpu_id(id);
31 atomic_inc(&init_mm.mm_count);
32 current->active_mm = &init_mm;
33 BUG_ON(current->mm);
34 enter_lazy_tlb(&init_mm, current);
35}
36
37/*
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010038 * show_cpuinfo - Get information on one CPU for use by procfs.
39 */
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010040static int show_cpuinfo(struct seq_file *m, void *v)
41{
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020042 static const char *hwcap_str[10] = {
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010043 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020044 "edat", "etf3eh", "highgprs"
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010045 };
Martin Schwidefsky7b468482009-03-26 15:24:42 +010046 unsigned long n = (unsigned long) v - 1;
47 int i;
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010048
Martin Schwidefsky7b468482009-03-26 15:24:42 +010049 s390_adjust_jiffies();
50 preempt_disable();
51 if (!n) {
52 seq_printf(m, "vendor_id : IBM/S390\n"
53 "# processors : %i\n"
54 "bogomips per cpu: %lu.%02lu\n",
55 num_online_cpus(), loops_per_jiffy/(500000/HZ),
56 (loops_per_jiffy/(5000/HZ))%100);
57 seq_puts(m, "features\t: ");
Andreas Krebbelbe6e3f92009-10-14 12:43:47 +020058 for (i = 0; i < 10; i++)
Martin Schwidefsky7b468482009-03-26 15:24:42 +010059 if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
60 seq_printf(m, "%s ", hwcap_str[i]);
61 seq_puts(m, "\n");
62 }
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010063
Martin Schwidefsky7b468482009-03-26 15:24:42 +010064 if (cpu_online(n)) {
Martin Schwidefsky94038a92010-05-17 10:00:00 +020065 struct cpuid *id = &per_cpu(cpu_id, n);
Martin Schwidefsky7b468482009-03-26 15:24:42 +010066 seq_printf(m, "processor %li: "
67 "version = %02X, "
68 "identification = %06X, "
69 "machine = %04X\n",
Martin Schwidefsky94038a92010-05-17 10:00:00 +020070 n, id->version, id->ident, id->machine);
Martin Schwidefsky7b468482009-03-26 15:24:42 +010071 }
72 preempt_enable();
73 return 0;
Martin Schwidefsky395d31d2008-12-25 13:39:50 +010074}
75
76static void *c_start(struct seq_file *m, loff_t *pos)
77{
78 return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
79}
80
81static void *c_next(struct seq_file *m, void *v, loff_t *pos)
82{
83 ++*pos;
84 return c_start(m, pos);
85}
86
87static void c_stop(struct seq_file *m, void *v)
88{
89}
90
91const struct seq_operations cpuinfo_op = {
92 .start = c_start,
93 .next = c_next,
94 .stop = c_stop,
95 .show = show_cpuinfo,
96};
97