processor.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 __cpuinit cpu_init(void)
  21. {
  22. struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
  23. struct cpuid *id = &__get_cpu_var(cpu_id);
  24. get_cpu_id(id);
  25. atomic_inc(&init_mm.mm_count);
  26. current->active_mm = &init_mm;
  27. BUG_ON(current->mm);
  28. enter_lazy_tlb(&init_mm, current);
  29. memset(idle, 0, sizeof(*idle));
  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[] = {
  37. "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
  38. "edat", "etf3eh", "highgprs", "te"
  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 < ARRAY_SIZE(hwcap_str); i++)
  51. if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
  52. seq_printf(m, "%s ", hwcap_str[i]);
  53. seq_puts(m, "\n");
  54. show_cacheinfo(m);
  55. }
  56. get_online_cpus();
  57. if (cpu_online(n)) {
  58. struct cpuid *id = &per_cpu(cpu_id, n);
  59. seq_printf(m, "processor %li: "
  60. "version = %02X, "
  61. "identification = %06X, "
  62. "machine = %04X\n",
  63. n, id->version, id->ident, id->machine);
  64. }
  65. put_online_cpus();
  66. return 0;
  67. }
  68. static void *c_start(struct seq_file *m, loff_t *pos)
  69. {
  70. return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
  71. }
  72. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  73. {
  74. ++*pos;
  75. return c_start(m, pos);
  76. }
  77. static void c_stop(struct seq_file *m, void *v)
  78. {
  79. }
  80. const struct seq_operations cpuinfo_op = {
  81. .start = c_start,
  82. .next = c_next,
  83. .stop = c_stop,
  84. .show = show_cpuinfo,
  85. };