processor.c 2.1 KB

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