In some cases, the number of Correctable Error messages is overwhelming, and even with the rate limit imposed, they fill up the logs. The system cannot do much about such errors, so a user might wish to silence them completely. Add a sysfs attribute to control reporting of the Correctable Error Messages per device. Signed-off-by: Karolina Stolarek <karolina.stolarek@xxxxxxxxxx> --- Documentation/ABI/testing/sysfs-bus-pci | 7 +++++ drivers/pci/pci-sysfs.c | 42 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index 5da6a14dc326..dba72ee37ce4 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -479,6 +479,13 @@ Description: The file is writable if the PF is bound to a driver that implements ->sriov_set_msix_vec_count(). +What: /sys/bus/pci/devices/.../cor_err_reporting_enable +Date: December 2024 +Contact: Linux PCI developers <linux-pci@xxxxxxxxxxxxxxx> +Description: + This file exposes a bit to control sending of Correctable Error + Messages. The value comes from the Device Control register. + What: /sys/bus/pci/devices/.../resourceN_resize Date: September 2022 Contact: Alex Williamson <alex.williamson@xxxxxxxxxx> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 6f1bb7514efb..f7f0d7971ad7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -186,6 +186,47 @@ static ssize_t resource_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(resource); +static ssize_t cor_err_reporting_enable_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct pci_dev *pdev = to_pci_dev(dev); + u16 reg; + int err; + + err = pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, ®); + + if (err) + return pcibios_err_to_errno(err); + + return sysfs_emit(buf, "%u\n", reg & PCI_EXP_DEVCTL_CERE); +} + +static ssize_t cor_err_reporting_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *pdev = to_pci_dev(dev); + u16 reg; + u8 val; + int err; + + if (kstrtou8(buf, 0, &val) < 0) + return -EINVAL; + + pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, ®); + + reg &= ~PCI_EXP_DEVCTL_CERE; + reg |= val; + err = pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, reg); + + if (err) + return pcibios_err_to_errno(err); + + return count; +} +static DEVICE_ATTR_RW(cor_err_reporting_enable); + static ssize_t max_link_speed_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -659,6 +700,7 @@ static struct attribute *pcie_dev_attrs[] = { &dev_attr_current_link_width.attr, &dev_attr_max_link_width.attr, &dev_attr_max_link_speed.attr, + &dev_attr_cor_err_reporting_enable.attr, NULL, }; -- 2.43.5