2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-10-08 16:55:02 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2014 IBM Corp.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#include "cxl.h"
|
|
|
|
|
|
|
|
static struct dentry *cxl_debugfs;
|
|
|
|
|
|
|
|
/* Helpers to export CXL mmaped IO registers via debugfs */
|
|
|
|
static int debugfs_io_u64_get(void *data, u64 *val)
|
|
|
|
{
|
|
|
|
*val = in_be64((u64 __iomem *)data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int debugfs_io_u64_set(void *data, u64 val)
|
|
|
|
{
|
|
|
|
out_be64((u64 __iomem *)data, val);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-22 18:13:27 +08:00
|
|
|
DEFINE_DEBUGFS_ATTRIBUTE(fops_io_x64, debugfs_io_u64_get, debugfs_io_u64_set,
|
|
|
|
"0x%016llx\n");
|
2014-10-08 16:55:02 +08:00
|
|
|
|
2019-06-12 23:54:18 +08:00
|
|
|
static void debugfs_create_io_x64(const char *name, umode_t mode,
|
|
|
|
struct dentry *parent, u64 __iomem *value)
|
2014-10-08 16:55:02 +08:00
|
|
|
{
|
2019-06-12 23:54:18 +08:00
|
|
|
debugfs_create_file_unsafe(name, mode, parent, (void __force *)value,
|
|
|
|
&fops_io_x64);
|
2014-10-08 16:55:02 +08:00
|
|
|
}
|
|
|
|
|
2017-04-12 22:34:07 +08:00
|
|
|
void cxl_debugfs_add_adapter_regs_psl9(struct cxl *adapter, struct dentry *dir)
|
|
|
|
{
|
|
|
|
debugfs_create_io_x64("fir1", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_FIR1));
|
2017-10-10 01:56:27 +08:00
|
|
|
debugfs_create_io_x64("fir_mask", 0400, dir,
|
|
|
|
_cxl_p1_addr(adapter, CXL_PSL9_FIR_MASK));
|
2017-04-12 22:34:07 +08:00
|
|
|
debugfs_create_io_x64("fir_cntl", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_FIR_CNTL));
|
|
|
|
debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1_addr(adapter, CXL_PSL9_TRACECFG));
|
2017-09-20 14:23:22 +08:00
|
|
|
debugfs_create_io_x64("debug", 0600, dir,
|
|
|
|
_cxl_p1_addr(adapter, CXL_PSL9_DEBUG));
|
|
|
|
debugfs_create_io_x64("xsl-debug", 0600, dir,
|
|
|
|
_cxl_p1_addr(adapter, CXL_XSL9_DBG));
|
2017-04-12 22:34:07 +08:00
|
|
|
}
|
|
|
|
|
2017-04-07 22:11:57 +08:00
|
|
|
void cxl_debugfs_add_adapter_regs_psl8(struct cxl *adapter, struct dentry *dir)
|
2016-05-24 01:39:18 +08:00
|
|
|
{
|
|
|
|
debugfs_create_io_x64("fir1", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_FIR1));
|
|
|
|
debugfs_create_io_x64("fir2", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_FIR2));
|
|
|
|
debugfs_create_io_x64("fir_cntl", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_FIR_CNTL));
|
|
|
|
debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_TRACE));
|
|
|
|
}
|
|
|
|
|
2019-06-12 23:54:18 +08:00
|
|
|
void cxl_debugfs_adapter_add(struct cxl *adapter)
|
2014-10-08 16:55:02 +08:00
|
|
|
{
|
|
|
|
struct dentry *dir;
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (!cxl_debugfs)
|
2019-06-12 23:54:18 +08:00
|
|
|
return;
|
2014-10-08 16:55:02 +08:00
|
|
|
|
|
|
|
snprintf(buf, 32, "card%i", adapter->adapter_num);
|
|
|
|
dir = debugfs_create_dir(buf, cxl_debugfs);
|
|
|
|
adapter->debugfs = dir;
|
|
|
|
|
|
|
|
debugfs_create_io_x64("err_ivte", S_IRUSR, dir, _cxl_p1_addr(adapter, CXL_PSL_ErrIVTE));
|
|
|
|
|
2017-04-07 22:11:56 +08:00
|
|
|
if (adapter->native->sl_ops->debugfs_add_adapter_regs)
|
|
|
|
adapter->native->sl_ops->debugfs_add_adapter_regs(adapter, dir);
|
2014-10-08 16:55:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void cxl_debugfs_adapter_remove(struct cxl *adapter)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(adapter->debugfs);
|
|
|
|
}
|
|
|
|
|
2017-04-12 22:34:07 +08:00
|
|
|
void cxl_debugfs_add_afu_regs_psl9(struct cxl_afu *afu, struct dentry *dir)
|
|
|
|
{
|
|
|
|
debugfs_create_io_x64("serr", S_IRUSR, dir, _cxl_p1n_addr(afu, CXL_PSL_SERR_An));
|
|
|
|
}
|
|
|
|
|
2017-04-07 22:11:57 +08:00
|
|
|
void cxl_debugfs_add_afu_regs_psl8(struct cxl_afu *afu, struct dentry *dir)
|
2016-05-24 01:39:18 +08:00
|
|
|
{
|
2017-04-07 22:11:58 +08:00
|
|
|
debugfs_create_io_x64("sstp0", S_IRUSR, dir, _cxl_p2n_addr(afu, CXL_SSTP0_An));
|
|
|
|
debugfs_create_io_x64("sstp1", S_IRUSR, dir, _cxl_p2n_addr(afu, CXL_SSTP1_An));
|
|
|
|
|
2016-05-24 01:39:18 +08:00
|
|
|
debugfs_create_io_x64("fir", S_IRUSR, dir, _cxl_p1n_addr(afu, CXL_PSL_FIR_SLICE_An));
|
|
|
|
debugfs_create_io_x64("serr", S_IRUSR, dir, _cxl_p1n_addr(afu, CXL_PSL_SERR_An));
|
|
|
|
debugfs_create_io_x64("afu_debug", S_IRUSR, dir, _cxl_p1n_addr(afu, CXL_AFU_DEBUG_An));
|
|
|
|
debugfs_create_io_x64("trace", S_IRUSR | S_IWUSR, dir, _cxl_p1n_addr(afu, CXL_PSL_SLICE_TRACE));
|
|
|
|
}
|
|
|
|
|
2019-06-12 23:54:18 +08:00
|
|
|
void cxl_debugfs_afu_add(struct cxl_afu *afu)
|
2014-10-08 16:55:02 +08:00
|
|
|
{
|
|
|
|
struct dentry *dir;
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (!afu->adapter->debugfs)
|
2019-06-12 23:54:18 +08:00
|
|
|
return;
|
2014-10-08 16:55:02 +08:00
|
|
|
|
|
|
|
snprintf(buf, 32, "psl%i.%i", afu->adapter->adapter_num, afu->slice);
|
|
|
|
dir = debugfs_create_dir(buf, afu->adapter->debugfs);
|
|
|
|
afu->debugfs = dir;
|
|
|
|
|
|
|
|
debugfs_create_io_x64("sr", S_IRUSR, dir, _cxl_p1n_addr(afu, CXL_PSL_SR_An));
|
|
|
|
debugfs_create_io_x64("dsisr", S_IRUSR, dir, _cxl_p2n_addr(afu, CXL_PSL_DSISR_An));
|
|
|
|
debugfs_create_io_x64("dar", S_IRUSR, dir, _cxl_p2n_addr(afu, CXL_PSL_DAR_An));
|
2017-04-07 22:11:58 +08:00
|
|
|
|
2014-10-08 16:55:02 +08:00
|
|
|
debugfs_create_io_x64("err_status", S_IRUSR, dir, _cxl_p2n_addr(afu, CXL_PSL_ErrStat_An));
|
|
|
|
|
2017-04-07 22:11:56 +08:00
|
|
|
if (afu->adapter->native->sl_ops->debugfs_add_afu_regs)
|
|
|
|
afu->adapter->native->sl_ops->debugfs_add_afu_regs(afu, dir);
|
2014-10-08 16:55:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void cxl_debugfs_afu_remove(struct cxl_afu *afu)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(afu->debugfs);
|
|
|
|
}
|
|
|
|
|
2019-06-12 23:54:18 +08:00
|
|
|
void __init cxl_debugfs_init(void)
|
2014-10-08 16:55:02 +08:00
|
|
|
{
|
2016-03-04 19:26:30 +08:00
|
|
|
if (!cpu_has_feature(CPU_FTR_HVMODE))
|
2019-06-12 23:54:18 +08:00
|
|
|
return;
|
2014-10-08 16:55:02 +08:00
|
|
|
|
2019-06-12 23:54:18 +08:00
|
|
|
cxl_debugfs = debugfs_create_dir("cxl", NULL);
|
2014-10-08 16:55:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void cxl_debugfs_exit(void)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(cxl_debugfs);
|
|
|
|
}
|