diff mbox

[3/3] PCI/MSI: Refactor msi_bus to support EP enable/disable MSI

Message ID 1406339316-20163-4-git-send-email-wangyijing@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Yijing Wang July 26, 2014, 1:48 a.m. UTC
From: Yijing Wang <wangyijing@huawei.com>

Msi_bus attribute is only valid for bridge device.
We can enable or disable MSI capability for a bus,
if we echo 1/0 > /sys/bus/pci/devices/$EP/msi_bus,
the action will be ignored. Sometime we need to
only enable/disable a device MSI, not all devices share
the same bus.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
 drivers/pci/pci-sysfs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9ff0a90..b199ad9 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -251,11 +251,9 @@  static ssize_t msi_bus_show(struct device *dev, struct device_attribute *attr,
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 
-	if (!pdev->subordinate)
-		return 0;
-
-	return sprintf(buf, "%u\n",
-		       !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI));
+	return sprintf(buf, "%u\n", pdev->subordinate ?
+		       !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)
+			   : !pdev->no_msi);
 }
 
 static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
@@ -278,8 +276,10 @@  static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
 	 * Maybe devices without subordinate buses shouldn't have this
 	 * attribute in the first place?
 	 */
-	if (!pdev->subordinate)
+	if (!pdev->subordinate) {
+		pdev->no_msi = !val;
 		return count;
+	}
 
 	/* Is the flag going to change, or keep the value it already had? */
 	if (!(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) ^