summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2021-11-05 11:28:44 -0500
committerBjorn Helgaas <bhelgaas@google.com>2021-11-05 11:28:44 -0500
commitefe6856390bae3a2aa170bdd51c34b8832b83bc6 (patch)
tree812a150653bf1998deca69b4fc8d3495ba943cee /drivers/pci
parent4917f7189bd8be326d0910055b029d3cbf50256c (diff)
parentac8e3cef588c5affc6dfa7b693ec64bbf3cead6a (diff)
Merge branch 'pci/msi'
- Document sysfs "irq" attribute, which contains either the INTx IRQ (the intended behavior) or the first MSI IRQ (historical mistake retained for backwards compatibility) (Barry Song) - Rework "irq" sysfs show function to explicitly fetch first MSI IRQ instead of depending on core to put it in dev->irq, to enable future core cleanup (Barry Song) * pci/msi: PCI/sysfs: Explicitly show first MSI IRQ for 'irq' PCI: Document /sys/bus/pci/devices/.../irq
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-sysfs.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 7fb5cd17cc98..b50fe7ce234b 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/vgaarb.h>
#include <linux/pm_runtime.h>
+#include <linux/msi.h>
#include <linux/of.h>
#include "pci.h"
@@ -49,7 +50,28 @@ pci_config_attr(subsystem_vendor, "0x%04x\n");
pci_config_attr(subsystem_device, "0x%04x\n");
pci_config_attr(revision, "0x%02x\n");
pci_config_attr(class, "0x%06x\n");
-pci_config_attr(irq, "%u\n");
+
+static ssize_t irq_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+#ifdef CONFIG_PCI_MSI
+ /*
+ * For MSI, show the first MSI IRQ; for all other cases including
+ * MSI-X, show the legacy INTx IRQ.
+ */
+ if (pdev->msi_enabled) {
+ struct msi_desc *desc = first_pci_msi_entry(pdev);
+
+ return sysfs_emit(buf, "%u\n", desc->irq);
+ }
+#endif
+
+ return sysfs_emit(buf, "%u\n", pdev->irq);
+}
+static DEVICE_ATTR_RO(irq);
static ssize_t broken_parity_status_show(struct device *dev,
struct device_attribute *attr,