processor.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. void __cpuinit print_cpu_info(struct cpuinfo_S390 *cpuinfo)
  18. {
  19. pr_info("Processor %d started, address %d, identification %06X\n",
  20. cpuinfo->cpu_nr, cpuinfo->cpu_addr, cpuinfo->cpu_id.ident);
  21. }
  22. /*
  23. * show_cpuinfo - Get information on one CPU for use by procfs.
  24. */
  25. static int show_cpuinfo(struct seq_file *m, void *v)
  26. {
  27. static const char *hwcap_str[8] = {
  28. "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
  29. "edat"
  30. };
  31. struct cpuinfo_S390 *cpuinfo;
  32. unsigned long n = (unsigned long) v - 1;
  33. int i;
  34. s390_adjust_jiffies();
  35. preempt_disable();
  36. if (!n) {
  37. seq_printf(m, "vendor_id : IBM/S390\n"
  38. "# processors : %i\n"
  39. "bogomips per cpu: %lu.%02lu\n",
  40. num_online_cpus(), loops_per_jiffy/(500000/HZ),
  41. (loops_per_jiffy/(5000/HZ))%100);
  42. seq_puts(m, "features\t: ");
  43. for (i = 0; i < 8; i++)
  44. if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
  45. seq_printf(m, "%s ", hwcap_str[i]);
  46. seq_puts(m, "\n");
  47. }
  48. if (cpu_online(n)) {
  49. #ifdef CONFIG_SMP
  50. if (smp_processor_id() == n)
  51. cpuinfo = &S390_lowcore.cpu_data;
  52. else
  53. cpuinfo = &lowcore_ptr[n]->cpu_data;
  54. #else
  55. cpuinfo = &S390_lowcore.cpu_data;
  56. #endif
  57. seq_printf(m, "processor %li: "
  58. "version = %02X, "
  59. "identification = %06X, "
  60. "machine = %04X\n",
  61. n, cpuinfo->cpu_id.version,
  62. cpuinfo->cpu_id.ident,
  63. cpuinfo->cpu_id.machine);
  64. }
  65. preempt_enable();
  66. return 0;
  67. }
  68. static void *c_start(struct seq_file *m, loff_t *pos)
  69. {
  70. return *pos < NR_CPUS ? (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. };