diff options
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index fdefa7dcd156..010e01c4bd43 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -131,6 +131,46 @@ is_enabled_store(struct device *dev, struct device_attribute *attr, | |||
131 | return count; | 131 | return count; |
132 | } | 132 | } |
133 | 133 | ||
134 | static ssize_t | ||
135 | msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
136 | { | ||
137 | struct pci_dev *pdev = to_pci_dev(dev); | ||
138 | |||
139 | if (!pdev->subordinate) | ||
140 | return 0; | ||
141 | |||
142 | return sprintf (buf, "%u\n", | ||
143 | !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)); | ||
144 | } | ||
145 | |||
146 | static ssize_t | ||
147 | msi_bus_store(struct device *dev, struct device_attribute *attr, | ||
148 | const char *buf, size_t count) | ||
149 | { | ||
150 | struct pci_dev *pdev = to_pci_dev(dev); | ||
151 | |||
152 | /* bad things may happen if the no_msi flag is changed | ||
153 | * while some drivers are loaded */ | ||
154 | if (!capable(CAP_SYS_ADMIN)) | ||
155 | return count; | ||
156 | |||
157 | if (!pdev->subordinate) | ||
158 | return count; | ||
159 | |||
160 | if (*buf == '0') { | ||
161 | pdev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | ||
162 | dev_warn(&pdev->dev, "forced subordinate bus to not support MSI," | ||
163 | " bad things could happen.\n"); | ||
164 | } | ||
165 | |||
166 | if (*buf == '1') { | ||
167 | pdev->subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; | ||
168 | dev_warn(&pdev->dev, "forced subordinate bus to support MSI," | ||
169 | " bad things could happen.\n"); | ||
170 | } | ||
171 | |||
172 | return count; | ||
173 | } | ||
134 | 174 | ||
135 | struct device_attribute pci_dev_attrs[] = { | 175 | struct device_attribute pci_dev_attrs[] = { |
136 | __ATTR_RO(resource), | 176 | __ATTR_RO(resource), |
@@ -145,6 +185,7 @@ struct device_attribute pci_dev_attrs[] = { | |||
145 | __ATTR(enable, 0600, is_enabled_show, is_enabled_store), | 185 | __ATTR(enable, 0600, is_enabled_show, is_enabled_store), |
146 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), | 186 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), |
147 | broken_parity_status_show,broken_parity_status_store), | 187 | broken_parity_status_show,broken_parity_status_store), |
188 | __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), | ||
148 | __ATTR_NULL, | 189 | __ATTR_NULL, |
149 | }; | 190 | }; |
150 | 191 | ||