lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 25 Aug 2021 18:26:35 +0800
From:   Barry Song <21cnbao@...il.com>
To:     bhelgaas@...gle.com, maz@...nel.org, tglx@...utronix.de
Cc:     Jonathan.Cameron@...wei.com, bilbao@...edu, corbet@....net,
        gregkh@...uxfoundation.org, leon@...nel.org,
        linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
        linuxarm@...wei.com, luzmaximilian@...il.com,
        mchehab+huawei@...nel.org, schnelle@...ux.ibm.com,
        jesse.brandeburg@...el.com, anthony.l.nguyen@...el.com,
        intel-wired-lan@...ts.osuosl.org,
        Barry Song <song.bao.hua@...ilicon.com>
Subject: [PATCH v3 2/3] PCI/sysfs: Don't depend on pci_dev.irq for IRQ entry

From: Barry Song <song.bao.hua@...ilicon.com>

Explicitly use IRQ number from MSI list for IRQ sysfs entry. Then sysfs
will decouple with the odd implementation depending on pci_dev.irq.

Signed-off-by: Barry Song <song.bao.hua@...ilicon.com>
---
 drivers/pci/pci-sysfs.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 7bbf2673..f5a06b9 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,27 @@ static DEVICE_ATTR_RO(field)
 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, return the 1st IRQ in IRQ vector; for all other cases
+	 * including MSI-X, return legacy INTx
+	 */
+	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,
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ