Skip to content

Commit 9bc9310

Browse files
Naveenaidubjorn-helgaas
authored andcommitted
PCI: Use PCI_SET_ERROR_RESPONSE() for disconnected devices
A config read from a PCI device that doesn't exist or doesn't respond causes a PCI error. There's no real data to return to satisfy the CPU read, so most hardware fabricates ~0 data. Use PCI_SET_ERROR_RESPONSE() to set the error response when we think the device has already been disconnected. This helps unify PCI error response checking and make error checks consistent and easier to find. Link: https://lore.kernel.org/r/29db0a6874716db80757e4e3cdd03562f13eb0cb.1637243717.git.naveennaidu479@gmail.com Signed-off-by: Naveen Naidu <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent f4f7eb4 commit 9bc9310

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pci/access.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
529529
int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
530530
{
531531
if (pci_dev_is_disconnected(dev)) {
532-
*val = ~0;
532+
PCI_SET_ERROR_RESPONSE(val);
533533
return PCIBIOS_DEVICE_NOT_FOUND;
534534
}
535535
return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
@@ -539,7 +539,7 @@ EXPORT_SYMBOL(pci_read_config_byte);
539539
int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
540540
{
541541
if (pci_dev_is_disconnected(dev)) {
542-
*val = ~0;
542+
PCI_SET_ERROR_RESPONSE(val);
543543
return PCIBIOS_DEVICE_NOT_FOUND;
544544
}
545545
return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
@@ -550,7 +550,7 @@ int pci_read_config_dword(const struct pci_dev *dev, int where,
550550
u32 *val)
551551
{
552552
if (pci_dev_is_disconnected(dev)) {
553-
*val = ~0;
553+
PCI_SET_ERROR_RESPONSE(val);
554554
return PCIBIOS_DEVICE_NOT_FOUND;
555555
}
556556
return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);

0 commit comments

Comments
 (0)