Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Copyright 2016-17 IBM Corp.
0004  */
0005 
0006 #define pr_fmt(fmt) "vas: " fmt
0007 
0008 #include <linux/types.h>
0009 #include <linux/slab.h>
0010 #include <linux/debugfs.h>
0011 #include <linux/seq_file.h>
0012 #include <asm/vas.h>
0013 #include "vas.h"
0014 
0015 static struct dentry *vas_debugfs;
0016 
0017 static char *cop_to_str(int cop)
0018 {
0019     switch (cop) {
0020     case VAS_COP_TYPE_FAULT:    return "Fault";
0021     case VAS_COP_TYPE_842:      return "NX-842 Normal Priority";
0022     case VAS_COP_TYPE_842_HIPRI:    return "NX-842 High Priority";
0023     case VAS_COP_TYPE_GZIP:     return "NX-GZIP Normal Priority";
0024     case VAS_COP_TYPE_GZIP_HIPRI:   return "NX-GZIP High Priority";
0025     case VAS_COP_TYPE_FTW:      return "Fast Thread-wakeup";
0026     default:            return "Unknown";
0027     }
0028 }
0029 
0030 static int info_show(struct seq_file *s, void *private)
0031 {
0032     struct pnv_vas_window *window = s->private;
0033 
0034     mutex_lock(&vas_mutex);
0035 
0036     /* ensure window is not unmapped */
0037     if (!window->hvwc_map)
0038         goto unlock;
0039 
0040     seq_printf(s, "Type: %s, %s\n", cop_to_str(window->vas_win.cop),
0041                     window->tx_win ? "Send" : "Receive");
0042     seq_printf(s, "Pid : %d\n", vas_window_pid(&window->vas_win));
0043 
0044 unlock:
0045     mutex_unlock(&vas_mutex);
0046     return 0;
0047 }
0048 
0049 DEFINE_SHOW_ATTRIBUTE(info);
0050 
0051 static inline void print_reg(struct seq_file *s, struct pnv_vas_window *win,
0052             char *name, u32 reg)
0053 {
0054     seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);
0055 }
0056 
0057 static int hvwc_show(struct seq_file *s, void *private)
0058 {
0059     struct pnv_vas_window *window = s->private;
0060 
0061     mutex_lock(&vas_mutex);
0062 
0063     /* ensure window is not unmapped */
0064     if (!window->hvwc_map)
0065         goto unlock;
0066 
0067     print_reg(s, window, VREG(LPID));
0068     print_reg(s, window, VREG(PID));
0069     print_reg(s, window, VREG(XLATE_MSR));
0070     print_reg(s, window, VREG(XLATE_LPCR));
0071     print_reg(s, window, VREG(XLATE_CTL));
0072     print_reg(s, window, VREG(AMR));
0073     print_reg(s, window, VREG(SEIDR));
0074     print_reg(s, window, VREG(FAULT_TX_WIN));
0075     print_reg(s, window, VREG(OSU_INTR_SRC_RA));
0076     print_reg(s, window, VREG(HV_INTR_SRC_RA));
0077     print_reg(s, window, VREG(PSWID));
0078     print_reg(s, window, VREG(LFIFO_BAR));
0079     print_reg(s, window, VREG(LDATA_STAMP_CTL));
0080     print_reg(s, window, VREG(LDMA_CACHE_CTL));
0081     print_reg(s, window, VREG(LRFIFO_PUSH));
0082     print_reg(s, window, VREG(CURR_MSG_COUNT));
0083     print_reg(s, window, VREG(LNOTIFY_AFTER_COUNT));
0084     print_reg(s, window, VREG(LRX_WCRED));
0085     print_reg(s, window, VREG(LRX_WCRED_ADDER));
0086     print_reg(s, window, VREG(TX_WCRED));
0087     print_reg(s, window, VREG(TX_WCRED_ADDER));
0088     print_reg(s, window, VREG(LFIFO_SIZE));
0089     print_reg(s, window, VREG(WINCTL));
0090     print_reg(s, window, VREG(WIN_STATUS));
0091     print_reg(s, window, VREG(WIN_CTX_CACHING_CTL));
0092     print_reg(s, window, VREG(TX_RSVD_BUF_COUNT));
0093     print_reg(s, window, VREG(LRFIFO_WIN_PTR));
0094     print_reg(s, window, VREG(LNOTIFY_CTL));
0095     print_reg(s, window, VREG(LNOTIFY_PID));
0096     print_reg(s, window, VREG(LNOTIFY_LPID));
0097     print_reg(s, window, VREG(LNOTIFY_TID));
0098     print_reg(s, window, VREG(LNOTIFY_SCOPE));
0099     print_reg(s, window, VREG(NX_UTIL_ADDER));
0100 unlock:
0101     mutex_unlock(&vas_mutex);
0102     return 0;
0103 }
0104 
0105 DEFINE_SHOW_ATTRIBUTE(hvwc);
0106 
0107 void vas_window_free_dbgdir(struct pnv_vas_window *pnv_win)
0108 {
0109     struct vas_window *window =  &pnv_win->vas_win;
0110 
0111     if (window->dbgdir) {
0112         debugfs_remove_recursive(window->dbgdir);
0113         kfree(window->dbgname);
0114         window->dbgdir = NULL;
0115         window->dbgname = NULL;
0116     }
0117 }
0118 
0119 void vas_window_init_dbgdir(struct pnv_vas_window *window)
0120 {
0121     struct dentry *d;
0122 
0123     if (!window->vinst->dbgdir)
0124         return;
0125 
0126     window->vas_win.dbgname = kzalloc(16, GFP_KERNEL);
0127     if (!window->vas_win.dbgname)
0128         return;
0129 
0130     snprintf(window->vas_win.dbgname, 16, "w%d", window->vas_win.winid);
0131 
0132     d = debugfs_create_dir(window->vas_win.dbgname, window->vinst->dbgdir);
0133     window->vas_win.dbgdir = d;
0134 
0135     debugfs_create_file("info", 0444, d, window, &info_fops);
0136     debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
0137 }
0138 
0139 void vas_instance_init_dbgdir(struct vas_instance *vinst)
0140 {
0141     struct dentry *d;
0142 
0143     vas_init_dbgdir();
0144 
0145     vinst->dbgname = kzalloc(16, GFP_KERNEL);
0146     if (!vinst->dbgname)
0147         return;
0148 
0149     snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id);
0150 
0151     d = debugfs_create_dir(vinst->dbgname, vas_debugfs);
0152     vinst->dbgdir = d;
0153 }
0154 
0155 /*
0156  * Set up the "root" VAS debugfs dir. Return if we already set it up
0157  * (or failed to) in an earlier instance of VAS.
0158  */
0159 void vas_init_dbgdir(void)
0160 {
0161     static bool first_time = true;
0162 
0163     if (!first_time)
0164         return;
0165 
0166     first_time = false;
0167     vas_debugfs = debugfs_create_dir("vas", NULL);
0168 }