From owner-linux-pci@atrey.karlin.mff.cuni.cz Thu Jul 13 11:01:00 2006 Message-Id: <20060713165609.014146000@myri.com> Date: Thu, 13 Jul 2006 12:56:13 -0400 From: Brice Goglin To: linux-pci@atrey.karlin.mff.cuni.cz Cc: Brice Goglin Subject: MSI: Export the PCI no_msi flag in sysfs Content-Disposition: inline; filename=msi-05-add_no_msi_to_sysfs.patch Export the no_msi flag of PCI devices in sysfs and make it writable. Could be used to: * disable MSI on a device which has not been blacklisted yet * allow MSI when some setpci hacks enable MSI support (for instance on the ServerWorks HT2000 chipset where the MSI HT cap is disabled by default). Signed-off-by: Brice Goglin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-sysfs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) --- gregkh-2.6.orig/drivers/pci/pci-sysfs.c +++ gregkh-2.6/drivers/pci/pci-sysfs.c @@ -131,6 +131,29 @@ is_enabled_store(struct device *dev, str return count; } +static ssize_t no_msi_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct pci_dev *pdev = to_pci_dev(dev); + return sprintf (buf, "%u\n", pdev->no_msi); +} + +static ssize_t no_msi_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct pci_dev *pdev = to_pci_dev(dev); + + /* this might crash the machine when done at a bad time */ + if (!capable(CAP_SYS_ADMIN)) + return count; + + if (*buf == '0') + pdev->no_msi = 0; + + if (*buf == '1') + pdev->no_msi = 1; + + return count; +} struct device_attribute pci_dev_attrs[] = { __ATTR_RO(resource), @@ -145,6 +168,7 @@ struct device_attribute pci_dev_attrs[] __ATTR(enable, 0600, is_enabled_show, is_enabled_store), __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), broken_parity_status_show,broken_parity_status_store), + __ATTR(no_msi, 0644, no_msi_show, no_msi_store), __ATTR_NULL, };