]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'pci/next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 16 Jan 2014 00:25:36 +0000 (11:25 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 16 Jan 2014 00:25:36 +0000 (11:25 +1100)
12 files changed:
1  2 
arch/powerpc/kernel/eeh_driver.c
arch/s390/pci/pci.c
drivers/acpi/pci_root.c
drivers/ata/ahci.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/pci/host/pci-tegra.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/quirks.c
drivers/platform/x86/eeepc-laptop.c
include/linux/pci.h

index 7db39203a07341030fb394ea22b201c6d3ed9557,c17f90d0f73c62a2bcb12bd5445ab53a2ee935f3..3d69b39176a271aa6f79b54c32d8b937585db102
@@@ -217,8 -217,7 +217,8 @@@ static void *eeh_report_mmio_enabled(vo
        if (!driver) return NULL;
  
        if (!driver->err_handler ||
 -          !driver->err_handler->mmio_enabled) {
 +          !driver->err_handler->mmio_enabled ||
 +          (edev->mode & EEH_DEV_NO_HANDLER)) {
                eeh_pcid_put(dev);
                return NULL;
        }
@@@ -259,8 -258,7 +259,8 @@@ static void *eeh_report_reset(void *dat
        eeh_enable_irq(dev);
  
        if (!driver->err_handler ||
 -          !driver->err_handler->slot_reset) {
 +          !driver->err_handler->slot_reset ||
 +          (edev->mode & EEH_DEV_NO_HANDLER)) {
                eeh_pcid_put(dev);
                return NULL;
        }
@@@ -299,9 -297,7 +299,9 @@@ static void *eeh_report_resume(void *da
        eeh_enable_irq(dev);
  
        if (!driver->err_handler ||
 -          !driver->err_handler->resume) {
 +          !driver->err_handler->resume ||
 +          (edev->mode & EEH_DEV_NO_HANDLER)) {
 +              edev->mode &= ~EEH_DEV_NO_HANDLER;
                eeh_pcid_put(dev);
                return NULL;
        }
@@@ -373,7 -369,9 +373,9 @@@ static void *eeh_rmv_device(void *data
        edev->mode |= EEH_DEV_DISCONNECTED;
        (*removed)++;
  
+       pci_lock_rescan_remove();
        pci_stop_and_remove_bus_device(dev);
+       pci_unlock_rescan_remove();
  
        return NULL;
  }
@@@ -420,10 -418,13 +422,13 @@@ static int eeh_reset_device(struct eeh_
         * into pcibios_add_pci_devices().
         */
        eeh_pe_state_mark(pe, EEH_PE_KEEP);
-       if (bus)
+       if (bus) {
+               pci_lock_rescan_remove();
                pcibios_remove_pci_devices(bus);
-       else if (frozen_bus)
+               pci_unlock_rescan_remove();
+       } else if (frozen_bus) {
                eeh_pe_dev_traverse(pe, eeh_rmv_device, &removed);
+       }
  
        /* Reset the pci controller. (Asserts RST#; resets config space).
         * Reconfigure bridges and devices. Don't try to bring the system
        if (rc)
                return rc;
  
+       pci_lock_rescan_remove();
        /* Restore PE */
        eeh_ops->configure_bridge(pe);
        eeh_pe_restore_bars(pe);
        pe->tstamp = tstamp;
        pe->freeze_count = cnt;
  
+       pci_unlock_rescan_remove();
        return 0;
  }
  
  /* The longest amount of time to wait for a pci device
   * to come back on line, in seconds.
   */
 -#define MAX_WAIT_FOR_RECOVERY 150
 +#define MAX_WAIT_FOR_RECOVERY 300
  
  static void eeh_handle_normal_event(struct eeh_pe *pe)
  {
@@@ -622,8 -626,11 +630,11 @@@ perm_error
        eeh_pe_dev_traverse(pe, eeh_report_failure, NULL);
  
        /* Shut down the device drivers for good. */
-       if (frozen_bus)
+       if (frozen_bus) {
+               pci_lock_rescan_remove();
                pcibios_remove_pci_devices(frozen_bus);
+               pci_unlock_rescan_remove();
+       }
  }
  
  static void eeh_handle_special_event(void)
        if (rc == 2 || rc == 1)
                eeh_handle_normal_event(pe);
        else {
+               pci_lock_rescan_remove();
                list_for_each_entry_safe(hose, tmp,
                        &hose_list, list_node) {
                        phb_pe = eeh_phb_pe_get(hose);
                        eeh_pe_dev_traverse(pe, eeh_report_failure, NULL);
                        pcibios_remove_pci_devices(bus);
                }
+               pci_unlock_rescan_remove();
        }
  }
  
diff --combined arch/s390/pci/pci.c
index 0820362c7b0f190ec66029597dee6d006d9487c0,4859c401b75e9cd82ad14e9a4263208745eeab60..66670ff262a0b5b722aa2f20418f1dae3c2e389f
@@@ -407,8 -407,8 +407,8 @@@ int arch_setup_msi_irqs(struct pci_dev 
        struct msi_msg msg;
        int rc;
  
-       if (type != PCI_CAP_ID_MSIX && type != PCI_CAP_ID_MSI)
-               return -EINVAL;
+       if (type == PCI_CAP_ID_MSI && nvec > 1)
+               return 1;
        msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX);
        msi_vecs = min_t(unsigned int, msi_vecs, CONFIG_PCI_NR_MSI);
  
@@@ -919,23 -919,17 +919,23 @@@ static void zpci_mem_exit(void
        kmem_cache_destroy(zdev_fmb_cache);
  }
  
 -static unsigned int s390_pci_probe;
 +static unsigned int s390_pci_probe = 1;
 +static unsigned int s390_pci_initialized;
  
  char * __init pcibios_setup(char *str)
  {
 -      if (!strcmp(str, "on")) {
 -              s390_pci_probe = 1;
 +      if (!strcmp(str, "off")) {
 +              s390_pci_probe = 0;
                return NULL;
        }
        return str;
  }
  
 +bool zpci_is_enabled(void)
 +{
 +      return s390_pci_initialized;
 +}
 +
  static int __init pci_base_init(void)
  {
        int rc;
        if (rc)
                goto out_find;
  
 +      s390_pci_initialized = 1;
        return 0;
  
  out_find:
@@@ -985,6 -978,5 +985,6 @@@ subsys_initcall_sync(pci_base_init)
  
  void zpci_rescan(void)
  {
 -      clp_rescan_pci_devices_simple();
 +      if (zpci_is_enabled())
 +              clp_rescan_pci_devices_simple();
  }
diff --combined drivers/acpi/pci_root.c
index 20360e480bd8d81c0070cc25b5cd2cddd05d0447,07ee02aa3c51a4ea99df9780ac1069fa3025ef75..5b01bd6d5ea0e01481d93b305f2453b7e68ba48c
@@@ -65,9 -65,6 +65,9 @@@ static struct acpi_scan_handler pci_roo
        .ids = root_device_ids,
        .attach = acpi_pci_root_add,
        .detach = acpi_pci_root_remove,
 +      .hotplug = {
 +              .ignore = true,
 +      },
  };
  
  static DEFINE_MUTEX(osc_lock);
@@@ -599,7 -596,9 +599,9 @@@ static int acpi_pci_root_add(struct acp
                pci_assign_unassigned_root_bus_resources(root->bus);
        }
  
+       pci_lock_rescan_remove();
        pci_bus_add_devices(root->bus);
+       pci_unlock_rescan_remove();
        return 1;
  
  end:
@@@ -611,6 -610,8 +613,8 @@@ static void acpi_pci_root_remove(struc
  {
        struct acpi_pci_root *root = acpi_driver_data(device);
  
+       pci_lock_rescan_remove();
        pci_stop_root_bus(root->bus);
  
        device_set_run_wake(root->bus->bridge, false);
  
        pci_remove_root_bus(root->bus);
  
+       pci_unlock_rescan_remove();
        kfree(root);
  }
  
diff --combined drivers/ata/ahci.c
index e3a92a6da39ae258cf9a4094f4293799e378271b,8516f4d47893b07a352ab520d4c2d5ca6a0a782e..0ef5ac6103520af5151da1b879d2ae470333f9d7
@@@ -427,9 -427,6 +427,9 @@@ static const struct pci_device_id ahci_
          .driver_data = board_ahci_yes_fbs },                  /* 88se9128 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9125),
          .driver_data = board_ahci_yes_fbs },                  /* 88se9125 */
 +      { PCI_DEVICE_SUB(PCI_VENDOR_ID_MARVELL_EXT, 0x9178,
 +                       PCI_VENDOR_ID_MARVELL_EXT, 0x9170),
 +        .driver_data = board_ahci_yes_fbs },                  /* 88se9170 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x917a),
          .driver_data = board_ahci_yes_fbs },                  /* 88se9172 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9172),
          .driver_data = board_ahci_yes_fbs },                  /* 88se9172 on some Gigabyte */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3),
          .driver_data = board_ahci_yes_fbs },
 +      { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
 +        .driver_data = board_ahci_yes_fbs },
  
        /* Promise */
        { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci },   /* PDC42819 */
@@@ -1100,26 -1095,40 +1100,40 @@@ static inline void ahci_gtf_filter_work
  {}
  #endif
  
- int ahci_init_interrupts(struct pci_dev *pdev, struct ahci_host_priv *hpriv)
+ int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
+                        struct ahci_host_priv *hpriv)
  {
-       int rc;
-       unsigned int maxvec;
+       int rc, nvec;
  
-       if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) {
-               rc = pci_enable_msi_block_auto(pdev, &maxvec);
-               if (rc > 0) {
-                       if ((rc == maxvec) || (rc == 1))
-                               return rc;
-                       /*
-                        * Assume that advantage of multipe MSIs is negated,
-                        * so fallback to single MSI mode to save resources
-                        */
-                       pci_disable_msi(pdev);
-                       if (!pci_enable_msi(pdev))
-                               return 1;
-               }
-       }
+       if (hpriv->flags & AHCI_HFLAG_NO_MSI)
+               goto intx;
+       rc = pci_msi_vec_count(pdev);
+       if (rc < 0)
+               goto intx;
+       /*
+        * If number of MSIs is less than number of ports then Sharing Last
+        * Message mode could be enforced. In this case assume that advantage
+        * of multipe MSIs is negated and use single MSI mode instead.
+        */
+       if (rc < n_ports)
+               goto single_msi;
+       nvec = rc;
+       rc = pci_enable_msi_block(pdev, nvec);
+       if (rc)
+               goto intx;
  
+       return nvec;
+ single_msi:
+       rc = pci_enable_msi(pdev);
+       if (rc)
+               goto intx;
+       return 1;
+ intx:
        pci_intx(pdev, 1);
        return 0;
  }
@@@ -1241,6 -1250,15 +1255,6 @@@ static int ahci_init_one(struct pci_de
        if (rc)
                return rc;
  
 -      /* AHCI controllers often implement SFF compatible interface.
 -       * Grab all PCI BARs just in case.
 -       */
 -      rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME);
 -      if (rc == -EBUSY)
 -              pcim_pin_device(pdev);
 -      if (rc)
 -              return rc;
 -
        if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
            (pdev->device == 0x2652 || pdev->device == 0x2653)) {
                u8 map;
                }
        }
  
 +      /* AHCI controllers often implement SFF compatible interface.
 +       * Grab all PCI BARs just in case.
 +       */
 +      rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME);
 +      if (rc == -EBUSY)
 +              pcim_pin_device(pdev);
 +      if (rc)
 +              return rc;
 +
        hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
        if (!hpriv)
                return -ENOMEM;
  
        hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
  
-       n_msis = ahci_init_interrupts(pdev, hpriv);
-       if (n_msis > 1)
-               hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
        /* save initial config */
        ahci_pci_save_initial_config(pdev, hpriv);
  
         */
        n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
  
+       n_msis = ahci_init_interrupts(pdev, n_ports, hpriv);
+       if (n_msis > 1)
+               hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
        host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
        if (!host)
                return -ENOMEM;
index d3c3b5b15824ee8bb927a7b1a382582309b31376,15604b3dda3e6f442e0f52f07e352c9bd09d481c..3540569948dbd62db3a2fd5980e141879162115d
@@@ -57,9 -57,7 +57,9 @@@ typedef gen8_gtt_pte_t gen8_ppgtt_pde_t
  #define HSW_WB_LLC_AGE3                       HSW_CACHEABILITY_CONTROL(0x2)
  #define HSW_WB_LLC_AGE0                       HSW_CACHEABILITY_CONTROL(0x3)
  #define HSW_WB_ELLC_LLC_AGE0          HSW_CACHEABILITY_CONTROL(0xb)
 +#define HSW_WB_ELLC_LLC_AGE3          HSW_CACHEABILITY_CONTROL(0x8)
  #define HSW_WT_ELLC_LLC_AGE0          HSW_CACHEABILITY_CONTROL(0x6)
 +#define HSW_WT_ELLC_LLC_AGE3          HSW_CACHEABILITY_CONTROL(0x7)
  
  #define GEN8_PTES_PER_PAGE            (PAGE_SIZE / sizeof(gen8_gtt_pte_t))
  #define GEN8_PDES_PER_PAGE            (PAGE_SIZE / sizeof(gen8_ppgtt_pde_t))
@@@ -187,10 -185,10 +187,10 @@@ static gen6_gtt_pte_t iris_pte_encode(d
        case I915_CACHE_NONE:
                break;
        case I915_CACHE_WT:
 -              pte |= HSW_WT_ELLC_LLC_AGE0;
 +              pte |= HSW_WT_ELLC_LLC_AGE3;
                break;
        default:
 -              pte |= HSW_WB_ELLC_LLC_AGE0;
 +              pte |= HSW_WB_ELLC_LLC_AGE3;
                break;
        }
  
@@@ -337,8 -335,8 +337,8 @@@ static void gen8_ppgtt_cleanup(struct i
                kfree(ppgtt->gen8_pt_dma_addr[i]);
        }
  
 -      __free_pages(ppgtt->gen8_pt_pages, ppgtt->num_pt_pages << PAGE_SHIFT);
 -      __free_pages(ppgtt->pd_pages, ppgtt->num_pd_pages << PAGE_SHIFT);
 +      __free_pages(ppgtt->gen8_pt_pages, get_order(ppgtt->num_pt_pages << PAGE_SHIFT));
 +      __free_pages(ppgtt->pd_pages, get_order(ppgtt->num_pd_pages << PAGE_SHIFT));
  }
  
  /**
@@@ -906,12 -904,14 +906,12 @@@ static void gen8_ggtt_insert_entries(st
                WARN_ON(readq(&gtt_entries[i-1])
                        != gen8_pte_encode(addr, level, true));
  
 -#if 0 /* TODO: Still needed on GEN8? */
        /* This next bit makes the above posting read even more important. We
         * want to flush the TLBs only after we're certain all the PTE updates
         * have finished.
         */
        I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
        POSTING_READ(GFX_FLSH_CNTL_GEN6);
 -#endif
  }
  
  /*
@@@ -1239,11 -1239,6 +1239,11 @@@ static inline unsigned int gen8_get_tot
        bdw_gmch_ctl &= BDW_GMCH_GGMS_MASK;
        if (bdw_gmch_ctl)
                bdw_gmch_ctl = 1 << bdw_gmch_ctl;
 +      if (bdw_gmch_ctl > 4) {
 +              WARN_ON(!i915_preliminary_hw_support);
 +              return 4<<20;
 +      }
 +
        return bdw_gmch_ctl << 20;
  }
  
@@@ -1265,14 -1260,14 +1265,14 @@@ static int ggtt_probe_common(struct drm
                             size_t gtt_size)
  {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       phys_addr_t gtt_bus_addr;
+       phys_addr_t gtt_phys_addr;
        int ret;
  
        /* For Modern GENs the PTEs and register space are split in the BAR */
-       gtt_bus_addr = pci_resource_start(dev->pdev, 0) +
+       gtt_phys_addr = pci_resource_start(dev->pdev, 0) +
                (pci_resource_len(dev->pdev, 0) / 2);
  
-       dev_priv->gtt.gsm = ioremap_wc(gtt_bus_addr, gtt_size);
+       dev_priv->gtt.gsm = ioremap_wc(gtt_phys_addr, gtt_size);
        if (!dev_priv->gtt.gsm) {
                DRM_ERROR("Failed to map the gtt page table\n");
                return -ENOMEM;
index 0175041ab728b8a641194f432146fa3e1e84c646,b8ba2f794559c65fba1aed5b6eebfd82f4c364b5..330f7e3a32dd9f3694a09844106b551751235296
@@@ -25,6 -25,7 +25,6 @@@
   */
  
  #include <linux/clk.h>
 -#include <linux/clk/tegra.h>
  #include <linux/delay.h>
  #include <linux/export.h>
  #include <linux/interrupt.h>
@@@ -38,7 -39,6 +38,7 @@@
  #include <linux/of_platform.h>
  #include <linux/pci.h>
  #include <linux/platform_device.h>
 +#include <linux/reset.h>
  #include <linux/sizes.h>
  #include <linux/slab.h>
  #include <linux/tegra-cpuidle.h>
@@@ -259,13 -259,10 +259,13 @@@ struct tegra_pcie 
  
        struct clk *pex_clk;
        struct clk *afi_clk;
 -      struct clk *pcie_xclk;
        struct clk *pll_e;
        struct clk *cml_clk;
  
 +      struct reset_control *pex_rst;
 +      struct reset_control *afi_rst;
 +      struct reset_control *pcie_xrst;
 +
        struct tegra_msi msi;
  
        struct list_head ports;
@@@ -808,7 -805,7 +808,7 @@@ static int tegra_pcie_enable_controller
        afi_writel(pcie, value, AFI_PCIE_CONFIG);
  
        value = afi_readl(pcie, AFI_FUSE);
-       value &= ~AFI_FUSE_PCIE_T0_GEN2_DIS;
+       value |= AFI_FUSE_PCIE_T0_GEN2_DIS;
        afi_writel(pcie, value, AFI_FUSE);
  
        /* initialize internal PHY, enable up to 16 PCIE lanes */
        pads_writel(pcie, value, PADS_CTL);
  
        /* take the PCIe interface module out of reset */
 -      tegra_periph_reset_deassert(pcie->pcie_xclk);
 +      reset_control_deassert(pcie->pcie_xrst);
  
        /* finally enable PCIe */
        value = afi_readl(pcie, AFI_CONFIGURATION);
@@@ -894,9 -891,9 +894,9 @@@ static void tegra_pcie_power_off(struc
  
        /* TODO: disable and unprepare clocks? */
  
 -      tegra_periph_reset_assert(pcie->pcie_xclk);
 -      tegra_periph_reset_assert(pcie->afi_clk);
 -      tegra_periph_reset_assert(pcie->pex_clk);
 +      reset_control_assert(pcie->pcie_xrst);
 +      reset_control_assert(pcie->afi_rst);
 +      reset_control_assert(pcie->pex_rst);
  
        tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
  
@@@ -924,9 -921,9 +924,9 @@@ static int tegra_pcie_power_on(struct t
        const struct tegra_pcie_soc_data *soc = pcie->soc_data;
        int err;
  
 -      tegra_periph_reset_assert(pcie->pcie_xclk);
 -      tegra_periph_reset_assert(pcie->afi_clk);
 -      tegra_periph_reset_assert(pcie->pex_clk);
 +      reset_control_assert(pcie->pcie_xrst);
 +      reset_control_assert(pcie->afi_rst);
 +      reset_control_assert(pcie->pex_rst);
  
        tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
  
        }
  
        err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE,
 -                                              pcie->pex_clk);
 +                                              pcie->pex_clk,
 +                                              pcie->pex_rst);
        if (err) {
                dev_err(pcie->dev, "powerup sequence failed: %d\n", err);
                return err;
        }
  
 -      tegra_periph_reset_deassert(pcie->afi_clk);
 +      reset_control_deassert(pcie->afi_rst);
  
        err = clk_prepare_enable(pcie->afi_clk);
        if (err < 0) {
@@@ -1000,6 -996,10 +1000,6 @@@ static int tegra_pcie_clocks_get(struc
        if (IS_ERR(pcie->afi_clk))
                return PTR_ERR(pcie->afi_clk);
  
 -      pcie->pcie_xclk = devm_clk_get(pcie->dev, "pcie_xclk");
 -      if (IS_ERR(pcie->pcie_xclk))
 -              return PTR_ERR(pcie->pcie_xclk);
 -
        pcie->pll_e = devm_clk_get(pcie->dev, "pll_e");
        if (IS_ERR(pcie->pll_e))
                return PTR_ERR(pcie->pll_e);
        return 0;
  }
  
 +static int tegra_pcie_resets_get(struct tegra_pcie *pcie)
 +{
 +      pcie->pex_rst = devm_reset_control_get(pcie->dev, "pex");
 +      if (IS_ERR(pcie->pex_rst))
 +              return PTR_ERR(pcie->pex_rst);
 +
 +      pcie->afi_rst = devm_reset_control_get(pcie->dev, "afi");
 +      if (IS_ERR(pcie->afi_rst))
 +              return PTR_ERR(pcie->afi_rst);
 +
 +      pcie->pcie_xrst = devm_reset_control_get(pcie->dev, "pcie_x");
 +      if (IS_ERR(pcie->pcie_xrst))
 +              return PTR_ERR(pcie->pcie_xrst);
 +
 +      return 0;
 +}
 +
  static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
  {
        struct platform_device *pdev = to_platform_device(pcie->dev);
                return err;
        }
  
 +      err = tegra_pcie_resets_get(pcie);
 +      if (err) {
 +              dev_err(&pdev->dev, "failed to get resets: %d\n", err);
 +              return err;
 +      }
 +
        err = tegra_pcie_power_on(pcie);
        if (err) {
                dev_err(&pdev->dev, "failed to power up: %d\n", err);
index e86439283a5d1911933eed185e22a50146093968,641ba6761bd756ca9aa24471fdc53abfc1aaf041..ee26bac2d3787e2cc45aa8755ffe5db14609209e
@@@ -279,9 -279,7 +279,9 @@@ static acpi_status register_slot(acpi_h
  
        status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
        if (ACPI_FAILURE(status)) {
 -              acpi_handle_warn(handle, "can't evaluate _ADR (%#x)\n", status);
 +              if (status != AE_NOT_FOUND)
 +                      acpi_handle_warn(handle,
 +                              "can't evaluate _ADR (%#x)\n", status);
                return AE_OK;
        }
  
@@@ -432,6 -430,7 +432,7 @@@ static void cleanup_bridge(struct acpip
                                        pr_err("failed to remove notify handler\n");
                        }
                }
+               slot->flags |= SLOT_IS_GOING_AWAY;
                if (slot->slot)
                        acpiphp_unregister_hotplug_slot(slot);
        }
        mutex_lock(&bridge_mutex);
        list_del(&bridge->list);
        mutex_unlock(&bridge_mutex);
+       bridge->is_going_away = true;
  }
  
  /**
@@@ -645,24 -646,6 +648,24 @@@ static void disable_slot(struct acpiphp
        slot->flags &= (~SLOT_ENABLED);
  }
  
 +static bool acpiphp_no_hotplug(acpi_handle handle)
 +{
 +      struct acpi_device *adev = NULL;
 +
 +      acpi_bus_get_device(handle, &adev);
 +      return adev && adev->flags.no_hotplug;
 +}
 +
 +static bool slot_no_hotplug(struct acpiphp_slot *slot)
 +{
 +      struct acpiphp_func *func;
 +
 +      list_for_each_entry(func, &slot->funcs, sibling)
 +              if (acpiphp_no_hotplug(func_to_handle(func)))
 +                      return true;
 +
 +      return false;
 +}
  
  /**
   * get_slot_status - get ACPI slot status
@@@ -721,8 -704,7 +724,8 @@@ static void trim_stale_devices(struct p
                unsigned long long sta;
  
                status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
 -              alive = ACPI_SUCCESS(status) && sta == ACPI_STA_ALL;
 +              alive = (ACPI_SUCCESS(status) && sta == ACPI_STA_ALL)
 +                      || acpiphp_no_hotplug(handle);
        }
        if (!alive) {
                u32 v;
@@@ -757,14 -739,17 +760,18 @@@ static void acpiphp_check_bridge(struc
  {
        struct acpiphp_slot *slot;
  
+       /* Bail out if the bridge is going away. */
+       if (bridge->is_going_away)
+               return;
        list_for_each_entry(slot, &bridge->slots, node) {
                struct pci_bus *bus = slot->bus;
                struct pci_dev *dev, *tmp;
  
                mutex_lock(&slot->crit_sect);
 -              /* wake up all functions */
 -              if (get_slot_status(slot) == ACPI_STA_ALL) {
 +              if (slot_no_hotplug(slot)) {
 +                      ; /* do nothing */
 +              } else if (get_slot_status(slot) == ACPI_STA_ALL) {
                        /* remove stale devices if any */
                        list_for_each_entry_safe(dev, tmp, &bus->devices,
                                                 bus_list)
@@@ -827,6 -812,8 +834,8 @@@ void acpiphp_check_host_bridge(acpi_han
        }
  }
  
+ static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
  static void hotplug_event(acpi_handle handle, u32 type, void *data)
  {
        struct acpiphp_context *context = data;
                } else {
                        struct acpiphp_slot *slot = func->slot;
  
+                       if (slot->flags & SLOT_IS_GOING_AWAY)
+                               break;
                        mutex_lock(&slot->crit_sect);
                        enable_slot(slot);
                        mutex_unlock(&slot->crit_sect);
                        struct acpiphp_slot *slot = func->slot;
                        int ret;
  
+                       if (slot->flags & SLOT_IS_GOING_AWAY)
+                               break;
                        /*
                         * Check if anything has changed in the slot and rescan
                         * from the parent if that's the case.
@@@ -900,9 -893,11 +915,11 @@@ static void hotplug_event_work(void *da
        acpi_handle handle = context->handle;
  
        acpi_scan_lock_acquire();
+       pci_lock_rescan_remove();
  
        hotplug_event(handle, type, context);
  
+       pci_unlock_rescan_remove();
        acpi_scan_lock_release();
        acpi_evaluate_hotplug_ost(handle, type, ACPI_OST_SC_SUCCESS, NULL);
        put_bridge(context->func.parent);
@@@ -1070,12 -1065,19 +1087,19 @@@ void acpiphp_remove_slots(struct pci_bu
   */
  int acpiphp_enable_slot(struct acpiphp_slot *slot)
  {
+       pci_lock_rescan_remove();
+       if (slot->flags & SLOT_IS_GOING_AWAY)
+               return -ENODEV;
        mutex_lock(&slot->crit_sect);
        /* configure all functions */
        if (!(slot->flags & SLOT_ENABLED))
                enable_slot(slot);
  
        mutex_unlock(&slot->crit_sect);
+       pci_unlock_rescan_remove();
        return 0;
  }
  
   * acpiphp_disable_and_eject_slot - power off and eject slot
   * @slot: ACPI PHP slot
   */
- int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
  {
        struct acpiphp_func *func;
-       int retval = 0;
+       if (slot->flags & SLOT_IS_GOING_AWAY)
+               return -ENODEV;
  
        mutex_lock(&slot->crit_sect);
  
                }
  
        mutex_unlock(&slot->crit_sect);
-       return retval;
+       return 0;
  }
  
+ int acpiphp_disable_slot(struct acpiphp_slot *slot)
+ {
+       int ret;
+       pci_lock_rescan_remove();
+       ret = acpiphp_disable_and_eject_slot(slot);
+       pci_unlock_rescan_remove();
+       return ret;
+ }
  
  /*
   * slot enabled:  1
@@@ -1117,7 -1130,6 +1152,6 @@@ u8 acpiphp_get_power_status(struct acpi
        return (slot->flags & SLOT_ENABLED);
  }
  
  /*
   * latch   open:  1
   * latch closed:  0
@@@ -1127,7 -1139,6 +1161,6 @@@ u8 acpiphp_get_latch_status(struct acpi
        return !(get_slot_status(slot) & ACPI_STA_DEVICE_UI);
  }
  
  /*
   * adapter presence : 1
   *          absence : 0
diff --combined drivers/pci/pci-acpi.c
index f7ebdba14bde9bc1c7e3dd702bc6e47506067ff5,e0431f1af33bc81a386cd7c9bd77226818804746..2bdbc00802041454a8258792b3cbbe617cffd0b6
@@@ -330,38 -330,35 +330,38 @@@ static int acpi_pci_find_device(struct 
  static void pci_acpi_setup(struct device *dev)
  {
        struct pci_dev *pci_dev = to_pci_dev(dev);
 -      acpi_handle handle = ACPI_HANDLE(dev);
 -      struct acpi_device *adev;
 +      struct acpi_device *adev = ACPI_COMPANION(dev);
  
 -      if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid)
 +      if (!adev)
 +              return;
 +
 +      pci_acpi_add_pm_notifier(adev, pci_dev);
 +      if (!adev->wakeup.flags.valid)
                return;
  
        device_set_wakeup_capable(dev, true);
        acpi_pci_sleep_wake(pci_dev, false);
 -
 -      pci_acpi_add_pm_notifier(adev, pci_dev);
        if (adev->wakeup.flags.run_wake)
                device_set_run_wake(dev, true);
  }
  
  static void pci_acpi_cleanup(struct device *dev)
  {
 -      acpi_handle handle = ACPI_HANDLE(dev);
 -      struct acpi_device *adev;
 +      struct acpi_device *adev = ACPI_COMPANION(dev);
 +
 +      if (!adev)
 +              return;
  
 -      if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) {
 +      pci_acpi_remove_pm_notifier(adev);
 +      if (adev->wakeup.flags.valid) {
                device_set_wakeup_capable(dev, false);
                device_set_run_wake(dev, false);
 -              pci_acpi_remove_pm_notifier(adev);
        }
  }
  
  static bool pci_acpi_bus_match(struct device *dev)
  {
-       return dev->bus == &pci_bus_type;
+       return dev_is_pci(dev);
  }
  
  static struct acpi_bus_type acpi_pci_bus = {
diff --combined drivers/pci/pci.c
index 07369f32e8bbdd79b1294ad844baeb7dc80ef7ea,b6d4afa8ba40653a8dccf4cce447fbb7cc8c69bd..1febe90831b442303b7414faec770d4850ca53ed
@@@ -430,6 -430,32 +430,32 @@@ pci_find_parent_resource(const struct p
        return best;
  }
  
+ /**
+  * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
+  * @dev: the PCI device to operate on
+  * @pos: config space offset of status word
+  * @mask: mask of bit(s) to care about in status word
+  *
+  * Return 1 when mask bit(s) in status word clear, 0 otherwise.
+  */
+ int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask)
+ {
+       int i;
+       /* Wait for Transaction Pending bit clean */
+       for (i = 0; i < 4; i++) {
+               u16 status;
+               if (i)
+                       msleep((1 << (i - 1)) * 100);
+               pci_read_config_word(dev, pos, &status);
+               if (!(status & mask))
+                       return 1;
+       }
+       return 0;
+ }
  /**
   * pci_restore_bars - restore a devices BAR values (e.g. after wake-up)
   * @dev: PCI device to have its BARs restored
@@@ -656,6 -682,28 +682,28 @@@ static int pci_platform_power_transitio
        return error;
  }
  
+ /**
+  * pci_wakeup - Wake up a PCI device
+  * @pci_dev: Device to handle.
+  * @ign: ignored parameter
+  */
+ static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
+ {
+       pci_wakeup_event(pci_dev);
+       pm_request_resume(&pci_dev->dev);
+       return 0;
+ }
+ /**
+  * pci_wakeup_bus - Walk given bus and wake up devices on it
+  * @bus: Top bus of the subtree to walk.
+  */
+ static void pci_wakeup_bus(struct pci_bus *bus)
+ {
+       if (bus)
+               pci_walk_bus(bus, pci_wakeup, NULL);
+ }
  /**
   * __pci_start_power_transition - Start power transition of a PCI device
   * @dev: PCI device to handle.
@@@ -835,18 -883,28 +883,28 @@@ EXPORT_SYMBOL(pci_choose_state)
  #define PCI_EXP_SAVE_REGS     7
  
  
- static struct pci_cap_saved_state *pci_find_saved_cap(
-       struct pci_dev *pci_dev, char cap)
+ static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev,
+                                                      u16 cap, bool extended)
  {
        struct pci_cap_saved_state *tmp;
  
        hlist_for_each_entry(tmp, &pci_dev->saved_cap_space, next) {
-               if (tmp->cap.cap_nr == cap)
+               if (tmp->cap.cap_extended == extended && tmp->cap.cap_nr == cap)
                        return tmp;
        }
        return NULL;
  }
  
+ struct pci_cap_saved_state *pci_find_saved_cap(struct pci_dev *dev, char cap)
+ {
+       return _pci_find_saved_cap(dev, cap, false);
+ }
+ struct pci_cap_saved_state *pci_find_saved_ext_cap(struct pci_dev *dev, u16 cap)
+ {
+       return _pci_find_saved_cap(dev, cap, true);
+ }
  static int pci_save_pcie_state(struct pci_dev *dev)
  {
        int i = 0;
@@@ -948,6 -1006,8 +1006,8 @@@ pci_save_state(struct pci_dev *dev
                return i;
        if ((i = pci_save_pcix_state(dev)) != 0)
                return i;
+       if ((i = pci_save_vc_state(dev)) != 0)
+               return i;
        return 0;
  }
  
@@@ -1010,6 -1070,7 +1070,7 @@@ void pci_restore_state(struct pci_dev *
        /* PCI Express register must be restored first */
        pci_restore_pcie_state(dev);
        pci_restore_ats_state(dev);
+       pci_restore_vc_state(dev);
  
        pci_restore_config_space(dev);
  
@@@ -1071,7 -1132,8 +1132,8 @@@ EXPORT_SYMBOL_GPL(pci_store_saved_state
   * @dev: PCI device that we're dealing with
   * @state: Saved state returned from pci_store_saved_state()
   */
- int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state)
+ static int pci_load_saved_state(struct pci_dev *dev,
+                               struct pci_saved_state *state)
  {
        struct pci_cap_saved_data *cap;
  
        while (cap->size) {
                struct pci_cap_saved_state *tmp;
  
-               tmp = pci_find_saved_cap(dev, cap->cap_nr);
+               tmp = _pci_find_saved_cap(dev, cap->cap_nr, cap->cap_extended);
                if (!tmp || tmp->cap.size != cap->size)
                        return -EINVAL;
  
        dev->state_saved = true;
        return 0;
  }
- EXPORT_SYMBOL_GPL(pci_load_saved_state);
  
  /**
   * pci_load_and_free_saved_state - Reload the save state pointed to by state,
@@@ -1531,27 -1592,6 +1592,6 @@@ void pci_pme_wakeup_bus(struct pci_bus 
                pci_walk_bus(bus, pci_pme_wakeup, (void *)true);
  }
  
- /**
-  * pci_wakeup - Wake up a PCI device
-  * @pci_dev: Device to handle.
-  * @ign: ignored parameter
-  */
- static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
- {
-       pci_wakeup_event(pci_dev);
-       pm_request_resume(&pci_dev->dev);
-       return 0;
- }
- /**
-  * pci_wakeup_bus - Walk given bus and wake up devices on it
-  * @bus: Top bus of the subtree to walk.
-  */
- void pci_wakeup_bus(struct pci_bus *bus)
- {
-       if (bus)
-               pci_walk_bus(bus, pci_wakeup, NULL);
- }
  
  /**
   * pci_pme_capable - check the capability of PCI device to generate PME#
@@@ -1765,7 -1805,7 +1805,7 @@@ int pci_wake_from_d3(struct pci_dev *de
   * If the platform can't manage @dev, return the deepest state from which it
   * can generate wake events, based on any available PME info.
   */
- pci_power_t pci_target_state(struct pci_dev *dev)
static pci_power_t pci_target_state(struct pci_dev *dev)
  {
        pci_power_t target_state = PCI_D3hot;
  
@@@ -2021,18 -2061,24 +2061,24 @@@ static void pci_add_saved_cap(struct pc
  }
  
  /**
-  * pci_add_cap_save_buffer - allocate buffer for saving given capability registers
+  * _pci_add_cap_save_buffer - allocate buffer for saving given
+  *                            capability registers
   * @dev: the PCI device
   * @cap: the capability to allocate the buffer for
+  * @extended: Standard or Extended capability ID
   * @size: requested size of the buffer
   */
- static int pci_add_cap_save_buffer(
-       struct pci_dev *dev, char cap, unsigned int size)
+ static int _pci_add_cap_save_buffer(struct pci_dev *dev, u16 cap,
+                                   bool extended, unsigned int size)
  {
        int pos;
        struct pci_cap_saved_state *save_state;
  
-       pos = pci_find_capability(dev, cap);
+       if (extended)
+               pos = pci_find_ext_capability(dev, cap);
+       else
+               pos = pci_find_capability(dev, cap);
        if (pos <= 0)
                return 0;
  
                return -ENOMEM;
  
        save_state->cap.cap_nr = cap;
+       save_state->cap.cap_extended = extended;
        save_state->cap.size = size;
        pci_add_saved_cap(dev, save_state);
  
        return 0;
  }
  
+ int pci_add_cap_save_buffer(struct pci_dev *dev, char cap, unsigned int size)
+ {
+       return _pci_add_cap_save_buffer(dev, cap, false, size);
+ }
+ int pci_add_ext_cap_save_buffer(struct pci_dev *dev, u16 cap, unsigned int size)
+ {
+       return _pci_add_cap_save_buffer(dev, cap, true, size);
+ }
  /**
   * pci_allocate_cap_save_buffers - allocate buffers for saving capabilities
   * @dev: the PCI device
@@@ -2065,6 -2122,8 +2122,8 @@@ void pci_allocate_cap_save_buffers(stru
        if (error)
                dev_err(&dev->dev,
                        "unable to preallocate PCI-X save buffer\n");
+       pci_allocate_vc_save_buffers(dev);
  }
  
  void pci_free_cap_save_buffers(struct pci_dev *dev)
@@@ -2110,242 -2169,6 +2169,6 @@@ void pci_configure_ari(struct pci_dev *
        }
  }
  
- /**
-  * pci_enable_ido - enable ID-based Ordering on a device
-  * @dev: the PCI device
-  * @type: which types of IDO to enable
-  *
-  * Enable ID-based ordering on @dev.  @type can contain the bits
-  * %PCI_EXP_IDO_REQUEST and/or %PCI_EXP_IDO_COMPLETION to indicate
-  * which types of transactions are allowed to be re-ordered.
-  */
- void pci_enable_ido(struct pci_dev *dev, unsigned long type)
- {
-       u16 ctrl = 0;
-       if (type & PCI_EXP_IDO_REQUEST)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_REQ_EN;
-       if (type & PCI_EXP_IDO_COMPLETION)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_CMP_EN;
-       if (ctrl)
-               pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, ctrl);
- }
- EXPORT_SYMBOL(pci_enable_ido);
- /**
-  * pci_disable_ido - disable ID-based ordering on a device
-  * @dev: the PCI device
-  * @type: which types of IDO to disable
-  */
- void pci_disable_ido(struct pci_dev *dev, unsigned long type)
- {
-       u16 ctrl = 0;
-       if (type & PCI_EXP_IDO_REQUEST)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_REQ_EN;
-       if (type & PCI_EXP_IDO_COMPLETION)
-               ctrl |= PCI_EXP_DEVCTL2_IDO_CMP_EN;
-       if (ctrl)
-               pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, ctrl);
- }
- EXPORT_SYMBOL(pci_disable_ido);
- /**
-  * pci_enable_obff - enable optimized buffer flush/fill
-  * @dev: PCI device
-  * @type: type of signaling to use
-  *
-  * Try to enable @type OBFF signaling on @dev.  It will try using WAKE#
-  * signaling if possible, falling back to message signaling only if
-  * WAKE# isn't supported.  @type should indicate whether the PCIe link
-  * be brought out of L0s or L1 to send the message.  It should be either
-  * %PCI_EXP_OBFF_SIGNAL_ALWAYS or %PCI_OBFF_SIGNAL_L0.
-  *
-  * If your device can benefit from receiving all messages, even at the
-  * power cost of bringing the link back up from a low power state, use
-  * %PCI_EXP_OBFF_SIGNAL_ALWAYS.  Otherwise, use %PCI_OBFF_SIGNAL_L0 (the
-  * preferred type).
-  *
-  * RETURNS:
-  * Zero on success, appropriate error number on failure.
-  */
- int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type type)
- {
-       u32 cap;
-       u16 ctrl;
-       int ret;
-       pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);
-       if (!(cap & PCI_EXP_DEVCAP2_OBFF_MASK))
-               return -ENOTSUPP; /* no OBFF support at all */
-       /* Make sure the topology supports OBFF as well */
-       if (dev->bus->self) {
-               ret = pci_enable_obff(dev->bus->self, type);
-               if (ret)
-                       return ret;
-       }
-       pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &ctrl);
-       if (cap & PCI_EXP_DEVCAP2_OBFF_WAKE)
-               ctrl |= PCI_EXP_DEVCTL2_OBFF_WAKE_EN;
-       else {
-               switch (type) {
-               case PCI_EXP_OBFF_SIGNAL_L0:
-                       if (!(ctrl & PCI_EXP_DEVCTL2_OBFF_WAKE_EN))
-                               ctrl |= PCI_EXP_DEVCTL2_OBFF_MSGA_EN;
-                       break;
-               case PCI_EXP_OBFF_SIGNAL_ALWAYS:
-                       ctrl &= ~PCI_EXP_DEVCTL2_OBFF_WAKE_EN;
-                       ctrl |= PCI_EXP_DEVCTL2_OBFF_MSGB_EN;
-                       break;
-               default:
-                       WARN(1, "bad OBFF signal type\n");
-                       return -ENOTSUPP;
-               }
-       }
-       pcie_capability_write_word(dev, PCI_EXP_DEVCTL2, ctrl);
-       return 0;
- }
- EXPORT_SYMBOL(pci_enable_obff);
- /**
-  * pci_disable_obff - disable optimized buffer flush/fill
-  * @dev: PCI device
-  *
-  * Disable OBFF on @dev.
-  */
- void pci_disable_obff(struct pci_dev *dev)
- {
-       pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2,
-                                  PCI_EXP_DEVCTL2_OBFF_WAKE_EN);
- }
- EXPORT_SYMBOL(pci_disable_obff);
- /**
-  * pci_ltr_supported - check whether a device supports LTR
-  * @dev: PCI device
-  *
-  * RETURNS:
-  * True if @dev supports latency tolerance reporting, false otherwise.
-  */
- static bool pci_ltr_supported(struct pci_dev *dev)
- {
-       u32 cap;
-       pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);
-       return cap & PCI_EXP_DEVCAP2_LTR;
- }
- /**
-  * pci_enable_ltr - enable latency tolerance reporting
-  * @dev: PCI device
-  *
-  * Enable LTR on @dev if possible, which means enabling it first on
-  * upstream ports.
-  *
-  * RETURNS:
-  * Zero on success, errno on failure.
-  */
- int pci_enable_ltr(struct pci_dev *dev)
- {
-       int ret;
-       /* Only primary function can enable/disable LTR */
-       if (PCI_FUNC(dev->devfn) != 0)
-               return -EINVAL;
-       if (!pci_ltr_supported(dev))
-               return -ENOTSUPP;
-       /* Enable upstream ports first */
-       if (dev->bus->self) {
-               ret = pci_enable_ltr(dev->bus->self);
-               if (ret)
-                       return ret;
-       }
-       return pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
-                                       PCI_EXP_DEVCTL2_LTR_EN);
- }
- EXPORT_SYMBOL(pci_enable_ltr);
- /**
-  * pci_disable_ltr - disable latency tolerance reporting
-  * @dev: PCI device
-  */
- void pci_disable_ltr(struct pci_dev *dev)
- {
-       /* Only primary function can enable/disable LTR */
-       if (PCI_FUNC(dev->devfn) != 0)
-               return;
-       if (!pci_ltr_supported(dev))
-               return;
-       pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2,
-                                  PCI_EXP_DEVCTL2_LTR_EN);
- }
- EXPORT_SYMBOL(pci_disable_ltr);
- static int __pci_ltr_scale(int *val)
- {
-       int scale = 0;
-       while (*val > 1023) {
-               *val = (*val + 31) / 32;
-               scale++;
-       }
-       return scale;
- }
- /**
-  * pci_set_ltr - set LTR latency values
-  * @dev: PCI device
-  * @snoop_lat_ns: snoop latency in nanoseconds
-  * @nosnoop_lat_ns: nosnoop latency in nanoseconds
-  *
-  * Figure out the scale and set the LTR values accordingly.
-  */
- int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns)
- {
-       int pos, ret, snoop_scale, nosnoop_scale;
-       u16 val;
-       if (!pci_ltr_supported(dev))
-               return -ENOTSUPP;
-       snoop_scale = __pci_ltr_scale(&snoop_lat_ns);
-       nosnoop_scale = __pci_ltr_scale(&nosnoop_lat_ns);
-       if (snoop_lat_ns > PCI_LTR_VALUE_MASK ||
-           nosnoop_lat_ns > PCI_LTR_VALUE_MASK)
-               return -EINVAL;
-       if ((snoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT)) ||
-           (nosnoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT)))
-               return -EINVAL;
-       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR);
-       if (!pos)
-               return -ENOTSUPP;
-       val = (snoop_scale << PCI_LTR_SCALE_SHIFT) | snoop_lat_ns;
-       ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_SNOOP_LAT, val);
-       if (ret != 4)
-               return -EIO;
-       val = (nosnoop_scale << PCI_LTR_SCALE_SHIFT) | nosnoop_lat_ns;
-       ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_NOSNOOP_LAT, val);
-       if (ret != 4)
-               return -EIO;
-       return 0;
- }
- EXPORT_SYMBOL(pci_set_ltr);
  static int pci_acs_enable;
  
  /**
@@@ -3138,7 -2961,7 +2961,7 @@@ bool pci_check_and_mask_intx(struct pci
  EXPORT_SYMBOL_GPL(pci_check_and_mask_intx);
  
  /**
-  * pci_check_and_mask_intx - unmask INTx of no interrupt is pending
+  * pci_check_and_unmask_intx - unmask INTx if no interrupt is pending
   * @dev: the PCI device to operate on
   *
   * Check if the device dev has its INTx line asserted, unmask it if not
@@@ -3204,20 -3027,10 +3027,10 @@@ EXPORT_SYMBOL(pci_set_dma_seg_boundary)
   */
  int pci_wait_for_pending_transaction(struct pci_dev *dev)
  {
-       int i;
-       u16 status;
-       /* Wait for Transaction Pending bit clean */
-       for (i = 0; i < 4; i++) {
-               if (i)
-                       msleep((1 << (i - 1)) * 100);
-               pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);
-               if (!(status & PCI_EXP_DEVSTA_TRPND))
-                       return 1;
-       }
+       if (!pci_is_pcie(dev))
+               return 1;
  
-       return 0;
+       return pci_wait_for_pending(dev, PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_TRPND);
  }
  EXPORT_SYMBOL(pci_wait_for_pending_transaction);
  
@@@ -3244,10 -3057,8 +3057,8 @@@ static int pcie_flr(struct pci_dev *dev
  
  static int pci_af_flr(struct pci_dev *dev, int probe)
  {
-       int i;
        int pos;
        u8 cap;
-       u8 status;
  
        pos = pci_find_capability(dev, PCI_CAP_ID_AF);
        if (!pos)
                return 0;
  
        /* Wait for Transaction Pending bit clean */
-       for (i = 0; i < 4; i++) {
-               if (i)
-                       msleep((1 << (i - 1)) * 100);
-               pci_read_config_byte(dev, pos + PCI_AF_STATUS, &status);
-               if (!(status & PCI_AF_STATUS_TP))
-                       goto clear;
-       }
+       if (pci_wait_for_pending(dev, PCI_AF_STATUS, PCI_AF_STATUS_TP))
+               goto clear;
  
        dev_err(&dev->dev, "transaction is not cleared; "
                        "proceeding with reset anyway\n");
@@@ -3445,6 -3250,18 +3250,18 @@@ static void pci_dev_lock(struct pci_de
        device_lock(&dev->dev);
  }
  
+ /* Return 1 on successful lock, 0 on contention */
+ static int pci_dev_trylock(struct pci_dev *dev)
+ {
+       if (pci_cfg_access_trylock(dev)) {
+               if (device_trylock(&dev->dev))
+                       return 1;
+               pci_cfg_access_unlock(dev);
+       }
+       return 0;
+ }
  static void pci_dev_unlock(struct pci_dev *dev)
  {
        device_unlock(&dev->dev);
@@@ -3588,6 -3405,34 +3405,34 @@@ int pci_reset_function(struct pci_dev *
  }
  EXPORT_SYMBOL_GPL(pci_reset_function);
  
+ /**
+  * pci_try_reset_function - quiesce and reset a PCI device function
+  * @dev: PCI device to reset
+  *
+  * Same as above, except return -EAGAIN if unable to lock device.
+  */
+ int pci_try_reset_function(struct pci_dev *dev)
+ {
+       int rc;
+       rc = pci_dev_reset(dev, 1);
+       if (rc)
+               return rc;
+       pci_dev_save_and_disable(dev);
+       if (pci_dev_trylock(dev)) {
+               rc = __pci_dev_reset(dev, 0);
+               pci_dev_unlock(dev);
+       } else
+               rc = -EAGAIN;
+       pci_dev_restore(dev);
+       return rc;
+ }
+ EXPORT_SYMBOL_GPL(pci_try_reset_function);
  /* Lock devices from the top of the tree down */
  static void pci_bus_lock(struct pci_bus *bus)
  {
@@@ -3612,6 -3457,32 +3457,32 @@@ static void pci_bus_unlock(struct pci_b
        }
  }
  
+ /* Return 1 on successful lock, 0 on contention */
+ static int pci_bus_trylock(struct pci_bus *bus)
+ {
+       struct pci_dev *dev;
+       list_for_each_entry(dev, &bus->devices, bus_list) {
+               if (!pci_dev_trylock(dev))
+                       goto unlock;
+               if (dev->subordinate) {
+                       if (!pci_bus_trylock(dev->subordinate)) {
+                               pci_dev_unlock(dev);
+                               goto unlock;
+                       }
+               }
+       }
+       return 1;
+ unlock:
+       list_for_each_entry_continue_reverse(dev, &bus->devices, bus_list) {
+               if (dev->subordinate)
+                       pci_bus_unlock(dev->subordinate);
+               pci_dev_unlock(dev);
+       }
+       return 0;
+ }
  /* Lock devices from the top of the tree down */
  static void pci_slot_lock(struct pci_slot *slot)
  {
@@@ -3640,6 -3511,37 +3511,37 @@@ static void pci_slot_unlock(struct pci_
        }
  }
  
+ /* Return 1 on successful lock, 0 on contention */
+ static int pci_slot_trylock(struct pci_slot *slot)
+ {
+       struct pci_dev *dev;
+       list_for_each_entry(dev, &slot->bus->devices, bus_list) {
+               if (!dev->slot || dev->slot != slot)
+                       continue;
+               if (!pci_dev_trylock(dev))
+                       goto unlock;
+               if (dev->subordinate) {
+                       if (!pci_bus_trylock(dev->subordinate)) {
+                               pci_dev_unlock(dev);
+                               goto unlock;
+                       }
+               }
+       }
+       return 1;
+ unlock:
+       list_for_each_entry_continue_reverse(dev,
+                                            &slot->bus->devices, bus_list) {
+               if (!dev->slot || dev->slot != slot)
+                       continue;
+               if (dev->subordinate)
+                       pci_bus_unlock(dev->subordinate);
+               pci_dev_unlock(dev);
+       }
+       return 0;
+ }
  /* Save and disable devices from the top of the tree down */
  static void pci_bus_save_and_disable(struct pci_bus *bus)
  {
@@@ -3763,6 -3665,35 +3665,35 @@@ int pci_reset_slot(struct pci_slot *slo
  }
  EXPORT_SYMBOL_GPL(pci_reset_slot);
  
+ /**
+  * pci_try_reset_slot - Try to reset a PCI slot
+  * @slot: PCI slot to reset
+  *
+  * Same as above except return -EAGAIN if the slot cannot be locked
+  */
+ int pci_try_reset_slot(struct pci_slot *slot)
+ {
+       int rc;
+       rc = pci_slot_reset(slot, 1);
+       if (rc)
+               return rc;
+       pci_slot_save_and_disable(slot);
+       if (pci_slot_trylock(slot)) {
+               might_sleep();
+               rc = pci_reset_hotplug_slot(slot->hotplug, 0);
+               pci_slot_unlock(slot);
+       } else
+               rc = -EAGAIN;
+       pci_slot_restore(slot);
+       return rc;
+ }
+ EXPORT_SYMBOL_GPL(pci_try_reset_slot);
  static int pci_bus_reset(struct pci_bus *bus, int probe)
  {
        if (!bus->self)
@@@ -3821,6 -3752,35 +3752,35 @@@ int pci_reset_bus(struct pci_bus *bus
  }
  EXPORT_SYMBOL_GPL(pci_reset_bus);
  
+ /**
+  * pci_try_reset_bus - Try to reset a PCI bus
+  * @bus: top level PCI bus to reset
+  *
+  * Same as above except return -EAGAIN if the bus cannot be locked
+  */
+ int pci_try_reset_bus(struct pci_bus *bus)
+ {
+       int rc;
+       rc = pci_bus_reset(bus, 1);
+       if (rc)
+               return rc;
+       pci_bus_save_and_disable(bus);
+       if (pci_bus_trylock(bus)) {
+               might_sleep();
+               pci_reset_bridge_secondary_bus(bus->self);
+               pci_bus_unlock(bus);
+       } else
+               rc = -EAGAIN;
+       pci_bus_restore(bus);
+       return rc;
+ }
+ EXPORT_SYMBOL_GPL(pci_try_reset_bus);
  /**
   * pcix_get_max_mmrbc - get PCI-X maximum designed memory read byte count
   * @dev: PCI device to query
@@@ -4165,14 -4125,6 +4125,14 @@@ int pci_set_vga_state(struct pci_dev *d
        return 0;
  }
  
 +bool pci_device_is_present(struct pci_dev *pdev)
 +{
 +      u32 v;
 +
 +      return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
 +}
 +EXPORT_SYMBOL_GPL(pci_device_is_present);
 +
  #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
  static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
  static DEFINE_SPINLOCK(resource_alignment_lock);
@@@ -4450,7 -4402,6 +4410,6 @@@ EXPORT_SYMBOL(pci_restore_state)
  EXPORT_SYMBOL(pci_pme_capable);
  EXPORT_SYMBOL(pci_pme_active);
  EXPORT_SYMBOL(pci_wake_from_d3);
- EXPORT_SYMBOL(pci_target_state);
  EXPORT_SYMBOL(pci_prepare_to_sleep);
  EXPORT_SYMBOL(pci_back_from_sleep);
  EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
diff --combined drivers/pci/quirks.c
index 3a02717473adc7dfb775a543d6c8f786ddb91ff4,4ad6bf6c107b1c36cff8d567736988189ecf2c4a..5cb726c193de824db34ece33610cc6b3bec86eaa
@@@ -9,6 -9,10 +9,6 @@@
   *
   *  Init/reset quirks for USB host controllers should be in the
   *  USB quirks file, where their drivers can access reuse it.
 - *
 - *  The bridge optimization stuff has been removed. If you really
 - *  have a silly BIOS which is unable to set your host bridge right,
 - *  use the PowerTweak utility (see http://powertweak.sourceforge.net).
   */
  
  #include <linux/types.h>
@@@ -339,7 -343,7 +339,7 @@@ static void quirk_io_region(struct pci_
        /* Convert from PCI bus to resource space */
        bus_region.start = region;
        bus_region.end = region + size - 1;
-       pcibios_bus_to_resource(dev, res, &bus_region);
+       pcibios_bus_to_resource(dev->bus, res, &bus_region);
  
        if (!pci_claim_resource(dev, nr))
                dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name);
index dec68e7a99c79482f5f7cf4eb78b98bd0e2cd58d,538521b009488931227dacad13b7c68c32035543..7029cba7025b3f51e592765d4ec71e5477073f7e
@@@ -592,6 -592,7 +592,7 @@@ static void eeepc_rfkill_hotplug(struc
                rfkill_set_sw_state(eeepc->wlan_rfkill, blocked);
  
        mutex_lock(&eeepc->hotplug_lock);
+       pci_lock_rescan_remove();
  
        if (eeepc->hotplug_slot) {
                port = acpi_get_pci_dev(handle);
@@@ -649,6 -650,7 +650,7 @@@ out_put_dev
        }
  
  out_unlock:
+       pci_unlock_rescan_remove();
        mutex_unlock(&eeepc->hotplug_lock);
  }
  
@@@ -1203,8 -1205,10 +1205,8 @@@ static int eeepc_input_init(struct eeep
        int error;
  
        input = input_allocate_device();
 -      if (!input) {
 -              pr_info("Unable to allocate input device\n");
 +      if (!input)
                return -ENOMEM;
 -      }
  
        input->name = "Asus EeePC extra buttons";
        input->phys = EEEPC_LAPTOP_FILE "/input0";
diff --combined include/linux/pci.h
index a13d6825e586972835ba2b3d53ac4ab504ba5369,fa959aac6169f93ea22b9f1f7633fdd8a4e1fa8b..fb57c892b214d6b3482c63a28061130f3a700a9c
@@@ -224,7 -224,8 +224,8 @@@ enum pci_bus_speed 
  };
  
  struct pci_cap_saved_data {
-       char cap_nr;
+       u16 cap_nr;
+       bool cap_extended;
        unsigned int size;
        u32 data[0];
  };
@@@ -351,7 -352,7 +352,7 @@@ struct pci_dev 
        struct bin_attribute *res_attr_wc[DEVICE_COUNT_RESOURCE]; /* sysfs file for WC mapping of resources */
  #ifdef CONFIG_PCI_MSI
        struct list_head msi_list;
-       struct kset *msi_kset;
+       const struct attribute_group **msi_irq_groups;
  #endif
        struct pci_vpd *vpd;
  #ifdef CONFIG_PCI_ATS
@@@ -375,7 -376,6 +376,6 @@@ static inline struct pci_dev *pci_physf
  }
  
  struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
- struct pci_dev * __deprecated alloc_pci_dev(void);
  
  #define       to_pci_dev(n) container_of(n, struct pci_dev, dev)
  #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
@@@ -385,8 -385,6 +385,6 @@@ static inline int pci_channel_offline(s
        return (pdev->error_state != pci_channel_io_normal);
  }
  
- extern struct resource busn_resource;
  struct pci_host_bridge_window {
        struct list_head list;
        struct resource *res;           /* host bridge aperture (CPU address) */
@@@ -551,8 -549,8 +549,8 @@@ int raw_pci_write(unsigned int domain, 
                  int reg, int len, u32 val);
  
  struct pci_bus_region {
-       resource_size_t start;
-       resource_size_t end;
+       dma_addr_t start;
+       dma_addr_t end;
  };
  
  struct pci_dynids {
@@@ -634,8 -632,7 +632,7 @@@ struct pci_driver 
   * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
   * @_table: device table name
   *
-  * This macro is used to create a struct pci_device_id array (a device table)
-  * in a generic manner.
+  * This macro is deprecated and should not be used in new code.
   */
  #define DEFINE_PCI_DEVICE_TABLE(_table) \
        const struct pci_device_id _table[]
@@@ -737,9 -734,9 +734,9 @@@ void pci_fixup_cardbus(struct pci_bus *
  
  /* Generic PCI functions used internally */
  
- void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+ void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
                             struct resource *res);
- void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
                             struct pci_bus_region *region);
  void pcibios_scan_specific_bus(int busn);
  struct pci_bus *pci_find_bus(int domain, int busnr);
@@@ -763,7 -760,6 +760,6 @@@ struct pci_slot *pci_create_slot(struc
                                 const char *name,
                                 struct hotplug_slot *hotplug);
  void pci_destroy_slot(struct pci_slot *slot);
- void pci_renumber_slot(struct pci_slot *slot, int slot_nr);
  int pci_scan_slot(struct pci_bus *bus, int devfn);
  struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
  void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
@@@ -779,6 -775,7 +775,7 @@@ struct pci_dev *pci_dev_get(struct pci_
  void pci_dev_put(struct pci_dev *dev);
  void pci_remove_bus(struct pci_bus *b);
  void pci_stop_and_remove_bus_device(struct pci_dev *dev);
+ void pci_stop_and_remove_bus_device_locked(struct pci_dev *dev);
  void pci_stop_root_bus(struct pci_bus *bus);
  void pci_remove_root_bus(struct pci_bus *bus);
  void pci_setup_cardbus(struct pci_bus *bus);
@@@ -938,6 -935,7 +935,7 @@@ bool pci_check_and_unmask_intx(struct p
  void pci_msi_off(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);
  int pcix_get_mmrbc(struct pci_dev *dev);
@@@ -951,16 -949,18 +949,19 @@@ int pcie_get_minimum_link(struct pci_de
  int __pci_reset_function(struct pci_dev *dev);
  int __pci_reset_function_locked(struct pci_dev *dev);
  int pci_reset_function(struct pci_dev *dev);
+ int pci_try_reset_function(struct pci_dev *dev);
  int pci_probe_reset_slot(struct pci_slot *slot);
  int pci_reset_slot(struct pci_slot *slot);
+ int pci_try_reset_slot(struct pci_slot *slot);
  int pci_probe_reset_bus(struct pci_bus *bus);
  int pci_reset_bus(struct pci_bus *bus);
+ int pci_try_reset_bus(struct pci_bus *bus);
  void pci_reset_bridge_secondary_bus(struct pci_dev *dev);
  void pci_update_resource(struct pci_dev *dev, int resno);
  int __must_check pci_assign_resource(struct pci_dev *dev, int i);
  int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align);
  int pci_select_bars(struct pci_dev *dev, unsigned long flags);
 +bool pci_device_is_present(struct pci_dev *pdev);
  
  /* ROM control related routines */
  int pci_enable_rom(struct pci_dev *pdev);
@@@ -974,9 -974,14 +975,14 @@@ void __iomem __must_check *pci_platform
  int pci_save_state(struct pci_dev *dev);
  void pci_restore_state(struct pci_dev *dev);
  struct pci_saved_state *pci_store_saved_state(struct pci_dev *dev);
- int pci_load_saved_state(struct pci_dev *dev, struct pci_saved_state *state);
  int pci_load_and_free_saved_state(struct pci_dev *dev,
                                  struct pci_saved_state **state);
+ struct pci_cap_saved_state *pci_find_saved_cap(struct pci_dev *dev, char cap);
+ struct pci_cap_saved_state *pci_find_saved_ext_cap(struct pci_dev *dev,
+                                                  u16 cap);
+ int pci_add_cap_save_buffer(struct pci_dev *dev, char cap, unsigned int size);
+ int pci_add_ext_cap_save_buffer(struct pci_dev *dev,
+                               u16 cap, unsigned int size);
  int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state);
  int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
  pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
@@@ -985,7 -990,6 +991,6 @@@ void pci_pme_active(struct pci_dev *dev
  int __pci_enable_wake(struct pci_dev *dev, pci_power_t state,
                      bool runtime, bool enable);
  int pci_wake_from_d3(struct pci_dev *dev, bool enable);
- pci_power_t pci_target_state(struct pci_dev *dev);
  int pci_prepare_to_sleep(struct pci_dev *dev);
  int pci_back_from_sleep(struct pci_dev *dev);
  bool pci_dev_run_wake(struct pci_dev *dev);
@@@ -998,21 -1002,10 +1003,10 @@@ static inline int pci_enable_wake(struc
        return __pci_enable_wake(dev, state, false, enable);
  }
  
- #define PCI_EXP_IDO_REQUEST   (1<<0)
- #define PCI_EXP_IDO_COMPLETION        (1<<1)
- void pci_enable_ido(struct pci_dev *dev, unsigned long type);
- void pci_disable_ido(struct pci_dev *dev, unsigned long type);
- enum pci_obff_signal_type {
-       PCI_EXP_OBFF_SIGNAL_L0 = 0,
-       PCI_EXP_OBFF_SIGNAL_ALWAYS = 1,
- };
- int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type);
- void pci_disable_obff(struct pci_dev *dev);
- int pci_enable_ltr(struct pci_dev *dev);
- void pci_disable_ltr(struct pci_dev *dev);
- int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns);
+ /* PCI Virtual Channel */
+ int pci_save_vc_state(struct pci_dev *dev);
+ void pci_restore_vc_state(struct pci_dev *dev);
+ void pci_allocate_vc_save_buffers(struct pci_dev *dev);
  
  /* For use by arch with custom probe code */
  void set_pcie_port_type(struct pci_dev *pdev);
@@@ -1022,11 -1015,12 +1016,12 @@@ void set_pcie_hotplug_bridge(struct pci
  int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
  unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
  unsigned int pci_rescan_bus(struct pci_bus *bus);
+ void pci_lock_rescan_remove(void);
+ void pci_unlock_rescan_remove(void);
  
  /* Vital product data routines */
  ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
  ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
- int pci_vpd_truncate(struct pci_dev *dev, size_t size);
  
  /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
  resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
@@@ -1078,6 -1072,14 +1073,14 @@@ int __must_check pci_bus_alloc_resource
                                                  resource_size_t),
                        void *alignf_data);
  
+ static inline dma_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
+ {
+       struct pci_bus_region region;
+       pcibios_resource_to_bus(pdev->bus, &region, &pdev->resource[bar]);
+       return region.start;
+ }
  /* Proper probing supporting hot-pluggable devices */
  int __must_check __pci_register_driver(struct pci_driver *, struct module *,
                                       const char *mod_name);
@@@ -1115,7 -1117,6 +1118,6 @@@ int pci_scan_bridge(struct pci_bus *bus
  
  void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
                  void *userdata);
- int pci_cfg_space_size_ext(struct pci_dev *dev);
  int pci_cfg_space_size(struct pci_dev *dev);
  unsigned char pci_bus_max_busnr(struct pci_bus *bus);
  void pci_setup_bridge(struct pci_bus *bus);
@@@ -1154,59 -1155,42 +1156,42 @@@ struct msix_entry 
  };
  
  
- #ifndef CONFIG_PCI_MSI
- static inline int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
- {
-       return -1;
- }
- static inline int
- pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec)
- {
-       return -1;
- }
- static inline void pci_msi_shutdown(struct pci_dev *dev)
- { }
- static inline void pci_disable_msi(struct pci_dev *dev)
- { }
- static inline int pci_msix_table_size(struct pci_dev *dev)
- {
-       return 0;
- }
- static inline int pci_enable_msix(struct pci_dev *dev,
-                                 struct msix_entry *entries, int nvec)
- {
-       return -1;
- }
- static inline void pci_msix_shutdown(struct pci_dev *dev)
- { }
- static inline void pci_disable_msix(struct pci_dev *dev)
- { }
- static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev)
- { }
- static inline void pci_restore_msi_state(struct pci_dev *dev)
- { }
- static inline int pci_msi_enabled(void)
- {
-       return 0;
- }
- #else
- int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
- int pci_enable_msi_block_auto(struct pci_dev *dev, unsigned int *maxvec);
+ #ifdef CONFIG_PCI_MSI
+ int pci_msi_vec_count(struct pci_dev *dev);
+ int pci_enable_msi_block(struct pci_dev *dev, int nvec);
  void pci_msi_shutdown(struct pci_dev *dev);
  void pci_disable_msi(struct pci_dev *dev);
- int pci_msix_table_size(struct pci_dev *dev);
+ int pci_msix_vec_count(struct pci_dev *dev);
  int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec);
  void pci_msix_shutdown(struct pci_dev *dev);
  void pci_disable_msix(struct pci_dev *dev);
  void msi_remove_pci_irq_vectors(struct pci_dev *dev);
  void pci_restore_msi_state(struct pci_dev *dev);
  int pci_msi_enabled(void);
+ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec);
+ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
+                         int minvec, int maxvec);
+ #else
+ static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
+ static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec)
+ { return -ENOSYS; }
+ static inline void pci_msi_shutdown(struct pci_dev *dev) { }
+ static inline void pci_disable_msi(struct pci_dev *dev) { }
+ static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
+ static inline int pci_enable_msix(struct pci_dev *dev,
+                                 struct msix_entry *entries, int nvec)
+ { return -ENOSYS; }
+ static inline void pci_msix_shutdown(struct pci_dev *dev) { }
+ static inline void pci_disable_msix(struct pci_dev *dev) { }
+ static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) { }
+ static inline void pci_restore_msi_state(struct pci_dev *dev) { }
+ static inline int pci_msi_enabled(void) { return 0; }
+ static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec,
+                                      int maxvec)
+ { return -ENOSYS; }
+ static inline int pci_enable_msix_range(struct pci_dev *dev,
+                     struct msix_entry *entries, int minvec, int maxvec)
+ { return -ENOSYS; }
  #endif
  
  #ifdef CONFIG_PCIEPORTBUS
@@@ -1217,12 -1201,10 +1202,10 @@@ extern bool pcie_ports_auto
  #define pcie_ports_auto               false
  #endif
  
- #ifndef CONFIG_PCIEASPM
- static inline int pcie_aspm_enabled(void) { return 0; }
- static inline bool pcie_aspm_support_enabled(void) { return false; }
- #else
- int pcie_aspm_enabled(void);
+ #ifdef CONFIG_PCIEASPM
  bool pcie_aspm_support_enabled(void);
+ #else
+ static inline bool pcie_aspm_support_enabled(void) { return false; }
  #endif
  
  #ifdef CONFIG_PCIEAER
@@@ -1233,15 -1215,12 +1216,12 @@@ static inline void pci_no_aer(void) { 
  static inline bool pci_aer_available(void) { return false; }
  #endif
  
- #ifndef CONFIG_PCIE_ECRC
- static inline void pcie_set_ecrc_checking(struct pci_dev *dev)
- {
-       return;
- }
- static inline void pcie_ecrc_get_policy(char *str) {};
- #else
+ #ifdef CONFIG_PCIE_ECRC
  void pcie_set_ecrc_checking(struct pci_dev *dev);
  void pcie_ecrc_get_policy(char *str);
+ #else
+ static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
+ static inline void pcie_ecrc_get_policy(char *str) { }
  #endif
  
  #define pci_enable_msi(pdev)  pci_enable_msi_block(pdev, 1)
@@@ -1265,15 -1244,8 +1245,8 @@@ void pci_cfg_access_unlock(struct pci_d
  extern int pci_domains_supported;
  #else
  enum { pci_domains_supported = 0 };
- static inline int pci_domain_nr(struct pci_bus *bus)
- {
-       return 0;
- }
- static inline int pci_proc_domain(struct pci_bus *bus)
- {
-       return 0;
- }
+ static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
+ static inline int pci_proc_domain(struct pci_bus *bus) { return 0; }
  #endif /* CONFIG_PCI_DOMAINS */
  
  /* some architectures require additional setup to direct VGA traffic */
@@@ -1302,180 -1274,88 +1275,88 @@@ _PCI_NOP_ALL(write,
  static inline struct pci_dev *pci_get_device(unsigned int vendor,
                                             unsigned int device,
                                             struct pci_dev *from)
- {
-       return NULL;
- }
+ { return NULL; }
  
  static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
                                             unsigned int device,
                                             unsigned int ss_vendor,
                                             unsigned int ss_device,
                                             struct pci_dev *from)
- {
-       return NULL;
- }
+ { return NULL; }
  
  static inline struct pci_dev *pci_get_class(unsigned int class,
                                            struct pci_dev *from)
- {
-       return NULL;
- }
+ { return NULL; }
  
  #define pci_dev_present(ids)  (0)
  #define no_pci_devices()      (1)
  #define pci_dev_put(dev)      do { } while (0)
  
- 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 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;
- }
+ { return -EIO; }
  static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
- {
-       return -EIO;
- }
+ { return -EIO; }
  static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
                                        unsigned int size)
- {
-       return -EIO;
- }
+ { return -EIO; }
  static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
                                        unsigned long mask)
- {
-       return -EIO;
- }
+ { return -EIO; }
  static inline int pci_assign_resource(struct pci_dev *dev, int i)
- {
-       return -EBUSY;
- }
+ { return -EBUSY; }
  static inline int __pci_register_driver(struct pci_driver *drv,
                                        struct module *owner)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_register_driver(struct pci_driver *drv)
- {
-       return 0;
- }
- static inline void pci_unregister_driver(struct pci_driver *drv)
- { }
+ { return 0; }
+ static inline void pci_unregister_driver(struct pci_driver *drv) { }
  static inline int pci_find_capability(struct pci_dev *dev, int cap)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
                                           int cap)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
- {
-       return 0;
- }
+ { return 0; }
  
  /* Power management related routines */
- static inline int pci_save_state(struct pci_dev *dev)
- {
-       return 0;
- }
- static inline void pci_restore_state(struct pci_dev *dev)
- { }
+ static inline int pci_save_state(struct pci_dev *dev) { return 0; }
+ static inline void pci_restore_state(struct pci_dev *dev) { }
  static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_wake_from_d3(struct pci_dev *dev, bool enable)
- {
-       return 0;
- }
+ { return 0; }
  static inline pci_power_t pci_choose_state(struct pci_dev *dev,
                                           pm_message_t state)
- {
-       return PCI_D0;
- }
+ { return PCI_D0; }
  static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
                                  int enable)
- {
-       return 0;
- }
- static inline void pci_enable_ido(struct pci_dev *dev, unsigned long type)
- {
- }
- static inline void pci_disable_ido(struct pci_dev *dev, unsigned long type)
- {
- }
- static inline int pci_enable_obff(struct pci_dev *dev, unsigned long type)
- {
-       return 0;
- }
- static inline void pci_disable_obff(struct pci_dev *dev)
- {
- }
+ { return 0; }
  
  static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
- {
-       return -EIO;
- }
- static inline void pci_release_regions(struct pci_dev *dev)
- { }
+ { return -EIO; }
+ static inline void pci_release_regions(struct pci_dev *dev) { }
  
  #define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
  
- static inline void pci_block_cfg_access(struct pci_dev *dev)
- { }
+ static inline void pci_block_cfg_access(struct pci_dev *dev) { }
  static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
  { return 0; }
- static inline void pci_unblock_cfg_access(struct pci_dev *dev)
- { }
+ static inline void pci_unblock_cfg_access(struct pci_dev *dev) { }
  
  static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
  { return NULL; }
  static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
                                                unsigned int devfn)
  { return NULL; }
  static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
                                                unsigned int devfn)
  { return NULL; }
  
- static inline int pci_domain_nr(struct pci_bus *bus)
- { return 0; }
- static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
- { return NULL; }
+ static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
+ static inline struct pci_dev *pci_dev_get(struct pci_dev *dev) { return NULL; }
  
  #define dev_is_pci(d) (false)
  #define dev_is_pf(d) (false)
  
  #include <asm/pci.h>
  
- #ifndef PCIBIOS_MAX_MEM_32
- #define PCIBIOS_MAX_MEM_32 (-1)
- #endif
  /* these helpers provide future and backwards compatibility
   * for accessing popular PCI BAR info */
  #define pci_resource_start(dev, bar)  ((dev)->resource[(bar)].start)
@@@ -1635,7 -1511,7 +1512,7 @@@ struct pci_dev *pci_get_dma_source(stru
  int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags);
  #else
  static inline void pci_fixup_device(enum pci_fixup_pass pass,
-                                   struct pci_dev *dev) {}
+                                   struct pci_dev *dev) { }
  static inline struct pci_dev *pci_get_dma_source(struct pci_dev *dev)
  {
        return pci_dev_get(dev);
@@@ -1707,32 -1583,17 +1584,17 @@@ int pci_sriov_set_totalvfs(struct pci_d
  int pci_sriov_get_totalvfs(struct pci_dev *dev);
  #else
  static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
- {
-       return -ENODEV;
- }
- static inline void pci_disable_sriov(struct pci_dev *dev)
- {
- }
+ { return -ENODEV; }
+ static inline void pci_disable_sriov(struct pci_dev *dev) { }
  static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
- {
-       return IRQ_NONE;
- }
- static inline int pci_num_vf(struct pci_dev *dev)
- {
-       return 0;
- }
+ { return IRQ_NONE; }
+ static inline int pci_num_vf(struct pci_dev *dev) { return 0; }
  static inline int pci_vfs_assigned(struct pci_dev *dev)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
- {
-       return 0;
- }
+ { return 0; }
  static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
- {
-       return 0;
- }
+ { return 0; }
  #endif
  
  #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)