]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
PCI: Add support for DMA alias quirks
authorAlex Williamson <alex.williamson@redhat.com>
Thu, 22 May 2014 23:07:43 +0000 (17:07 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 28 May 2014 21:20:31 +0000 (15:20 -0600)
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>
drivers/pci/search.c
include/linux/pci.h

index 5601cdb8bbb31677f5686f7845cdbdbcd96a784b..2c19f3f406216008a8cf1ae5e5e77401a9f0a72c 100644 (file)
@@ -37,6 +37,17 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
        if (ret)
                return ret;
 
+       /*
+        * If the device is broken and uses an alias requester ID for
+        * DMA, iterate over that too.
+        */
+       if (unlikely(pdev->dev_flags & PCI_DEV_FLAGS_DMA_ALIAS_DEVFN)) {
+               ret = fn(pdev, PCI_DEVID(pdev->bus->number,
+                                        pdev->dma_alias_devfn), data);
+               if (ret)
+                       return ret;
+       }
+
        for (bus = pdev->bus; !pci_is_root_bus(bus); bus = bus->parent) {
                struct pci_dev *tmp;
 
index 545903df00dc46ef51ec3c929903ec5cf2930122..9d4035c276f47df39cf7d0415e80df4d1cc7f7c0 100644 (file)
@@ -171,6 +171,8 @@ enum pci_dev_flags {
        PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) (1 << 2),
        /* Flag for quirk use to store if quirk-specific ACS is enabled */
        PCI_DEV_FLAGS_ACS_ENABLED_QUIRK = (__force pci_dev_flags_t) (1 << 3),
+       /* Flag to indicate the device uses dma_alias_devfn */
+       PCI_DEV_FLAGS_DMA_ALIAS_DEVFN = (__force pci_dev_flags_t) (1 << 4),
 };
 
 enum pci_irq_reroute_variant {
@@ -268,6 +270,7 @@ struct pci_dev {
        u8              rom_base_reg;   /* which config register controls the ROM */
        u8              pin;            /* which interrupt pin this device uses */
        u16             pcie_flags_reg; /* cached PCIe Capabilities Register */
+       u8              dma_alias_devfn;/* devfn of DMA alias, if any */
 
        struct pci_driver *driver;      /* which driver has allocated this device */
        u64             dma_mask;       /* Mask of the bits of bus address this