Merge branches 'pci/aer', 'pci/enumeration', 'pci/kconfig', 'pci/misc', 'pci/virtuali...
authorBjorn Helgaas <bhelgaas@google.com>
Tue, 15 Mar 2016 13:55:02 +0000 (08:55 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 15 Mar 2016 13:55:02 +0000 (08:55 -0500)
* pci/aer:
  PCI/AER: Log aer_inject error injections
  PCI/AER: Log actual error causes in aer_inject
  PCI/AER: Use dev_warn() in aer_inject
  PCI/AER: Fix aer_inject error codes

* pci/enumeration:
  PCI: Fix broken URL for Dell biosdevname

* pci/kconfig:
  PCI: Cleanup pci/pcie/Kconfig whitespace
  PCI: Include pci/hotplug Kconfig directly from pci/Kconfig
  PCI: Include pci/pcie/Kconfig directly from pci/Kconfig

* pci/misc:
  PCI: Add PCI_CLASS_SERIAL_USB_DEVICE definition
  PCI: Add QEMU top-level IDs for (sub)vendor & device
  unicore32: Remove unused HAVE_ARCH_PCI_SET_DMA_MASK definition
  PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
  PCI: Move pci_dma_* helpers to common code
  frv/PCI: Remove stray pci_{alloc,free}_consistent() declaration

* pci/virtualization:
  PCI: Wait for up to 1000ms after FLR reset
  PCI: Support SR-IOV on any function type

* pci/vpd:
  PCI: Prevent VPD access for buggy devices
  PCI: Sleep rather than busy-wait for VPD access completion
  PCI: Fold struct pci_vpd_pci22 into struct pci_vpd
  PCI: Rename VPD symbols to remove unnecessary "pci22"
  PCI: Remove struct pci_vpd_ops.release function pointer
  PCI: Move pci_vpd_release() from header file to pci/access.c
  PCI: Move pci_read_vpd() and pci_write_vpd() close to other VPD code
  PCI: Determine actual VPD size on first access
  PCI: Use bitfield instead of bool for struct pci_vpd_pci22.busy
  PCI: Allow access to VPD attributes with size 0
  PCI: Update VPD definitions

1  2  3  4  5  6  7 
drivers/pci/pci.c
drivers/pci/probe.c
drivers/pci/quirks.c
include/linux/pci.h

diff --combined drivers/pci/pci.c
index 64c0a1215f842b2d00e488d0bd8675f4198a1534,602eb422351060c611967538359b8409885397a1,602eb422351060c611967538359b8409885397a1,602eb422351060c611967538359b8409885397a1,0a9c8db51c08f8f7bbb6a1fda9240e063535767d,123408e5a1d628f36490f88115a35aa525b957d8,602eb422351060c611967538359b8409885397a1..eaf4ffc0c27363bcde85fc4141f882fede59fcde
       #include <linux/device.h>
       #include <linux/pm_runtime.h>
       #include <linux/pci_hotplug.h>
 --- --#include <asm-generic/pci-bridge.h>
       #include <asm/setup.h>
       #include <linux/aer.h>
       #include "pci.h"
@@@@@@@@ -3385,18 -3386,18 -3386,18 -3386,18 -3385,6 -3386,18 -3386,18 +3385,6 @@@@@@@@ bool pci_check_and_unmask_intx(struct p
       }
       EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx);
       
---- --int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size)
---- --{
---- -- return dma_set_max_seg_size(&dev->dev, size);
---- --}
---- --EXPORT_SYMBOL(pci_set_dma_max_seg_size);
---- --
---- --int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask)
---- --{
---- -- return dma_set_seg_boundary(&dev->dev, mask);
---- --}
---- --EXPORT_SYMBOL(pci_set_dma_seg_boundary);
---- --
       /**
        * pci_wait_for_pending_transaction - waits for pending transaction
        * @dev: the PCI device to operate on
@@@@@@@@ -3413,6 -3414,6 -3414,6 -3414,6 -3401,6 -3414,29 -3414,6 +3401,29 @@@@@@@@ int pci_wait_for_pending_transaction(st
       }
       EXPORT_SYMBOL(pci_wait_for_pending_transaction);
       
+++++ +/*
+++++ + * We should only need to wait 100ms after FLR, but some devices take longer.
+++++ + * Wait for up to 1000ms for config space to return something other than -1.
+++++ + * Intel IGD requires this when an LCD panel is attached.  We read the 2nd
+++++ + * dword because VFs don't implement the 1st dword.
+++++ + */
+++++ +static void pci_flr_wait(struct pci_dev *dev)
+++++ +{
+++++ + int i = 0;
+++++ + u32 id;
+++++ +
+++++ + do {
+++++ +         msleep(100);
+++++ +         pci_read_config_dword(dev, PCI_COMMAND, &id);
+++++ + } while (i++ < 10 && id == ~0);
+++++ +
+++++ + if (id == ~0)
+++++ +         dev_warn(&dev->dev, "Failed to return from FLR\n");
+++++ + else if (i > 1)
+++++ +         dev_info(&dev->dev, "Required additional %dms to return from FLR\n",
+++++ +                  (i - 1) * 100);
+++++ +}
+++++ +
       static int pcie_flr(struct pci_dev *dev, int probe)
       {
        u32 cap;
                dev_err(&dev->dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
       
        pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
----- - msleep(100);
+++++ + pci_flr_wait(dev);
        return 0;
       }
       
@@@@@@@@ -3458,7 -3459,7 -3459,7 -3459,7 -3446,7 -3482,7 -3459,7 +3469,7 @@@@@@@@ static int pci_af_flr(struct pci_dev *d
                dev_err(&dev->dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n");
       
        pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
----- - msleep(100);
+++++ + pci_flr_wait(dev);
        return 0;
       }
       
diff --combined drivers/pci/probe.c
index 5eb378fbe8496dd2b715164e9fd6fcaaef417bd0,6d7ab9bb0d5a6f002debd5a3b83e569f78c44c96,6d7ab9bb0d5a6f002debd5a3b83e569f78c44c96,6d7ab9bb0d5a6f002debd5a3b83e569f78c44c96,5eb378fbe8496dd2b715164e9fd6fcaaef417bd0,6d7ab9bb0d5a6f002debd5a3b83e569f78c44c96,39b017447b70a57fba2288370f1b788ca106acfa..3f1d0095235588f3a5b84bcf95f920276e40cb67
       #include <linux/pci-aspm.h>
       #include <linux/aer.h>
       #include <linux/acpi.h>
 --- --#include <asm-generic/pci-bridge.h>
       #include "pci.h"
       
       #define CARDBUS_LATENCY_TIMER    176     /* secondary latency timer */
@@@@@@@@ -1607,7 -1608,7 -1608,7 -1608,7 -1607,7 -1608,7 -1608,7 +1607,7 @@@@@@@@ static void pci_init_capabilities(struc
        pci_pm_init(dev);
       
        /* Vital Product Data */
------  pci_vpd_pci22_init(dev);
++++++  pci_vpd_init(dev);
       
        /* Alternative Routing-ID Forwarding */
        pci_configure_ari(dev);
@@@@@@@@ -1802,13 -1803,6 -1803,6 -1803,6 -1802,13 -1803,6 -1803,6 +1802,13 @@@@@@@@ static int only_one_child(struct pci_bu
                return 0;
        if (pci_pcie_type(parent) == PCI_EXP_TYPE_ROOT_PORT)
                return 1;
 +++ ++
 +++ ++ /*
 +++ ++  * PCIe downstream ports are bridges that normally lead to only a
 +++ ++  * device 0, but if PCI_SCAN_ALL_PCIE_DEVS is set, scan all
 +++ ++  * possible devices, not just device 0.  See PCIe spec r3.0,
 +++ ++  * sec 7.3.1.
 +++ ++  */
        if (parent->has_secondary_link &&
            !pci_has_flag(PCI_SCAN_ALL_PCIE_DEVS))
                return 1;
diff --combined drivers/pci/quirks.c
index 85fa6a2a6dd20c8866b9e58f12193b6f6a20a390,0575a1e026b4c4550ee07655910cc64d0e0e9341,0575a1e026b4c4550ee07655910cc64d0e0e9341,0575a1e026b4c4550ee07655910cc64d0e0e9341,5714fcfde302bcf1d38734f87d174295dad0433f,85fa6a2a6dd20c8866b9e58f12193b6f6a20a390,626c3b22c053685ddba31f47b46e647a8ba27b5d..8e678027b9008ee15e741967313332db2818c8d8
@@@@@@@@ -438,7 -438,7 -438,7 -438,7 -438,7 -438,7 -438,7 +438,7 @@@@@@@@ static void quirk_amd_nl_class(struct p
        u32 class = pdev->class;
       
        /* Use "USB Device (not host controller)" class */
---- -- pdev->class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe;
++++ ++ pdev->class = PCI_CLASS_SERIAL_USB_DEVICE;
        dev_info(&pdev->dev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n",
                 class, pdev->class);
       }
@@@@@@@@ -2134,6 -2134,6 -2134,6 -2134,6 -2134,6 -2134,6 -2134,35 +2134,35 @@@@@@@@ static void quirk_via_cx700_pci_parking
       }
       DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching);
       
++++++ /*
++++++  * If a device follows the VPD format spec, the PCI core will not read or
++++++  * write past the VPD End Tag.  But some vendors do not follow the VPD
++++++  * format spec, so we can't tell how much data is safe to access.  Devices
++++++  * may behave unpredictably if we access too much.  Blacklist these devices
++++++  * so we don't touch VPD at all.
++++++  */
++++++ static void quirk_blacklist_vpd(struct pci_dev *dev)
++++++ {
++++++  if (dev->vpd) {
++++++          dev->vpd->len = 0;
++++++          dev_warn(&dev->dev, FW_BUG "VPD access disabled\n");
++++++  }
++++++ }
++++++ 
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0060, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x007c, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0413, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0078, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0079, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0073, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x0071, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005b, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x002f, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005d, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LSI_LOGIC, 0x005f, quirk_blacklist_vpd);
++++++ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, PCI_ANY_ID,
++++++          quirk_blacklist_vpd);
++++++ 
       /*
        * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the
        * VPD end tag will hang the device.  This problem was initially
@@@@@@@@ -3832,19 -3832,6 -3832,6 -3832,6 -3832,6 -3832,19 -3861,6 +3861,19 @@@@@@@@ static int pci_quirk_amd_sb_acs(struct 
       #endif
       }
       
 ++++ +static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
 ++++ +{
 ++++ + /*
 ++++ +  * Cavium devices matching this quirk do not perform peer-to-peer
 ++++ +  * with other functions, allowing masking out these bits as if they
 ++++ +  * were unimplemented in the ACS capability.
 ++++ +  */
 ++++ + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR |
 ++++ +                PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT);
 ++++ +
 ++++ + return acs_flags ? 0 : 1;
 ++++ +}
 ++++ +
       /*
        * Many Intel PCH root ports do provide ACS-like features to disable peer
        * transactions and validate bus numbers in requests, but do not provide an
@@@@@@@@ -3997,8 -3984,6 -3984,6 -3984,6 -3984,6 -3997,8 -4013,6 +4026,8 @@@@@@@@ static const struct pci_dev_acs_enable
        { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs },
        { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */
        { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */
 ++++ + /* Cavium ThunderX */
 ++++ + { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs },
        { 0 }
       };
       
diff --combined include/linux/pci.h
index 3d371c15075316670f37ee2ac284d9befc9f9de8,27df4a6585daedcc6a74865bf048cfd06a0593ba,27df4a6585daedcc6a74865bf048cfd06a0593ba,27df4a6585daedcc6a74865bf048cfd06a0593ba,5049bd60ba90a291270d7d3223d68cc22fd3e796,27df4a6585daedcc6a74865bf048cfd06a0593ba,49ad85c3e88e40302c5788d194590a4f50f39068..c4defbc77a8ff7d8a888158d3bca85bcd3dd375b
@@@@@@@@ -70,12 -70,12 -70,12 -70,12 -70,6 -70,12 -70,12 +70,6 @@@@@@@@ enum pci_mmap_state 
        pci_mmap_mem
       };
       
---- --/* This defines the direction arg to the DMA mapping routines. */
---- --#define PCI_DMA_BIDIRECTIONAL    0
---- --#define PCI_DMA_TODEVICE 1
---- --#define PCI_DMA_FROMDEVICE       2
---- --#define PCI_DMA_NONE             3
---- --
       /*
        *  For PCI devices, the region numbers are assigned this way:
        */
@@@@@@@@ -746,26 -746,9 -746,9 -746,9 -740,26 -746,9 -746,9 +740,26 @@@@@@@@ struct pci_driver 
        .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
        .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
       
 +++ ++enum {
 +++ ++ PCI_REASSIGN_ALL_RSRC   = 0x00000001,   /* ignore firmware setup */
 +++ ++ PCI_REASSIGN_ALL_BUS    = 0x00000002,   /* reassign all bus numbers */
 +++ ++ PCI_PROBE_ONLY          = 0x00000004,   /* use existing setup */
 +++ ++ PCI_CAN_SKIP_ISA_ALIGN  = 0x00000008,   /* don't do ISA alignment */
 +++ ++ PCI_ENABLE_PROC_DOMAINS = 0x00000010,   /* enable domains in /proc */
 +++ ++ PCI_COMPAT_DOMAIN_0     = 0x00000020,   /* ... except domain 0 */
 +++ ++ PCI_SCAN_ALL_PCIE_DEVS  = 0x00000040,   /* scan all, not just dev 0 */
 +++ ++};
 +++ ++
       /* these external functions are only available when PCI support is enabled */
       #ifdef CONFIG_PCI
       
 +++ ++extern unsigned int pci_flags;
 +++ ++
 +++ ++static inline void pci_set_flags(int flags) { pci_flags = flags; }
 +++ ++static inline void pci_add_flags(int flags) { pci_flags |= flags; }
 +++ ++static inline void pci_clear_flags(int flags) { pci_flags &= ~flags; }
 +++ ++static inline int pci_has_flag(int flag) { return pci_flags & flag; }
 +++ ++
       void pcie_bus_configure_settings(struct pci_bus *bus);
       
       enum pcie_bus_config_types {
@@@@@@@@ -1038,8 -1021,8 -1021,8 -1021,8 -1032,6 -1021,8 -1021,8 +1032,6 @@@@@@@@ void pci_intx(struct pci_dev *dev, int 
       bool pci_intx_mask_supported(struct pci_dev *dev);
       bool pci_check_and_mask_intx(struct pci_dev *dev);
       bool pci_check_and_unmask_intx(struct pci_dev *dev);
---- --int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
---- --int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
       int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask);
       int pci_wait_for_pending_transaction(struct pci_dev *dev);
       int pcix_get_max_mmrbc(struct pci_dev *dev);
@@@@@@@@ -1255,6 -1238,6 -1238,6 -1238,6 -1247,7 -1238,6 -1238,6 +1247,7 @@@@@@@@ resource_size_t pcibios_iov_resource_al
       
       int pci_set_vga_state(struct pci_dev *pdev, bool decode,
                      unsigned int command_bits, u32 flags);
++++ ++
       /* kmem_cache style wrapper around pci_alloc_consistent() */
       
       #include <linux/pci-dma.h>
@@@@@@@@ -1422,11 -1405,6 -1405,6 -1405,6 -1415,11 -1405,6 -1405,6 +1415,11 @@@@@@@@ void pci_register_set_vga_state(arch_se
       
       #else /* CONFIG_PCI is not enabled */
       
 +++ ++static inline void pci_set_flags(int flags) { }
 +++ ++static inline void pci_add_flags(int flags) { }
 +++ ++static inline void pci_clear_flags(int flags) { }
 +++ ++static inline int pci_has_flag(int flag) { return 0; }
 +++ ++
       /*
        *  If the system does not have PCI, clearly these return errors.  Define
        *  these as simple inline functions to avoid hair in drivers.
@@@@@@@@ -1466,16 -1444,16 -1444,16 -1444,16 -1459,6 -1444,16 -1444,16 +1459,6 @@@@@@@@ static inline struct pci_dev *pci_get_c
       static inline void pci_set_master(struct pci_dev *dev) { }
       static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
       static inline void pci_disable_device(struct pci_dev *dev) { }
---- --static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
---- --{ return -EIO; }
---- --static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
---- --{ return -EIO; }
---- --static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
---- --                                 unsigned int size)
---- --{ return -EIO; }
---- --static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
---- --                                 unsigned long mask)
---- --{ return -EIO; }
       static inline int pci_assign_resource(struct pci_dev *dev, int i)
       { return -EBUSY; }
       static inline int __pci_register_driver(struct pci_driver *drv,
@@@@@@@@ -1856,12 -1834,12 -1834,12 -1834,12 -1839,12 -1834,12 -1834,13 +1839,13 @@@@@@@@ bool pci_acs_path_enabled(struct pci_de
       #define PCI_VPD_LRDT_RW_DATA             PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
       
       /* Small Resource Data Type Tag Item Names */
------ #define PCI_VPD_STIN_END         0x78    /* End */
++++++ #define PCI_VPD_STIN_END         0x0f    /* End */
       
------ #define PCI_VPD_SRDT_END         PCI_VPD_STIN_END
++++++ #define PCI_VPD_SRDT_END         (PCI_VPD_STIN_END << 3)
       
       #define PCI_VPD_SRDT_TIN_MASK            0x78
       #define PCI_VPD_SRDT_LEN_MASK            0x07
++++++ #define PCI_VPD_LRDT_TIN_MASK            0x7f
       
       #define PCI_VPD_LRDT_TAG_SIZE            3
       #define PCI_VPD_SRDT_TAG_SIZE            1
@@@@@@@@ -1884,6 -1862,6 -1862,6 -1862,6 -1867,6 -1862,6 -1863,17 +1868,17 @@@@@@@@ static inline u16 pci_vpd_lrdt_size(con
        return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
       }
       
++++++ /**
++++++  * pci_vpd_lrdt_tag - Extracts the Large Resource Data Type Tag Item
++++++  * @lrdt: Pointer to the beginning of the Large Resource Data Type tag
++++++  *
++++++  * Returns the extracted Large Resource Data Type Tag item.
++++++  */
++++++ static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt)
++++++ {
++++++     return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK);
++++++ }
++++++ 
       /**
        * pci_vpd_srdt_size - Extracts the Small Resource Data Type length
        * @lrdt: Pointer to the beginning of the Small Resource Data Type tag
@@@@@@@@ -1895,6 -1873,6 -1873,6 -1873,6 -1878,6 -1873,6 -1885,17 +1890,17 @@@@@@@@ static inline u8 pci_vpd_srdt_size(cons
        return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
       }
       
++++++ /**
++++++  * pci_vpd_srdt_tag - Extracts the Small Resource Data Type Tag Item
++++++  * @lrdt: Pointer to the beginning of the Small Resource Data Type tag
++++++  *
++++++  * Returns the extracted Small Resource Data Type Tag Item.
++++++  */
++++++ static inline u8 pci_vpd_srdt_tag(const u8 *srdt)
++++++ {
++++++  return ((*srdt) & PCI_VPD_SRDT_TIN_MASK) >> 3;
++++++ }
++++++ 
       /**
        * pci_vpd_info_field_size - Extracts the information field length
        * @lrdt: Pointer to the beginning of an information field header
@@@@@@@@ -2011,4 -1989,4 -1989,4 -1989,4 -1994,8 -1989,4 -2012,4 +2017,8 @@@@@@@@ static inline bool pci_ari_enabled(stru
       {
        return bus->self && bus->self->ari_enabled;
       }
++++ ++
++++ ++/* provide the legacy pci_dma_* API */
++++ ++#include <linux/pci-dma-compat.h>
++++ ++
       #endif /* LINUX_PCI_H */