Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Jan 2012 02:50:26 +0000 (18:50 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Jan 2012 02:50:26 +0000 (18:50 -0800)
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci: (80 commits)
  x86/PCI: Expand the x86_msi_ops to have a restore MSIs.
  PCI: Increase resource array mask bit size in pcim_iomap_regions()
  PCI: DEVICE_COUNT_RESOURCE should be equal to PCI_NUM_RESOURCES
  PCI: pci_ids: add device ids for STA2X11 device (aka ConneXT)
  PNP: work around Dell 1536/1546 BIOS MMCONFIG bug that breaks USB
  x86/PCI: amd: factor out MMCONFIG discovery
  PCI: Enable ATS at the device state restore
  PCI: msi: fix imbalanced refcount of msi irq sysfs objects
  PCI: kconfig: English typo in pci/pcie/Kconfig
  PCI/PM/Runtime: make PCI traces quieter
  PCI: remove pci_create_bus()
  xtensa/PCI: convert to pci_scan_root_bus() for correct root bus resources
  x86/PCI: convert to pci_create_root_bus() and pci_scan_root_bus()
  x86/PCI: use pci_scan_bus() instead of pci_scan_bus_parented()
  x86/PCI: read Broadcom CNB20LE host bridge info before PCI scan
  sparc32, leon/PCI: convert to pci_scan_root_bus() for correct root bus resources
  sparc/PCI: convert to pci_create_root_bus()
  sh/PCI: convert to pci_scan_root_bus() for correct root bus resources
  powerpc/PCI: convert to pci_create_root_bus()
  powerpc/PCI: split PHB part out of pcibios_map_io_space()
  ...

Fix up conflicts in drivers/pci/msi.c and include/linux/pci_regs.h due
to the same patches being applied in other branches.

22 files changed:
1  2 
Documentation/feature-removal-schedule.txt
arch/alpha/kernel/pci.c
arch/arm/mach-dove/pcie.c
arch/arm/mach-ixp2000/enp2611.c
arch/arm/mach-kirkwood/pcie.c
arch/arm/mach-mv78xx0/pcie.c
arch/arm/mach-orion5x/pci.c
arch/arm/mach-tegra/pcie.c
arch/microblaze/pci/pci-common.c
arch/powerpc/include/asm/pci-bridge.h
arch/powerpc/include/asm/pci.h
arch/powerpc/kernel/pci-common.c
arch/sh/drivers/pci/pci.c
arch/tile/include/asm/pci.h
arch/tile/kernel/pci.c
arch/x86/include/asm/topology.h
arch/x86/include/asm/x86_init.h
arch/x86/kernel/amd_nb.c
arch/x86/kernel/x86_init.c
drivers/pci/ats.c
include/linux/pci_regs.h
lib/devres.c

index 5575759b84eedccead799d851499ec69c5da3d8d,dca11ea6d2d510151027699260ba2daecbcd136e..d49c2ec72d12762ee01c2c9474bc573efb53c26a
@@@ -85,6 -85,17 +85,6 @@@ Who: Robin Getz <rgetz@blackfin.uclinux
  
  ---------------------------
  
 -What: Deprecated snapshot ioctls
 -When: 2.6.36
 -
 -Why:  The ioctls in kernel/power/user.c were marked as deprecated long time
 -      ago. Now they notify users about that so that they need to replace
 -      their userspace. After some more time, remove them completely.
 -
 -Who:  Jiri Slaby <jirislaby@gmail.com>
 -
 ----------------------------
 -
  What: The ieee80211_regdom module parameter
  When: March 2010 / desktop catchup
  
@@@ -252,7 -263,8 +252,7 @@@ Who:       Ravikiran Thirumalai <kiran@scalex
  
  What: Code that is now under CONFIG_WIRELESS_EXT_SYSFS
        (in net/core/net-sysfs.c)
 -When: After the only user (hal) has seen a release with the patches
 -      for enough time, probably some time in 2010.
 +When: 3.5
  Why:  Over 1K .text/.data size reduction, data is available in other
        ways (ioctls)
  Who:  Johannes Berg <johannes@sipsolutions.net>
@@@ -350,6 -362,15 +350,6 @@@ Who:      anybody or Florian Mickler <flori
  
  ----------------------------
  
 -What: KVM paravirt mmu host support
 -When: January 2011
 -Why:  The paravirt mmu host support is slower than non-paravirt mmu, both
 -      on newer and older hardware.  It is already not exposed to the guest,
 -      and kept only for live migration purposes.
 -Who:  Avi Kivity <avi@redhat.com>
 -
 -----------------------------
 -
  What: iwlwifi 50XX module parameters
  When: 3.0
  Why:  The "..50" modules parameters were used to configure 5000 series and
@@@ -514,20 -535,6 +514,20 @@@ Why:    In 3.0, we can now autodetect i
        information log when acer-wmi initial.
  Who:    Lee, Chun-Yi <jlee@novell.com>
  
 +---------------------------
 +
 +What: /sys/devices/platform/_UDC_/udc/_UDC_/is_dualspeed file and
 +      is_dualspeed line in /sys/devices/platform/ci13xxx_*/udc/device file.
 +When: 3.8
 +Why:  The is_dualspeed file is superseded by maximum_speed in the same
 +      directory and is_dualspeed line in device file is superseded by
 +      max_speed line in the same file.
 +
 +      The maximum_speed/max_speed specifies maximum speed supported by UDC.
 +      To check if dualspeeed is supported, check if the value is >= 3.
 +      Various possible speeds are defined in <linux/usb/ch9.h>.
 +Who:  Michal Nazarewicz <mina86@mina86.com>
 +
  ----------------------------
  
  What: The XFS nodelaylog mount option
@@@ -544,3 -551,15 +544,15 @@@ When:    3.
  Why:  The iwlagn module has been renamed iwlwifi.  The alias will be around
        for backward compatibility for several cycles and then dropped.
  Who:  Don Fry <donald.h.fry@intel.com>
+ ----------------------------
+ What: pci_scan_bus_parented()
+ When: 3.5
+ Why:  The pci_scan_bus_parented() interface creates a new root bus.  The
+       bus is created with default resources (ioport_resource and
+       iomem_resource) that are always wrong, so we rely on arch code to
+       correct them later.  Callers of pci_scan_bus_parented() should
+       convert to using pci_scan_root_bus() so they can supply a list of
+       bus resources when the bus is created.
+ Who:  Bjorn Helgaas <bhelgaas@google.com>
diff --combined arch/alpha/kernel/pci.c
index f3cae275d3f5e875142c67f89691c891227e2d19,fcb4b914d4bb939370a81b70f7a8d2af3a9c8459..8c723c1b086a03fd26ca69beabd794da836cc41b
@@@ -281,27 -281,9 +281,9 @@@ pcibios_fixup_device_resources(struct p
  void __devinit
  pcibios_fixup_bus(struct pci_bus *bus)
  {
-       /* Propagate hose info into the subordinate devices.  */
-       struct pci_controller *hose = bus->sysdata;
        struct pci_dev *dev = bus->self;
  
-       if (!dev) {
-               /* Root bus. */
-               u32 pci_mem_end;
-               u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
-               unsigned long end;
-               bus->resource[0] = hose->io_space;
-               bus->resource[1] = hose->mem_space;
-               /* Adjust hose mem_space limit to prevent PCI allocations
-                  in the iommu windows. */
-               pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
-               end = hose->mem_space->start + pci_mem_end;
-               if (hose->mem_space->end > end)
-                       hose->mem_space->end = end;
-       } else if (pci_probe_only &&
+       if (pci_probe_only && dev &&
                   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
                pci_read_bridge_bases(bus);
                pcibios_fixup_device_resources(dev, bus);
@@@ -414,13 -396,31 +396,31 @@@ void __ini
  common_init_pci(void)
  {
        struct pci_controller *hose;
+       struct list_head resources;
        struct pci_bus *bus;
        int next_busno;
        int need_domain_info = 0;
+       u32 pci_mem_end;
+       u32 sg_base;
+       unsigned long end;
  
        /* Scan all of the recorded PCI controllers.  */
        for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
-               bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
+               sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
+               /* Adjust hose mem_space limit to prevent PCI allocations
+                  in the iommu windows. */
+               pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
+               end = hose->mem_space->start + pci_mem_end;
+               if (hose->mem_space->end > end)
+                       hose->mem_space->end = end;
+               INIT_LIST_HEAD(&resources);
+               pci_add_resource(&resources, hose->io_space);
+               pci_add_resource(&resources, hose->mem_space);
+               bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
+                                       hose, &resources);
                hose->bus = bus;
                hose->need_domain_info = need_domain_info;
                next_busno = bus->subordinate + 1;
@@@ -508,7 -508,30 +508,7 @@@ sys_pciconfig_iobase(long which, unsign
        return -EOPNOTSUPP;
  }
  
 -/* Create an __iomem token from a PCI BAR.  Copied from lib/iomap.c with
 -   no changes, since we don't want the other things in that object file.  */
 -
 -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
 -{
 -      resource_size_t start = pci_resource_start(dev, bar);
 -      resource_size_t len = pci_resource_len(dev, bar);
 -      unsigned long flags = pci_resource_flags(dev, bar);
 -
 -      if (!len || !start)
 -              return NULL;
 -      if (maxlen && len > maxlen)
 -              len = maxlen;
 -      if (flags & IORESOURCE_IO)
 -              return ioport_map(start, len);
 -      if (flags & IORESOURCE_MEM) {
 -              /* Not checking IORESOURCE_CACHEABLE because alpha does
 -                 not distinguish between ioremap and ioremap_nocache.  */
 -              return ioremap(start, len);
 -      }
 -      return NULL;
 -}
 -
 -/* Destroy that token.  Not copied from lib/iomap.c.  */
 +/* Destroy an __iomem token.  Not copied from lib/iomap.c.  */
  
  void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
  {
                iounmap(addr);
  }
  
 -EXPORT_SYMBOL(pci_iomap);
  EXPORT_SYMBOL(pci_iounmap);
  
  /* FIXME: Some boxes have multiple ISA bridges! */
index 6c11a4df71781493a9470b9c59af8541dbc41605,d5b5dce3d5f390bc12f961b683b35c574fd454ae..52e96d397ba8cfffe68b1085f3cdbf5eee2bc463
@@@ -10,6 -10,7 +10,6 @@@
  
  #include <linux/kernel.h>
  #include <linux/pci.h>
 -#include <linux/mbus.h>
  #include <video/vga.h>
  #include <asm/mach/pci.h>
  #include <asm/mach/arch.h>
@@@ -18,7 -19,6 +18,7 @@@
  #include <plat/pcie.h>
  #include <mach/irqs.h>
  #include <mach/bridge-regs.h>
 +#include <plat/addr-map.h>
  #include "common.h"
  
  struct pcie_port {
@@@ -50,7 -50,7 +50,7 @@@ static int __init dove_pcie_setup(int n
         */
        orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
  
 -      orion_pcie_setup(pp->base, &dove_mbus_dram_info);
 +      orion_pcie_setup(pp->base);
  
        /*
         * IORESOURCE_IO
@@@ -69,7 -69,7 +69,7 @@@
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       sys->resource[0] = &pp->res[0];
+       pci_add_resource(&sys->resources, &pp->res[0]);
  
        /*
         * IORESOURCE_MEM
@@@ -88,9 -88,7 +88,7 @@@
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       sys->resource[1] = &pp->res[1];
-       sys->resource[2] = NULL;
+       pci_add_resource(&sys->resources, &pp->res[1]);
  
        return 1;
  }
@@@ -184,7 -182,8 +182,8 @@@ dove_pcie_scan_bus(int nr, struct pci_s
        struct pci_bus *bus;
  
        if (nr < num_pcie_ports) {
-               bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                       &sys->resources);
        } else {
                bus = NULL;
                BUG();
index ee525416f0d20b0ca6a69b42cd9820c8b45a0731,39c08a11a686beb2d725defae6c492cadb9900e4..e872d238cd0fd36103f29581544404c3a08de098
@@@ -145,7 -145,8 +145,8 @@@ static struct pci_ops enp2611_pci_ops 
  static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
                                                struct pci_sys_data *sys)
  {
-       return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
+       return pci_scan_root_bus(NULL, sys->busnr, &enp2611_pci_ops, sys,
+                                &sys->resources);
  }
  
  static int __init enp2611_pci_map_irq(const struct pci_dev *dev, u8 slot,
@@@ -259,7 -260,6 +260,7 @@@ MACHINE_START(ENP2611, "Radisys ENP-261
        .init_irq       = ixp2000_init_irq,
        .timer          = &enp2611_timer,
        .init_machine   = enp2611_init_machine,
 +      .restart        = ixp2000_restart,
  MACHINE_END
  
  
index fb451bfe478b9ad5c32f5588caa71a7cb84786c1,9ca38de527e1bc209900fc976fa70373668c8e61..a066a6d8d9d2126bc577401b8710e16a1b40d133
  #include <linux/kernel.h>
  #include <linux/pci.h>
  #include <linux/slab.h>
 -#include <linux/mbus.h>
  #include <video/vga.h>
  #include <asm/irq.h>
  #include <asm/mach/pci.h>
  #include <plat/pcie.h>
  #include <mach/bridge-regs.h>
 +#include <plat/addr-map.h>
  #include "common.h"
  
  void kirkwood_enable_pcie(void)
@@@ -198,9 -198,8 +198,8 @@@ static int __init kirkwood_pcie_setup(i
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe%d Memory resource failed\n", index);
  
-       sys->resource[0] = &pp->res[0];
-       sys->resource[1] = &pp->res[1];
-       sys->resource[2] = NULL;
+       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource(&sys->resources, &pp->res[1]);
        sys->io_offset = 0;
  
        /*
         */
        orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
  
 -      orion_pcie_setup(pp->base, &kirkwood_mbus_dram_info);
 +      orion_pcie_setup(pp->base);
  
        return 1;
  }
@@@ -236,7 -235,8 +235,8 @@@ kirkwood_pcie_scan_bus(int nr, struct p
        struct pci_bus *bus;
  
        if (nr < num_pcie_ports) {
-               bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                       &sys->resources);
        } else {
                bus = NULL;
                BUG();
index 12fcb108b0e13036c7de59583e3af5f7e1d99007,c701135f139e876d92ac3fcb85e232bdedf0124c..8459f6d7d8caff6091fe05d2862895ba94460626
  
  #include <linux/kernel.h>
  #include <linux/pci.h>
 -#include <linux/mbus.h>
  #include <video/vga.h>
  #include <asm/irq.h>
  #include <asm/mach/pci.h>
  #include <plat/pcie.h>
 +#include <plat/addr-map.h>
  #include "common.h"
  
  struct pcie_port {
@@@ -153,11 -153,10 +153,10 @@@ static int __init mv78xx0_pcie_setup(in
         * Generic PCIe unit setup.
         */
        orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
 -      orion_pcie_setup(pp->base, &mv78xx0_mbus_dram_info);
 +      orion_pcie_setup(pp->base);
  
-       sys->resource[0] = &pp->res[0];
-       sys->resource[1] = &pp->res[1];
-       sys->resource[2] = NULL;
+       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource(&sys->resources, &pp->res[1]);
  
        return 1;
  }
@@@ -251,7 -250,8 +250,8 @@@ mv78xx0_pcie_scan_bus(int nr, struct pc
        struct pci_bus *bus;
  
        if (nr < num_pcie_ports) {
-               bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                       &sys->resources);
        } else {
                bus = NULL;
                BUG();
index a494c470e3e4c62dc0cb85d2de14e2b18fefb5a9,4eb93647aab7ae8fd4dfe51fb77df629b78cc869..09a045f0c406c50b64275f450993874b1af18f02
@@@ -18,7 -18,6 +18,7 @@@
  #include <asm/irq.h>
  #include <asm/mach/pci.h>
  #include <plat/pcie.h>
 +#include <plat/addr-map.h>
  #include "common.h"
  
  /*****************************************************************************
@@@ -146,7 -145,7 +146,7 @@@ static int __init pcie_setup(struct pci
        /*
         * Generic PCIe unit setup.
         */
 -      orion_pcie_setup(PCIE_BASE, &orion5x_mbus_dram_info);
 +      orion_pcie_setup(PCIE_BASE);
  
        /*
         * Check whether to apply Orion-1/Orion-NAS PCIe config
        res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCIe IO resource failed\n");
-       sys->resource[0] = &res[0];
+       pci_add_resource(&sys->resources, &res[0]);
  
        /*
         * IORESOURCE_MEM
        res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCIe Memory resource failed\n");
-       sys->resource[1] = &res[1];
+       pci_add_resource(&sys->resources, &res[1]);
  
-       sys->resource[2] = NULL;
        sys->io_offset = 0;
  
        return 1;
@@@ -478,7 -476,7 +477,7 @@@ static int __init pci_setup(struct pci_
        /*
         * Point PCI unit MBUS decode windows to DRAM space.
         */
 -      orion5x_setup_pci_wins(&orion5x_mbus_dram_info);
 +      orion5x_setup_pci_wins(&orion_mbus_dram_info);
  
        /*
         * Master + Slave enable
        res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCI IO resource failed\n");
-       sys->resource[0] = &res[0];
+       pci_add_resource(&sys->resources, &res[0]);
  
        /*
         * IORESOURCE_MEM
        res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCI Memory resource failed\n");
-       sys->resource[1] = &res[1];
+       pci_add_resource(&sys->resources, &res[1]);
  
-       sys->resource[2] = NULL;
        sys->io_offset = 0;
  
        return 1;
@@@ -580,9 -577,11 +578,11 @@@ struct pci_bus __init *orion5x_pci_sys_
        struct pci_bus *bus;
  
        if (nr == 0) {
-               bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+               bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+                                       &sys->resources);
        } else if (nr == 1 && !orion5x_pci_disabled) {
-               bus = pci_scan_bus(sys->busnr, &pci_ops, sys);
+               bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
+                                       &sys->resources);
        } else {
                bus = NULL;
                BUG();
index ec63c6b2b6b536c1d32939f1df14c443a3ef562d,92947d86fc87f3a77f569c1e4bb1fe85f203a27b..af8b634357278b5682955d7eca3f4a3f946e0895
@@@ -37,6 -37,7 +37,6 @@@
  #include <asm/sizes.h>
  #include <asm/mach/pci.h>
  
 -#include <mach/pinmux.h>
  #include <mach/iomap.h>
  #include <mach/clk.h>
  #include <mach/powergate.h>
@@@ -408,7 -409,7 +408,7 @@@ static int tegra_pcie_setup(int nr, str
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       sys->resource[0] = &pp->res[0];
+       pci_add_resource(&sys->resources, &pp->res[0]);
  
        /*
         * IORESOURCE_MEM
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       sys->resource[1] = &pp->res[1];
+       pci_add_resource(&sys->resources, &pp->res[1]);
  
        /*
         * IORESOURCE_MEM | IORESOURCE_PREFETCH
        pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
        if (request_resource(&iomem_resource, &pp->res[2]))
                panic("Request PCIe Prefetch Memory resource failed\n");
-       sys->resource[2] = &pp->res[2];
+       pci_add_resource(&sys->resources, &pp->res[2]);
  
        return 1;
  }
@@@ -467,7 -468,8 +467,8 @@@ static struct pci_bus __init *tegra_pci
        pp = tegra_pcie.port + nr;
        pp->root_bus_nr = sys->busnr;
  
-       return pci_scan_bus(sys->busnr, &tegra_pcie_ops, sys);
+       return pci_scan_root_bus(NULL, sys->busnr, &tegra_pcie_ops, sys,
+                                &sys->resources);
  }
  
  static struct hw_pci tegra_pcie_hw __initdata = {
index 0d71b2ed81074befc649e5d369ebfdafb13ccf1a,016d420f0ec735319f9eede27fb4f3431b114c22..85f2ac1230a8f5e89d78955f67819999f69367c3
@@@ -190,6 -190,11 +190,11 @@@ int pcibios_add_platform_entries(struc
        return device_create_file(&pdev->dev, &dev_attr_devspec);
  }
  
+ void pcibios_set_master(struct pci_dev *dev)
+ {
+       /* No special bus mastering setup handling */
+ }
  char __devinit *pcibios_setup(char *str)
  {
        return str;
@@@ -242,7 -247,7 +247,7 @@@ int pci_read_irq_line(struct pci_dev *p
                         line, pin);
  
                virq = irq_create_mapping(NULL, line);
 -              if (virq != NO_IRQ)
 +              if (virq)
                        irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
        } else {
                pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
                virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
                                             oirq.size);
        }
 -      if (virq == NO_IRQ) {
 +      if (!virq) {
                pr_debug(" Failed to map !\n");
                return -1;
        }
@@@ -1019,7 -1024,6 +1024,6 @@@ static void __devinit pcibios_fixup_bri
        struct pci_dev *dev = bus->self;
  
        pci_bus_for_each_resource(bus, res, i) {
-               res = bus->resource[i];
                if (!res)
                        continue;
                if (!res->flags)
@@@ -1219,7 -1223,6 +1223,6 @@@ void pcibios_allocate_bus_resources(str
                 pci_domain_nr(bus), bus->number);
  
        pci_bus_for_each_resource(bus, res, i) {
-               res = bus->resource[i];
                if (!res || !res->flags
                    || res->start > res->end || res->parent)
                        continue;
@@@ -1510,14 -1513,18 +1513,18 @@@ int pcibios_enable_device(struct pci_de
        return pci_enable_resources(dev, mask);
  }
  
void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
  {
-       struct pci_bus *bus = hose->bus;
        struct resource *res;
        int i;
  
        /* Hookup PHB IO resource */
-       bus->resource[0] = res = &hose->io_resource;
+       res = &hose->io_resource;
+       /* Fixup IO space offset */
+       io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
+       res->start = (res->start + io_offset) & 0xffffffffu;
+       res->end = (res->end + io_offset) & 0xffffffffu;
  
        if (!res->flags) {
                printk(KERN_WARNING "PCI: I/O resource not set for host"
                res->end = res->start + IO_SPACE_LIMIT;
                res->flags = IORESOURCE_IO;
        }
+       pci_add_resource(resources, res);
  
        pr_debug("PCI: PHB IO resource    = %016llx-%016llx [%lx]\n",
                 (unsigned long long)res->start,
                        res->flags = IORESOURCE_MEM;
  
                }
-               bus->resource[i+1] = res;
+               pci_add_resource(resources, res);
  
                pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n",
                        i, (unsigned long long)res->start,
@@@ -1573,34 -1581,27 +1581,27 @@@ struct device_node *pcibios_get_phb_of_
  
  static void __devinit pcibios_scan_phb(struct pci_controller *hose)
  {
+       LIST_HEAD(resources);
        struct pci_bus *bus;
        struct device_node *node = hose->dn;
-       unsigned long io_offset;
-       struct resource *res = &hose->io_resource;
  
        pr_debug("PCI: Scanning PHB %s\n",
                 node ? node->full_name : "<NO NAME>");
  
-       /* Create an empty bus for the toplevel */
-       bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+       pcibios_setup_phb_resources(hose, &resources);
+       bus = pci_scan_root_bus(hose->parent, hose->first_busno,
+                               hose->ops, hose, &resources);
        if (bus == NULL) {
                printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
                       hose->global_number);
+               pci_free_resource_list(&resources);
                return;
        }
        bus->secondary = hose->first_busno;
        hose->bus = bus;
  
-       /* Fixup IO space offset */
-       io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
-       res->start = (res->start + io_offset) & 0xffffffffu;
-       res->end = (res->end + io_offset) & 0xffffffffu;
-       /* Wire up PHB bus resources */
-       pcibios_setup_phb_resources(hose);
-       /* Scan children */
-       hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
+       hose->last_busno = bus->subordinate;
  }
  
  static int __init pcibios_init(void)
        list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
                hose->last_busno = 0xff;
                pcibios_scan_phb(hose);
-               printk(KERN_INFO "calling pci_bus_add_devices()\n");
-               pci_bus_add_devices(hose->bus);
                if (next_busno <= hose->last_busno)
                        next_busno = hose->last_busno + 1;
        }
index 882b6aa6c85765f9bdd5df1f55c1cfad13d07ac1,31bf836ad22cc947a42f3de9ebf5345427206f34..5d487657322e11d38ccfd47591a264dd2e73145e
@@@ -153,8 -153,8 +153,8 @@@ struct pci_dn 
  
        int     pci_ext_config_space;   /* for pci devices */
  
 -#ifdef CONFIG_EEH
        struct  pci_dev *pcidev;        /* back-pointer to the pci device */
 +#ifdef CONFIG_EEH
        int     class_code;             /* pci device class */
        int     eeh_mode;               /* See eeh.h for possible EEH_MODEs */
        int     eeh_config_addr;
        int     eeh_false_positives;    /* # times this device reported #ff's */
        u32     config_space[16];       /* saved PCI config space */
  #endif
 +#define IODA_INVALID_PE               (-1)
 +#ifdef CONFIG_PPC_POWERNV
 +      int     pe_number;
 +#endif
  };
  
  /* Get the pointer to a device_node's pci_dn */
@@@ -226,7 -222,6 +226,6 @@@ extern void pci_process_bridge_OF_range
  /* Allocate & free a PCI host bridge structure */
  extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
  extern void pcibios_free_controller(struct pci_controller *phb);
- extern void pcibios_setup_phb_resources(struct pci_controller *hose);
  
  #ifdef CONFIG_PCI
  extern int pcibios_vaddr_is_ioport(void __iomem *address);
index 1c92013466e3c68d3bd1792864b62548df037846,9284fe85046a62253001ad92f2000f7b115df81d..f54b3d26ce9d80e1f361d33d451253b048c0521b
@@@ -46,11 -46,6 +46,6 @@@ struct pci_dev
  #define pcibios_assign_all_busses() \
        (pci_has_flag(PCI_REASSIGN_ALL_BUS))
  
- static inline void pcibios_set_master(struct pci_dev *dev)
- {
-       /* No special bus mastering setup handling */
- }
  static inline void pcibios_penalize_isa_irq(int irq, int active)
  {
        /* We don't do dynamic PCI IRQ allocation */
@@@ -184,6 -179,8 +179,6 @@@ extern void of_scan_pci_bridge(struct p
  extern void of_scan_bus(struct device_node *node, struct pci_bus *bus);
  extern void of_rescan_bus(struct device_node *node, struct pci_bus *bus);
  
 -extern int pci_read_irq_line(struct pci_dev *dev);
 -
  struct file;
  extern pgprot_t       pci_phys_mem_access_prot(struct file *file,
                                         unsigned long pfn,
index fa4a573d6716aa3bfe1a10eba2286224adff2388,0dbc5fb53c6803c5558fefb1473b5d99ef13219b..cce98d76e905ad2188ce0d27e985308abaa2a433
@@@ -214,7 -214,7 +214,7 @@@ char __devinit *pcibios_setup(char *str
   * If the interrupt is used, then gets the interrupt line from the
   * openfirmware and sets it in the pci_dev and pci_config line.
   */
 -int pci_read_irq_line(struct pci_dev *pci_dev)
 +static int pci_read_irq_line(struct pci_dev *pci_dev)
  {
        struct of_irq oirq;
        unsigned int virq;
  
        return 0;
  }
 -EXPORT_SYMBOL(pci_read_irq_line);
  
  /*
   * Platform support for /proc/bus/pci/X/Y mmap()s,
@@@ -920,22 -921,18 +920,22 @@@ static void __devinit pcibios_fixup_res
                struct resource *res = dev->resource + i;
                if (!res->flags)
                        continue;
 -              /* On platforms that have PCI_PROBE_ONLY set, we don't
 -               * consider 0 as an unassigned BAR value. It's technically
 -               * a valid value, but linux doesn't like it... so when we can
 -               * re-assign things, we do so, but if we can't, we keep it
 -               * around and hope for the best...
 +
 +              /* If we're going to re-assign everything, we mark all resources
 +               * as unset (and 0-base them). In addition, we mark BARs starting
 +               * at 0 as unset as well, except if PCI_PROBE_ONLY is also set
 +               * since in that case, we don't want to re-assign anything
                 */
 -              if (res->start == 0 && !pci_has_flag(PCI_PROBE_ONLY)) {
 -                      pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] is unassigned\n",
 -                               pci_name(dev), i,
 -                               (unsigned long long)res->start,
 -                               (unsigned long long)res->end,
 -                               (unsigned int)res->flags);
 +              if (pci_has_flag(PCI_REASSIGN_ALL_RSRC) ||
 +                  (res->start == 0 && !pci_has_flag(PCI_PROBE_ONLY))) {
 +                      /* Only print message if not re-assigning */
 +                      if (!pci_has_flag(PCI_REASSIGN_ALL_RSRC))
 +                              pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] "
 +                                       "is unassigned\n",
 +                                       pci_name(dev), i,
 +                                       (unsigned long long)res->start,
 +                                       (unsigned long long)res->end,
 +                                       (unsigned int)res->flags);
                        res->end -= res->start;
                        res->start = 0;
                        res->flags |= IORESOURCE_UNSET;
@@@ -1045,16 -1042,6 +1045,16 @@@ static void __devinit pcibios_fixup_bri
                if (i >= 3 && bus->self->transparent)
                        continue;
  
 +              /* If we are going to re-assign everything, mark the resource
 +               * as unset and move it down to 0
 +               */
 +              if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
 +                      res->flags |= IORESOURCE_UNSET;
 +                      res->end -= res->start;
 +                      res->start = 0;
 +                      continue;
 +              }
 +
                pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n",
                         pci_name(dev), i,
                         (unsigned long long)res->start,\
@@@ -1131,6 -1118,11 +1131,11 @@@ void __devinit pcibios_setup_bus_device
        }
  }
  
+ void pcibios_set_master(struct pci_dev *dev)
+ {
+       /* No special bus mastering setup handling */
+ }
  void __devinit pcibios_fixup_bus(struct pci_bus *bus)
  {
        /* When called from the generic PCI probe, read PCI<->PCI bridge
@@@ -1275,15 -1267,18 +1280,15 @@@ void pcibios_allocate_bus_resources(str
        pci_bus_for_each_resource(bus, res, i) {
                if (!res || !res->flags || res->start > res->end || res->parent)
                        continue;
 +
 +              /* If the resource was left unset at this point, we clear it */
 +              if (res->flags & IORESOURCE_UNSET)
 +                      goto clear_resource;
 +
                if (bus->parent == NULL)
                        pr = (res->flags & IORESOURCE_IO) ?
                                &ioport_resource : &iomem_resource;
                else {
 -                      /* Don't bother with non-root busses when
 -                       * re-assigning all resources. We clear the
 -                       * resource flags as if they were colliding
 -                       * and as such ensure proper re-allocation
 -                       * later.
 -                       */
 -                      if (pci_has_flag(PCI_REASSIGN_ALL_RSRC))
 -                              goto clear_resource;
                        pr = pci_find_parent_resource(bus->self, res);
                        if (pr == res) {
                                /* this happens when the generic PCI
                        if (reparent_resources(pr, res) == 0)
                                continue;
                }
 -              printk(KERN_WARNING "PCI: Cannot allocate resource region "
 -                     "%d of PCI bridge %d, will remap\n", i, bus->number);
 -clear_resource:
 +              pr_warning("PCI: Cannot allocate resource region "
 +                         "%d of PCI bridge %d, will remap\n", i, bus->number);
 +      clear_resource:
                res->start = res->end = 0;
                res->flags = 0;
        }
@@@ -1461,11 -1456,16 +1466,11 @@@ void __init pcibios_resource_survey(voi
  {
        struct pci_bus *b;
  
 -      /* Allocate and assign resources. If we re-assign everything, then
 -       * we skip the allocate phase
 -       */
 +      /* Allocate and assign resources */
        list_for_each_entry(b, &pci_root_buses, node)
                pcibios_allocate_bus_resources(b);
 -
 -      if (!pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
 -              pcibios_allocate_resources(0);
 -              pcibios_allocate_resources(1);
 -      }
 +      pcibios_allocate_resources(0);
 +      pcibios_allocate_resources(1);
  
        /* Before we start assigning unassigned resource, we try to reserve
         * the low IO area and the VGA memory area if they intersect the
@@@ -1560,14 -1560,13 +1565,13 @@@ int pcibios_enable_device(struct pci_de
        return pci_enable_resources(dev, mask);
  }
  
void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
  {
-       struct pci_bus *bus = hose->bus;
        struct resource *res;
        int i;
  
        /* Hookup PHB IO resource */
-       bus->resource[0] = res = &hose->io_resource;
+       res = &hose->io_resource;
  
        if (!res->flags) {
                printk(KERN_WARNING "PCI: I/O resource not set for host"
                 (unsigned long long)res->start,
                 (unsigned long long)res->end,
                 (unsigned long)res->flags);
+       pci_add_resource(resources, res);
  
        /* Hookup PHB Memory resources */
        for (i = 0; i < 3; ++i) {
                        res->flags = IORESOURCE_MEM;
  #endif /* CONFIG_PPC32 */
                }
-               bus->resource[i+1] = res;
  
                pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
                         (unsigned long long)res->start,
                         (unsigned long long)res->end,
                         (unsigned long)res->flags);
+               pci_add_resource(resources, res);
        }
  
        pr_debug("PCI: PHB MEM offset     = %016llx\n",
@@@ -1701,6 -1701,7 +1706,7 @@@ struct device_node *pcibios_get_phb_of_
   */
  void __devinit pcibios_scan_phb(struct pci_controller *hose)
  {
+       LIST_HEAD(resources);
        struct pci_bus *bus;
        struct device_node *node = hose->dn;
        int mode;
        pr_debug("PCI: Scanning PHB %s\n",
                 node ? node->full_name : "<NO NAME>");
  
+       /* Get some IO space for the new PHB */
+       pcibios_setup_phb_io_space(hose);
+       /* Wire up PHB bus resources */
+       pcibios_setup_phb_resources(hose, &resources);
        /* Create an empty bus for the toplevel */
-       bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+       bus = pci_create_root_bus(hose->parent, hose->first_busno,
+                                 hose->ops, hose, &resources);
        if (bus == NULL) {
                pr_err("Failed to create bus for PCI domain %04x\n",
                        hose->global_number);
+               pci_free_resource_list(&resources);
                return;
        }
        bus->secondary = hose->first_busno;
        hose->bus = bus;
  
-       /* Get some IO space for the new PHB */
-       pcibios_setup_phb_io_space(hose);
-       /* Wire up PHB bus resources */
-       pcibios_setup_phb_resources(hose);
        /* Get probe mode and perform scan */
        mode = PCI_PROBE_NORMAL;
        if (node && ppc_md.pci_probe_mode)
        if (mode == PCI_PROBE_NORMAL)
                hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
  
 +      /* Platform gets a chance to do some global fixups before
 +       * we proceed to resource allocation
 +       */
 +      if (ppc_md.pcibios_fixup_phb)
 +              ppc_md.pcibios_fixup_phb(hose);
 +
        /* Configure PCI Express settings */
        if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
                struct pci_bus *child;
  static void fixup_hide_host_resource_fsl(struct pci_dev *dev)
  {
        int i, class = dev->class >> 8;
 +      /* When configured as agent, programing interface = 1 */
 +      int prog_if = dev->class & 0xf;
  
        if ((class == PCI_CLASS_PROCESSOR_POWERPC ||
             class == PCI_CLASS_BRIDGE_OTHER) &&
                (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) &&
 +              (prog_if == 0) &&
                (dev->bus->parent == NULL)) {
                for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
                        dev->resource[i].start = 0;
index 11aaf2fdec84348513565122448c13aa2b2b59fc,5872c798d62d24dc01f0537aa62e24caa11d93f7..8f18dd090a66021b2a17051a0ade4f03f8ae71b4
@@@ -36,9 -36,15 +36,15 @@@ static void __devinit pcibios_scanbus(s
  {
        static int next_busno;
        static int need_domain_info;
+       LIST_HEAD(resources);
+       int i;
        struct pci_bus *bus;
  
-       bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
+       for (i = 0; i < hose->nr_resources; i++)
+               pci_add_resource(&resources, hose->resources + i);
+       bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
+                               &resources);
        hose->bus = bus;
  
        need_domain_info = need_domain_info || hose->index;
@@@ -55,6 -61,8 +61,8 @@@
                pci_bus_size_bridges(bus);
                pci_bus_assign_resources(bus);
                pci_enable_bridges(bus);
+       } else {
+               pci_free_resource_list(&resources);
        }
  }
  
@@@ -162,16 -170,8 +170,8 @@@ static void pcibios_fixup_device_resour
   */
  void __devinit pcibios_fixup_bus(struct pci_bus *bus)
  {
-       struct pci_dev *dev = bus->self;
+       struct pci_dev *dev;
        struct list_head *ln;
-       struct pci_channel *hose = bus->sysdata;
-       if (!dev) {
-               int i;
-               for (i = 0; i < hose->nr_resources; i++)
-                       bus->resource[i] = hose->resources + i;
-       }
  
        for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
                dev = pci_dev_b(ln);
@@@ -243,27 -243,6 +243,6 @@@ int pcibios_enable_device(struct pci_de
        return pci_enable_resources(dev, mask);
  }
  
- /*
-  *  If we set up a device for bus mastering, we need to check and set
-  *  the latency timer as it may not be properly set.
-  */
- static unsigned int pcibios_max_latency = 255;
- void pcibios_set_master(struct pci_dev *dev)
- {
-       u8 lat;
-       pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-       if (lat < 16)
-               lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
-       else if (lat > pcibios_max_latency)
-               lat = pcibios_max_latency;
-       else
-               return;
-       printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n",
-              pci_name(dev), lat);
-       pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
- }
  void __init pcibios_update_irq(struct pci_dev *dev, int irq)
  {
        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
@@@ -393,6 -372,29 +372,6 @@@ static void __iomem *ioport_map_pci(str
        return (void __iomem *)(chan->io_map_base + port);
  }
  
 -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
 -{
 -      resource_size_t start = pci_resource_start(dev, bar);
 -      resource_size_t len = pci_resource_len(dev, bar);
 -      unsigned long flags = pci_resource_flags(dev, bar);
 -
 -      if (unlikely(!len || !start))
 -              return NULL;
 -      if (maxlen && len > maxlen)
 -              len = maxlen;
 -
 -      if (flags & IORESOURCE_IO)
 -              return ioport_map_pci(dev, start, len);
 -      if (flags & IORESOURCE_MEM) {
 -              if (flags & IORESOURCE_CACHEABLE)
 -                      return ioremap(start, len);
 -              return ioremap_nocache(start, len);
 -      }
 -
 -      return NULL;
 -}
 -EXPORT_SYMBOL(pci_iomap);
 -
  void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
  {
        iounmap(addr);
index 1d25fea42e547a554344aa47e25abb107c646aa5,2a2abc742483c3ea90fbb8a870d90a1f0ed507f1..5d5a635530bd5ed527eb6387ce3a0170d605e0b0
@@@ -16,7 -16,6 +16,7 @@@
  #define _ASM_TILE_PCI_H
  
  #include <linux/pci.h>
 +#include <asm-generic/pci_iomap.h>
  
  /*
   * Structure of a PCI controller (host bridge)
@@@ -50,6 -49,7 +50,6 @@@ struct pci_controller 
  int __devinit tile_pci_init(void);
  int __devinit pcibios_init(void);
  
 -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
  static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
  
  void __devinit pcibios_fixup_bus(struct pci_bus *bus);
@@@ -76,13 -76,6 +76,6 @@@ static inline int pcibios_assign_all_bu
        return 1;
  }
  
- /*
-  * No special bus mastering setup handling.
-  */
- static inline void pcibios_set_master(struct pci_dev *dev)
- {
- }
  #define PCIBIOS_MIN_MEM               0
  #define PCIBIOS_MIN_IO                0
  
diff --combined arch/tile/kernel/pci.c
index 25567934a21e90cc5546a7495d784daa2e4e8cfa,b1025f6b48d1c683a674a3688e3afe0a4ac97ea3..a1bb59eecc1850bcd7aedf6f1ec538498e0d1573
@@@ -395,6 -395,11 +395,11 @@@ void __devinit pcibios_fixup_bus(struc
        /* Nothing needs to be done. */
  }
  
+ void pcibios_set_master(struct pci_dev *dev)
+ {
+       /* No special bus mastering setup handling. */
+ }
  /*
   * This can be called from the generic PCI layer, but doesn't need to
   * do anything.
@@@ -466,6 -471,27 +471,6 @@@ int pcibios_enable_device(struct pci_de
        return 0;
  }
  
 -void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
 -{
 -      unsigned long start = pci_resource_start(dev, bar);
 -      unsigned long len = pci_resource_len(dev, bar);
 -      unsigned long flags = pci_resource_flags(dev, bar);
 -
 -      if (!len)
 -              return NULL;
 -      if (max && len > max)
 -              len = max;
 -
 -      if (!(flags & IORESOURCE_MEM)) {
 -              pr_info("PCI: Trying to map invalid resource %#lx\n", flags);
 -              start = 0;
 -      }
 -
 -      return (void __iomem *)start;
 -}
 -EXPORT_SYMBOL(pci_iomap);
 -
 -
  /****************************************************************
   *
   * Tile PCI config space read/write routines
index 800f77c600510e431947e2e92f32d950d3d6c6b7,5f83b136dda75685d6988b16b5973f787beaa890..b9676ae37ada7ddbf7c7d208653ecb892ca2a9c8
@@@ -130,8 -130,10 +130,8 @@@ extern void setup_node_to_cpumask_map(v
        .balance_interval       = 1,                                    \
  }
  
 -#ifdef CONFIG_X86_64
  extern int __node_distance(int, int);
  #define node_distance(a, b) __node_distance(a, b)
 -#endif
  
  #else /* !CONFIG_NUMA */
  
@@@ -172,7 -174,7 +172,7 @@@ static inline void arch_fix_phys_packag
  }
  
  struct pci_bus;
- void x86_pci_root_bus_res_quirks(struct pci_bus *b);
+ void x86_pci_root_bus_resources(int bus, struct list_head *resources);
  
  #ifdef CONFIG_SMP
  #define mc_capable()  ((boot_cpu_data.x86_max_cores > 1) && \
index 1ac860a098495e70421563d1bd0d9f2b3b848448,cd5208446c2da49109691920da299cecb2125b6b..517d4767ffdda95e249cc5c173eb008a439cd346
@@@ -7,7 -7,6 +7,7 @@@
  struct mpc_bus;
  struct mpc_cpu;
  struct mpc_table;
 +struct cpuinfo_x86;
  
  /**
   * struct x86_init_mpparse - platform specific mpparse ops
@@@ -148,7 -147,6 +148,7 @@@ struct x86_init_ops 
   */
  struct x86_cpuinit_ops {
        void (*setup_percpu_clockev)(void);
 +      void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
  };
  
  /**
@@@ -179,6 -177,7 +179,7 @@@ struct x86_msi_ops 
        int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type);
        void (*teardown_msi_irq)(unsigned int irq);
        void (*teardown_msi_irqs)(struct pci_dev *dev);
+       void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
  };
  
  extern struct x86_init_ops x86_init;
@@@ -188,6 -187,5 +189,6 @@@ extern struct x86_msi_ops x86_msi
  
  extern void x86_init_noop(void);
  extern void x86_init_uint_noop(unsigned int unused);
 +extern void x86_default_fixup_cpu_id(struct cpuinfo_x86 *c, int node);
  
  #endif
diff --combined arch/x86/kernel/amd_nb.c
index 013c1810ce72938c3bbe18a57f22664d1732f27b,bae1efe6d515e2c7fc79f1ab10c60a8489afc11f..be16854591cc26a2b0349b6f7d9e0cc446340e32
@@@ -119,18 -119,51 +119,49 @@@ bool __init early_is_amd_nb(u32 device
        return false;
  }
  
+ struct resource *amd_get_mmconfig_range(struct resource *res)
+ {
+       u32 address;
+       u64 base, msr;
+       unsigned segn_busn_bits;
+       if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+               return NULL;
+       /* assume all cpus from fam10h have mmconfig */
+         if (boot_cpu_data.x86 < 0x10)
+               return NULL;
+       address = MSR_FAM10H_MMIO_CONF_BASE;
+       rdmsrl(address, msr);
+       /* mmconfig is not enabled */
+       if (!(msr & FAM10H_MMIO_CONF_ENABLE))
+               return NULL;
+       base = msr & (FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT);
+       segn_busn_bits = (msr >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) &
+                        FAM10H_MMIO_CONF_BUSRANGE_MASK;
+       res->flags = IORESOURCE_MEM;
+       res->start = base;
+       res->end = base + (1ULL<<(segn_busn_bits + 20)) - 1;
+       return res;
+ }
  int amd_get_subcaches(int cpu)
  {
        struct pci_dev *link = node_to_amd_nb(amd_get_nb_id(cpu))->link;
        unsigned int mask;
 -      int cuid = 0;
 +      int cuid;
  
        if (!amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
                return 0;
  
        pci_read_config_dword(link, 0x1d4, &mask);
  
 -#ifdef CONFIG_SMP
        cuid = cpu_data(cpu).compute_unit_id;
 -#endif
        return (mask >> (4 * cuid)) & 0xf;
  }
  
@@@ -139,7 -172,7 +170,7 @@@ int amd_set_subcaches(int cpu, int mask
        static unsigned int reset, ban;
        struct amd_northbridge *nb = node_to_amd_nb(amd_get_nb_id(cpu));
        unsigned int reg;
 -      int cuid = 0;
 +      int cuid;
  
        if (!amd_nb_has_feature(AMD_NB_L3_PARTITIONING) || mask > 0xf)
                return -EINVAL;
                pci_write_config_dword(nb->misc, 0x1b8, reg & ~0x180000);
        }
  
 -#ifdef CONFIG_SMP
        cuid = cpu_data(cpu).compute_unit_id;
 -#endif
        mask <<= 4 * cuid;
        mask |= (0xf ^ (1 << cuid)) << 26;
  
index 91f83e21b989e54147b4e8750a4f2be909a8f78f,83b05adaadf1f73473f89840c63f3fcfe4b2293c..947a06ccc67305d014dd558a68be75f0f8a34c11
@@@ -92,7 -92,6 +92,7 @@@ struct x86_init_ops x86_init __initdat
  
  struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
        .setup_percpu_clockev           = setup_secondary_APIC_clock,
 +      .fixup_cpu_id                   = x86_default_fixup_cpu_id,
  };
  
  static void default_nmi_init(void) { };
@@@ -115,4 -114,5 +115,5 @@@ struct x86_msi_ops x86_msi = 
        .setup_msi_irqs = native_setup_msi_irqs,
        .teardown_msi_irq = native_teardown_msi_irq,
        .teardown_msi_irqs = default_teardown_msi_irqs,
+       .restore_msi_irqs = default_restore_msi_irqs,
  };
diff --combined drivers/pci/ats.c
index 9dd90b30f91a23703c420f5b60cf1fc2d31f55cd,a4a1b369853b7bf5d112fd93fc738d8224b4cbb1..95655d7c0d0b1abdd7e2d4c584af7f0f4217d184
@@@ -128,6 -128,23 +128,23 @@@ void pci_disable_ats(struct pci_dev *de
  }
  EXPORT_SYMBOL_GPL(pci_disable_ats);
  
+ void pci_restore_ats_state(struct pci_dev *dev)
+ {
+       u16 ctrl;
+       if (!pci_ats_enabled(dev))
+               return;
+       if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS))
+               BUG();
+       ctrl = PCI_ATS_CTRL_ENABLE;
+       if (!dev->is_virtfn)
+               ctrl |= PCI_ATS_CTRL_STU(dev->ats->stu - PCI_ATS_MIN_STU);
+       pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl);
+ }
+ EXPORT_SYMBOL_GPL(pci_restore_ats_state);
  /**
   * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
   * @dev: the PCI device
@@@ -179,18 -196,17 +196,18 @@@ int pci_enable_pri(struct pci_dev *pdev
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 -      pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF,  &status);
 -      if ((control & PCI_PRI_ENABLE) || !(status & PCI_PRI_STATUS_STOPPED))
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
 +      pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
 +      if ((control & PCI_PRI_CTRL_ENABLE) ||
 +          !(status & PCI_PRI_STATUS_STOPPED))
                return -EBUSY;
  
 -      pci_read_config_dword(pdev, pos + PCI_PRI_MAX_REQ_OFF, &max_requests);
 +      pci_read_config_dword(pdev, pos + PCI_PRI_MAX_REQ, &max_requests);
        reqs = min(max_requests, reqs);
 -      pci_write_config_dword(pdev, pos + PCI_PRI_ALLOC_REQ_OFF, reqs);
 +      pci_write_config_dword(pdev, pos + PCI_PRI_ALLOC_REQ, reqs);
  
 -      control |= PCI_PRI_ENABLE;
 -      pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control);
 +      control |= PCI_PRI_CTRL_ENABLE;
 +      pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
  
        return 0;
  }
@@@ -211,9 -227,9 +228,9 @@@ void pci_disable_pri(struct pci_dev *pd
        if (!pos)
                return;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 -      control &= ~PCI_PRI_ENABLE;
 -      pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control);
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
 +      control &= ~PCI_PRI_CTRL_ENABLE;
 +      pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
  }
  EXPORT_SYMBOL_GPL(pci_disable_pri);
  
@@@ -232,9 -248,9 +249,9 @@@ bool pci_pri_enabled(struct pci_dev *pd
        if (!pos)
                return false;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
  
 -      return (control & PCI_PRI_ENABLE) ? true : false;
 +      return (control & PCI_PRI_CTRL_ENABLE) ? true : false;
  }
  EXPORT_SYMBOL_GPL(pci_pri_enabled);
  
@@@ -254,13 -270,13 +271,13 @@@ int pci_reset_pri(struct pci_dev *pdev
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 -      if (control & PCI_PRI_ENABLE)
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
 +      if (control & PCI_PRI_CTRL_ENABLE)
                return -EBUSY;
  
 -      control |= PCI_PRI_RESET;
 +      control |= PCI_PRI_CTRL_RESET;
  
 -      pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control);
 +      pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
  
        return 0;
  }
@@@ -287,10 -303,10 +304,10 @@@ bool pci_pri_stopped(struct pci_dev *pd
        if (!pos)
                return true;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 -      pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF,  &status);
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
 +      pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
  
 -      if (control & PCI_PRI_ENABLE)
 +      if (control & PCI_PRI_CTRL_ENABLE)
                return false;
  
        return (status & PCI_PRI_STATUS_STOPPED) ? true : false;
@@@ -316,11 -332,11 +333,11 @@@ int pci_pri_status(struct pci_dev *pdev
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);
 -      pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF,  &status);
 +      pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
 +      pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
  
        /* Stopped bit is undefined when enable == 1, so clear it */
 -      if (control & PCI_PRI_ENABLE)
 +      if (control & PCI_PRI_CTRL_ENABLE)
                status &= ~PCI_PRI_STATUS_STOPPED;
  
        return status;
@@@ -347,21 -363,21 +364,21 @@@ int pci_enable_pasid(struct pci_dev *pd
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, &control);
 -      pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF,     &supported);
 +      pci_read_config_word(pdev, pos + PCI_PASID_CTRL, &control);
 +      pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
  
 -      if (!(supported & PCI_PASID_ENABLE))
 +      if (control & PCI_PASID_CTRL_ENABLE)
                return -EINVAL;
  
 -      supported &= PCI_PASID_EXEC | PCI_PASID_PRIV;
 +      supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;
  
        /* User wants to enable anything unsupported? */
        if ((supported & features) != features)
                return -EINVAL;
  
 -      control = PCI_PASID_ENABLE | features;
 +      control = PCI_PASID_CTRL_ENABLE | features;
  
 -      pci_write_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, control);
 +      pci_write_config_word(pdev, pos + PCI_PASID_CTRL, control);
  
        return 0;
  }
@@@ -381,7 -397,7 +398,7 @@@ void pci_disable_pasid(struct pci_dev *
        if (!pos)
                return;
  
 -      pci_write_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, control);
 +      pci_write_config_word(pdev, pos + PCI_PASID_CTRL, control);
  }
  EXPORT_SYMBOL_GPL(pci_disable_pasid);
  
   * Returns a negative value when no PASI capability is present.
   * Otherwise is returns a bitmask with supported features. Current
   * features reported are:
 - * PCI_PASID_ENABLE - PASID capability can be enabled
 - * PCI_PASID_EXEC - Execute permission supported
 - * PCI_PASID_PRIV - Priviledged mode supported
 + * PCI_PASID_CAP_EXEC - Execute permission supported
 + * PCI_PASID_CAP_PRIV - Priviledged mode supported
   */
  int pci_pasid_features(struct pci_dev *pdev)
  {
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF, &supported);
 +      pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
  
 -      supported &= PCI_PASID_ENABLE | PCI_PASID_EXEC | PCI_PASID_PRIV;
 +      supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;
  
        return supported;
  }
@@@ -430,7 -447,7 +447,7 @@@ int pci_max_pasids(struct pci_dev *pdev
        if (!pos)
                return -EINVAL;
  
 -      pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF, &supported);
 +      pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
  
        supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
  
diff --combined include/linux/pci_regs.h
index 28fe380cb19d59f83f507cfc4e841b7dbf4c288a,9e37250a2a2235dc9c2cc77bb9fcbbe37a9cc2e2..e41a10f5ae83814c602002af8abdf59dba3d2b6c
  #define  PCI_EXP_TYPE_DOWNSTREAM 0x6  /* Downstream Port */
  #define  PCI_EXP_TYPE_PCI_BRIDGE 0x7  /* PCI/PCI-X Bridge */
  #define  PCI_EXP_TYPE_RC_END  0x9     /* Root Complex Integrated Endpoint */
- #define  PCI_EXP_TYPE_RC_EC   0x10    /* Root Complex Event Collector */
+ #define  PCI_EXP_TYPE_RC_EC   0x    /* Root Complex Event Collector */
  #define PCI_EXP_FLAGS_SLOT    0x0100  /* Slot implemented */
  #define PCI_EXP_FLAGS_IRQ     0x3e00  /* Interrupt message number */
  #define PCI_EXP_DEVCAP                4       /* Device capabilities */
  #define  PCI_ATS_MIN_STU      12      /* shift of minimum STU block */
  
  /* Page Request Interface */
 -#define PCI_PRI_CONTROL_OFF   0x04    /* Offset of control register */
 -#define PCI_PRI_STATUS_OFF    0x06    /* Offset of status register */
 -#define PCI_PRI_ENABLE                0x0001  /* Enable mask */
 -#define PCI_PRI_RESET         0x0002  /* Reset bit mask */
 -#define PCI_PRI_STATUS_RF     0x0001  /* Request Failure */
 -#define PCI_PRI_STATUS_UPRGI  0x0002  /* Unexpected PRG index */
 -#define PCI_PRI_STATUS_STOPPED        0x0100  /* PRI Stopped */
 -#define PCI_PRI_MAX_REQ_OFF   0x08    /* Cap offset for max reqs supported */
 -#define PCI_PRI_ALLOC_REQ_OFF 0x0c    /* Cap offset for max reqs allowed */
 +#define PCI_PRI_CTRL          0x04    /* PRI control register */
 +#define  PCI_PRI_CTRL_ENABLE  0x01    /* Enable */
 +#define  PCI_PRI_CTRL_RESET   0x02    /* Reset */
 +#define PCI_PRI_STATUS                0x06    /* PRI status register */
 +#define  PCI_PRI_STATUS_RF    0x001   /* Response Failure */
 +#define  PCI_PRI_STATUS_UPRGI 0x002   /* Unexpected PRG index */
 +#define  PCI_PRI_STATUS_STOPPED       0x100   /* PRI Stopped */
 +#define PCI_PRI_MAX_REQ               0x08    /* PRI max reqs supported */
 +#define PCI_PRI_ALLOC_REQ     0x0c    /* PRI max reqs allowed */
  
  /* PASID capability */
 -#define PCI_PASID_CAP_OFF     0x04    /* PASID feature register */
 -#define PCI_PASID_CONTROL_OFF   0x06    /* PASID control register */
 -#define PCI_PASID_ENABLE      0x01    /* Enable/Supported bit */
 -#define PCI_PASID_EXEC                0x02    /* Exec permissions Enable/Supported */
 -#define PCI_PASID_PRIV                0x04    /* Priviledge Mode Enable/Support */
 +#define PCI_PASID_CAP         0x04    /* PASID feature register */
 +#define  PCI_PASID_CAP_EXEC   0x02    /* Exec permissions Supported */
 +#define  PCI_PASID_CAP_PRIV   0x04    /* Priviledge Mode Supported */
 +#define PCI_PASID_CTRL                0x06    /* PASID control register */
 +#define  PCI_PASID_CTRL_ENABLE        0x01    /* Enable bit */
 +#define  PCI_PASID_CTRL_EXEC  0x02    /* Exec permissions Enable */
 +#define  PCI_PASID_CTRL_PRIV  0x04    /* Priviledge Mode Enable */
  
  /* Single Root I/O Virtualization */
  #define PCI_SRIOV_CAP         0x04    /* SR-IOV Capabilities */
diff --combined lib/devres.c
index 4fbc09e6e9e6f9a83dbdc14ba99bfb1328bef577,2c851bd903bd4fa42a2b6a4c2aca693e47c78d57..9676617b44863fb1b19148abf2964beff1739c13
@@@ -85,57 -85,6 +85,57 @@@ void devm_iounmap(struct device *dev, v
  }
  EXPORT_SYMBOL(devm_iounmap);
  
 +/**
 + * devm_request_and_ioremap() - Check, request region, and ioremap resource
 + * @dev: Generic device to handle the resource for
 + * @res: resource to be handled
 + *
 + * Takes all necessary steps to ioremap a mem resource. Uses managed device, so
 + * everything is undone on driver detach. Checks arguments, so you can feed
 + * it the result from e.g. platform_get_resource() directly. Returns the
 + * remapped pointer or NULL on error. Usage example:
 + *
 + *    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 + *    base = devm_request_and_ioremap(&pdev->dev, res);
 + *    if (!base)
 + *            return -EADDRNOTAVAIL;
 + */
 +void __iomem *devm_request_and_ioremap(struct device *dev,
 +                      struct resource *res)
 +{
 +      resource_size_t size;
 +      const char *name;
 +      void __iomem *dest_ptr;
 +
 +      BUG_ON(!dev);
 +
 +      if (!res || resource_type(res) != IORESOURCE_MEM) {
 +              dev_err(dev, "invalid resource\n");
 +              return NULL;
 +      }
 +
 +      size = resource_size(res);
 +      name = res->name ?: dev_name(dev);
 +
 +      if (!devm_request_mem_region(dev, res->start, size, name)) {
 +              dev_err(dev, "can't request region for resource %pR\n", res);
 +              return NULL;
 +      }
 +
 +      if (res->flags & IORESOURCE_CACHEABLE)
 +              dest_ptr = devm_ioremap(dev, res->start, size);
 +      else
 +              dest_ptr = devm_ioremap_nocache(dev, res->start, size);
 +
 +      if (!dest_ptr) {
 +              dev_err(dev, "ioremap failed for resource %pR\n", res);
 +              devm_release_mem_region(dev, res->start, size);
 +      }
 +
 +      return dest_ptr;
 +}
 +EXPORT_SYMBOL(devm_request_and_ioremap);
 +
  #ifdef CONFIG_HAS_IOPORT
  /*
   * Generic iomap devres
@@@ -304,7 -253,7 +304,7 @@@ EXPORT_SYMBOL(pcim_iounmap)
   *
   * Request and iomap regions specified by @mask.
   */
- int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
+ int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name)
  {
        void __iomem * const *iomap;
        int i, rc;
@@@ -357,7 -306,7 +357,7 @@@ EXPORT_SYMBOL(pcim_iomap_regions)
   *
   * Request all PCI BARs and iomap regions specified by @mask.
   */
- int pcim_iomap_regions_request_all(struct pci_dev *pdev, u16 mask,
+ int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
                                   const char *name)
  {
        int request_mask = ((1 << 6) - 1) & ~mask;
@@@ -381,7 -330,7 +381,7 @@@ EXPORT_SYMBOL(pcim_iomap_regions_reques
   *
   * Unmap and release regions specified by @mask.
   */
- void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask)
+ void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
  {
        void __iomem * const *iomap;
        int i;
        }
  }
  EXPORT_SYMBOL(pcim_iounmap_regions);
 -#endif
 -#endif
 +#endif /* CONFIG_PCI */
 +#endif /* CONFIG_HAS_IOPORT */