aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajat Jain <rajatja@google.com>2018-06-21 19:48:29 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-07-19 17:19:52 -0400
commit12833017e581c384afa35fb85ce540082b2d59fc (patch)
treef1f66b0ca8de58a863393b14df6deeade6f1e3e8
parent81aa5206f9a7c9793e2f7971400351664e40b04f (diff)
PCI/AER: Add sysfs attributes for rootport cumulative stats
Add sysfs attributes for rootport statistics (that are cumulative of all the ERR_* messages seen on this PCI hierarchy). Signed-off-by: Rajat Jain <rajatja@google.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats28
-rw-r--r--drivers/pci/pcie/aer.c47
2 files changed, 75 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
index 3a784297cfed..4b0318c99507 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
@@ -92,3 +92,31 @@ AtomicOp Egress Blocked 0
92TLP Prefix Blocked Error 0 92TLP Prefix Blocked Error 0
93TOTAL_ERR_NONFATAL 0 93TOTAL_ERR_NONFATAL 0
94------------------------------------------------------------------------- 94-------------------------------------------------------------------------
95
96============================
97PCIe Rootport AER statistics
98============================
99These attributes show up under only the rootports (or root complex event
100collectors) that are AER capable. These indicate the number of error messages as
101"reported to" the rootport. Please note that the rootports also transmit
102(internally) the ERR_* messages for errors seen by the internal rootport PCI
103device, so these counters include them and are thus cumulative of all the error
104messages on the PCI hierarchy originating at that root port.
105
106Where: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_cor
107Date: July 2018
108Kernel Version: 4.19.0
109Contact: linux-pci@vger.kernel.org, rajatja@google.com
110Description: Total number of ERR_COR messages reported to rootport.
111
112Where: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_fatal
113Date: July 2018
114Kernel Version: 4.19.0
115Contact: linux-pci@vger.kernel.org, rajatja@google.com
116Description: Total number of ERR_FATAL messages reported to rootport.
117
118Where: /sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_nonfatal
119Date: July 2018
120Kernel Version: 4.19.0
121Contact: linux-pci@vger.kernel.org, rajatja@google.com
122Description: Total number of ERR_NONFATAL messages reported to rootport.
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index b18c5aca30bd..47c67de1ccf1 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -577,10 +577,30 @@ aer_stats_dev_attr(aer_dev_nonfatal, dev_nonfatal_errs,
577 aer_uncorrectable_error_string, "ERR_NONFATAL", 577 aer_uncorrectable_error_string, "ERR_NONFATAL",
578 dev_total_nonfatal_errs); 578 dev_total_nonfatal_errs);
579 579
580#define aer_stats_rootport_attr(name, field) \
581 static ssize_t \
582 name##_show(struct device *dev, struct device_attribute *attr, \
583 char *buf) \
584{ \
585 struct pci_dev *pdev = to_pci_dev(dev); \
586 return sprintf(buf, "%llu\n", pdev->aer_stats->field); \
587} \
588static DEVICE_ATTR_RO(name)
589
590aer_stats_rootport_attr(aer_rootport_total_err_cor,
591 rootport_total_cor_errs);
592aer_stats_rootport_attr(aer_rootport_total_err_fatal,
593 rootport_total_fatal_errs);
594aer_stats_rootport_attr(aer_rootport_total_err_nonfatal,
595 rootport_total_nonfatal_errs);
596
580static struct attribute *aer_stats_attrs[] __ro_after_init = { 597static struct attribute *aer_stats_attrs[] __ro_after_init = {
581 &dev_attr_aer_dev_correctable.attr, 598 &dev_attr_aer_dev_correctable.attr,
582 &dev_attr_aer_dev_fatal.attr, 599 &dev_attr_aer_dev_fatal.attr,
583 &dev_attr_aer_dev_nonfatal.attr, 600 &dev_attr_aer_dev_nonfatal.attr,
601 &dev_attr_aer_rootport_total_err_cor.attr,
602 &dev_attr_aer_rootport_total_err_fatal.attr,
603 &dev_attr_aer_rootport_total_err_nonfatal.attr,
584 NULL 604 NULL
585}; 605};
586 606
@@ -593,6 +613,12 @@ static umode_t aer_stats_attrs_are_visible(struct kobject *kobj,
593 if (!pdev->aer_stats) 613 if (!pdev->aer_stats)
594 return 0; 614 return 0;
595 615
616 if ((a == &dev_attr_aer_rootport_total_err_cor.attr ||
617 a == &dev_attr_aer_rootport_total_err_fatal.attr ||
618 a == &dev_attr_aer_rootport_total_err_nonfatal.attr) &&
619 pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT)
620 return 0;
621
596 return a->mode; 622 return a->mode;
597} 623}
598 624
@@ -635,6 +661,25 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
635 counter[i]++; 661 counter[i]++;
636} 662}
637 663
664static void pci_rootport_aer_stats_incr(struct pci_dev *pdev,
665 struct aer_err_source *e_src)
666{
667 struct aer_stats *aer_stats = pdev->aer_stats;
668
669 if (!aer_stats)
670 return;
671
672 if (e_src->status & PCI_ERR_ROOT_COR_RCV)
673 aer_stats->rootport_total_cor_errs++;
674
675 if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) {
676 if (e_src->status & PCI_ERR_ROOT_FATAL_RCV)
677 aer_stats->rootport_total_fatal_errs++;
678 else
679 aer_stats->rootport_total_nonfatal_errs++;
680 }
681}
682
638static void __print_tlp_header(struct pci_dev *dev, 683static void __print_tlp_header(struct pci_dev *dev,
639 struct aer_header_log_regs *t) 684 struct aer_header_log_regs *t)
640{ 685{
@@ -1085,6 +1130,8 @@ static void aer_isr_one_error(struct aer_rpc *rpc,
1085 struct pci_dev *pdev = rpc->rpd; 1130 struct pci_dev *pdev = rpc->rpd;
1086 struct aer_err_info *e_info = &rpc->e_info; 1131 struct aer_err_info *e_info = &rpc->e_info;
1087 1132
1133 pci_rootport_aer_stats_incr(pdev, e_src);
1134
1088 /* 1135 /*
1089 * There is a possibility that both correctable error and 1136 * There is a possibility that both correctable error and
1090 * uncorrectable error being logged. Report correctable error first. 1137 * uncorrectable error being logged. Report correctable error first.