vas-debug.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2016-17 IBM Corp.
  4. */
  5. #define pr_fmt(fmt) "vas: " fmt
  6. #include <linux/types.h>
  7. #include <linux/slab.h>
  8. #include <linux/debugfs.h>
  9. #include <linux/seq_file.h>
  10. #include <asm/vas.h>
  11. #include "vas.h"
  12. static struct dentry *vas_debugfs;
  13. static char *cop_to_str(int cop)
  14. {
  15. switch (cop) {
  16. case VAS_COP_TYPE_FAULT: return "Fault";
  17. case VAS_COP_TYPE_842: return "NX-842 Normal Priority";
  18. case VAS_COP_TYPE_842_HIPRI: return "NX-842 High Priority";
  19. case VAS_COP_TYPE_GZIP: return "NX-GZIP Normal Priority";
  20. case VAS_COP_TYPE_GZIP_HIPRI: return "NX-GZIP High Priority";
  21. case VAS_COP_TYPE_FTW: return "Fast Thread-wakeup";
  22. default: return "Unknown";
  23. }
  24. }
  25. static int info_show(struct seq_file *s, void *private)
  26. {
  27. struct pnv_vas_window *window = s->private;
  28. mutex_lock(&vas_mutex);
  29. /* ensure window is not unmapped */
  30. if (!window->hvwc_map)
  31. goto unlock;
  32. seq_printf(s, "Type: %s, %s\n", cop_to_str(window->vas_win.cop),
  33. window->tx_win ? "Send" : "Receive");
  34. seq_printf(s, "Pid : %d\n", vas_window_pid(&window->vas_win));
  35. unlock:
  36. mutex_unlock(&vas_mutex);
  37. return 0;
  38. }
  39. DEFINE_SHOW_ATTRIBUTE(info);
  40. static inline void print_reg(struct seq_file *s, struct pnv_vas_window *win,
  41. char *name, u32 reg)
  42. {
  43. seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);
  44. }
  45. static int hvwc_show(struct seq_file *s, void *private)
  46. {
  47. struct pnv_vas_window *window = s->private;
  48. mutex_lock(&vas_mutex);
  49. /* ensure window is not unmapped */
  50. if (!window->hvwc_map)
  51. goto unlock;
  52. print_reg(s, window, VREG(LPID));
  53. print_reg(s, window, VREG(PID));
  54. print_reg(s, window, VREG(XLATE_MSR));
  55. print_reg(s, window, VREG(XLATE_LPCR));
  56. print_reg(s, window, VREG(XLATE_CTL));
  57. print_reg(s, window, VREG(AMR));
  58. print_reg(s, window, VREG(SEIDR));
  59. print_reg(s, window, VREG(FAULT_TX_WIN));
  60. print_reg(s, window, VREG(OSU_INTR_SRC_RA));
  61. print_reg(s, window, VREG(HV_INTR_SRC_RA));
  62. print_reg(s, window, VREG(PSWID));
  63. print_reg(s, window, VREG(LFIFO_BAR));
  64. print_reg(s, window, VREG(LDATA_STAMP_CTL));
  65. print_reg(s, window, VREG(LDMA_CACHE_CTL));
  66. print_reg(s, window, VREG(LRFIFO_PUSH));
  67. print_reg(s, window, VREG(CURR_MSG_COUNT));
  68. print_reg(s, window, VREG(LNOTIFY_AFTER_COUNT));
  69. print_reg(s, window, VREG(LRX_WCRED));
  70. print_reg(s, window, VREG(LRX_WCRED_ADDER));
  71. print_reg(s, window, VREG(TX_WCRED));
  72. print_reg(s, window, VREG(TX_WCRED_ADDER));
  73. print_reg(s, window, VREG(LFIFO_SIZE));
  74. print_reg(s, window, VREG(WINCTL));
  75. print_reg(s, window, VREG(WIN_STATUS));
  76. print_reg(s, window, VREG(WIN_CTX_CACHING_CTL));
  77. print_reg(s, window, VREG(TX_RSVD_BUF_COUNT));
  78. print_reg(s, window, VREG(LRFIFO_WIN_PTR));
  79. print_reg(s, window, VREG(LNOTIFY_CTL));
  80. print_reg(s, window, VREG(LNOTIFY_PID));
  81. print_reg(s, window, VREG(LNOTIFY_LPID));
  82. print_reg(s, window, VREG(LNOTIFY_TID));
  83. print_reg(s, window, VREG(LNOTIFY_SCOPE));
  84. print_reg(s, window, VREG(NX_UTIL_ADDER));
  85. unlock:
  86. mutex_unlock(&vas_mutex);
  87. return 0;
  88. }
  89. DEFINE_SHOW_ATTRIBUTE(hvwc);
  90. void vas_window_free_dbgdir(struct pnv_vas_window *pnv_win)
  91. {
  92. struct vas_window *window = &pnv_win->vas_win;
  93. if (window->dbgdir) {
  94. debugfs_remove_recursive(window->dbgdir);
  95. kfree(window->dbgname);
  96. window->dbgdir = NULL;
  97. window->dbgname = NULL;
  98. }
  99. }
  100. void vas_window_init_dbgdir(struct pnv_vas_window *window)
  101. {
  102. struct dentry *d;
  103. if (!window->vinst->dbgdir)
  104. return;
  105. window->vas_win.dbgname = kzalloc(16, GFP_KERNEL);
  106. if (!window->vas_win.dbgname)
  107. return;
  108. snprintf(window->vas_win.dbgname, 16, "w%d", window->vas_win.winid);
  109. d = debugfs_create_dir(window->vas_win.dbgname, window->vinst->dbgdir);
  110. window->vas_win.dbgdir = d;
  111. debugfs_create_file("info", 0444, d, window, &info_fops);
  112. debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
  113. }
  114. void vas_instance_init_dbgdir(struct vas_instance *vinst)
  115. {
  116. struct dentry *d;
  117. vas_init_dbgdir();
  118. vinst->dbgname = kzalloc(16, GFP_KERNEL);
  119. if (!vinst->dbgname)
  120. return;
  121. snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id);
  122. d = debugfs_create_dir(vinst->dbgname, vas_debugfs);
  123. vinst->dbgdir = d;
  124. }
  125. /*
  126. * Set up the "root" VAS debugfs dir. Return if we already set it up
  127. * (or failed to) in an earlier instance of VAS.
  128. */
  129. void vas_init_dbgdir(void)
  130. {
  131. static bool first_time = true;
  132. if (!first_time)
  133. return;
  134. first_time = false;
  135. vas_debugfs = debugfs_create_dir("vas", NULL);
  136. }