diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2015-12-03 14:18:18 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2015-12-10 20:38:06 -0500 |
commit | 93de6901766c6821538b74a092e47780a9120fac (patch) | |
tree | 05431f12c64191c2b8784afe2001b5a0f99b1a01 /drivers | |
parent | 1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff) |
PCI: Check for PCI_HEADER_TYPE_BRIDGE equality, not bitmask
Bit 7 of the "Header Type" register indicates a multi-function device when
set. Bits 0-6 contain encoded values, where 0x1 indicates a PCI-PCI
bridge. It is incorrect to test this as though it were a mask.
For example, while the PCI 3.0 spec only defines values 0x0, 0x1, and 0x2,
it's conceivable that a future spec could define 0x3 to mean something
else; then tests for "(hdr_type & 0x7f) & PCI_HEADER_TYPE_BRIDGE" would
incorrectly succeed for this new 0x3 header type.
Test bits 0-6 of the Header Type for equality with PCI_HEADER_TYPE_BRIDGE.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/hotplug/ibmphp_pci.c | 2 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_core.c | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index 814cea22a9fa..5824df538f72 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c | |||
@@ -1119,7 +1119,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) | |||
1119 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); | 1119 | pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); |
1120 | 1120 | ||
1121 | debug ("hdr_type behind the bridge is %x\n", hdr_type); | 1121 | debug ("hdr_type behind the bridge is %x\n", hdr_type); |
1122 | if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 1122 | if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) { |
1123 | err ("embedded bridges not supported for hot-plugging.\n"); | 1123 | err ("embedded bridges not supported for hot-plugging.\n"); |
1124 | amount->not_correct = 1; | 1124 | amount->not_correct = 1; |
1125 | return amount; | 1125 | return amount; |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index fba785e9df75..712392504ed9 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -246,7 +246,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
246 | !dev->driver->err_handler || | 246 | !dev->driver->err_handler || |
247 | !dev->driver->err_handler->error_detected) { | 247 | !dev->driver->err_handler->error_detected) { |
248 | if (result_data->state == pci_channel_io_frozen && | 248 | if (result_data->state == pci_channel_io_frozen && |
249 | !(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) { | 249 | dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { |
250 | /* | 250 | /* |
251 | * In case of fatal recovery, if one of down- | 251 | * In case of fatal recovery, if one of down- |
252 | * stream device has no driver. We might be | 252 | * stream device has no driver. We might be |
@@ -269,7 +269,7 @@ static int report_error_detected(struct pci_dev *dev, void *data) | |||
269 | * without recovery. | 269 | * without recovery. |
270 | */ | 270 | */ |
271 | 271 | ||
272 | if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) | 272 | if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) |
273 | vote = PCI_ERS_RESULT_NO_AER_DRIVER; | 273 | vote = PCI_ERS_RESULT_NO_AER_DRIVER; |
274 | else | 274 | else |
275 | vote = PCI_ERS_RESULT_NONE; | 275 | vote = PCI_ERS_RESULT_NONE; |
@@ -369,7 +369,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev, | |||
369 | else | 369 | else |
370 | result_data.result = PCI_ERS_RESULT_RECOVERED; | 370 | result_data.result = PCI_ERS_RESULT_RECOVERED; |
371 | 371 | ||
372 | if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 372 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
373 | /* | 373 | /* |
374 | * If the error is reported by a bridge, we think this error | 374 | * If the error is reported by a bridge, we think this error |
375 | * is related to the downstream link of the bridge, so we | 375 | * is related to the downstream link of the bridge, so we |
@@ -440,7 +440,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) | |||
440 | pci_ers_result_t status; | 440 | pci_ers_result_t status; |
441 | struct pcie_port_service_driver *driver; | 441 | struct pcie_port_service_driver *driver; |
442 | 442 | ||
443 | if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) { | 443 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { |
444 | /* Reset this port for all subordinates */ | 444 | /* Reset this port for all subordinates */ |
445 | udev = dev; | 445 | udev = dev; |
446 | } else { | 446 | } else { |
@@ -660,7 +660,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) | |||
660 | &info->mask); | 660 | &info->mask); |
661 | if (!(info->status & ~info->mask)) | 661 | if (!(info->status & ~info->mask)) |
662 | return 0; | 662 | return 0; |
663 | } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE || | 663 | } else if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || |
664 | info->severity == AER_NONFATAL) { | 664 | info->severity == AER_NONFATAL) { |
665 | 665 | ||
666 | /* Link is still healthy for IO reads */ | 666 | /* Link is still healthy for IO reads */ |