aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2014-05-22 19:07:43 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-05-28 17:20:31 -0400
commit31c2b8153c58f11ddb80dfd392c16f13c2d709c6 (patch)
tree7ceb946ee75079ed1552f9a60e471a97bb3fa72b
parent6b121592f8a3fd2bd0de128637b76a0d0864d993 (diff)
PCI: Add support for DMA alias quirks
Some devices are broken and use a requester ID other than their physical devfn. Add a byte, using an existing gap in the pci_dev structure, to store an alternate "alias" devfn. A bit in the dev_flags tells us when this is valid. We then add the alias as one more step in the pci_for_each_dma_alias() iterator. Tested-by: George Spelvin <linux@horizon.com> Tested-by: Pat Erley <pat-lkml@erley.org> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/search.c11
-rw-r--r--include/linux/pci.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 5601cdb8bbb3..2c19f3f40621 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -37,6 +37,17 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
37 if (ret) 37 if (ret)
38 return ret; 38 return ret;
39 39
40 /*
41 * If the device is broken and uses an alias requester ID for
42 * DMA, iterate over that too.
43 */
44 if (unlikely(pdev->dev_flags & PCI_DEV_FLAGS_DMA_ALIAS_DEVFN)) {
45 ret = fn(pdev, PCI_DEVID(pdev->bus->number,
46 pdev->dma_alias_devfn), data);
47 if (ret)
48 return ret;
49 }
50
40 for (bus = pdev->bus; !pci_is_root_bus(bus); bus = bus->parent) { 51 for (bus = pdev->bus; !pci_is_root_bus(bus); bus = bus->parent) {
41 struct pci_dev *tmp; 52 struct pci_dev *tmp;
42 53
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 545903df00dc..9d4035c276f4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -171,6 +171,8 @@ enum pci_dev_flags {
171 PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) (1 << 2), 171 PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) (1 << 2),
172 /* Flag for quirk use to store if quirk-specific ACS is enabled */ 172 /* Flag for quirk use to store if quirk-specific ACS is enabled */
173 PCI_DEV_FLAGS_ACS_ENABLED_QUIRK = (__force pci_dev_flags_t) (1 << 3), 173 PCI_DEV_FLAGS_ACS_ENABLED_QUIRK = (__force pci_dev_flags_t) (1 << 3),
174 /* Flag to indicate the device uses dma_alias_devfn */
175 PCI_DEV_FLAGS_DMA_ALIAS_DEVFN = (__force pci_dev_flags_t) (1 << 4),
174}; 176};
175 177
176enum pci_irq_reroute_variant { 178enum pci_irq_reroute_variant {
@@ -268,6 +270,7 @@ struct pci_dev {
268 u8 rom_base_reg; /* which config register controls the ROM */ 270 u8 rom_base_reg; /* which config register controls the ROM */
269 u8 pin; /* which interrupt pin this device uses */ 271 u8 pin; /* which interrupt pin this device uses */
270 u16 pcie_flags_reg; /* cached PCIe Capabilities Register */ 272 u16 pcie_flags_reg; /* cached PCIe Capabilities Register */
273 u8 dma_alias_devfn;/* devfn of DMA alias, if any */
271 274
272 struct pci_driver *driver; /* which driver has allocated this device */ 275 struct pci_driver *driver; /* which driver has allocated this device */
273 u64 dma_mask; /* Mask of the bits of bus address this 276 u64 dma_mask; /* Mask of the bits of bus address this