Path: blob/master/arch/powerpc/platforms/powernv/vas-debug.c
26481 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* Copyright 2016-17 IBM Corp.3*/45#define pr_fmt(fmt) "vas: " fmt67#include <linux/types.h>8#include <linux/slab.h>9#include <linux/debugfs.h>10#include <linux/seq_file.h>11#include <asm/vas.h>12#include "vas.h"1314static struct dentry *vas_debugfs;1516static char *cop_to_str(int cop)17{18switch (cop) {19case VAS_COP_TYPE_FAULT: return "Fault";20case VAS_COP_TYPE_842: return "NX-842 Normal Priority";21case VAS_COP_TYPE_842_HIPRI: return "NX-842 High Priority";22case VAS_COP_TYPE_GZIP: return "NX-GZIP Normal Priority";23case VAS_COP_TYPE_GZIP_HIPRI: return "NX-GZIP High Priority";24case VAS_COP_TYPE_FTW: return "Fast Thread-wakeup";25default: return "Unknown";26}27}2829static int info_show(struct seq_file *s, void *private)30{31struct pnv_vas_window *window = s->private;3233mutex_lock(&vas_mutex);3435/* ensure window is not unmapped */36if (!window->hvwc_map)37goto unlock;3839seq_printf(s, "Type: %s, %s\n", cop_to_str(window->vas_win.cop),40window->tx_win ? "Send" : "Receive");41seq_printf(s, "Pid : %d\n", vas_window_pid(&window->vas_win));4243unlock:44mutex_unlock(&vas_mutex);45return 0;46}4748DEFINE_SHOW_ATTRIBUTE(info);4950static inline void print_reg(struct seq_file *s, struct pnv_vas_window *win,51char *name, u32 reg)52{53seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);54}5556static int hvwc_show(struct seq_file *s, void *private)57{58struct pnv_vas_window *window = s->private;5960mutex_lock(&vas_mutex);6162/* ensure window is not unmapped */63if (!window->hvwc_map)64goto unlock;6566print_reg(s, window, VREG(LPID));67print_reg(s, window, VREG(PID));68print_reg(s, window, VREG(XLATE_MSR));69print_reg(s, window, VREG(XLATE_LPCR));70print_reg(s, window, VREG(XLATE_CTL));71print_reg(s, window, VREG(AMR));72print_reg(s, window, VREG(SEIDR));73print_reg(s, window, VREG(FAULT_TX_WIN));74print_reg(s, window, VREG(OSU_INTR_SRC_RA));75print_reg(s, window, VREG(HV_INTR_SRC_RA));76print_reg(s, window, VREG(PSWID));77print_reg(s, window, VREG(LFIFO_BAR));78print_reg(s, window, VREG(LDATA_STAMP_CTL));79print_reg(s, window, VREG(LDMA_CACHE_CTL));80print_reg(s, window, VREG(LRFIFO_PUSH));81print_reg(s, window, VREG(CURR_MSG_COUNT));82print_reg(s, window, VREG(LNOTIFY_AFTER_COUNT));83print_reg(s, window, VREG(LRX_WCRED));84print_reg(s, window, VREG(LRX_WCRED_ADDER));85print_reg(s, window, VREG(TX_WCRED));86print_reg(s, window, VREG(TX_WCRED_ADDER));87print_reg(s, window, VREG(LFIFO_SIZE));88print_reg(s, window, VREG(WINCTL));89print_reg(s, window, VREG(WIN_STATUS));90print_reg(s, window, VREG(WIN_CTX_CACHING_CTL));91print_reg(s, window, VREG(TX_RSVD_BUF_COUNT));92print_reg(s, window, VREG(LRFIFO_WIN_PTR));93print_reg(s, window, VREG(LNOTIFY_CTL));94print_reg(s, window, VREG(LNOTIFY_PID));95print_reg(s, window, VREG(LNOTIFY_LPID));96print_reg(s, window, VREG(LNOTIFY_TID));97print_reg(s, window, VREG(LNOTIFY_SCOPE));98print_reg(s, window, VREG(NX_UTIL_ADDER));99unlock:100mutex_unlock(&vas_mutex);101return 0;102}103104DEFINE_SHOW_ATTRIBUTE(hvwc);105106void vas_window_free_dbgdir(struct pnv_vas_window *pnv_win)107{108struct vas_window *window = &pnv_win->vas_win;109110if (window->dbgdir) {111debugfs_remove_recursive(window->dbgdir);112kfree(window->dbgname);113window->dbgdir = NULL;114window->dbgname = NULL;115}116}117118void vas_window_init_dbgdir(struct pnv_vas_window *window)119{120struct dentry *d;121122if (!window->vinst->dbgdir)123return;124125window->vas_win.dbgname = kzalloc(16, GFP_KERNEL);126if (!window->vas_win.dbgname)127return;128129snprintf(window->vas_win.dbgname, 16, "w%d", window->vas_win.winid);130131d = debugfs_create_dir(window->vas_win.dbgname, window->vinst->dbgdir);132window->vas_win.dbgdir = d;133134debugfs_create_file("info", 0444, d, window, &info_fops);135debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);136}137138void vas_instance_init_dbgdir(struct vas_instance *vinst)139{140struct dentry *d;141142vas_init_dbgdir();143144vinst->dbgname = kzalloc(16, GFP_KERNEL);145if (!vinst->dbgname)146return;147148snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id);149150d = debugfs_create_dir(vinst->dbgname, vas_debugfs);151vinst->dbgdir = d;152}153154/*155* Set up the "root" VAS debugfs dir. Return if we already set it up156* (or failed to) in an earlier instance of VAS.157*/158void vas_init_dbgdir(void)159{160static bool first_time = true;161162if (!first_time)163return;164165first_time = false;166vas_debugfs = debugfs_create_dir("vas", NULL);167}168169170