|
3 | 3 | #include <linux/platform_device.h>
|
4 | 4 | #include <linux/memregion.h>
|
5 | 5 | #include <linux/workqueue.h>
|
| 6 | +#include <linux/einj-cxl.h> |
6 | 7 | #include <linux/debugfs.h>
|
7 | 8 | #include <linux/device.h>
|
8 | 9 | #include <linux/module.h>
|
@@ -793,6 +794,40 @@ static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport,
|
793 | 794 | return rc;
|
794 | 795 | }
|
795 | 796 |
|
| 797 | +DEFINE_SHOW_ATTRIBUTE(einj_cxl_available_error_type); |
| 798 | + |
| 799 | +static int cxl_einj_inject(void *data, u64 type) |
| 800 | +{ |
| 801 | + struct cxl_dport *dport = data; |
| 802 | + |
| 803 | + if (dport->rch) |
| 804 | + return einj_cxl_inject_rch_error(dport->rcrb.base, type); |
| 805 | + |
| 806 | + return einj_cxl_inject_error(to_pci_dev(dport->dport_dev), type); |
| 807 | +} |
| 808 | +DEFINE_DEBUGFS_ATTRIBUTE(cxl_einj_inject_fops, NULL, cxl_einj_inject, |
| 809 | + "0x%llx\n"); |
| 810 | + |
| 811 | +static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) |
| 812 | +{ |
| 813 | + struct dentry *dir; |
| 814 | + |
| 815 | + if (!einj_cxl_is_initialized()) |
| 816 | + return; |
| 817 | + |
| 818 | + /* |
| 819 | + * dport_dev needs to be a PCIe port for CXL 2.0+ ports because |
| 820 | + * EINJ expects a dport SBDF to be specified for 2.0 error injection. |
| 821 | + */ |
| 822 | + if (!dport->rch && !dev_is_pci(dport->dport_dev)) |
| 823 | + return; |
| 824 | + |
| 825 | + dir = cxl_debugfs_create_dir(dev_name(dport->dport_dev)); |
| 826 | + |
| 827 | + debugfs_create_file("einj_inject", 0200, dir, dport, |
| 828 | + &cxl_einj_inject_fops); |
| 829 | +} |
| 830 | + |
796 | 831 | static struct cxl_port *__devm_cxl_add_port(struct device *host,
|
797 | 832 | struct device *uport_dev,
|
798 | 833 | resource_size_t component_reg_phys,
|
@@ -1149,6 +1184,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,
|
1149 | 1184 | if (dev_is_pci(dport_dev))
|
1150 | 1185 | dport->link_latency = cxl_pci_get_latency(to_pci_dev(dport_dev));
|
1151 | 1186 |
|
| 1187 | + cxl_debugfs_create_dport_dir(dport); |
| 1188 | + |
1152 | 1189 | return dport;
|
1153 | 1190 | }
|
1154 | 1191 |
|
@@ -2221,6 +2258,10 @@ static __init int cxl_core_init(void)
|
2221 | 2258 |
|
2222 | 2259 | cxl_debugfs = debugfs_create_dir("cxl", NULL);
|
2223 | 2260 |
|
| 2261 | + if (einj_cxl_is_initialized()) |
| 2262 | + debugfs_create_file("einj_types", 0400, cxl_debugfs, NULL, |
| 2263 | + &einj_cxl_available_error_type_fops); |
| 2264 | + |
2224 | 2265 | cxl_mbox_init();
|
2225 | 2266 |
|
2226 | 2267 | rc = cxl_memdev_init();
|
|
0 commit comments