processor.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * arch/s390/kernel/processor.c
  3. *
  4. * Copyright IBM Corp. 2008
  5. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  6. */
  7. #define KMSG_COMPONENT "cpu"
  8. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/smp.h>
  12. #include <linux/seq_file.h>
  13. #include <linux/delay.h>
  14. #include <linux/cpu.h>
  15. #include <asm/elf.h>
  16. #include <asm/lowcore.h>
  17. #include <asm/param.h>
  18. static DEFINE_PER_CPU(struct cpuid, cpu_id);
  19. /*
  20. * cpu_init - initializes state that is per-CPU.
  21. */
  22. void __cpuinit cpu_init(void)
  23. {
  24. struct cpuid *id = &per_cpu(cpu_id, smp_processor_id());
  25. get_cpu_id(id);
  26. atomic_inc(&init_mm.mm_count);
  27. current->active_mm = &init_mm;
  28. BUG_ON(current->mm);
  29. enter_lazy_tlb(&init_mm, current);
  30. }
  31. /*
  32. * show_cpuinfo - Get information on one CPU for use by procfs.
  33. */
  34. static int show_cpuinfo(struct seq_file *m, void *v)
  35. {
  36. static const char *hwcap_str[10] = {
  37. "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
  38. "edat", "etf3eh", "highgprs"
  39. };
  40. unsigned long n = (unsigned long) v - 1;
  41. int i;
  42. if (!n) {
  43. s390_adjust_jiffies();
  44. seq_printf(m, "vendor_id : IBM/S390\n"
  45. "# processors : %i\n"
  46. "bogomips per cpu: %lu.%02lu\n",
  47. num_online_cpus(), loops_per_jiffy/(500000/HZ),
  48. (loops_per_jiffy/(5000/HZ))%100);
  49. seq_puts(m, "features\t: ");
  50. for (i = 0; i < 10; i++)
  51. if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
  52. seq_printf(m, "%s ", hwcap_str[i]);
  53. seq_puts(m, "\n");
  54. }
  55. get_online_cpus();
  56. if (cpu_online(n)) {
  57. struct cpuid *id = &per_cpu(cpu_id, n);
  58. seq_printf(m, "processor %li: "
  59. "version = %02X, "
  60. "identification = %06X, "
  61. "machine = %04X\n",
  62. n, id->version, id->ident, id->machine);
  63. }
  64. put_online_cpus();
  65. return 0;
  66. }
  67. static void *c_start(struct seq_file *m, loff_t *pos)
  68. {
  69. return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
  70. }
  71. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  72. {
  73. ++*pos;
  74. return c_start(m, pos);
  75. }
  76. static void c_stop(struct seq_file *m, void *v)
  77. {
  78. }
  79. const struct seq_operations cpuinfo_op = {
  80. .start = c_start,
  81. .next = c_next,
  82. .stop = c_stop,
  83. .show = show_cpuinfo,
  84. };