clk: samsung: Add bus clock for GPU/G3D on Exynos4412
[linux/fpc-iii.git] / arch / s390 / kernel / processor.c
blob5de13307b7038a591561173594060fc9ea3bede0
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright IBM Corp. 2008
4 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
5 */
7 #define KMSG_COMPONENT "cpu"
8 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
10 #include <linux/cpufeature.h>
11 #include <linux/bitops.h>
12 #include <linux/kernel.h>
13 #include <linux/sched/mm.h>
14 #include <linux/init.h>
15 #include <linux/seq_file.h>
16 #include <linux/mm_types.h>
17 #include <linux/delay.h>
18 #include <linux/cpu.h>
20 #include <asm/diag.h>
21 #include <asm/facility.h>
22 #include <asm/elf.h>
23 #include <asm/lowcore.h>
24 #include <asm/param.h>
25 #include <asm/smp.h>
27 struct cpu_info {
28 unsigned int cpu_mhz_dynamic;
29 unsigned int cpu_mhz_static;
30 struct cpuid cpu_id;
33 static DEFINE_PER_CPU(struct cpu_info, cpu_info);
35 static bool machine_has_cpu_mhz;
37 void __init cpu_detect_mhz_feature(void)
39 if (test_facility(34) && __ecag(ECAG_CPU_ATTRIBUTE, 0) != -1UL)
40 machine_has_cpu_mhz = true;
43 static void update_cpu_mhz(void *arg)
45 unsigned long mhz;
46 struct cpu_info *c;
48 mhz = __ecag(ECAG_CPU_ATTRIBUTE, 0);
49 c = this_cpu_ptr(&cpu_info);
50 c->cpu_mhz_dynamic = mhz >> 32;
51 c->cpu_mhz_static = mhz & 0xffffffff;
54 void s390_update_cpu_mhz(void)
56 s390_adjust_jiffies();
57 if (machine_has_cpu_mhz)
58 on_each_cpu(update_cpu_mhz, NULL, 0);
61 void notrace cpu_relax_yield(void)
63 if (!smp_cpu_mtid && MACHINE_HAS_DIAG44) {
64 diag_stat_inc(DIAG_STAT_X044);
65 asm volatile("diag 0,0,0x44");
67 barrier();
69 EXPORT_SYMBOL(cpu_relax_yield);
72 * cpu_init - initializes state that is per-CPU.
74 void cpu_init(void)
76 struct cpuid *id = this_cpu_ptr(&cpu_info.cpu_id);
78 get_cpu_id(id);
79 if (machine_has_cpu_mhz)
80 update_cpu_mhz(NULL);
81 mmgrab(&init_mm);
82 current->active_mm = &init_mm;
83 BUG_ON(current->mm);
84 enter_lazy_tlb(&init_mm, current);
88 * cpu_have_feature - Test CPU features on module initialization
90 int cpu_have_feature(unsigned int num)
92 return elf_hwcap & (1UL << num);
94 EXPORT_SYMBOL(cpu_have_feature);
96 static void show_facilities(struct seq_file *m)
98 unsigned int bit;
99 long *facilities;
101 facilities = (long *)&S390_lowcore.stfle_fac_list;
102 seq_puts(m, "facilities :");
103 for_each_set_bit_inv(bit, facilities, MAX_FACILITY_BIT)
104 seq_printf(m, " %d", bit);
105 seq_putc(m, '\n');
108 static void show_cpu_summary(struct seq_file *m, void *v)
110 static const char *hwcap_str[] = {
111 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
112 "edat", "etf3eh", "highgprs", "te", "vx", "vxd", "vxe", "gs",
113 "vxe2", "vxp", "sort", "dflt"
115 static const char * const int_hwcap_str[] = {
116 "sie"
118 int i, cpu;
120 seq_printf(m, "vendor_id : IBM/S390\n"
121 "# processors : %i\n"
122 "bogomips per cpu: %lu.%02lu\n",
123 num_online_cpus(), loops_per_jiffy/(500000/HZ),
124 (loops_per_jiffy/(5000/HZ))%100);
125 seq_printf(m, "max thread id : %d\n", smp_cpu_mtid);
126 seq_puts(m, "features\t: ");
127 for (i = 0; i < ARRAY_SIZE(hwcap_str); i++)
128 if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
129 seq_printf(m, "%s ", hwcap_str[i]);
130 for (i = 0; i < ARRAY_SIZE(int_hwcap_str); i++)
131 if (int_hwcap_str[i] && (int_hwcap & (1UL << i)))
132 seq_printf(m, "%s ", int_hwcap_str[i]);
133 seq_puts(m, "\n");
134 show_facilities(m);
135 show_cacheinfo(m);
136 for_each_online_cpu(cpu) {
137 struct cpuid *id = &per_cpu(cpu_info.cpu_id, cpu);
139 seq_printf(m, "processor %d: "
140 "version = %02X, "
141 "identification = %06X, "
142 "machine = %04X\n",
143 cpu, id->version, id->ident, id->machine);
147 static void show_cpu_mhz(struct seq_file *m, unsigned long n)
149 struct cpu_info *c = per_cpu_ptr(&cpu_info, n);
151 seq_printf(m, "cpu MHz dynamic : %d\n", c->cpu_mhz_dynamic);
152 seq_printf(m, "cpu MHz static : %d\n", c->cpu_mhz_static);
156 * show_cpuinfo - Get information on one CPU for use by procfs.
158 static int show_cpuinfo(struct seq_file *m, void *v)
160 unsigned long n = (unsigned long) v - 1;
162 if (!n)
163 show_cpu_summary(m, v);
164 if (!machine_has_cpu_mhz)
165 return 0;
166 seq_printf(m, "\ncpu number : %ld\n", n);
167 show_cpu_mhz(m, n);
168 return 0;
171 static inline void *c_update(loff_t *pos)
173 if (*pos)
174 *pos = cpumask_next(*pos - 1, cpu_online_mask);
175 return *pos < nr_cpu_ids ? (void *)*pos + 1 : NULL;
178 static void *c_start(struct seq_file *m, loff_t *pos)
180 get_online_cpus();
181 return c_update(pos);
184 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
186 ++*pos;
187 return c_update(pos);
190 static void c_stop(struct seq_file *m, void *v)
192 put_online_cpus();
195 const struct seq_operations cpuinfo_op = {
196 .start = c_start,
197 .next = c_next,
198 .stop = c_stop,
199 .show = show_cpuinfo,
202 int s390_isolate_bp(void)
204 if (!test_facility(82))
205 return -EOPNOTSUPP;
206 set_thread_flag(TIF_ISOLATE_BP);
207 return 0;
209 EXPORT_SYMBOL(s390_isolate_bp);
211 int s390_isolate_bp_guest(void)
213 if (!test_facility(82))
214 return -EOPNOTSUPP;
215 set_thread_flag(TIF_ISOLATE_BP_GUEST);
216 return 0;
218 EXPORT_SYMBOL(s390_isolate_bp_guest);