processor.c 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 *  Copyright IBM Corp. 2008
 *  Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
 */

#define KMSG_COMPONENT "cpu"
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/smp.h>
#include <linux/seq_file.h>
#include <linux/delay.h>
14
#include <linux/cpu.h>
15 16 17 18
#include <asm/elf.h>
#include <asm/lowcore.h>
#include <asm/param.h>

19 20 21 22 23 24 25
static DEFINE_PER_CPU(struct cpuid, cpu_id);

/*
 * cpu_init - initializes state that is per-CPU.
 */
void __cpuinit cpu_init(void)
{
26
	struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
27
	struct cpuid *id = &__get_cpu_var(cpu_id);
28 29 30 31 32 33

	get_cpu_id(id);
	atomic_inc(&init_mm.mm_count);
	current->active_mm = &init_mm;
	BUG_ON(current->mm);
	enter_lazy_tlb(&init_mm, current);
34
	memset(idle, 0, sizeof(*idle));
35 36
}

37 38 39 40 41
/*
 * show_cpuinfo - Get information on one CPU for use by procfs.
 */
static int show_cpuinfo(struct seq_file *m, void *v)
{
42
	static const char *hwcap_str[] = {
43
		"esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
44
		"edat", "etf3eh", "highgprs", "te"
45
	};
46 47
	unsigned long n = (unsigned long) v - 1;
	int i;
48

49
	if (!n) {
50
		s390_adjust_jiffies();
51 52 53 54 55 56
		seq_printf(m, "vendor_id       : IBM/S390\n"
			   "# processors    : %i\n"
			   "bogomips per cpu: %lu.%02lu\n",
			   num_online_cpus(), loops_per_jiffy/(500000/HZ),
			   (loops_per_jiffy/(5000/HZ))%100);
		seq_puts(m, "features\t: ");
57
		for (i = 0; i < ARRAY_SIZE(hwcap_str); i++)
58 59 60
			if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
				seq_printf(m, "%s ", hwcap_str[i]);
		seq_puts(m, "\n");
61
		show_cacheinfo(m);
62
	}
63
	get_online_cpus();
64
	if (cpu_online(n)) {
65
		struct cpuid *id = &per_cpu(cpu_id, n);
66 67 68 69
		seq_printf(m, "processor %li: "
			   "version = %02X,  "
			   "identification = %06X,  "
			   "machine = %04X\n",
70
			   n, id->version, id->ident, id->machine);
71
	}
72
	put_online_cpus();
73
	return 0;
74 75 76 77
}

static void *c_start(struct seq_file *m, loff_t *pos)
{
78
	return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
}

static void *c_next(struct seq_file *m, void *v, loff_t *pos)
{
	++*pos;
	return c_start(m, pos);
}

static void c_stop(struct seq_file *m, void *v)
{
}

const struct seq_operations cpuinfo_op = {
	.start	= c_start,
	.next	= c_next,
	.stop	= c_stop,
	.show	= show_cpuinfo,
};