processor.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 <asm/elf.h>
  15. #include <asm/lowcore.h>
  16. #include <asm/param.h>
  17. static DEFINE_PER_CPU(struct cpuid, cpu_id);
  18. /*
  19. * cpu_init - initializes state that is per-CPU.
  20. */
  21. void __cpuinit cpu_init(void)
  22. {
  23. struct cpuid *id = &per_cpu(cpu_id, smp_processor_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. }
  30. /*
  31. * print_cpu_info - print basic information about a cpu
  32. */
  33. void __cpuinit print_cpu_info(void)
  34. {
  35. struct cpuid *id = &per_cpu(cpu_id, smp_processor_id());
  36. pr_info("Processor %d started, address %d, identification %06X\n",
  37. S390_lowcore.cpu_nr, stap(), id->ident);
  38. }
  39. /*
  40. * show_cpuinfo - Get information on one CPU for use by procfs.
  41. */
  42. static int show_cpuinfo(struct seq_file *m, void *v)
  43. {
  44. static const char *hwcap_str[10] = {
  45. "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
  46. "edat", "etf3eh", "highgprs"
  47. };
  48. unsigned long n = (unsigned long) v - 1;
  49. int i;
  50. s390_adjust_jiffies();
  51. preempt_disable();
  52. if (!n) {
  53. seq_printf(m, "vendor_id : IBM/S390\n"
  54. "# processors : %i\n"
  55. "bogomips per cpu: %lu.%02lu\n",
  56. num_online_cpus(), loops_per_jiffy/(500000/HZ),
  57. (loops_per_jiffy/(5000/HZ))%100);
  58. seq_puts(m, "features\t: ");
  59. for (i = 0; i < 10; i++)
  60. if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
  61. seq_printf(m, "%s ", hwcap_str[i]);
  62. seq_puts(m, "\n");
  63. }
  64. if (cpu_online(n)) {
  65. struct cpuid *id = &per_cpu(cpu_id, n);
  66. seq_printf(m, "processor %li: "
  67. "version = %02X, "
  68. "identification = %06X, "
  69. "machine = %04X\n",
  70. n, id->version, id->ident, id->machine);
  71. }
  72. preempt_enable();
  73. return 0;
  74. }
  75. static void *c_start(struct seq_file *m, loff_t *pos)
  76. {
  77. return *pos < NR_CPUS ? (void *)((unsigned long) *pos + 1) : NULL;
  78. }
  79. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  80. {
  81. ++*pos;
  82. return c_start(m, pos);
  83. }
  84. static void c_stop(struct seq_file *m, void *v)
  85. {
  86. }
  87. const struct seq_operations cpuinfo_op = {
  88. .start = c_start,
  89. .next = c_next,
  90. .stop = c_stop,
  91. .show = show_cpuinfo,
  92. };