^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright IBM Corp. 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define KMSG_COMPONENT "cpu"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/stop_machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/cpufeature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mm_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <asm/diag.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <asm/facility.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <asm/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <asm/lowcore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <asm/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct cpu_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int cpu_mhz_dynamic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int cpu_mhz_static;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct cpuid cpu_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static DEFINE_PER_CPU(struct cpu_info, cpu_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static DEFINE_PER_CPU(int, cpu_relax_retry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static bool machine_has_cpu_mhz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) void __init cpu_detect_mhz_feature(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (test_facility(34) && __ecag(ECAG_CPU_ATTRIBUTE, 0) != -1UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) machine_has_cpu_mhz = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void update_cpu_mhz(void *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned long mhz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct cpu_info *c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) mhz = __ecag(ECAG_CPU_ATTRIBUTE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) c = this_cpu_ptr(&cpu_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) c->cpu_mhz_dynamic = mhz >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) c->cpu_mhz_static = mhz & 0xffffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void s390_update_cpu_mhz(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) s390_adjust_jiffies();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (machine_has_cpu_mhz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) on_each_cpu(update_cpu_mhz, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) void notrace stop_machine_yield(const struct cpumask *cpumask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int cpu, this_cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) this_cpu = smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (__this_cpu_inc_return(cpu_relax_retry) >= spin_retry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) __this_cpu_write(cpu_relax_retry, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) cpu = cpumask_next_wrap(this_cpu, cpumask, this_cpu, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) if (cpu >= nr_cpu_ids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (arch_vcpu_is_preempted(cpu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) smp_yield_cpu(cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * cpu_init - initializes state that is per-CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void cpu_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct cpuid *id = this_cpu_ptr(&cpu_info.cpu_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) get_cpu_id(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (machine_has_cpu_mhz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) update_cpu_mhz(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) mmgrab(&init_mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) current->active_mm = &init_mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) BUG_ON(current->mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) enter_lazy_tlb(&init_mm, current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * cpu_have_feature - Test CPU features on module initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) int cpu_have_feature(unsigned int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return elf_hwcap & (1UL << num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) EXPORT_SYMBOL(cpu_have_feature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static void show_facilities(struct seq_file *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned int bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) long *facilities;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) facilities = (long *)&S390_lowcore.stfle_fac_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) seq_puts(m, "facilities :");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) for_each_set_bit_inv(bit, facilities, MAX_FACILITY_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) seq_printf(m, " %d", bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static void show_cpu_summary(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static const char *hwcap_str[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) "edat", "etf3eh", "highgprs", "te", "vx", "vxd", "vxe", "gs",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) "vxe2", "vxp", "sort", "dflt"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static const char * const int_hwcap_str[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) "sie"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int i, cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) seq_printf(m, "vendor_id : IBM/S390\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) "# processors : %i\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) "bogomips per cpu: %lu.%02lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) num_online_cpus(), loops_per_jiffy/(500000/HZ),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) (loops_per_jiffy/(5000/HZ))%100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) seq_printf(m, "max thread id : %d\n", smp_cpu_mtid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) seq_puts(m, "features\t: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) for (i = 0; i < ARRAY_SIZE(hwcap_str); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) seq_printf(m, "%s ", hwcap_str[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) for (i = 0; i < ARRAY_SIZE(int_hwcap_str); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (int_hwcap_str[i] && (int_hwcap & (1UL << i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) seq_printf(m, "%s ", int_hwcap_str[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) seq_puts(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) show_facilities(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) show_cacheinfo(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) for_each_online_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct cpuid *id = &per_cpu(cpu_info.cpu_id, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) seq_printf(m, "processor %d: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) "version = %02X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) "identification = %06X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) "machine = %04X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) cpu, id->version, id->ident, id->machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static void show_cpu_topology(struct seq_file *m, unsigned long n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #ifdef CONFIG_SCHED_TOPOLOGY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) seq_printf(m, "physical id : %d\n", topology_physical_package_id(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) seq_printf(m, "core id : %d\n", topology_core_id(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) seq_printf(m, "book id : %d\n", topology_book_id(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) seq_printf(m, "drawer id : %d\n", topology_drawer_id(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) seq_printf(m, "dedicated : %d\n", topology_cpu_dedicated(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) seq_printf(m, "address : %d\n", smp_cpu_get_cpu_address(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) seq_printf(m, "siblings : %d\n", cpumask_weight(topology_core_cpumask(n)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) seq_printf(m, "cpu cores : %d\n", topology_booted_cores(n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #endif /* CONFIG_SCHED_TOPOLOGY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static void show_cpu_ids(struct seq_file *m, unsigned long n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct cpuid *id = &per_cpu(cpu_info.cpu_id, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) seq_printf(m, "version : %02X\n", id->version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) seq_printf(m, "identification : %06X\n", id->ident);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) seq_printf(m, "machine : %04X\n", id->machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static void show_cpu_mhz(struct seq_file *m, unsigned long n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct cpu_info *c = per_cpu_ptr(&cpu_info, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (!machine_has_cpu_mhz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) seq_printf(m, "cpu MHz dynamic : %d\n", c->cpu_mhz_dynamic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) seq_printf(m, "cpu MHz static : %d\n", c->cpu_mhz_static);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * show_cpuinfo - Get information on one CPU for use by procfs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static int show_cpuinfo(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) unsigned long n = (unsigned long) v - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) unsigned long first = cpumask_first(cpu_online_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (n == first)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) show_cpu_summary(m, v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) seq_printf(m, "\ncpu number : %ld\n", n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) show_cpu_topology(m, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) show_cpu_ids(m, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) show_cpu_mhz(m, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static inline void *c_update(loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (*pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) *pos = cpumask_next(*pos - 1, cpu_online_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *pos = cpumask_first(cpu_online_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return *pos < nr_cpu_ids ? (void *)*pos + 1 : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static void *c_start(struct seq_file *m, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) get_online_cpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return c_update(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static void *c_next(struct seq_file *m, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) ++*pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return c_update(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static void c_stop(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) put_online_cpus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) const struct seq_operations cpuinfo_op = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) .start = c_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) .next = c_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) .stop = c_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) .show = show_cpuinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) int s390_isolate_bp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (!test_facility(82))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) set_thread_flag(TIF_ISOLATE_BP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) EXPORT_SYMBOL(s390_isolate_bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int s390_isolate_bp_guest(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) if (!test_facility(82))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) set_thread_flag(TIF_ISOLATE_BP_GUEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) EXPORT_SYMBOL(s390_isolate_bp_guest);