Merge tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Dec 2012 20:14:47 +0000 (12:14 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Dec 2012 20:14:47 +0000 (12:14 -0800)
Pull PCI update from Bjorn Helgaas:
 "Host bridge hotplug:
   - Untangle _PRT from struct pci_bus (Bjorn Helgaas)
   - Request _OSC control before scanning root bus (Taku Izumi)
   - Assign resources when adding host bridge (Yinghai Lu)
   - Remove root bus when removing host bridge (Yinghai Lu)
   - Remove _PRT during hot remove (Yinghai Lu)

  SRIOV
    - Add sysfs knobs to control numVFs (Don Dutile)

  Power management
   - Notify devices when power resource turned on (Huang Ying)

  Bug fixes
   - Work around broken _SEG on HP xw9300 (Bjorn Helgaas)
   - Keep runtime PM enabled for unbound PCI devices (Huang Ying)
   - Fix Optimus dual-GPU runtime D3 suspend issue (Dave Airlie)
   - Fix xen frontend shutdown issue (David Vrabel)
   - Work around PLX PCI 9050 BAR alignment erratum (Ian Abbott)

  Miscellaneous
   - Add GPL license for drivers/pci/ioapic (Andrew Cooks)
   - Add standard PCI-X, PCIe ASPM register #defines (Bjorn Helgaas)
   - NumaChip remote PCI support (Daniel Blueman)
   - Fix PCIe Link Capabilities Supported Link Speed definition (Jingoo
     Han)
   - Convert dev_printk() to dev_info(), etc (Joe Perches)
   - Add support for non PCI BAR ROM data (Matthew Garrett)
   - Add x86 support for host bridge translation offset (Mike Yoknis)
   - Report success only when every driver supports AER (Vijay
     Pandarathil)"

Fix up trivial conflicts.

* tag 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (48 commits)
  PCI: Use phys_addr_t for physical ROM address
  x86/PCI: Add NumaChip remote PCI support
  ath9k: Use standard #defines for PCIe Capability ASPM fields
  iwlwifi: Use standard #defines for PCIe Capability ASPM fields
  iwlwifi: collapse wrapper for pcie_capability_read_word()
  iwlegacy: Use standard #defines for PCIe Capability ASPM fields
  iwlegacy: collapse wrapper for pcie_capability_read_word()
  cxgb3: Use standard #defines for PCIe Capability ASPM fields
  PCI: Add standard PCIe Capability Link ASPM field names
  PCI/portdrv: Use PCI Express Capability accessors
  PCI: Use standard PCIe Capability Link register field names
  x86: Use PCI setup data
  PCI: Add support for non-BAR ROMs
  PCI: Add pcibios_add_device
  EFI: Stash ROMs if they're not in the PCI BAR
  PCI: Add and use standard PCI-X Capability register names
  PCI/PM: Keep runtime PM enabled for unbound PCI devices
  xen-pcifront: Handle backend CLOSED without CLOSING
  PCI: SRIOV control and status via sysfs (documentation)
  PCI/AER: Report success only when every device has AER-aware driver
  ...

17 files changed:
1  2 
arch/x86/Kconfig
arch/x86/boot/compressed/eboot.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_root.c
drivers/net/wireless/ath/ath9k/pci.c
drivers/net/wireless/iwlegacy/common.h
drivers/net/wireless/iwlwifi/pcie/trans.c
drivers/pci/ioapic.c
drivers/pci/pci-driver.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/probe.c
drivers/pci/quirks.c
drivers/pci/xen-pcifront.c
include/linux/efi.h
include/linux/pci.h

diff --combined arch/x86/Kconfig
@@@ -69,8 -69,8 +69,8 @@@ config X8
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_DEBUG_KMEMLEAK
        select ANON_INODES
 -      select HAVE_ALIGNED_STRUCT_PAGE if SLUB && !M386
 -      select HAVE_CMPXCHG_LOCAL if !M386
 +      select HAVE_ALIGNED_STRUCT_PAGE if SLUB
 +      select HAVE_CMPXCHG_LOCAL
        select HAVE_CMPXCHG_DOUBLE
        select HAVE_ARCH_KMEMCHECK
        select HAVE_USER_RETURN_NOTIFIER
        select KTIME_SCALAR if X86_32
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
 -      select HAVE_RCU_USER_QS if X86_64
 +      select HAVE_CONTEXT_TRACKING if X86_64
        select HAVE_IRQ_TIME_ACCOUNTING
        select GENERIC_KERNEL_THREAD
        select GENERIC_KERNEL_EXECVE
        select MODULES_USE_ELF_REL if X86_32
        select MODULES_USE_ELF_RELA if X86_64
 +      select CLONE_BACKWARDS if X86_32
  
  config INSTRUCTION_DECODER
        def_bool y
@@@ -172,8 -171,13 +172,8 @@@ config ARCH_MAY_HAVE_PC_FD
        def_bool y
        depends on ISA_DMA_API
  
 -config RWSEM_GENERIC_SPINLOCK
 -      def_bool y
 -      depends on !X86_XADD
 -
  config RWSEM_XCHGADD_ALGORITHM
        def_bool y
 -      depends on X86_XADD
  
  config GENERIC_CALIBRATE_DELAY
        def_bool y
@@@ -306,7 -310,7 +306,7 @@@ config X86_X2API
          If you don't know what to do here, say N.
  
  config X86_MPPARSE
 -      bool "Enable MPS table" if ACPI
 +      bool "Enable MPS table" if ACPI || SFI
        default y
        depends on X86_LOCAL_APIC
        ---help---
@@@ -370,6 -374,7 +370,7 @@@ config X86_NUMACHI
        depends on NUMA
        depends on SMP
        depends on X86_X2APIC
+       depends on PCI_MMCONFIG
        ---help---
          Adds support for Numascale NumaChip large-SMP systems. Needed to
          enable more than ~168 cores.
@@@ -1096,7 -1101,7 +1097,7 @@@ config HIGHMEM4
  
  config HIGHMEM64G
        bool "64GB"
 -      depends on !M386 && !M486
 +      depends on !M486
        select X86_PAE
        ---help---
          Select this if you have a 32-bit processor and more than 4
@@@ -1694,50 -1699,6 +1695,50 @@@ config HOTPLUG_CP
            automatically on SMP systems. )
          Say N if you want to disable CPU hotplug.
  
 +config BOOTPARAM_HOTPLUG_CPU0
 +      bool "Set default setting of cpu0_hotpluggable"
 +      default n
 +      depends on HOTPLUG_CPU && EXPERIMENTAL
 +      ---help---
 +        Set whether default state of cpu0_hotpluggable is on or off.
 +
 +        Say Y here to enable CPU0 hotplug by default. If this switch
 +        is turned on, there is no need to give cpu0_hotplug kernel
 +        parameter and the CPU0 hotplug feature is enabled by default.
 +
 +        Please note: there are two known CPU0 dependencies if you want
 +        to enable the CPU0 hotplug feature either by this switch or by
 +        cpu0_hotplug kernel parameter.
 +
 +        First, resume from hibernate or suspend always starts from CPU0.
 +        So hibernate and suspend are prevented if CPU0 is offline.
 +
 +        Second dependency is PIC interrupts always go to CPU0. CPU0 can not
 +        offline if any interrupt can not migrate out of CPU0. There may
 +        be other CPU0 dependencies.
 +
 +        Please make sure the dependencies are under your control before
 +        you enable this feature.
 +
 +        Say N if you don't want to enable CPU0 hotplug feature by default.
 +        You still can enable the CPU0 hotplug feature at boot by kernel
 +        parameter cpu0_hotplug.
 +
 +config DEBUG_HOTPLUG_CPU0
 +      def_bool n
 +      prompt "Debug CPU0 hotplug"
 +      depends on HOTPLUG_CPU && EXPERIMENTAL
 +      ---help---
 +        Enabling this option offlines CPU0 (if CPU0 can be offlined) as
 +        soon as possible and boots up userspace with CPU0 offlined. User
 +        can online CPU0 back after boot time.
 +
 +        To debug CPU0 hotplug, you need to enable CPU0 offline/online
 +        feature by either turning on CONFIG_BOOTPARAM_HOTPLUG_CPU0 during
 +        compilation or giving cpu0_hotplug kernel parameter at boot.
 +
 +        If unsure, say N.
 +
  config COMPAT_VDSO
        def_bool y
        prompt "Compat VDSO support"
@@@ -8,12 -8,11 +8,13 @@@
   * ----------------------------------------------------------------------- */
  
  #include <linux/efi.h>
+ #include <linux/pci.h>
  #include <asm/efi.h>
  #include <asm/setup.h>
  #include <asm/desc.h>
  
 +#undef memcpy                 /* Use memcpy from misc.c */
 +
  #include "eboot.h"
  
  static efi_system_table_t *sys_table;
@@@ -245,6 -244,121 +246,121 @@@ static void find_bits(unsigned long mas
        *size = len;
  }
  
+ static efi_status_t setup_efi_pci(struct boot_params *params)
+ {
+       efi_pci_io_protocol *pci;
+       efi_status_t status;
+       void **pci_handle;
+       efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
+       unsigned long nr_pci, size = 0;
+       int i;
+       struct setup_data *data;
+       data = (struct setup_data *)params->hdr.setup_data;
+       while (data && data->next)
+               data = (struct setup_data *)data->next;
+       status = efi_call_phys5(sys_table->boottime->locate_handle,
+                               EFI_LOCATE_BY_PROTOCOL, &pci_proto,
+                               NULL, &size, pci_handle);
+       if (status == EFI_BUFFER_TOO_SMALL) {
+               status = efi_call_phys3(sys_table->boottime->allocate_pool,
+                                       EFI_LOADER_DATA, size, &pci_handle);
+               if (status != EFI_SUCCESS)
+                       return status;
+               status = efi_call_phys5(sys_table->boottime->locate_handle,
+                                       EFI_LOCATE_BY_PROTOCOL, &pci_proto,
+                                       NULL, &size, pci_handle);
+       }
+       if (status != EFI_SUCCESS)
+               goto free_handle;
+       nr_pci = size / sizeof(void *);
+       for (i = 0; i < nr_pci; i++) {
+               void *h = pci_handle[i];
+               uint64_t attributes;
+               struct pci_setup_rom *rom;
+               status = efi_call_phys3(sys_table->boottime->handle_protocol,
+                                       h, &pci_proto, &pci);
+               if (status != EFI_SUCCESS)
+                       continue;
+               if (!pci)
+                       continue;
+               status = efi_call_phys4(pci->attributes, pci,
+                                       EfiPciIoAttributeOperationGet, 0,
+                                       &attributes);
+               if (status != EFI_SUCCESS)
+                       continue;
+               if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM)
+                       continue;
+               if (!pci->romimage || !pci->romsize)
+                       continue;
+               size = pci->romsize + sizeof(*rom);
+               status = efi_call_phys3(sys_table->boottime->allocate_pool,
+                               EFI_LOADER_DATA, size, &rom);
+               if (status != EFI_SUCCESS)
+                       continue;
+               rom->data.type = SETUP_PCI;
+               rom->data.len = size - sizeof(struct setup_data);
+               rom->data.next = 0;
+               rom->pcilen = pci->romsize;
+               status = efi_call_phys5(pci->pci.read, pci,
+                                       EfiPciIoWidthUint16, PCI_VENDOR_ID,
+                                       1, &(rom->vendor));
+               if (status != EFI_SUCCESS)
+                       goto free_struct;
+               status = efi_call_phys5(pci->pci.read, pci,
+                                       EfiPciIoWidthUint16, PCI_DEVICE_ID,
+                                       1, &(rom->devid));
+               if (status != EFI_SUCCESS)
+                       goto free_struct;
+               status = efi_call_phys5(pci->get_location, pci,
+                                       &(rom->segment), &(rom->bus),
+                                       &(rom->device), &(rom->function));
+               if (status != EFI_SUCCESS)
+                       goto free_struct;
+               memcpy(rom->romdata, pci->romimage, pci->romsize);
+               if (data)
+                       data->next = (uint64_t)rom;
+               else
+                       params->hdr.setup_data = (uint64_t)rom;
+               data = (struct setup_data *)rom;
+               continue;
+       free_struct:
+               efi_call_phys1(sys_table->boottime->free_pool, rom);
+       }
+ free_handle:
+       efi_call_phys1(sys_table->boottime->free_pool, pci_handle);
+       return status;
+ }
  /*
   * See if we have Graphics Output Protocol
   */
@@@ -1028,6 -1142,8 +1144,8 @@@ struct boot_params *efi_main(void *hand
  
        setup_graphics(boot_params);
  
+       setup_efi_pci(boot_params);
        status = efi_call_phys3(sys_table->boottime->allocate_pool,
                                EFI_LOADER_DATA, sizeof(*gdt),
                                (void **)&gdt);
diff --combined drivers/acpi/pci_irq.c
@@@ -184,7 -184,7 +184,7 @@@ static void do_prt_fixups(struct acpi_p
        }
  }
  
- static int acpi_pci_irq_add_entry(acpi_handle handle, struct pci_bus *bus,
+ static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
                                  struct acpi_pci_routing_table *prt)
  {
        struct acpi_prt_entry *entry;
         * 1=INTA, 2=INTB.  We use the PCI encoding throughout, so convert
         * it here.
         */
-       entry->id.segment = pci_domain_nr(bus);
-       entry->id.bus = bus->number;
+       entry->id.segment = segment;
+       entry->id.bus = bus;
        entry->id.device = (prt->address >> 16) & 0xFFFF;
        entry->pin = prt->pin + 1;
  
        return 0;
  }
  
- int acpi_pci_irq_add_prt(acpi_handle handle, struct pci_bus *bus)
+ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
  {
        acpi_status status;
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
  
        entry = buffer.pointer;
        while (entry && (entry->length > 0)) {
-               acpi_pci_irq_add_entry(handle, bus, entry);
+               acpi_pci_irq_add_entry(handle, segment, bus, entry);
                entry = (struct acpi_pci_routing_table *)
                    ((unsigned long)entry + entry->length);
        }
        return 0;
  }
  
- void acpi_pci_irq_del_prt(struct pci_bus *bus)
+ void acpi_pci_irq_del_prt(int segment, int bus)
  {
        struct acpi_prt_entry *entry, *tmp;
  
        printk(KERN_DEBUG
               "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
-              pci_domain_nr(bus), bus->number);
+              segment, bus);
        spin_lock(&acpi_prt_lock);
        list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
-               if (pci_domain_nr(bus) == entry->id.segment
-                       && bus->number == entry->id.bus) {
+               if (segment == entry->id.segment && bus == entry->id.bus) {
                        list_del(&entry->list);
                        kfree(entry);
                }
@@@ -459,19 -458,19 +458,19 @@@ int acpi_pci_irq_enable(struct pci_dev 
         */
        if (gsi < 0) {
                u32 dev_gsi;
 -              dev_warn(&dev->dev, "PCI INT %c: no GSI", pin_name(pin));
                /* Interrupt Line values above 0xF are forbidden */
                if (dev->irq > 0 && (dev->irq <= 0xF) &&
                    (acpi_isa_irq_to_gsi(dev->irq, &dev_gsi) == 0)) {
 -                      printk(" - using ISA IRQ %d\n", dev->irq);
 +                      dev_warn(&dev->dev, "PCI INT %c: no GSI - using ISA IRQ %d\n",
 +                               pin_name(pin), dev->irq);
                        acpi_register_gsi(&dev->dev, dev_gsi,
                                          ACPI_LEVEL_SENSITIVE,
                                          ACPI_ACTIVE_LOW);
 -                      return 0;
                } else {
 -                      printk("\n");
 -                      return 0;
 +                      dev_warn(&dev->dev, "PCI INT %c: no GSI\n",
 +                               pin_name(pin));
                }
 +              return 0;
        }
  
        rc = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
        return 0;
  }
  
 -/* FIXME: implement x86/x86_64 version */
 -void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
 -{
 -}
 -
  void acpi_pci_irq_disable(struct pci_dev *dev)
  {
        struct acpi_prt_entry *entry;
diff --combined drivers/acpi/pci_root.c
@@@ -445,7 -445,7 +445,7 @@@ out
  }
  EXPORT_SYMBOL(acpi_pci_osc_control_set);
  
 -static int __devinit acpi_pci_root_add(struct acpi_device *device)
 +static int acpi_pci_root_add(struct acpi_device *device)
  {
        unsigned long long segment, bus;
        acpi_status status;
        acpi_handle handle;
        struct acpi_device *child;
        u32 flags, base_flags;
+       bool is_osc_granted = false;
  
        root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
        if (!root)
        strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
        device->driver_data = root;
  
-       root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
-       /*
-        * All supported architectures that use ACPI have support for
-        * PCI domains, so we indicate this in _OSC support capabilities.
-        */
-       flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
-       acpi_pci_osc_support(root, flags);
-       /*
-        * TBD: Need PCI interface for enumeration/configuration of roots.
-        */
-       mutex_lock(&acpi_pci_root_lock);
-       list_add_tail(&root->node, &acpi_pci_roots);
-       mutex_unlock(&acpi_pci_root_lock);
        printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n",
               acpi_device_name(device), acpi_device_bid(device),
               root->segment, &root->secondary);
  
-       /*
-        * Scan the Root Bridge
-        * --------------------
-        * Must do this prior to any attempt to bind the root device, as the
-        * PCI namespace does not get created until this call is made (and 
-        * thus the root bridge's pci_dev does not exist).
-        */
-       root->bus = pci_acpi_scan_root(root);
-       if (!root->bus) {
-               printk(KERN_ERR PREFIX
-                           "Bus %04x:%02x not present in PCI namespace\n",
-                           root->segment, (unsigned int)root->secondary.start);
-               result = -ENODEV;
-               goto out_del_root;
-       }
-       /*
-        * Attach ACPI-PCI Context
-        * -----------------------
-        * Thus binding the ACPI and PCI devices.
-        */
-       result = acpi_pci_bind_root(device);
-       if (result)
-               goto out_del_root;
        /*
         * PCI Routing Table
         * -----------------
         */
        status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
        if (ACPI_SUCCESS(status))
-               result = acpi_pci_irq_add_prt(device->handle, root->bus);
+               result = acpi_pci_irq_add_prt(device->handle, root->segment,
+                                             root->secondary.start);
+       root->mcfg_addr = acpi_pci_root_get_mcfg_addr(device->handle);
  
        /*
-        * Scan and bind all _ADR-Based Devices
+        * All supported architectures that use ACPI have support for
+        * PCI domains, so we indicate this in _OSC support capabilities.
         */
-       list_for_each_entry(child, &device->children, node)
-               acpi_pci_bridge_scan(child);
+       flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
+       acpi_pci_osc_support(root, flags);
  
        /* Indicate support for various _OSC capabilities. */
-       if (pci_ext_cfg_avail(root->bus->self))
+       if (pci_ext_cfg_avail())
                flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
-       if (pcie_aspm_support_enabled())
+       if (pcie_aspm_support_enabled()) {
                flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
-                       OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
+               OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
+       }
        if (pci_msi_enabled())
                flags |= OSC_MSI_SUPPORT;
        if (flags != base_flags) {
                status = acpi_pci_osc_support(root, flags);
                if (ACPI_FAILURE(status)) {
-                       dev_info(root->bus->bridge, "ACPI _OSC support "
+                       dev_info(&device->dev, "ACPI _OSC support "
                                "notification failed, disabling PCIe ASPM\n");
                        pcie_no_aspm();
                        flags = base_flags;
                }
        }
        if (!pcie_ports_disabled
            && (flags & ACPI_PCIE_REQ_SUPPORT) == ACPI_PCIE_REQ_SUPPORT) {
                flags = OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL
  
                if (pci_aer_available()) {
                        if (aer_acpi_firmware_first())
-                               dev_dbg(root->bus->bridge,
+                               dev_dbg(&device->dev,
                                        "PCIe errors handled by BIOS.\n");
                        else
                                flags |= OSC_PCI_EXPRESS_AER_CONTROL;
                }
  
-               dev_info(root->bus->bridge,
+               dev_info(&device->dev,
                        "Requesting ACPI _OSC control (0x%02x)\n", flags);
  
                status = acpi_pci_osc_control_set(device->handle, &flags,
-                                       OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
+                                      OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
                if (ACPI_SUCCESS(status)) {
-                       dev_info(root->bus->bridge,
+                       is_osc_granted = true;
+                       dev_info(&device->dev,
                                "ACPI _OSC control (0x%02x) granted\n", flags);
-                       if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
-                               /*
-                                * We have ASPM control, but the FADT indicates
-                                * that it's unsupported. Clear it.
-                                */
-                               pcie_clear_aspm(root->bus);
-                       }
                } else {
-                       dev_info(root->bus->bridge,
+                       is_osc_granted = false;
+                       dev_info(&device->dev,
                                "ACPI _OSC request failed (%s), "
                                "returned control mask: 0x%02x\n",
                                acpi_format_exception(status), flags);
-                       pr_info("ACPI _OSC control for PCIe not granted, "
-                               "disabling ASPM\n");
-                       pcie_no_aspm();
                }
        } else {
-               dev_info(root->bus->bridge,
-                        "Unable to request _OSC control "
-                        "(_OSC support mask: 0x%02x)\n", flags);
+               dev_info(&device->dev,
+                       "Unable to request _OSC control "
+                       "(_OSC support mask: 0x%02x)\n", flags);
+       }
+       /*
+        * TBD: Need PCI interface for enumeration/configuration of roots.
+        */
+       mutex_lock(&acpi_pci_root_lock);
+       list_add_tail(&root->node, &acpi_pci_roots);
+       mutex_unlock(&acpi_pci_root_lock);
+       /*
+        * Scan the Root Bridge
+        * --------------------
+        * Must do this prior to any attempt to bind the root device, as the
+        * PCI namespace does not get created until this call is made (and 
+        * thus the root bridge's pci_dev does not exist).
+        */
+       root->bus = pci_acpi_scan_root(root);
+       if (!root->bus) {
+               printk(KERN_ERR PREFIX
+                           "Bus %04x:%02x not present in PCI namespace\n",
+                           root->segment, (unsigned int)root->secondary.start);
+               result = -ENODEV;
+               goto out_del_root;
+       }
+       /*
+        * Attach ACPI-PCI Context
+        * -----------------------
+        * Thus binding the ACPI and PCI devices.
+        */
+       result = acpi_pci_bind_root(device);
+       if (result)
+               goto out_del_root;
+       /*
+        * Scan and bind all _ADR-Based Devices
+        */
+       list_for_each_entry(child, &device->children, node)
+               acpi_pci_bridge_scan(child);
+       /* ASPM setting */
+       if (is_osc_granted) {
+               if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
+                       pcie_clear_aspm(root->bus);
+       } else {
+               pr_info("ACPI _OSC control for PCIe not granted, "
+                       "disabling ASPM\n");
+               pcie_no_aspm();
        }
  
        pci_acpi_add_bus_pm_notifier(device, root->bus);
@@@ -634,6 -638,8 +638,8 @@@ out_del_root
        mutex_lock(&acpi_pci_root_lock);
        list_del(&root->node);
        mutex_unlock(&acpi_pci_root_lock);
+       acpi_pci_irq_del_prt(root->segment, root->secondary.start);
  end:
        kfree(root);
        return result;
@@@ -644,12 -650,19 +650,19 @@@ static int acpi_pci_root_start(struct a
        struct acpi_pci_root *root = acpi_driver_data(device);
        struct acpi_pci_driver *driver;
  
+       if (system_state != SYSTEM_BOOTING)
+               pci_assign_unassigned_bus_resources(root->bus);
        mutex_lock(&acpi_pci_root_lock);
        list_for_each_entry(driver, &acpi_pci_drivers, node)
                if (driver->add)
                        driver->add(root);
        mutex_unlock(&acpi_pci_root_lock);
  
+       /* need to after hot-added ioapic is registered */
+       if (system_state != SYSTEM_BOOTING)
+               pci_enable_bridges(root->bus);
        pci_bus_add_devices(root->bus);
  
        return 0;
  
  static int acpi_pci_root_remove(struct acpi_device *device, int type)
  {
+       acpi_status status;
+       acpi_handle handle;
        struct acpi_pci_root *root = acpi_driver_data(device);
        struct acpi_pci_driver *driver;
  
+       pci_stop_root_bus(root->bus);
        mutex_lock(&acpi_pci_root_lock);
-       list_for_each_entry(driver, &acpi_pci_drivers, node)
+       list_for_each_entry_reverse(driver, &acpi_pci_drivers, node)
                if (driver->remove)
                        driver->remove(root);
+       mutex_unlock(&acpi_pci_root_lock);
  
        device_set_run_wake(root->bus->bridge, false);
        pci_acpi_remove_bus_pm_notifier(device);
  
+       status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
+       if (ACPI_SUCCESS(status))
+               acpi_pci_irq_del_prt(root->segment, root->secondary.start);
+       pci_remove_root_bus(root->bus);
+       mutex_lock(&acpi_pci_root_lock);
        list_del(&root->node);
        mutex_unlock(&acpi_pci_root_lock);
        kfree(root);
@@@ -96,6 -96,17 +96,6 @@@ static bool ath_pci_eeprom_read(struct 
        return true;
  }
  
 -static void ath_pci_extn_synch_enable(struct ath_common *common)
 -{
 -      struct ath_softc *sc = (struct ath_softc *) common->priv;
 -      struct pci_dev *pdev = to_pci_dev(sc->dev);
 -      u8 lnkctl;
 -
 -      pci_read_config_byte(pdev, sc->sc_ah->caps.pcie_lcr_offset, &lnkctl);
 -      lnkctl |= PCI_EXP_LNKCTL_ES;
 -      pci_write_config_byte(pdev, sc->sc_ah->caps.pcie_lcr_offset, lnkctl);
 -}
 -
  /* Need to be called after we discover btcoex capabilities */
  static void ath_pci_aspm_init(struct ath_common *common)
  {
  
        if ((ath9k_hw_get_btcoex_scheme(ah) != ATH_BTCOEX_CFG_NONE) &&
            (AR_SREV_9285(ah))) {
-               /* Bluetooth coexistance requires disabling ASPM. */
+               /* Bluetooth coexistence requires disabling ASPM. */
                pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL,
-                       PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
+                       PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
  
                /*
                 * Both upstream and downstream PCIe components should
                 * have the same ASPM settings.
                 */
                pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
-                       PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
+                       PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1);
  
                ath_info(common, "Disabling ASPM since BTCOEX is enabled\n");
                return;
        }
  
        pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &aspm);
-       if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) {
+       if (aspm & (PCI_EXP_LNKCTL_ASPM_L0S | PCI_EXP_LNKCTL_ASPM_L1)) {
                ah->aspm_enabled = true;
                /* Initialize PCIe PM and SERDES registers. */
                ath9k_hw_configpcipowersave(ah, false);
@@@ -142,6 -153,7 +142,6 @@@ static const struct ath_bus_ops ath_pci
        .ath_bus_type = ATH_PCI,
        .read_cachesize = ath_pci_read_cachesize,
        .eeprom_read = ath_pci_eeprom_read,
 -      .extn_synch_en = ath_pci_extn_synch_enable,
        .aspm_init = ath_pci_aspm_init,
  };
  
@@@ -287,7 -299,7 +287,7 @@@ static void ath_pci_remove(struct pci_d
        pci_release_region(pdev, 0);
  }
  
 -#ifdef CONFIG_PM
 +#ifdef CONFIG_PM_SLEEP
  
  static int ath_pci_suspend(struct device *device)
  {
@@@ -333,15 -345,22 +333,15 @@@ static int ath_pci_resume(struct devic
        return 0;
  }
  
 -static const struct dev_pm_ops ath9k_pm_ops = {
 -      .suspend = ath_pci_suspend,
 -      .resume = ath_pci_resume,
 -      .freeze = ath_pci_suspend,
 -      .thaw = ath_pci_resume,
 -      .poweroff = ath_pci_suspend,
 -      .restore = ath_pci_resume,
 -};
 +static SIMPLE_DEV_PM_OPS(ath9k_pm_ops, ath_pci_suspend, ath_pci_resume);
  
  #define ATH9K_PM_OPS  (&ath9k_pm_ops)
  
 -#else /* !CONFIG_PM */
 +#else /* !CONFIG_PM_SLEEP */
  
  #define ATH9K_PM_OPS  NULL
  
 -#endif /* !CONFIG_PM */
 +#endif /* !CONFIG_PM_SLEEP */
  
  
  MODULE_DEVICE_TABLE(pci, ath_pci_id_table);
@@@ -1829,14 -1829,6 +1829,6 @@@ int il_enqueue_hcmd(struct il_priv *il
   * PCI                                                     *
   *****************************************************/
  
- static inline u16
- il_pcie_link_ctl(struct il_priv *il)
- {
-       u16 pci_lnk_ctl;
-       pcie_capability_read_word(il->pci_dev, PCI_EXP_LNKCTL, &pci_lnk_ctl);
-       return pci_lnk_ctl;
- }
  void il_bg_watchdog(unsigned long data);
  u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval);
  __le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon,
@@@ -2434,10 -2426,6 +2426,6 @@@ struct il_tfd 
  /* PCI registers */
  #define PCI_CFG_RETRY_TIMEOUT 0x041
  
- /* PCI register values */
- #define PCI_CFG_LINK_CTRL_VAL_L0S_EN  0x01
- #define PCI_CFG_LINK_CTRL_VAL_L1_EN   0x02
  struct il_rate_info {
        u8 plcp;                /* uCode API:  RATE_6M_PLCP, etc. */
        u8 plcp_siso;           /* uCode API:  RATE_SISO_6M_PLCP, etc. */
@@@ -2919,8 -2907,9 +2907,8 @@@ do {                                                                    
  #define IL_DBG(level, fmt, args...)                                   \
  do {                                                                  \
        if (il_get_debug_level(il) & level)                             \
 -              dev_printk(KERN_ERR, &il->hw->wiphy->dev,               \
 -                       "%c %s " fmt, in_interrupt() ? 'I' : 'U',      \
 -                      __func__ , ## args);                            \
 +              dev_err(&il->hw->wiphy->dev, "%c %s " fmt,              \
 +                      in_interrupt() ? 'I' : 'U', __func__ , ##args); \
  } while (0)
  
  #define il_print_hex_dump(il, level, p, len)                          \
  #include "iwl-prph.h"
  #include "iwl-agn-hw.h"
  #include "internal.h"
 -/* FIXME: need to abstract out TX command (once we know what it looks like) */
 -#include "dvm/commands.h"
  
 -#define SCD_QUEUECHAIN_SEL_ALL(trans, trans_pcie)     \
 -      (((1<<trans->cfg->base_params->num_of_queues) - 1) &\
 -      (~(1<<(trans_pcie)->cmd_queue)))
 -
 -static int iwl_trans_rx_alloc(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_rx_queue *rxq = &trans_pcie->rxq;
 -      struct device *dev = trans->dev;
 -
 -      memset(&trans_pcie->rxq, 0, sizeof(trans_pcie->rxq));
 -
 -      spin_lock_init(&rxq->lock);
 -
 -      if (WARN_ON(rxq->bd || rxq->rb_stts))
 -              return -EINVAL;
 -
 -      /* Allocate the circular buffer of Read Buffer Descriptors (RBDs) */
 -      rxq->bd = dma_zalloc_coherent(dev, sizeof(__le32) * RX_QUEUE_SIZE,
 -                                    &rxq->bd_dma, GFP_KERNEL);
 -      if (!rxq->bd)
 -              goto err_bd;
 -
 -      /*Allocate the driver's pointer to receive buffer status */
 -      rxq->rb_stts = dma_zalloc_coherent(dev, sizeof(*rxq->rb_stts),
 -                                         &rxq->rb_stts_dma, GFP_KERNEL);
 -      if (!rxq->rb_stts)
 -              goto err_rb_stts;
 -
 -      return 0;
 -
 -err_rb_stts:
 -      dma_free_coherent(dev, sizeof(__le32) * RX_QUEUE_SIZE,
 -                        rxq->bd, rxq->bd_dma);
 -      memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma));
 -      rxq->bd = NULL;
 -err_bd:
 -      return -ENOMEM;
 -}
 -
 -static void iwl_trans_rxq_free_rx_bufs(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_rx_queue *rxq = &trans_pcie->rxq;
 -      int i;
 -
 -      /* Fill the rx_used queue with _all_ of the Rx buffers */
 -      for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) {
 -              /* In the reset function, these buffers may have been allocated
 -               * to an SKB, so we need to unmap and free potential storage */
 -              if (rxq->pool[i].page != NULL) {
 -                      dma_unmap_page(trans->dev, rxq->pool[i].page_dma,
 -                                     PAGE_SIZE << trans_pcie->rx_page_order,
 -                                     DMA_FROM_DEVICE);
 -                      __free_pages(rxq->pool[i].page,
 -                                   trans_pcie->rx_page_order);
 -                      rxq->pool[i].page = NULL;
 -              }
 -              list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
 -      }
 -}
 -
 -static void iwl_trans_rx_hw_init(struct iwl_trans *trans,
 -                               struct iwl_rx_queue *rxq)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      u32 rb_size;
 -      const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */
 -      u32 rb_timeout = RX_RB_TIMEOUT; /* FIXME: RX_RB_TIMEOUT for all devices? */
 -
 -      if (trans_pcie->rx_buf_size_8k)
 -              rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K;
 -      else
 -              rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K;
 -
 -      /* Stop Rx DMA */
 -      iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
 -
 -      /* Reset driver's Rx queue write index */
 -      iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0);
 -
 -      /* Tell device where to find RBD circular buffer in DRAM */
 -      iwl_write_direct32(trans, FH_RSCSR_CHNL0_RBDCB_BASE_REG,
 -                         (u32)(rxq->bd_dma >> 8));
 -
 -      /* Tell device where in DRAM to update its Rx status */
 -      iwl_write_direct32(trans, FH_RSCSR_CHNL0_STTS_WPTR_REG,
 -                         rxq->rb_stts_dma >> 4);
 -
 -      /* Enable Rx DMA
 -       * FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in
 -       *      the credit mechanism in 5000 HW RX FIFO
 -       * Direct rx interrupts to hosts
 -       * Rx buffer size 4 or 8k
 -       * RB timeout 0x10
 -       * 256 RBDs
 -       */
 -      iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG,
 -                         FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL |
 -                         FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY |
 -                         FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL |
 -                         rb_size|
 -                         (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)|
 -                         (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS));
 -
 -      /* Set interrupt coalescing timer to default (2048 usecs) */
 -      iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
 -}
 -
 -static int iwl_rx_init(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_rx_queue *rxq = &trans_pcie->rxq;
 -
 -      int i, err;
 -      unsigned long flags;
 -
 -      if (!rxq->bd) {
 -              err = iwl_trans_rx_alloc(trans);
 -              if (err)
 -                      return err;
 -      }
 -
 -      spin_lock_irqsave(&rxq->lock, flags);
 -      INIT_LIST_HEAD(&rxq->rx_free);
 -      INIT_LIST_HEAD(&rxq->rx_used);
 -
 -      iwl_trans_rxq_free_rx_bufs(trans);
 -
 -      for (i = 0; i < RX_QUEUE_SIZE; i++)
 -              rxq->queue[i] = NULL;
 -
 -      /* Set us so that we have processed and used all buffers, but have
 -       * not restocked the Rx queue with fresh buffers */
 -      rxq->read = rxq->write = 0;
 -      rxq->write_actual = 0;
 -      rxq->free_count = 0;
 -      spin_unlock_irqrestore(&rxq->lock, flags);
 -
 -      iwl_rx_replenish(trans);
 -
 -      iwl_trans_rx_hw_init(trans, rxq);
 -
 -      spin_lock_irqsave(&trans_pcie->irq_lock, flags);
 -      rxq->need_update = 1;
 -      iwl_rx_queue_update_write_ptr(trans, rxq);
 -      spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
 -
 -      return 0;
 -}
 -
 -static void iwl_trans_pcie_rx_free(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_rx_queue *rxq = &trans_pcie->rxq;
 -      unsigned long flags;
 -
 -      /*if rxq->bd is NULL, it means that nothing has been allocated,
 -       * exit now */
 -      if (!rxq->bd) {
 -              IWL_DEBUG_INFO(trans, "Free NULL rx context\n");
 -              return;
 -      }
 -
 -      spin_lock_irqsave(&rxq->lock, flags);
 -      iwl_trans_rxq_free_rx_bufs(trans);
 -      spin_unlock_irqrestore(&rxq->lock, flags);
 -
 -      dma_free_coherent(trans->dev, sizeof(__le32) * RX_QUEUE_SIZE,
 -                        rxq->bd, rxq->bd_dma);
 -      memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma));
 -      rxq->bd = NULL;
 -
 -      if (rxq->rb_stts)
 -              dma_free_coherent(trans->dev,
 -                                sizeof(struct iwl_rb_status),
 -                                rxq->rb_stts, rxq->rb_stts_dma);
 -      else
 -              IWL_DEBUG_INFO(trans, "Free rxq->rb_stts which is NULL\n");
 -      memset(&rxq->rb_stts_dma, 0, sizeof(rxq->rb_stts_dma));
 -      rxq->rb_stts = NULL;
 -}
 -
 -static int iwl_trans_rx_stop(struct iwl_trans *trans)
 -{
 -
 -      /* stop Rx DMA */
 -      iwl_write_direct32(trans, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0);
 -      return iwl_poll_direct_bit(trans, FH_MEM_RSSR_RX_STATUS_REG,
 -                                 FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000);
 -}
 -
 -static int iwlagn_alloc_dma_ptr(struct iwl_trans *trans,
 -                              struct iwl_dma_ptr *ptr, size_t size)
 -{
 -      if (WARN_ON(ptr->addr))
 -              return -EINVAL;
 -
 -      ptr->addr = dma_alloc_coherent(trans->dev, size,
 -                                     &ptr->dma, GFP_KERNEL);
 -      if (!ptr->addr)
 -              return -ENOMEM;
 -      ptr->size = size;
 -      return 0;
 -}
 -
 -static void iwlagn_free_dma_ptr(struct iwl_trans *trans,
 -                              struct iwl_dma_ptr *ptr)
 -{
 -      if (unlikely(!ptr->addr))
 -              return;
 -
 -      dma_free_coherent(trans->dev, ptr->size, ptr->addr, ptr->dma);
 -      memset(ptr, 0, sizeof(*ptr));
 -}
 -
 -static void iwl_trans_pcie_queue_stuck_timer(unsigned long data)
 -{
 -      struct iwl_tx_queue *txq = (void *)data;
 -      struct iwl_queue *q = &txq->q;
 -      struct iwl_trans_pcie *trans_pcie = txq->trans_pcie;
 -      struct iwl_trans *trans = iwl_trans_pcie_get_trans(trans_pcie);
 -      u32 scd_sram_addr = trans_pcie->scd_base_addr +
 -              SCD_TX_STTS_MEM_LOWER_BOUND + (16 * txq->q.id);
 -      u8 buf[16];
 -      int i;
 -
 -      spin_lock(&txq->lock);
 -      /* check if triggered erroneously */
 -      if (txq->q.read_ptr == txq->q.write_ptr) {
 -              spin_unlock(&txq->lock);
 -              return;
 -      }
 -      spin_unlock(&txq->lock);
 -
 -      IWL_ERR(trans, "Queue %d stuck for %u ms.\n", txq->q.id,
 -              jiffies_to_msecs(trans_pcie->wd_timeout));
 -      IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n",
 -              txq->q.read_ptr, txq->q.write_ptr);
 -
 -      iwl_read_targ_mem_bytes(trans, scd_sram_addr, buf, sizeof(buf));
 -
 -      iwl_print_hex_error(trans, buf, sizeof(buf));
 -
 -      for (i = 0; i < FH_TCSR_CHNL_NUM; i++)
 -              IWL_ERR(trans, "FH TRBs(%d) = 0x%08x\n", i,
 -                      iwl_read_direct32(trans, FH_TX_TRB_REG(i)));
 -
 -      for (i = 0; i < trans->cfg->base_params->num_of_queues; i++) {
 -              u32 status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(i));
 -              u8 fifo = (status >> SCD_QUEUE_STTS_REG_POS_TXF) & 0x7;
 -              bool active = !!(status & BIT(SCD_QUEUE_STTS_REG_POS_ACTIVE));
 -              u32 tbl_dw =
 -                      iwl_read_targ_mem(trans,
 -                                        trans_pcie->scd_base_addr +
 -                                        SCD_TRANS_TBL_OFFSET_QUEUE(i));
 -
 -              if (i & 0x1)
 -                      tbl_dw = (tbl_dw & 0xFFFF0000) >> 16;
 -              else
 -                      tbl_dw = tbl_dw & 0x0000FFFF;
 -
 -              IWL_ERR(trans,
 -                      "Q %d is %sactive and mapped to fifo %d ra_tid 0x%04x [%d,%d]\n",
 -                      i, active ? "" : "in", fifo, tbl_dw,
 -                      iwl_read_prph(trans,
 -                                    SCD_QUEUE_RDPTR(i)) & (txq->q.n_bd - 1),
 -                      iwl_read_prph(trans, SCD_QUEUE_WRPTR(i)));
 -      }
 -
 -      for (i = q->read_ptr; i != q->write_ptr;
 -           i = iwl_queue_inc_wrap(i, q->n_bd)) {
 -              struct iwl_tx_cmd *tx_cmd =
 -                      (struct iwl_tx_cmd *)txq->entries[i].cmd->payload;
 -              IWL_ERR(trans, "scratch %d = 0x%08x\n", i,
 -                      get_unaligned_le32(&tx_cmd->scratch));
 -      }
 -
 -      iwl_op_mode_nic_error(trans->op_mode);
 -}
 -
 -static int iwl_trans_txq_alloc(struct iwl_trans *trans,
 -                             struct iwl_tx_queue *txq, int slots_num,
 -                             u32 txq_id)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      size_t tfd_sz = sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX;
 -      int i;
 -
 -      if (WARN_ON(txq->entries || txq->tfds))
 -              return -EINVAL;
 -
 -      setup_timer(&txq->stuck_timer, iwl_trans_pcie_queue_stuck_timer,
 -                  (unsigned long)txq);
 -      txq->trans_pcie = trans_pcie;
 -
 -      txq->q.n_window = slots_num;
 -
 -      txq->entries = kcalloc(slots_num,
 -                             sizeof(struct iwl_pcie_tx_queue_entry),
 -                             GFP_KERNEL);
 -
 -      if (!txq->entries)
 -              goto error;
 -
 -      if (txq_id == trans_pcie->cmd_queue)
 -              for (i = 0; i < slots_num; i++) {
 -                      txq->entries[i].cmd =
 -                              kmalloc(sizeof(struct iwl_device_cmd),
 -                                      GFP_KERNEL);
 -                      if (!txq->entries[i].cmd)
 -                              goto error;
 -              }
 -
 -      /* Circular buffer of transmit frame descriptors (TFDs),
 -       * shared with device */
 -      txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz,
 -                                     &txq->q.dma_addr, GFP_KERNEL);
 -      if (!txq->tfds) {
 -              IWL_ERR(trans, "dma_alloc_coherent(%zd) failed\n", tfd_sz);
 -              goto error;
 -      }
 -      txq->q.id = txq_id;
 -
 -      return 0;
 -error:
 -      if (txq->entries && txq_id == trans_pcie->cmd_queue)
 -              for (i = 0; i < slots_num; i++)
 -                      kfree(txq->entries[i].cmd);
 -      kfree(txq->entries);
 -      txq->entries = NULL;
 -
 -      return -ENOMEM;
 -
 -}
 -
 -static int iwl_trans_txq_init(struct iwl_trans *trans, struct iwl_tx_queue *txq,
 -                            int slots_num, u32 txq_id)
 -{
 -      int ret;
 -
 -      txq->need_update = 0;
 -
 -      /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
 -       * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
 -      BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
 -
 -      /* Initialize queue's high/low-water marks, and head/tail indexes */
 -      ret = iwl_queue_init(&txq->q, TFD_QUEUE_SIZE_MAX, slots_num,
 -                      txq_id);
 -      if (ret)
 -              return ret;
 -
 -      spin_lock_init(&txq->lock);
 -
 -      /*
 -       * Tell nic where to find circular buffer of Tx Frame Descriptors for
 -       * given Tx queue, and enable the DMA channel used for that queue.
 -       * Circular buffer (TFD queue in DRAM) physical base address */
 -      iwl_write_direct32(trans, FH_MEM_CBBC_QUEUE(txq_id),
 -                           txq->q.dma_addr >> 8);
 -
 -      return 0;
 -}
 -
 -/**
 - * iwl_tx_queue_unmap -  Unmap any remaining DMA mappings and free skb's
 - */
 -static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id];
 -      struct iwl_queue *q = &txq->q;
 -      enum dma_data_direction dma_dir;
 -
 -      if (!q->n_bd)
 -              return;
 -
 -      /* In the command queue, all the TBs are mapped as BIDI
 -       * so unmap them as such.
 -       */
 -      if (txq_id == trans_pcie->cmd_queue)
 -              dma_dir = DMA_BIDIRECTIONAL;
 -      else
 -              dma_dir = DMA_TO_DEVICE;
 -
 -      spin_lock_bh(&txq->lock);
 -      while (q->write_ptr != q->read_ptr) {
 -              iwl_txq_free_tfd(trans, txq, dma_dir);
 -              q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
 -      }
 -      spin_unlock_bh(&txq->lock);
 -}
 -
 -/**
 - * iwl_tx_queue_free - Deallocate DMA queue.
 - * @txq: Transmit queue to deallocate.
 - *
 - * Empty queue by removing and destroying all BD's.
 - * Free all buffers.
 - * 0-fill, but do not free "txq" descriptor structure.
 - */
 -static void iwl_tx_queue_free(struct iwl_trans *trans, int txq_id)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id];
 -      struct device *dev = trans->dev;
 -      int i;
 -
 -      if (WARN_ON(!txq))
 -              return;
 -
 -      iwl_tx_queue_unmap(trans, txq_id);
 -
 -      /* De-alloc array of command/tx buffers */
 -      if (txq_id == trans_pcie->cmd_queue)
 -              for (i = 0; i < txq->q.n_window; i++) {
 -                      kfree(txq->entries[i].cmd);
 -                      kfree(txq->entries[i].copy_cmd);
 -              }
 -
 -      /* De-alloc circular buffer of TFDs */
 -      if (txq->q.n_bd) {
 -              dma_free_coherent(dev, sizeof(struct iwl_tfd) *
 -                                txq->q.n_bd, txq->tfds, txq->q.dma_addr);
 -              memset(&txq->q.dma_addr, 0, sizeof(txq->q.dma_addr));
 -      }
 -
 -      kfree(txq->entries);
 -      txq->entries = NULL;
 -
 -      del_timer_sync(&txq->stuck_timer);
 -
 -      /* 0-fill queue descriptor structure */
 -      memset(txq, 0, sizeof(*txq));
 -}
 -
 -/**
 - * iwl_trans_tx_free - Free TXQ Context
 - *
 - * Destroy all TX DMA queues and structures
 - */
 -static void iwl_trans_pcie_tx_free(struct iwl_trans *trans)
 -{
 -      int txq_id;
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -
 -      /* Tx queues */
 -      if (trans_pcie->txq) {
 -              for (txq_id = 0;
 -                   txq_id < trans->cfg->base_params->num_of_queues; txq_id++)
 -                      iwl_tx_queue_free(trans, txq_id);
 -      }
 -
 -      kfree(trans_pcie->txq);
 -      trans_pcie->txq = NULL;
 -
 -      iwlagn_free_dma_ptr(trans, &trans_pcie->kw);
 -
 -      iwlagn_free_dma_ptr(trans, &trans_pcie->scd_bc_tbls);
 -}
 -
 -/**
 - * iwl_trans_tx_alloc - allocate TX context
 - * Allocate all Tx DMA structures and initialize them
 - *
 - * @param priv
 - * @return error code
 - */
 -static int iwl_trans_tx_alloc(struct iwl_trans *trans)
 -{
 -      int ret;
 -      int txq_id, slots_num;
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -
 -      u16 scd_bc_tbls_size = trans->cfg->base_params->num_of_queues *
 -                      sizeof(struct iwlagn_scd_bc_tbl);
 -
 -      /*It is not allowed to alloc twice, so warn when this happens.
 -       * We cannot rely on the previous allocation, so free and fail */
 -      if (WARN_ON(trans_pcie->txq)) {
 -              ret = -EINVAL;
 -              goto error;
 -      }
 -
 -      ret = iwlagn_alloc_dma_ptr(trans, &trans_pcie->scd_bc_tbls,
 -                                 scd_bc_tbls_size);
 -      if (ret) {
 -              IWL_ERR(trans, "Scheduler BC Table allocation failed\n");
 -              goto error;
 -      }
 -
 -      /* Alloc keep-warm buffer */
 -      ret = iwlagn_alloc_dma_ptr(trans, &trans_pcie->kw, IWL_KW_SIZE);
 -      if (ret) {
 -              IWL_ERR(trans, "Keep Warm allocation failed\n");
 -              goto error;
 -      }
 -
 -      trans_pcie->txq = kcalloc(trans->cfg->base_params->num_of_queues,
 -                                sizeof(struct iwl_tx_queue), GFP_KERNEL);
 -      if (!trans_pcie->txq) {
 -              IWL_ERR(trans, "Not enough memory for txq\n");
 -              ret = ENOMEM;
 -              goto error;
 -      }
 -
 -      /* Alloc and init all Tx queues, including the command queue (#4/#9) */
 -      for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
 -           txq_id++) {
 -              slots_num = (txq_id == trans_pcie->cmd_queue) ?
 -                                      TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
 -              ret = iwl_trans_txq_alloc(trans, &trans_pcie->txq[txq_id],
 -                                        slots_num, txq_id);
 -              if (ret) {
 -                      IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id);
 -                      goto error;
 -              }
 -      }
 -
 -      return 0;
 -
 -error:
 -      iwl_trans_pcie_tx_free(trans);
 -
 -      return ret;
 -}
 -static int iwl_tx_init(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      int ret;
 -      int txq_id, slots_num;
 -      unsigned long flags;
 -      bool alloc = false;
 -
 -      if (!trans_pcie->txq) {
 -              ret = iwl_trans_tx_alloc(trans);
 -              if (ret)
 -                      goto error;
 -              alloc = true;
 -      }
 -
 -      spin_lock_irqsave(&trans_pcie->irq_lock, flags);
 -
 -      /* Turn off all Tx DMA fifos */
 -      iwl_write_prph(trans, SCD_TXFACT, 0);
 -
 -      /* Tell NIC where to find the "keep warm" buffer */
 -      iwl_write_direct32(trans, FH_KW_MEM_ADDR_REG,
 -                         trans_pcie->kw.dma >> 4);
 -
 -      spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
 -
 -      /* Alloc and init all Tx queues, including the command queue (#4/#9) */
 -      for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
 -           txq_id++) {
 -              slots_num = (txq_id == trans_pcie->cmd_queue) ?
 -                                      TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
 -              ret = iwl_trans_txq_init(trans, &trans_pcie->txq[txq_id],
 -                                       slots_num, txq_id);
 -              if (ret) {
 -                      IWL_ERR(trans, "Tx %d queue init failed\n", txq_id);
 -                      goto error;
 -              }
 -      }
 -
 -      return 0;
 -error:
 -      /*Upon error, free only if we allocated something */
 -      if (alloc)
 -              iwl_trans_pcie_tx_free(trans);
 -      return ret;
 -}
 -
 -static void iwl_set_pwr_vmain(struct iwl_trans *trans)
 +static void iwl_pcie_set_pwr_vmain(struct iwl_trans *trans)
  {
  /*
   * (for documentation purposes)
  
  /* PCI registers */
  #define PCI_CFG_RETRY_TIMEOUT 0x041
- #define PCI_CFG_LINK_CTRL_VAL_L0S_EN  0x01
- #define PCI_CFG_LINK_CTRL_VAL_L1_EN   0x02
  
 -static void iwl_apm_config(struct iwl_trans *trans)
 +static void iwl_pcie_apm_config(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        u16 lctl;
         * If not (unlikely), enable L0S, so there is at least some
         *    power savings, even without L1.
         */
 -
        pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl);
-       if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
-                               PCI_CFG_LINK_CTRL_VAL_L1_EN) {
+       if (lctl & PCI_EXP_LNKCTL_ASPM_L1) {
                /* L1-ASPM enabled; disable(!) L0S */
                iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
 -              dev_printk(KERN_INFO, trans->dev,
 -                         "L1 Enabled; Disabling L0S\n");
 +              dev_info(trans->dev, "L1 Enabled; Disabling L0S\n");
        } else {
                /* L1-ASPM disabled; enable(!) L0S */
                iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
 -              dev_printk(KERN_INFO, trans->dev,
 -                         "L1 Disabled; Enabling L0S\n");
 +              dev_info(trans->dev, "L1 Disabled; Enabling L0S\n");
        }
-       trans->pm_support = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN);
+       trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);
  }
  
  /*
   * Start up NIC's basic functionality after it has been reset
 - * (e.g. after platform boot, or shutdown via iwl_apm_stop())
 + * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop())
   * NOTE:  This does not load uCode nor start the embedded processor
   */
 -static int iwl_apm_init(struct iwl_trans *trans)
 +static int iwl_pcie_apm_init(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        int ret = 0;
        iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
                    CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
  
 -      iwl_apm_config(trans);
 +      iwl_pcie_apm_config(trans);
  
        /* Configure analog phase-lock-loop before activating to D0A */
        if (trans->cfg->base_params->pll_cfg_val)
@@@ -208,7 -783,7 +204,7 @@@ out
        return ret;
  }
  
 -static int iwl_apm_stop_master(struct iwl_trans *trans)
 +static int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
  {
        int ret = 0;
  
        return ret;
  }
  
 -static void iwl_apm_stop(struct iwl_trans *trans)
 +static void iwl_pcie_apm_stop(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n");
        clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status);
  
        /* Stop device's DMA activity */
 -      iwl_apm_stop_master(trans);
 +      iwl_pcie_apm_stop_master(trans);
  
        /* Reset the entire device */
        iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
                      CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
  }
  
 -static int iwl_nic_init(struct iwl_trans *trans)
 +static int iwl_pcie_nic_init(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        unsigned long flags;
  
        /* nic_init */
        spin_lock_irqsave(&trans_pcie->irq_lock, flags);
 -      iwl_apm_init(trans);
 +      iwl_pcie_apm_init(trans);
  
        /* Set interrupt coalescing calibration timer to default (512 usecs) */
        iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
  
        spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  
 -      iwl_set_pwr_vmain(trans);
 +      iwl_pcie_set_pwr_vmain(trans);
  
        iwl_op_mode_nic_config(trans->op_mode);
  
        /* Allocate the RX queue, or reset if it is already allocated */
 -      iwl_rx_init(trans);
 +      iwl_pcie_rx_init(trans);
  
        /* Allocate or reset and init all Tx and Command queues */
 -      if (iwl_tx_init(trans))
 +      if (iwl_pcie_tx_init(trans))
                return -ENOMEM;
  
        if (trans->cfg->base_params->shadow_reg_enable) {
  #define HW_READY_TIMEOUT (50)
  
  /* Note: returns poll_bit return value, which is >= 0 if success */
 -static int iwl_set_hw_ready(struct iwl_trans *trans)
 +static int iwl_pcie_set_hw_ready(struct iwl_trans *trans)
  {
        int ret;
  
  }
  
  /* Note: returns standard 0/-ERROR code */
 -static int iwl_prepare_card_hw(struct iwl_trans *trans)
 +static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
  {
        int ret;
        int t = 0;
  
        IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n");
  
 -      ret = iwl_set_hw_ready(trans);
 +      ret = iwl_pcie_set_hw_ready(trans);
        /* If the card is ready, exit 0 */
        if (ret >= 0)
                return 0;
                    CSR_HW_IF_CONFIG_REG_PREPARE);
  
        do {
 -              ret = iwl_set_hw_ready(trans);
 +              ret = iwl_pcie_set_hw_ready(trans);
                if (ret >= 0)
                        return 0;
  
  /*
   * ucode
   */
 -static int iwl_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr,
 +static int iwl_pcie_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr,
                                   dma_addr_t phy_addr, u32 byte_cnt)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        return 0;
  }
  
 -static int iwl_load_section(struct iwl_trans *trans, u8 section_num,
 +static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,
                            const struct fw_desc *section)
  {
        u8 *v_addr;
                copy_size = min_t(u32, PAGE_SIZE, section->len - offset);
  
                memcpy(v_addr, (u8 *)section->data + offset, copy_size);
 -              ret = iwl_load_firmware_chunk(trans, section->offset + offset,
 -                                            p_addr, copy_size);
 +              ret = iwl_pcie_load_firmware_chunk(trans,
 +                                                 section->offset + offset,
 +                                                 p_addr, copy_size);
                if (ret) {
                        IWL_ERR(trans,
                                "Could not load the [%d] uCode section\n",
        return ret;
  }
  
 -static int iwl_load_given_ucode(struct iwl_trans *trans,
 +static int iwl_pcie_load_given_ucode(struct iwl_trans *trans,
                                const struct fw_img *image)
  {
        int i, ret = 0;
                if (!image->sec[i].data)
                        break;
  
 -              ret = iwl_load_section(trans, i, &image->sec[i]);
 +              ret = iwl_pcie_load_section(trans, i, &image->sec[i]);
                if (ret)
                        return ret;
        }
  static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
                                   const struct fw_img *fw)
  {
 +      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        int ret;
        bool hw_rfkill;
  
        /* This may fail if AMT took ownership of the device */
 -      if (iwl_prepare_card_hw(trans)) {
 +      if (iwl_pcie_prepare_card_hw(trans)) {
                IWL_WARN(trans, "Exit HW not ready\n");
                return -EIO;
        }
  
 +      clear_bit(STATUS_FW_ERROR, &trans_pcie->status);
 +
        iwl_enable_rfkill_int(trans);
  
        /* If platform's RF_KILL switch is NOT set to KILL */
  
        iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
  
 -      ret = iwl_nic_init(trans);
 +      ret = iwl_pcie_nic_init(trans);
        if (ret) {
                IWL_ERR(trans, "Unable to init nic\n");
                return ret;
        iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
  
        /* Load the given image to the HW */
 -      return iwl_load_given_ucode(trans, fw);
 -}
 -
 -/*
 - * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
 - */
 -static void iwl_trans_txq_set_sched(struct iwl_trans *trans, u32 mask)
 -{
 -      struct iwl_trans_pcie __maybe_unused *trans_pcie =
 -              IWL_TRANS_GET_PCIE_TRANS(trans);
 -
 -      iwl_write_prph(trans, SCD_TXFACT, mask);
 -}
 -
 -static void iwl_tx_start(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      u32 a;
 -      int chan;
 -      u32 reg_val;
 -
 -      /* make sure all queue are not stopped/used */
 -      memset(trans_pcie->queue_stopped, 0, sizeof(trans_pcie->queue_stopped));
 -      memset(trans_pcie->queue_used, 0, sizeof(trans_pcie->queue_used));
 -
 -      trans_pcie->scd_base_addr =
 -              iwl_read_prph(trans, SCD_SRAM_BASE_ADDR);
 -      a = trans_pcie->scd_base_addr + SCD_CONTEXT_MEM_LOWER_BOUND;
 -      /* reset conext data memory */
 -      for (; a < trans_pcie->scd_base_addr + SCD_CONTEXT_MEM_UPPER_BOUND;
 -              a += 4)
 -              iwl_write_targ_mem(trans, a, 0);
 -      /* reset tx status memory */
 -      for (; a < trans_pcie->scd_base_addr + SCD_TX_STTS_MEM_UPPER_BOUND;
 -              a += 4)
 -              iwl_write_targ_mem(trans, a, 0);
 -      for (; a < trans_pcie->scd_base_addr +
 -             SCD_TRANS_TBL_OFFSET_QUEUE(
 -                              trans->cfg->base_params->num_of_queues);
 -             a += 4)
 -              iwl_write_targ_mem(trans, a, 0);
 -
 -      iwl_write_prph(trans, SCD_DRAM_BASE_ADDR,
 -                     trans_pcie->scd_bc_tbls.dma >> 10);
 -
 -      /* The chain extension of the SCD doesn't work well. This feature is
 -       * enabled by default by the HW, so we need to disable it manually.
 -       */
 -      iwl_write_prph(trans, SCD_CHAINEXT_EN, 0);
 -
 -      iwl_trans_ac_txq_enable(trans, trans_pcie->cmd_queue,
 -                              trans_pcie->cmd_fifo);
 -
 -      /* Activate all Tx DMA/FIFO channels */
 -      iwl_trans_txq_set_sched(trans, IWL_MASK(0, 7));
 -
 -      /* Enable DMA channel */
 -      for (chan = 0; chan < FH_TCSR_CHNL_NUM ; chan++)
 -              iwl_write_direct32(trans, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
 -                                 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
 -                                 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
 -
 -      /* Update FH chicken bits */
 -      reg_val = iwl_read_direct32(trans, FH_TX_CHICKEN_BITS_REG);
 -      iwl_write_direct32(trans, FH_TX_CHICKEN_BITS_REG,
 -                         reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
 -
 -      /* Enable L1-Active */
 -      iwl_clear_bits_prph(trans, APMG_PCIDEV_STT_REG,
 -                          APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
 +      return iwl_pcie_load_given_ucode(trans, fw);
  }
  
 -static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans)
 +static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr)
  {
 -      iwl_reset_ict(trans);
 -      iwl_tx_start(trans);
 -}
 -
 -/**
 - * iwlagn_txq_ctx_stop - Stop all Tx DMA channels
 - */
 -static int iwl_trans_tx_stop(struct iwl_trans *trans)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      int ch, txq_id, ret;
 -      unsigned long flags;
 -
 -      /* Turn off all Tx DMA fifos */
 -      spin_lock_irqsave(&trans_pcie->irq_lock, flags);
 -
 -      iwl_trans_txq_set_sched(trans, 0);
 -
 -      /* Stop each Tx DMA channel, and wait for it to be idle */
 -      for (ch = 0; ch < FH_TCSR_CHNL_NUM; ch++) {
 -              iwl_write_direct32(trans,
 -                                 FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0);
 -              ret = iwl_poll_direct_bit(trans, FH_TSSR_TX_STATUS_REG,
 -                      FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000);
 -              if (ret < 0)
 -                      IWL_ERR(trans,
 -                              "Failing on timeout while stopping DMA channel %d [0x%08x]\n",
 -                              ch,
 -                              iwl_read_direct32(trans,
 -                                                FH_TSSR_TX_STATUS_REG));
 -      }
 -      spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
 -
 -      if (!trans_pcie->txq) {
 -              IWL_WARN(trans,
 -                       "Stopping tx queues that aren't allocated...\n");
 -              return 0;
 -      }
 -
 -      /* Unmap DMA from host system and free skb's */
 -      for (txq_id = 0; txq_id < trans->cfg->base_params->num_of_queues;
 -           txq_id++)
 -              iwl_tx_queue_unmap(trans, txq_id);
 -
 -      return 0;
 +      iwl_pcie_reset_ict(trans);
 +      iwl_pcie_tx_start(trans, scd_addr);
  }
  
  static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
        spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  
        /* device going down, Stop using ICT table */
 -      iwl_disable_ict(trans);
 +      iwl_pcie_disable_ict(trans);
  
        /*
         * If a HW restart happens during firmware loading,
         * already dead.
         */
        if (test_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status)) {
 -              iwl_trans_tx_stop(trans);
 -              iwl_trans_rx_stop(trans);
 +              iwl_pcie_tx_stop(trans);
 +              iwl_pcie_rx_stop(trans);
  
                /* Power-down device's busmaster DMA clocks */
                iwl_write_prph(trans, APMG_CLK_DIS_REG,
                      CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  
        /* Stop the device, and put it in low power state */
 -      iwl_apm_stop(trans);
 +      iwl_pcie_apm_stop(trans);
  
        /* Upon stop, the APM issues an interrupt if HW RF kill is set.
         * Clean again the interrupt here
        clear_bit(STATUS_INT_ENABLED, &trans_pcie->status);
        clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status);
        clear_bit(STATUS_TPOWER_PMI, &trans_pcie->status);
 +      clear_bit(STATUS_RFKILL, &trans_pcie->status);
  }
  
  static void iwl_trans_pcie_wowlan_suspend(struct iwl_trans *trans)
                      CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  }
  
 -static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
 -                           struct iwl_device_cmd *dev_cmd, int txq_id)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 -      struct iwl_tx_cmd *tx_cmd = (struct iwl_tx_cmd *) dev_cmd->payload;
 -      struct iwl_cmd_meta *out_meta;
 -      struct iwl_tx_queue *txq;
 -      struct iwl_queue *q;
 -      dma_addr_t phys_addr = 0;
 -      dma_addr_t txcmd_phys;
 -      dma_addr_t scratch_phys;
 -      u16 len, firstlen, secondlen;
 -      u8 wait_write_ptr = 0;
 -      __le16 fc = hdr->frame_control;
 -      u8 hdr_len = ieee80211_hdrlen(fc);
 -      u16 __maybe_unused wifi_seq;
 -
 -      txq = &trans_pcie->txq[txq_id];
 -      q = &txq->q;
 -
 -      if (unlikely(!test_bit(txq_id, trans_pcie->queue_used))) {
 -              WARN_ON_ONCE(1);
 -              return -EINVAL;
 -      }
 -
 -      spin_lock(&txq->lock);
 -
 -      /* In AGG mode, the index in the ring must correspond to the WiFi
 -       * sequence number. This is a HW requirements to help the SCD to parse
 -       * the BA.
 -       * Check here that the packets are in the right place on the ring.
 -       */
 -#ifdef CONFIG_IWLWIFI_DEBUG
 -      wifi_seq = SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
 -      WARN_ONCE((iwl_read_prph(trans, SCD_AGGR_SEL) & BIT(txq_id)) &&
 -                ((wifi_seq & 0xff) != q->write_ptr),
 -                "Q: %d WiFi Seq %d tfdNum %d",
 -                txq_id, wifi_seq, q->write_ptr);
 -#endif
 -
 -      /* Set up driver data for this TFD */
 -      txq->entries[q->write_ptr].skb = skb;
 -      txq->entries[q->write_ptr].cmd = dev_cmd;
 -
 -      dev_cmd->hdr.cmd = REPLY_TX;
 -      dev_cmd->hdr.sequence =
 -              cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
 -                          INDEX_TO_SEQ(q->write_ptr)));
 -
 -      /* Set up first empty entry in queue's array of Tx/cmd buffers */
 -      out_meta = &txq->entries[q->write_ptr].meta;
 -
 -      /*
 -       * Use the first empty entry in this queue's command buffer array
 -       * to contain the Tx command and MAC header concatenated together
 -       * (payload data will be in another buffer).
 -       * Size of this varies, due to varying MAC header length.
 -       * If end is not dword aligned, we'll have 2 extra bytes at the end
 -       * of the MAC header (device reads on dword boundaries).
 -       * We'll tell device about this padding later.
 -       */
 -      len = sizeof(struct iwl_tx_cmd) +
 -              sizeof(struct iwl_cmd_header) + hdr_len;
 -      firstlen = (len + 3) & ~3;
 -
 -      /* Tell NIC about any 2-byte padding after MAC header */
 -      if (firstlen != len)
 -              tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK;
 -
 -      /* Physical address of this Tx command's header (not MAC header!),
 -       * within command buffer array. */
 -      txcmd_phys = dma_map_single(trans->dev,
 -                                  &dev_cmd->hdr, firstlen,
 -                                  DMA_BIDIRECTIONAL);
 -      if (unlikely(dma_mapping_error(trans->dev, txcmd_phys)))
 -              goto out_err;
 -      dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
 -      dma_unmap_len_set(out_meta, len, firstlen);
 -
 -      if (!ieee80211_has_morefrags(fc)) {
 -              txq->need_update = 1;
 -      } else {
 -              wait_write_ptr = 1;
 -              txq->need_update = 0;
 -      }
 -
 -      /* Set up TFD's 2nd entry to point directly to remainder of skb,
 -       * if any (802.11 null frames have no payload). */
 -      secondlen = skb->len - hdr_len;
 -      if (secondlen > 0) {
 -              phys_addr = dma_map_single(trans->dev, skb->data + hdr_len,
 -                                         secondlen, DMA_TO_DEVICE);
 -              if (unlikely(dma_mapping_error(trans->dev, phys_addr))) {
 -                      dma_unmap_single(trans->dev,
 -                                       dma_unmap_addr(out_meta, mapping),
 -                                       dma_unmap_len(out_meta, len),
 -                                       DMA_BIDIRECTIONAL);
 -                      goto out_err;
 -              }
 -      }
 -
 -      /* Attach buffers to TFD */
 -      iwlagn_txq_attach_buf_to_tfd(trans, txq, txcmd_phys, firstlen, 1);
 -      if (secondlen > 0)
 -              iwlagn_txq_attach_buf_to_tfd(trans, txq, phys_addr,
 -                                           secondlen, 0);
 -
 -      scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
 -                              offsetof(struct iwl_tx_cmd, scratch);
 -
 -      /* take back ownership of DMA buffer to enable update */
 -      dma_sync_single_for_cpu(trans->dev, txcmd_phys, firstlen,
 -                              DMA_BIDIRECTIONAL);
 -      tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
 -      tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
 -
 -      IWL_DEBUG_TX(trans, "sequence nr = 0X%x\n",
 -                   le16_to_cpu(dev_cmd->hdr.sequence));
 -      IWL_DEBUG_TX(trans, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags));
 -
 -      /* Set up entry for this TFD in Tx byte-count array */
 -      iwl_trans_txq_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len));
 -
 -      dma_sync_single_for_device(trans->dev, txcmd_phys, firstlen,
 -                                 DMA_BIDIRECTIONAL);
 -
 -      trace_iwlwifi_dev_tx(trans->dev,
 -                           &txq->tfds[txq->q.write_ptr],
 -                           sizeof(struct iwl_tfd),
 -                           &dev_cmd->hdr, firstlen,
 -                           skb->data + hdr_len, secondlen);
 -
 -      /* start timer if queue currently empty */
 -      if (txq->need_update && q->read_ptr == q->write_ptr &&
 -          trans_pcie->wd_timeout)
 -              mod_timer(&txq->stuck_timer, jiffies + trans_pcie->wd_timeout);
 -
 -      /* Tell device the write index *just past* this latest filled TFD */
 -      q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
 -      iwl_txq_update_write_ptr(trans, txq);
 -
 -      /*
 -       * At this point the frame is "transmitted" successfully
 -       * and we will get a TX status notification eventually,
 -       * regardless of the value of ret. "ret" only indicates
 -       * whether or not we should update the write pointer.
 -       */
 -      if (iwl_queue_space(q) < q->high_mark) {
 -              if (wait_write_ptr) {
 -                      txq->need_update = 1;
 -                      iwl_txq_update_write_ptr(trans, txq);
 -              } else {
 -                      iwl_stop_queue(trans, txq);
 -              }
 -      }
 -      spin_unlock(&txq->lock);
 -      return 0;
 - out_err:
 -      spin_unlock(&txq->lock);
 -      return -1;
 -}
 -
  static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  
        if (!trans_pcie->irq_requested) {
                tasklet_init(&trans_pcie->irq_tasklet, (void (*)(unsigned long))
 -                      iwl_irq_tasklet, (unsigned long)trans);
 +                      iwl_pcie_tasklet, (unsigned long)trans);
  
 -              iwl_alloc_isr_ict(trans);
 +              iwl_pcie_alloc_ict(trans);
  
 -              err = request_irq(trans_pcie->irq, iwl_isr_ict, IRQF_SHARED,
 -                                DRV_NAME, trans);
 +              err = request_irq(trans_pcie->irq, iwl_pcie_isr_ict,
 +                                IRQF_SHARED, DRV_NAME, trans);
                if (err) {
                        IWL_ERR(trans, "Error allocating IRQ %d\n",
                                trans_pcie->irq);
                        goto error;
                }
  
 -              INIT_WORK(&trans_pcie->rx_replenish, iwl_bg_rx_replenish);
                trans_pcie->irq_requested = true;
        }
  
 -      err = iwl_prepare_card_hw(trans);
 +      err = iwl_pcie_prepare_card_hw(trans);
        if (err) {
                IWL_ERR(trans, "Error while preparing HW: %d\n", err);
                goto err_free_irq;
        }
  
 -      iwl_apm_init(trans);
 +      iwl_pcie_apm_init(trans);
  
        /* From now on, the op_mode will be kept updated about RF kill state */
        iwl_enable_rfkill_int(trans);
@@@ -611,7 -1457,7 +607,7 @@@ err_free_irq
        trans_pcie->irq_requested = false;
        free_irq(trans_pcie->irq, trans);
  error:
 -      iwl_free_isr_ict(trans);
 +      iwl_pcie_free_ict(trans);
        tasklet_kill(&trans_pcie->irq_tasklet);
        return err;
  }
@@@ -627,14 -1473,12 +623,14 @@@ static void iwl_trans_pcie_stop_hw(stru
        iwl_disable_interrupts(trans);
        spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  
 -      iwl_apm_stop(trans);
 +      iwl_pcie_apm_stop(trans);
  
        spin_lock_irqsave(&trans_pcie->irq_lock, flags);
        iwl_disable_interrupts(trans);
        spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
  
 +      iwl_pcie_disable_ict(trans);
 +
        if (!op_mode_leaving) {
                /*
                 * Even if we stop the HW, we still want the RF kill
        }
  }
  
 -static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
 -                                 struct sk_buff_head *skbs)
 -{
 -      struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id];
 -      /* n_bd is usually 256 => n_bd - 1 = 0xff */
 -      int tfd_num = ssn & (txq->q.n_bd - 1);
 -      int freed = 0;
 -
 -      spin_lock(&txq->lock);
 -
 -      if (txq->q.read_ptr != tfd_num) {
 -              IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d -> %d (%d)\n",
 -                                 txq_id, txq->q.read_ptr, tfd_num, ssn);
 -              freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs);
 -              if (iwl_queue_space(&txq->q) > txq->q.low_mark)
 -                      iwl_wake_queue(trans, txq);
 -      }
 -
 -      spin_unlock(&txq->lock);
 -}
 -
  static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val)
  {
        writeb(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs);
@@@ -668,20 -1534,6 +664,20 @@@ static u32 iwl_trans_pcie_read32(struc
        return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs);
  }
  
 +static u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg)
 +{
 +      iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
 +      return iwl_trans_pcie_read32(trans, HBUS_TARG_PRPH_RDAT);
 +}
 +
 +static void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr,
 +                                    u32 val)
 +{
 +      iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WADDR,
 +                             ((addr & 0x0000FFFF) | (3 << 24)));
 +      iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WDAT, val);
 +}
 +
  static void iwl_trans_pcie_configure(struct iwl_trans *trans,
                                     const struct iwl_trans_config *trans_cfg)
  {
@@@ -713,12 -1565,12 +709,12 @@@ void iwl_trans_pcie_free(struct iwl_tra
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
  
 -      iwl_trans_pcie_tx_free(trans);
 -      iwl_trans_pcie_rx_free(trans);
 +      iwl_pcie_tx_free(trans);
 +      iwl_pcie_rx_free(trans);
  
        if (trans_pcie->irq_requested == true) {
                free_irq(trans_pcie->irq, trans);
 -              iwl_free_isr_ict(trans);
 +              iwl_pcie_free_ict(trans);
        }
  
        pci_disable_msi(trans_pcie->pci_dev);
@@@ -764,10 -1616,10 +760,10 @@@ static int iwl_trans_pcie_resume(struc
  
  #define IWL_FLUSH_WAIT_MS     2000
  
 -static int iwl_trans_pcie_wait_tx_queue_empty(struct iwl_trans *trans)
 +static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans)
  {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_tx_queue *txq;
 +      struct iwl_txq *txq;
        struct iwl_queue *q;
        int cnt;
        unsigned long now = jiffies;
@@@ -811,7 -1663,7 +807,7 @@@ static const char *get_fh_string(int cm
  #undef IWL_CMD
  }
  
 -int iwl_dump_fh(struct iwl_trans *trans, char **buf)
 +int iwl_pcie_dump_fh(struct iwl_trans *trans, char **buf)
  {
        int i;
        static const u32 fh_tbl[] = {
@@@ -890,7 -1742,7 +886,7 @@@ static const char *get_csr_string(int c
  #undef IWL_CMD
  }
  
 -void iwl_dump_csr(struct iwl_trans *trans)
 +void iwl_pcie_dump_csr(struct iwl_trans *trans)
  {
        int i;
        static const u32 csr_tbl[] = {
@@@ -947,6 -1799,7 +943,6 @@@ static ssize_t iwl_dbgfs_##name##_write
                                        const char __user *user_buf,    \
                                        size_t count, loff_t *ppos);
  
 -
  #define DEBUGFS_READ_FILE_OPS(name)                                   \
        DEBUGFS_READ_FUNC(name);                                        \
  static const struct file_operations iwl_dbgfs_##name##_ops = {                \
@@@ -979,7 -1832,7 +975,7 @@@ static ssize_t iwl_dbgfs_tx_queue_read(
  {
        struct iwl_trans *trans = file->private_data;
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_tx_queue *txq;
 +      struct iwl_txq *txq;
        struct iwl_queue *q;
        char *buf;
        int pos = 0;
@@@ -1016,7 -1869,7 +1012,7 @@@ static ssize_t iwl_dbgfs_rx_queue_read(
  {
        struct iwl_trans *trans = file->private_data;
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 -      struct iwl_rx_queue *rxq = &trans_pcie->rxq;
 +      struct iwl_rxq *rxq = &trans_pcie->rxq;
        char buf[256];
        int pos = 0;
        const size_t bufsz = sizeof(buf);
@@@ -1135,7 -1988,7 +1131,7 @@@ static ssize_t iwl_dbgfs_csr_write(stru
        if (sscanf(buf, "%d", &csr) != 1)
                return -EFAULT;
  
 -      iwl_dump_csr(trans);
 +      iwl_pcie_dump_csr(trans);
  
        return count;
  }
@@@ -1149,7 -2002,7 +1145,7 @@@ static ssize_t iwl_dbgfs_fh_reg_read(st
        int pos = 0;
        ssize_t ret = -EFAULT;
  
 -      ret = pos = iwl_dump_fh(trans, &buf);
 +      ret = pos = iwl_pcie_dump_fh(trans, &buf);
        if (buf) {
                ret = simple_read_from_buffer(user_buf,
                                              count, ppos, buf, pos);
@@@ -1218,7 -2071,7 +1214,7 @@@ static const struct iwl_trans_ops trans
  
        .wowlan_suspend = iwl_trans_pcie_wowlan_suspend,
  
 -      .send_cmd = iwl_trans_pcie_send_cmd,
 +      .send_cmd = iwl_trans_pcie_send_hcmd,
  
        .tx = iwl_trans_pcie_tx,
        .reclaim = iwl_trans_pcie_reclaim,
  
        .dbgfs_register = iwl_trans_pcie_dbgfs_register,
  
 -      .wait_tx_queue_empty = iwl_trans_pcie_wait_tx_queue_empty,
 +      .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty,
  
  #ifdef CONFIG_PM_SLEEP
        .suspend = iwl_trans_pcie_suspend,
        .write8 = iwl_trans_pcie_write8,
        .write32 = iwl_trans_pcie_write32,
        .read32 = iwl_trans_pcie_read32,
 +      .read_prph = iwl_trans_pcie_read_prph,
 +      .write_prph = iwl_trans_pcie_write_prph,
        .configure = iwl_trans_pcie_configure,
        .set_pmi = iwl_trans_pcie_set_pmi,
  };
@@@ -1255,7 -2106,7 +1251,7 @@@ struct iwl_trans *iwl_trans_pcie_alloc(
        trans = kzalloc(sizeof(struct iwl_trans) +
                        sizeof(struct iwl_trans_pcie), GFP_KERNEL);
  
 -      if (WARN_ON(!trans))
 +      if (!trans)
                return NULL;
  
        trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
                                                          DMA_BIT_MASK(32));
                /* both attempts failed: */
                if (err) {
 -                      dev_printk(KERN_ERR, &pdev->dev,
 -                                 "No suitable DMA available.\n");
 +                      dev_err(&pdev->dev, "No suitable DMA available\n");
                        goto out_pci_disable_device;
                }
        }
  
        err = pci_request_regions(pdev, DRV_NAME);
        if (err) {
 -              dev_printk(KERN_ERR, &pdev->dev,
 -                         "pci_request_regions failed\n");
 +              dev_err(&pdev->dev, "pci_request_regions failed\n");
                goto out_pci_disable_device;
        }
  
        trans_pcie->hw_base = pci_ioremap_bar(pdev, 0);
        if (!trans_pcie->hw_base) {
 -              dev_printk(KERN_ERR, &pdev->dev, "pci_ioremap_bar failed\n");
 +              dev_err(&pdev->dev, "pci_ioremap_bar failed\n");
                err = -ENODEV;
                goto out_pci_release_regions;
        }
  
 -      dev_printk(KERN_INFO, &pdev->dev,
 -                 "pci_resource_len = 0x%08llx\n",
 -                 (unsigned long long) pci_resource_len(pdev, 0));
 -      dev_printk(KERN_INFO, &pdev->dev,
 -                 "pci_resource_base = %p\n", trans_pcie->hw_base);
 -
 -      dev_printk(KERN_INFO, &pdev->dev,
 -                 "HW Revision ID = 0x%X\n", pdev->revision);
 -
        /* We disable the RETRY_TIMEOUT register (0x41) to keep
         * PCI Tx retries from interfering with C3 CPU state */
        pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
  
        err = pci_enable_msi(pdev);
 -      if (err)
 -              dev_printk(KERN_ERR, &pdev->dev,
 -                         "pci_enable_msi failed(0X%x)\n", err);
 +      if (err) {
 +              dev_err(&pdev->dev, "pci_enable_msi failed(0X%x)\n", err);
 +              /* enable rfkill interrupt: hw bug w/a */
 +              pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
 +              if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
 +                      pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
 +                      pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
 +              }
 +      }
  
        trans->dev = &pdev->dev;
        trans_pcie->irq = pdev->irq;
        snprintf(trans->hw_id_str, sizeof(trans->hw_id_str),
                 "PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device);
  
 -      /* TODO: Move this away, not needed if not MSI */
 -      /* enable rfkill interrupt: hw bug w/a */
 -      pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
 -      if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
 -              pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
 -              pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
 -      }
 -
        /* Initialize the wait queue for commands */
 -      init_waitqueue_head(&trans->wait_command_queue);
 +      init_waitqueue_head(&trans_pcie->wait_command_queue);
        spin_lock_init(&trans->reg_lock);
  
        snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name),
diff --combined drivers/pci/ioapic.c
@@@ -27,7 -27,7 +27,7 @@@ struct ioapic 
        u32             gsi_base;
  };
  
 -static int __devinit ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
 +static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
  {
        acpi_handle handle;
        acpi_status status;
@@@ -88,7 -88,7 +88,7 @@@ exit_free
        return -ENODEV;
  }
  
 -static void __devexit ioapic_remove(struct pci_dev *dev)
 +static void ioapic_remove(struct pci_dev *dev)
  {
        struct ioapic *ioapic = pci_get_drvdata(dev);
  
@@@ -110,7 -110,7 +110,7 @@@ static struct pci_driver ioapic_driver 
        .name           = "ioapic",
        .id_table       = ioapic_devices,
        .probe          = ioapic_probe,
 -      .remove         = __devexit_p(ioapic_remove),
 +      .remove         = ioapic_remove,
  };
  
  static int __init ioapic_init(void)
@@@ -125,3 -125,5 +125,5 @@@ static void __exit ioapic_exit(void
  
  module_init(ioapic_init);
  module_exit(ioapic_exit);
+ MODULE_LICENSE("GPL");
diff --combined drivers/pci/pci-driver.c
@@@ -89,6 -89,10 +89,6 @@@ static void pci_free_dynids(struct pci_
        spin_unlock(&drv->dynids.lock);
  }
  
 -/*
 - * Dynamic device ID manipulation via sysfs is disabled for !CONFIG_HOTPLUG
 - */
 -#ifdef CONFIG_HOTPLUG
  /**
   * store_new_id - sysfs frontend to pci_add_dynid()
   * @driver: target device driver
@@@ -187,6 -191,10 +187,6 @@@ static struct driver_attribute pci_drv_
        __ATTR_NULL,
  };
  
 -#else
 -#define pci_drv_attrs NULL
 -#endif /* CONFIG_HOTPLUG */
 -
  /**
   * pci_match_id - See if a pci device matches a given pci_id table
   * @ids: array of PCI device id structures to search in
@@@ -248,31 -256,26 +248,26 @@@ struct drv_dev_and_id 
  static long local_pci_probe(void *_ddi)
  {
        struct drv_dev_and_id *ddi = _ddi;
-       struct device *dev = &ddi->dev->dev;
-       struct device *parent = dev->parent;
+       struct pci_dev *pci_dev = ddi->dev;
+       struct pci_driver *pci_drv = ddi->drv;
+       struct device *dev = &pci_dev->dev;
        int rc;
  
-       /* The parent bridge must be in active state when probing */
-       if (parent)
-               pm_runtime_get_sync(parent);
-       /* Unbound PCI devices are always set to disabled and suspended.
-        * During probe, the device is set to enabled and active and the
-        * usage count is incremented.  If the driver supports runtime PM,
-        * it should call pm_runtime_put_noidle() in its probe routine and
-        * pm_runtime_get_noresume() in its remove routine.
+       /*
+        * Unbound PCI devices are always put in D0, regardless of
+        * runtime PM status.  During probe, the device is set to
+        * active and the usage count is incremented.  If the driver
+        * supports runtime PM, it should call pm_runtime_put_noidle()
+        * in its probe routine and pm_runtime_get_noresume() in its
+        * remove routine.
         */
-       pm_runtime_get_noresume(dev);
-       pm_runtime_set_active(dev);
-       pm_runtime_enable(dev);
-       rc = ddi->drv->probe(ddi->dev, ddi->id);
+       pm_runtime_get_sync(dev);
+       pci_dev->driver = pci_drv;
+       rc = pci_drv->probe(pci_dev, ddi->id);
        if (rc) {
-               pm_runtime_disable(dev);
-               pm_runtime_set_suspended(dev);
-               pm_runtime_put_noidle(dev);
+               pci_dev->driver = NULL;
+               pm_runtime_put_sync(dev);
        }
-       if (parent)
-               pm_runtime_put(parent);
        return rc;
  }
  
@@@ -322,10 -325,8 +317,8 @@@ __pci_device_probe(struct pci_driver *d
                id = pci_match_device(drv, pci_dev);
                if (id)
                        error = pci_call_probe(drv, pci_dev, id);
-               if (error >= 0) {
-                       pci_dev->driver = drv;
+               if (error >= 0)
                        error = 0;
-               }
        }
        return error;
  }
@@@ -361,9 -362,7 +354,7 @@@ static int pci_device_remove(struct dev
        }
  
        /* Undo the runtime PM settings in local_pci_probe() */
-       pm_runtime_disable(dev);
-       pm_runtime_set_suspended(dev);
-       pm_runtime_put_noidle(dev);
+       pm_runtime_put_sync(dev);
  
        /*
         * If the device is still on, set the power state as "unknown",
@@@ -986,6 -985,13 +977,13 @@@ static int pci_pm_runtime_suspend(struc
        pci_power_t prev = pci_dev->current_state;
        int error;
  
+       /*
+        * If pci_dev->driver is not set (unbound), the device should
+        * always remain in D0 regardless of the runtime PM status
+        */
+       if (!pci_dev->driver)
+               return 0;
        if (!pm || !pm->runtime_suspend)
                return -ENOSYS;
  
                return 0;
        }
  
-       if (!pci_dev->state_saved)
+       if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
-       pci_finish_runtime_suspend(pci_dev);
+               pci_finish_runtime_suspend(pci_dev);
+       }
  
        return 0;
  }
@@@ -1021,6 -1027,13 +1019,13 @@@ static int pci_pm_runtime_resume(struc
        struct pci_dev *pci_dev = to_pci_dev(dev);
        const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
  
+       /*
+        * If pci_dev->driver is not set (unbound), the device should
+        * always remain in D0 regardless of the runtime PM status
+        */
+       if (!pci_dev->driver)
+               return 0;
        if (!pm || !pm->runtime_resume)
                return -ENOSYS;
  
  
  static int pci_pm_runtime_idle(struct device *dev)
  {
+       struct pci_dev *pci_dev = to_pci_dev(dev);
        const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
  
+       /*
+        * If pci_dev->driver is not set (unbound), the device should
+        * always remain in D0 regardless of the runtime PM status
+        */
+       if (!pci_dev->driver)
+               goto out;
        if (!pm)
                return -ENOSYS;
  
                        return ret;
        }
  
+ out:
        pm_runtime_suspend(dev);
        return 0;
  }
  
@@@ -1215,38 -1236,12 +1228,38 @@@ void pci_dev_put(struct pci_dev *dev
                put_device(&dev->dev);
  }
  
 -#ifndef CONFIG_HOTPLUG
 -int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
 +static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
  {
 -      return -ENODEV;
 +      struct pci_dev *pdev;
 +
 +      if (!dev)
 +              return -ENODEV;
 +
 +      pdev = to_pci_dev(dev);
 +      if (!pdev)
 +              return -ENODEV;
 +
 +      if (add_uevent_var(env, "PCI_CLASS=%04X", pdev->class))
 +              return -ENOMEM;
 +
 +      if (add_uevent_var(env, "PCI_ID=%04X:%04X", pdev->vendor, pdev->device))
 +              return -ENOMEM;
 +
 +      if (add_uevent_var(env, "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor,
 +                         pdev->subsystem_device))
 +              return -ENOMEM;
 +
 +      if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev)))
 +              return -ENOMEM;
 +
 +      if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
 +                         pdev->vendor, pdev->device,
 +                         pdev->subsystem_vendor, pdev->subsystem_device,
 +                         (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
 +                         (u8)(pdev->class)))
 +              return -ENOMEM;
 +      return 0;
  }
 -#endif
  
  struct bus_type pci_bus_type = {
        .name           = "pci",
diff --combined drivers/pci/pci-sysfs.c
@@@ -284,6 -284,7 +284,6 @@@ msi_bus_store(struct device *dev, struc
        return count;
  }
  
 -#ifdef CONFIG_HOTPLUG
  static DEFINE_MUTEX(pci_remove_rescan_mutex);
  static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
                                size_t count)
@@@ -376,6 -377,8 +376,6 @@@ dev_bus_rescan_store(struct device *dev
        return count;
  }
  
 -#endif
 -
  #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
  static ssize_t d3cold_allowed_store(struct device *dev,
                                    struct device_attribute *attr,
@@@ -401,6 -404,106 +401,106 @@@ static ssize_t d3cold_allowed_show(stru
  }
  #endif
  
+ #ifdef CONFIG_PCI_IOV
+ static ssize_t sriov_totalvfs_show(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+ {
+       struct pci_dev *pdev = to_pci_dev(dev);
+       return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
+ }
+ static ssize_t sriov_numvfs_show(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
+ {
+       struct pci_dev *pdev = to_pci_dev(dev);
+       return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
+ }
+ /*
+  * num_vfs > 0; number of vfs to enable
+  * num_vfs = 0; disable all vfs
+  *
+  * Note: SRIOV spec doesn't allow partial VF
+  *       disable, so its all or none.
+  */
+ static ssize_t sriov_numvfs_store(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *buf, size_t count)
+ {
+       struct pci_dev *pdev = to_pci_dev(dev);
+       int num_vfs_enabled = 0;
+       int num_vfs;
+       int ret = 0;
+       u16 total;
+       if (kstrtoint(buf, 0, &num_vfs) < 0)
+               return -EINVAL;
+       /* is PF driver loaded w/callback */
+       if (!pdev->driver || !pdev->driver->sriov_configure) {
+               dev_info(&pdev->dev,
+                        "Driver doesn't support SRIOV configuration via sysfs\n");
+               return -ENOSYS;
+       }
+       /* if enabling vf's ... */
+       total = pci_sriov_get_totalvfs(pdev);
+       /* Requested VFs to enable < totalvfs and none enabled already */
+       if ((num_vfs > 0) && (num_vfs <= total)) {
+               if (pdev->sriov->num_VFs == 0) {
+                       num_vfs_enabled =
+                               pdev->driver->sriov_configure(pdev, num_vfs);
+                       if ((num_vfs_enabled >= 0) &&
+                           (num_vfs_enabled != num_vfs)) {
+                               dev_warn(&pdev->dev,
+                                        "Only %d VFs enabled\n",
+                                        num_vfs_enabled);
+                               return count;
+                       } else if (num_vfs_enabled < 0)
+                               /* error code from driver callback */
+                               return num_vfs_enabled;
+               } else if (num_vfs == pdev->sriov->num_VFs) {
+                       dev_warn(&pdev->dev,
+                                "%d VFs already enabled; no enable action taken\n",
+                                num_vfs);
+                       return count;
+               } else {
+                       dev_warn(&pdev->dev,
+                                "%d VFs already enabled. Disable before enabling %d VFs\n",
+                                pdev->sriov->num_VFs, num_vfs);
+                       return -EINVAL;
+               }
+       }
+       /* disable vfs */
+       if (num_vfs == 0) {
+               if (pdev->sriov->num_VFs != 0) {
+                       ret = pdev->driver->sriov_configure(pdev, 0);
+                       return ret ? ret : count;
+               } else {
+                       dev_warn(&pdev->dev,
+                                "All VFs disabled; no disable action taken\n");
+                       return count;
+               }
+       }
+       dev_err(&pdev->dev,
+               "Invalid value for number of VFs to enable: %d\n", num_vfs);
+       return -EINVAL;
+ }
+ static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs);
+ static struct device_attribute sriov_numvfs_attr =
+               __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
+                      sriov_numvfs_show, sriov_numvfs_store);
+ #endif /* CONFIG_PCI_IOV */
  struct device_attribute pci_dev_attrs[] = {
        __ATTR_RO(resource),
        __ATTR_RO(vendor),
        __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
                broken_parity_status_show,broken_parity_status_store),
        __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
 -#ifdef CONFIG_HOTPLUG
        __ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store),
        __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store),
 -#endif
  #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
        __ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store),
  #endif
  };
  
  struct device_attribute pcibus_dev_attrs[] = {
 -#ifdef CONFIG_HOTPLUG
        __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store),
 -#endif
        __ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL),
        __ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL),
        __ATTR_NULL,
@@@ -1262,29 -1369,20 +1362,20 @@@ int __must_check pci_create_sysfs_dev_f
                pdev->rom_attr = attr;
        }
  
-       if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
-               retval = device_create_file(&pdev->dev, &vga_attr);
-               if (retval)
-                       goto err_rom_file;
-       }
        /* add platform-specific attributes */
        retval = pcibios_add_platform_entries(pdev);
        if (retval)
-               goto err_vga_file;
+               goto err_rom_file;
  
        /* add sysfs entries for various capabilities */
        retval = pci_create_capabilities_sysfs(pdev);
        if (retval)
-               goto err_vga_file;
+               goto err_rom_file;
  
        pci_create_firmware_label_files(pdev);
  
        return 0;
  
- err_vga_file:
-       if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
-               device_remove_file(&pdev->dev, &vga_attr);
  err_rom_file:
        if (rom_size) {
                sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
@@@ -1370,3 -1468,62 +1461,62 @@@ static int __init pci_sysfs_init(void
  }
  
  late_initcall(pci_sysfs_init);
+ static struct attribute *pci_dev_dev_attrs[] = {
+       &vga_attr.attr,
+       NULL,
+ };
+ static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
+                                               struct attribute *a, int n)
+ {
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct pci_dev *pdev = to_pci_dev(dev);
+       if (a == &vga_attr.attr)
+               if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+                       return 0;
+       return a->mode;
+ }
+ #ifdef CONFIG_PCI_IOV
+ static struct attribute *sriov_dev_attrs[] = {
+       &sriov_totalvfs_attr.attr,
+       &sriov_numvfs_attr.attr,
+       NULL,
+ };
+ static umode_t sriov_attrs_are_visible(struct kobject *kobj,
+                                        struct attribute *a, int n)
+ {
+       struct device *dev = container_of(kobj, struct device, kobj);
+       if (!dev_is_pf(dev))
+               return 0;
+       return a->mode;
+ }
+ static struct attribute_group sriov_dev_attr_group = {
+       .attrs = sriov_dev_attrs,
+       .is_visible = sriov_attrs_are_visible,
+ };
+ #endif /* CONFIG_PCI_IOV */
+ static struct attribute_group pci_dev_attr_group = {
+       .attrs = pci_dev_dev_attrs,
+       .is_visible = pci_dev_attrs_are_visible,
+ };
+ static const struct attribute_group *pci_dev_attr_groups[] = {
+       &pci_dev_attr_group,
+ #ifdef CONFIG_PCI_IOV
+       &sriov_dev_attr_group,
+ #endif
+       NULL,
+ };
+ struct device_type pci_dev_type = {
+       .groups = pci_dev_attr_groups,
+ };
diff --combined drivers/pci/pci.c
@@@ -86,7 -86,7 +86,7 @@@ enum pcie_bus_config_types pcie_bus_con
   * the dfl or actual value as it sees fit.  Don't forget this is
   * measured in 32-bit words, not bytes.
   */
 -u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2;
 +u8 pci_dfl_cache_line_size = L1_CACHE_BYTES >> 2;
  u8 pci_cache_line_size;
  
  /*
@@@ -1333,6 -1333,19 +1333,19 @@@ void pcim_pin_device(struct pci_dev *pd
                dr->pinned = 1;
  }
  
+ /*
+  * pcibios_add_device - provide arch specific hooks when adding device dev
+  * @dev: the PCI device being added
+  *
+  * Permits the platform to provide architecture specific functionality when
+  * devices are added. This is the default implementation. Architecture
+  * implementations can override this.
+  */
+ int __weak pcibios_add_device (struct pci_dev *dev)
+ {
+       return 0;
+ }
  /**
   * pcibios_disable_device - disable arch specific PCI resources for device dev
   * @dev: the PCI device to disable
@@@ -1578,15 -1591,25 +1591,25 @@@ void pci_pme_active(struct pci_dev *dev
  
        pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
  
-       /* PCI (as opposed to PCIe) PME requires that the device have
-          its PME# line hooked up correctly. Not all hardware vendors
-          do this, so the PME never gets delivered and the device
-          remains asleep. The easiest way around this is to
-          periodically walk the list of suspended devices and check
-          whether any have their PME flag set. The assumption is that
-          we'll wake up often enough anyway that this won't be a huge
-          hit, and the power savings from the devices will still be a
-          win. */
+       /*
+        * PCI (as opposed to PCIe) PME requires that the device have
+        * its PME# line hooked up correctly. Not all hardware vendors
+        * do this, so the PME never gets delivered and the device
+        * remains asleep. The easiest way around this is to
+        * periodically walk the list of suspended devices and check
+        * whether any have their PME flag set. The assumption is that
+        * we'll wake up often enough anyway that this won't be a huge
+        * hit, and the power savings from the devices will still be a
+        * win.
+        *
+        * Although PCIe uses in-band PME message instead of PME# line
+        * to report PME, PME does not work for some PCIe devices in
+        * reality.  For example, there are devices that set their PME
+        * status bits, but don't really bother to send a PME message;
+        * there are PCI Express Root Ports that don't bother to
+        * trigger interrupts when they receive PME messages from the
+        * devices below.  So PME poll is used for PCIe devices too.
+        */
  
        if (dev->pme_poll) {
                struct pci_pme_device *pme_dev;
@@@ -1900,6 -1923,8 +1923,8 @@@ void pci_pm_init(struct pci_dev *dev
        u16 pmc;
  
        pm_runtime_forbid(&dev->dev);
+       pm_runtime_set_active(&dev->dev);
+       pm_runtime_enable(&dev->dev);
        device_enable_async_suspend(&dev->dev);
        dev->wakeup_prepared = false;
  
@@@ -3857,7 -3882,7 +3882,7 @@@ static int __init pci_resource_alignmen
  
  late_initcall(pci_resource_alignment_sysfs_init);
  
 -static void __devinit pci_no_domains(void)
 +static void pci_no_domains(void)
  {
  #ifdef CONFIG_PCI_DOMAINS
        pci_domains_supported = 0;
  }
  
  /**
-  * pci_ext_cfg_enabled - can we access extended PCI config space?
-  * @dev: The PCI device of the root bridge.
+  * pci_ext_cfg_avail - can we access extended PCI config space?
   *
   * Returns 1 if we can access PCI extended config space (offsets
   * greater than 0xff). This is the default implementation. Architecture
   * implementations can override this.
   */
- int __weak pci_ext_cfg_avail(struct pci_dev *dev)
+ int __weak pci_ext_cfg_avail(void)
  {
        return 1;
  }
diff --combined drivers/pci/pci.h
@@@ -8,6 -8,7 +8,6 @@@
  
  /* Functions internal to the PCI core code */
  
 -extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
  extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
  extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI)
@@@ -158,7 -159,12 +158,8 @@@ static inline int pci_no_d1d2(struct pc
  }
  extern struct device_attribute pci_dev_attrs[];
  extern struct device_attribute pcibus_dev_attrs[];
 -#ifdef CONFIG_HOTPLUG
+ extern struct device_type pci_dev_type;
  extern struct bus_attribute pci_bus_attrs[];
 -#else
 -#define pci_bus_attrs NULL
 -#endif
  
  
  /**
@@@ -229,13 -235,14 +230,14 @@@ struct pci_sriov 
        int nres;               /* number of resources */
        u32 cap;                /* SR-IOV Capabilities */
        u16 ctrl;               /* SR-IOV Control */
-       u16 total;              /* total VFs associated with the PF */
-       u16 initial;            /* initial VFs associated with the PF */
-       u16 nr_virtfn;          /* number of VFs available */
+       u16 total_VFs;          /* total VFs associated with the PF */
+       u16 initial_VFs;        /* initial VFs associated with the PF */
+       u16 num_VFs;            /* number of VFs available */
        u16 offset;             /* first VF Routing ID offset */
        u16 stride;             /* following VF stride */
        u32 pgsz;               /* page size for BAR alignment */
        u8 link;                /* Function Dependency Link */
+       u16 driver_max_VFs;     /* max num VFs driver supports */
        struct pci_dev *dev;    /* lowest numbered PF */
        struct pci_dev *self;   /* this PF */
        struct mutex lock;      /* lock for VF bus */
diff --combined drivers/pci/probe.c
@@@ -305,7 -305,7 +305,7 @@@ static void pci_read_bases(struct pci_d
        }
  }
  
 -static void __devinit pci_read_bridge_io(struct pci_bus *child)
 +static void pci_read_bridge_io(struct pci_bus *child)
  {
        struct pci_dev *dev = child->self;
        u8 io_base_lo, io_limit_lo;
        }
  }
  
 -static void __devinit pci_read_bridge_mmio(struct pci_bus *child)
 +static void pci_read_bridge_mmio(struct pci_bus *child)
  {
        struct pci_dev *dev = child->self;
        u16 mem_base_lo, mem_limit_lo;
        }
  }
  
 -static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
 +static void pci_read_bridge_mmio_pref(struct pci_bus *child)
  {
        struct pci_dev *dev = child->self;
        u16 mem_base_lo, mem_limit_lo;
        }
  }
  
 -void __devinit pci_read_bridge_bases(struct pci_bus *child)
 +void pci_read_bridge_bases(struct pci_bus *child)
  {
        struct pci_dev *dev = child->self;
        struct resource *res;
@@@ -521,7 -521,7 +521,7 @@@ static unsigned char pcie_link_speed[] 
  
  void pcie_update_link_speed(struct pci_bus *bus, u16 linksta)
  {
-       bus->cur_bus_speed = pcie_link_speed[linksta & 0xf];
+       bus->cur_bus_speed = pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS];
  }
  EXPORT_SYMBOL_GPL(pcie_update_link_speed);
  
@@@ -579,14 -579,16 +579,16 @@@ static void pci_set_bus_speed(struct pc
        if (pos) {
                u16 status;
                enum pci_bus_speed max;
-               pci_read_config_word(bridge, pos + 2, &status);
  
-               if (status & 0x8000) {
+               pci_read_config_word(bridge, pos + PCI_X_BRIDGE_SSTATUS,
+                                    &status);
+               if (status & PCI_X_SSTATUS_533MHZ) {
                        max = PCI_SPEED_133MHz_PCIX_533;
-               } else if (status & 0x4000) {
+               } else if (status & PCI_X_SSTATUS_266MHZ) {
                        max = PCI_SPEED_133MHz_PCIX_266;
-               } else if (status & 0x0002) {
-                       if (((status >> 12) & 0x3) == 2) {
+               } else if (status & PCI_X_SSTATUS_133MHZ) {
+                       if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2) {
                                max = PCI_SPEED_133MHz_PCIX_ECC;
                        } else {
                                max = PCI_SPEED_133MHz_PCIX;
                }
  
                bus->max_bus_speed = max;
-               bus->cur_bus_speed = pcix_bus_speed[(status >> 6) & 0xf];
+               bus->cur_bus_speed = pcix_bus_speed[
+                       (status & PCI_X_SSTATUS_FREQ) >> 6];
  
                return;
        }
                u16 linksta;
  
                pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap);
-               bus->max_bus_speed = pcie_link_speed[linkcap & 0xf];
+               bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS];
  
                pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta);
                pcie_update_link_speed(bus, linksta);
@@@ -705,7 -708,7 +708,7 @@@ static void pci_fixup_parent_subordinat
   * them, we proceed to assigning numbers to the remaining buses in
   * order to avoid overlaps between old and new bus numbers.
   */
 -int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
 +int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
  {
        struct pci_bus *child;
        int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
@@@ -975,6 -978,7 +978,7 @@@ int pci_setup_device(struct pci_dev *de
        dev->sysdata = dev->bus->sysdata;
        dev->dev.parent = dev->bus->bridge;
        dev->dev.bus = &pci_bus_type;
+       dev->dev.type = &pci_dev_type;
        dev->hdr_type = hdr_type & 0x7f;
        dev->multifunction = !!(hdr_type & 0x80);
        dev->error_state = pci_channel_io_normal;
@@@ -1586,7 -1590,7 +1590,7 @@@ void pcie_bus_configure_settings(struc
  }
  EXPORT_SYMBOL_GPL(pcie_bus_configure_settings);
  
 -unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
 +unsigned int pci_scan_child_bus(struct pci_bus *bus)
  {
        unsigned int devfn, pass, max = bus->busn_res.start;
        struct pci_dev *dev;
@@@ -1790,7 -1794,7 +1794,7 @@@ void pci_bus_release_busn_res(struct pc
                        res, ret ? "can not be" : "is");
  }
  
 -struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
 +struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
                struct pci_ops *ops, void *sysdata, struct list_head *resources)
  {
        struct pci_host_bridge_window *window;
  EXPORT_SYMBOL(pci_scan_root_bus);
  
  /* Deprecated; use pci_scan_root_bus() instead */
 -struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 +struct pci_bus *pci_scan_bus_parented(struct device *parent,
                int bus, struct pci_ops *ops, void *sysdata)
  {
        LIST_HEAD(resources);
  }
  EXPORT_SYMBOL(pci_scan_bus_parented);
  
 -struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
 +struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
                                        void *sysdata)
  {
        LIST_HEAD(resources);
  }
  EXPORT_SYMBOL(pci_scan_bus);
  
 -#ifdef CONFIG_HOTPLUG
  /**
   * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.
   * @bridge: PCI bridge for the bus to scan
@@@ -1889,10 -1894,33 +1893,32 @@@ unsigned int __ref pci_rescan_bus_bridg
        return max;
  }
  
+ /**
+  * pci_rescan_bus - scan a PCI bus for devices.
+  * @bus: PCI bus to scan
+  *
+  * Scan a PCI bus and child buses for new devices, adds them,
+  * and enables them.
+  *
+  * Returns the max number of subordinate bus discovered.
+  */
+ unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
+ {
+       unsigned int max;
+       max = pci_scan_child_bus(bus);
+       pci_assign_unassigned_bus_resources(bus);
+       pci_enable_bridges(bus);
+       pci_bus_add_devices(bus);
+       return max;
+ }
+ EXPORT_SYMBOL_GPL(pci_rescan_bus);
  EXPORT_SYMBOL(pci_add_new_bus);
  EXPORT_SYMBOL(pci_scan_slot);
  EXPORT_SYMBOL(pci_scan_bridge);
  EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 -#endif
  
  static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
  {
diff --combined drivers/pci/quirks.c
@@@ -37,7 -37,7 +37,7 @@@
   * key system devices. For devices that need to have mmio decoding always-on,
   * we need to set the dev->mmio_always_on bit.
   */
 -static void __devinit quirk_mmio_always_on(struct pci_dev *dev)
 +static void quirk_mmio_always_on(struct pci_dev *dev)
  {
        dev->mmio_always_on = 1;
  }
@@@ -48,7 -48,7 +48,7 @@@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_I
   * Mark this device with a broken_parity_status, to allow
   * PCI scanning code to "skip" this now blacklisted device.
   */
 -static void __devinit quirk_mellanox_tavor(struct pci_dev *dev)
 +static void quirk_mellanox_tavor(struct pci_dev *dev)
  {
        dev->broken_parity_status = 1;  /* This device gives false positives */
  }
@@@ -83,7 -83,7 +83,7 @@@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_
      This appears to be BIOS not version dependent. So presumably there is a 
      chipset level fix */
      
 -static void __devinit quirk_isa_dma_hangs(struct pci_dev *dev)
 +static void quirk_isa_dma_hangs(struct pci_dev *dev)
  {
        if (!isa_dma_bridge_buggy) {
                isa_dma_bridge_buggy=1;
@@@ -106,7 -106,7 +106,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_N
   * Intel NM10 "TigerPoint" LPC PM1a_STS.BM_STS must be clear
   * for some HT machines to use C4 w/o hanging.
   */
 -static void __devinit quirk_tigerpoint_bm_sts(struct pci_dev *dev)
 +static void quirk_tigerpoint_bm_sts(struct pci_dev *dev)
  {
        u32 pmbase;
        u16 pm1a;
@@@ -125,7 -125,7 +125,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
  /*
   *    Chipsets where PCI->PCI transfers vanish or hang
   */
 -static void __devinit quirk_nopcipci(struct pci_dev *dev)
 +static void quirk_nopcipci(struct pci_dev *dev)
  {
        if ((pci_pci_problems & PCIPCI_FAIL)==0) {
                dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n");
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,     PCI_DEVICE_ID_SI_5597,          quirk_nopcipci);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,     PCI_DEVICE_ID_SI_496,           quirk_nopcipci);
  
 -static void __devinit quirk_nopciamd(struct pci_dev *dev)
 +static void quirk_nopciamd(struct pci_dev *dev)
  {
        u8 rev;
        pci_read_config_byte(dev, 0x08, &rev);
@@@ -150,7 -150,7 +150,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
  /*
   *    Triton requires workarounds to be used by the drivers
   */
 -static void __devinit quirk_triton(struct pci_dev *dev)
 +static void quirk_triton(struct pci_dev *dev)
  {
        if ((pci_pci_problems&PCIPCI_TRITON)==0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@@ -229,7 -229,7 +229,7 @@@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_
  /*
   *    VIA Apollo VP3 needs ETBF on BT848/878
   */
 -static void __devinit quirk_viaetbf(struct pci_dev *dev)
 +static void quirk_viaetbf(struct pci_dev *dev)
  {
        if ((pci_pci_problems&PCIPCI_VIAETBF)==0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
  }
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,    PCI_DEVICE_ID_VIA_82C597_0,     quirk_viaetbf);
  
 -static void __devinit quirk_vsfx(struct pci_dev *dev)
 +static void quirk_vsfx(struct pci_dev *dev)
  {
        if ((pci_pci_problems&PCIPCI_VSFX)==0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@@ -253,7 -253,7 +253,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_V
   *    workaround applied too
   *    [Info kindly provided by ALi]
   */   
 -static void __devinit quirk_alimagik(struct pci_dev *dev)
 +static void quirk_alimagik(struct pci_dev *dev)
  {
        if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@@ -267,7 -267,7 +267,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
   *    Natoma has some interesting boundary conditions with Zoran stuff
   *    at least
   */
 -static void __devinit quirk_natoma(struct pci_dev *dev)
 +static void quirk_natoma(struct pci_dev *dev)
  {
        if ((pci_pci_problems&PCIPCI_NATOMA)==0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@@ -285,7 -285,7 +285,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_I
   *  This chip can cause PCI parity errors if config register 0xA0 is read
   *  while DMAs are occurring.
   */
 -static void __devinit quirk_citrine(struct pci_dev *dev)
 +static void quirk_citrine(struct pci_dev *dev)
  {
        dev->cfg_size = 0xA0;
  }
@@@ -295,7 -295,7 +295,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   *  S3 868 and 968 chips report region size equal to 32M, but they decode 64M.
   *  If it's needed, re-allocate the region.
   */
 -static void __devinit quirk_s3_64M(struct pci_dev *dev)
 +static void quirk_s3_64M(struct pci_dev *dev)
  {
        struct resource *r = &dev->resource[0];
  
@@@ -313,7 -313,7 +313,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * BAR0 should be 8 bytes; instead, it may be set to something like 8k
   * (which conflicts w/ BAR1's memory range).
   */
 -static void __devinit quirk_cs5536_vsa(struct pci_dev *dev)
 +static void quirk_cs5536_vsa(struct pci_dev *dev)
  {
        if (pci_resource_len(dev, 0) != 8) {
                struct resource *res = &dev->resource[0];
  }
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa);
  
 -static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,
 +static void quirk_io_region(struct pci_dev *dev, unsigned region,
        unsigned size, int nr, const char *name)
  {
        region &= ~(size-1);
   *    ATI Northbridge setups MCE the processor if you even
   *    read somewhere between 0x3b0->0x3bb or read 0x3d3
   */
 -static void __devinit quirk_ati_exploding_mce(struct pci_dev *dev)
 +static void quirk_ati_exploding_mce(struct pci_dev *dev)
  {
        dev_info(&dev->dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
        /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */
@@@ -372,7 -372,7 +372,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
   *    0xE0 (64 bytes of ACPI registers)
   *    0xE2 (32 bytes of SMB registers)
   */
 -static void __devinit quirk_ali7101_acpi(struct pci_dev *dev)
 +static void quirk_ali7101_acpi(struct pci_dev *dev)
  {
        u16 region;
  
@@@ -440,7 -440,7 +440,7 @@@ static void piix4_mem_quirk(struct pci_
   *    0x90 (16 bytes of SMB registers)
   * and a few strange programmable PIIX4 device resources.
   */
 -static void __devinit quirk_piix4_acpi(struct pci_dev *dev)
 +static void quirk_piix4_acpi(struct pci_dev *dev)
  {
        u32 region, res_a;
  
@@@ -489,7 -489,7 +489,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   *    0x40 (128 bytes of ACPI, GPIO & TCO registers)
   *    0x58 (64 bytes of GPIO I/O space)
   */
 -static void __devinit quirk_ich4_lpc_acpi(struct pci_dev *dev)
 +static void quirk_ich4_lpc_acpi(struct pci_dev *dev)
  {
        u32 region;
        u8 enable;
@@@ -531,7 -531,7 +531,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801EB_0,               quirk_ich4_lpc_acpi);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ESB_1,           quirk_ich4_lpc_acpi);
  
 -static void __devinit ich6_lpc_acpi_gpio(struct pci_dev *dev)
 +static void ich6_lpc_acpi_gpio(struct pci_dev *dev)
  {
        u32 region;
        u8 enable;
        }
  }
  
 -static void __devinit ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name, int dynsize)
 +static void ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name, int dynsize)
  {
        u32 val;
        u32 size, base;
        dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1);
  }
  
 -static void __devinit quirk_ich6_lpc(struct pci_dev *dev)
 +static void quirk_ich6_lpc(struct pci_dev *dev)
  {
        /* Shared ACPI/GPIO decode with all ICH6+ */
        ich6_lpc_acpi_gpio(dev);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc);
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc);
  
 -static void __devinit ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name)
 +static void ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name)
  {
        u32 val;
        u32 mask, base;
  }
  
  /* ICH7-10 has the same common LPC generic IO decode registers */
 -static void __devinit quirk_ich7_lpc(struct pci_dev *dev)
 +static void quirk_ich7_lpc(struct pci_dev *dev)
  {
        /* We share the common ACPI/GPIO decode with ICH6 */
        ich6_lpc_acpi_gpio(dev);
@@@ -648,7 -648,7 +648,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * VIA ACPI: One IO region pointed to by longword at
   *    0x48 or 0x20 (256 bytes of ACPI registers)
   */
 -static void __devinit quirk_vt82c586_acpi(struct pci_dev *dev)
 +static void quirk_vt82c586_acpi(struct pci_dev *dev)
  {
        u32 region;
  
@@@ -666,7 -666,7 +666,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   *    0x70 (128 bytes of hardware monitoring register)
   *    0x90 (16 bytes of SMB registers)
   */
 -static void __devinit quirk_vt82c686_acpi(struct pci_dev *dev)
 +static void quirk_vt82c686_acpi(struct pci_dev *dev)
  {
        u16 hm;
        u32 smb;
@@@ -688,7 -688,7 +688,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   *    0x88 (128 bytes of power management registers)
   *    0xd0 (16 bytes of SMB registers)
   */
 -static void __devinit quirk_vt8235_acpi(struct pci_dev *dev)
 +static void quirk_vt8235_acpi(struct pci_dev *dev)
  {
        u16 pm, smb;
  
@@@ -706,7 -706,7 +706,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * TI XIO2000a PCIe-PCI Bridge erroneously reports it supports fast back-to-back:
   *    Disable fast back-to-back on the secondary bus segment
   */
 -static void __devinit quirk_xio2000a(struct pci_dev *dev)
 +static void quirk_xio2000a(struct pci_dev *dev)
  {
        struct pci_dev *pdev;
        u16 command;
@@@ -780,7 -780,7 +780,7 @@@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VEND
   * noapic specified. For the moment we assume it's the erratum. We may be wrong
   * of course. However the advice is demonstrably good even if so..
   */
 -static void __devinit quirk_amd_ioapic(struct pci_dev *dev)
 +static void quirk_amd_ioapic(struct pci_dev *dev)
  {
        if (dev->revision >= 0x02) {
                dev_warn(&dev->dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n");
  }
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD,    PCI_DEVICE_ID_AMD_VIPER_7410,   quirk_amd_ioapic);
  
 -static void __devinit quirk_ioapic_rmw(struct pci_dev *dev)
 +static void quirk_ioapic_rmw(struct pci_dev *dev)
  {
        if (dev->devfn == 0 && dev->bus->number == 0)
                sis_apic_bug = 1;
@@@ -801,7 -801,7 +801,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_S
   * Some settings of MMRBC can lead to data corruption so block changes.
   * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide
   */
 -static void __devinit quirk_amd_8131_mmrbc(struct pci_dev *dev)
 +static void quirk_amd_8131_mmrbc(struct pci_dev *dev)
  {
        if (dev->subordinate && dev->revision <= 0x12) {
                dev_info(&dev->dev, "AMD8131 rev %x detected; "
@@@ -819,7 -819,7 +819,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
   * value of the ACPI SCI interrupt is only done for convenience.
   *    -jgarzik
   */
 -static void __devinit quirk_via_acpi(struct pci_dev *d)
 +static void quirk_via_acpi(struct pci_dev *d)
  {
        /*
         * VIA ACPI device: SCI IRQ line in PCI config byte 0x42
@@@ -926,7 -926,7 +926,7 @@@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_
   * We need to switch it off to be able to recognize the real
   * type of the chip.
   */
 -static void __devinit quirk_vt82c598_id(struct pci_dev *dev)
 +static void quirk_vt82c598_id(struct pci_dev *dev)
  {
        pci_write_config_byte(dev, 0xfc, 0);
        pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device);
@@@ -978,7 -978,7 +978,7 @@@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VEND
   *    assigned to it. We force a larger allocation to ensure that
   *    nothing gets put too close to it.
   */
 -static void __devinit quirk_dunord ( struct pci_dev * dev )
 +static void quirk_dunord(struct pci_dev *dev)
  {
        struct resource *r = &dev->resource [1];
        r->start = 0;
@@@ -992,7 -992,7 +992,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * in the ProgIf. Unfortunately, the ProgIf value is wrong - 0x80
   * instead of 0x01.
   */
 -static void __devinit quirk_transparent_bridge(struct pci_dev *dev)
 +static void quirk_transparent_bridge(struct pci_dev *dev)
  {
        dev->transparent = 1;
  }
@@@ -1066,7 -1066,7 +1066,7 @@@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VEND
  /*
   *    Serverworks CSB5 IDE does not fully support native mode
   */
 -static void __devinit quirk_svwks_csb5ide(struct pci_dev *pdev)
 +static void quirk_svwks_csb5ide(struct pci_dev *pdev)
  {
        u8 prog;
        pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog);
@@@ -1082,7 -1082,7 +1082,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_S
  /*
   *    Intel 82801CAM ICH3-M datasheet says IDE modes must be the same
   */
 -static void __devinit quirk_ide_samemode(struct pci_dev *pdev)
 +static void quirk_ide_samemode(struct pci_dev *pdev)
  {
        u8 prog;
  
@@@ -1101,7 -1101,7 +1101,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_I
   * Some ATA devices break if put into D3
   */
  
 -static void __devinit quirk_no_ata_d3(struct pci_dev *pdev)
 +static void quirk_no_ata_d3(struct pci_dev *pdev)
  {
        pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;
  }
@@@ -1121,7 -1121,7 +1121,7 @@@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDO
  /* This was originally an Alpha specific thing, but it really fits here.
   * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
   */
 -static void __devinit quirk_eisa_bridge(struct pci_dev *dev)
 +static void quirk_eisa_bridge(struct pci_dev *dev)
  {
        dev->class = PCI_CLASS_BRIDGE_EISA << 8;
  }
@@@ -1155,7 -1155,7 +1155,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   */
  static int asus_hides_smbus;
  
 -static void __devinit asus_hides_smbus_hostbridge(struct pci_dev *dev)
 +static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
  {
        if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {
                if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB)
@@@ -1538,7 -1538,7 +1538,7 @@@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VEND
  #endif
  
  #ifdef CONFIG_X86_IO_APIC
 -static void __devinit quirk_alder_ioapic(struct pci_dev *pdev)
 +static void quirk_alder_ioapic(struct pci_dev *pdev)
  {
        int i;
  
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC,      quirk_alder_ioapic);
  #endif
  
 -static void __devinit quirk_pcie_mch(struct pci_dev *pdev)
 +static void quirk_pcie_mch(struct pci_dev *pdev)
  {
        pci_msi_off(pdev);
        pdev->no_msi = 1;
@@@ -1575,7 -1575,7 +1575,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_I
   * It's possible for the MSI to get corrupted if shpc and acpi
   * are used together on certain PXH-based systems.
   */
 -static void __devinit quirk_pcie_pxh(struct pci_dev *dev)
 +static void quirk_pcie_pxh(struct pci_dev *dev)
  {
        pci_msi_off(dev);
        dev->no_msi = 1;
@@@ -1777,7 -1777,7 +1777,7 @@@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_
   * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes.
   * Re-allocate the region if needed...
   */
 -static void __devinit quirk_tc86c001_ide(struct pci_dev *dev)
 +static void quirk_tc86c001_ide(struct pci_dev *dev)
  {
        struct resource *r = &dev->resource[0];
  
@@@ -1790,7 -1790,46 +1790,46 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
                         PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE,
                         quirk_tc86c001_ide);
  
 -static void __devinit quirk_plx_pci9050(struct pci_dev *dev)
+ /*
+  * PLX PCI 9050 PCI Target bridge controller has an errata that prevents the
+  * local configuration registers accessible via BAR0 (memory) or BAR1 (i/o)
+  * being read correctly if bit 7 of the base address is set.
+  * The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128).
+  * Re-allocate the regions to a 256-byte boundary if necessary.
+  */
 -static void __devinit quirk_netmos(struct pci_dev *dev)
++static void quirk_plx_pci9050(struct pci_dev *dev)
+ {
+       unsigned int bar;
+       /* Fixed in revision 2 (PCI 9052). */
+       if (dev->revision >= 2)
+               return;
+       for (bar = 0; bar <= 1; bar++)
+               if (pci_resource_len(dev, bar) == 0x80 &&
+                   (pci_resource_start(dev, bar) & 0x80)) {
+                       struct resource *r = &dev->resource[bar];
+                       dev_info(&dev->dev,
+                                "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
+                                bar);
+                       r->start = 0;
+                       r->end = 0xff;
+               }
+ }
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+                        quirk_plx_pci9050);
+ /*
+  * The following Meilhaus (vendor ID 0x1402) device IDs (amongst others)
+  * may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b,
+  * 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c,
+  * 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b.
+  *
+  * Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq"
+  * driver.
+  */
+ DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2000, quirk_plx_pci9050);
+ DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2600, quirk_plx_pci9050);
 +static void quirk_netmos(struct pci_dev *dev)
  {
        unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
        unsigned int num_serial = dev->subsystem_device & 0xf;
  DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID,
                         PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos);
  
 -static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
 +static void quirk_e100_interrupt(struct pci_dev *dev)
  {
        u16 command, pmcsr;
        u8 __iomem *csr;
@@@ -1901,7 -1940,7 +1940,7 @@@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDO
   * The 82575 and 82598 may experience data corruption issues when transitioning
   * out of L0S.  To prevent this we need to disable L0S on the pci-e link
   */
 -static void __devinit quirk_disable_aspm_l0s(struct pci_dev *dev)
 +static void quirk_disable_aspm_l0s(struct pci_dev *dev)
  {
        dev_info(&dev->dev, "Disabling L0s\n");
        pci_disable_link_state(dev, PCIE_LINK_STATE_L0S);
@@@ -1921,7 -1960,7 +1960,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_I
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s);
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s);
  
 -static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
 +static void fixup_rev1_53c810(struct pci_dev *dev)
  {
        /* rev 1 ncr53c810 chips don't set the class at all which means
         * they don't get their resources remapped. Fix that here.
  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);
  
  /* Enable 1k I/O space granularity on the Intel P64H2 */
 -static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev)
 +static void quirk_p64h2_1k_io(struct pci_dev *dev)
  {
        u16 en1k;
  
@@@ -1968,7 -2007,7 +2007,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_N
  DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA,  PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
                        quirk_nvidia_ck804_pcie_aer_ext_cap);
  
 -static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
 +static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
  {
        /*
         * Disable PCI Bus Parking and PCI Master read caching on CX700
@@@ -2031,7 -2070,7 +2070,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_V
   * We believe that it is legal to read beyond the end tag and
   * therefore the solution is to limit the read/write length.
   */
 -static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev)
 +static void quirk_brcm_570x_limit_vpd(struct pci_dev *dev)
  {
        /*
         * Only disable the VPD capability for 5706, 5706S, 5708,
@@@ -2091,7 -2130,7 +2130,7 @@@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_
   * the DRBs - this is where we expose device 6.
   * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm
   */
 -static void __devinit quirk_unhide_mch_dev6(struct pci_dev *dev)
 +static void quirk_unhide_mch_dev6(struct pci_dev *dev)
  {
        u8 reg;
  
@@@ -2115,7 -2154,7 +2154,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_I
   * supports link speed auto negotiation, but falsely sets
   * the link speed to 5GT/s.
   */
 -static void __devinit quirk_tile_plx_gen1(struct pci_dev *dev)
 +static void quirk_tile_plx_gen1(struct pci_dev *dev)
  {
        if (tile_plx_gen1) {
                pci_write_config_dword(dev, 0x98, 0x1);
@@@ -2132,7 -2171,7 +2171,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_P
   * aware of it.  Instead of setting the flag on all busses in the
   * machine, simply disable MSI globally.
   */
 -static void __devinit quirk_disable_all_msi(struct pci_dev *dev)
 +static void quirk_disable_all_msi(struct pci_dev *dev)
  {
        pci_no_msi();
        dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n");
@@@ -2146,7 -2185,7 +2185,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_V
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8380_0, quirk_disable_all_msi);
  
  /* Disable MSI on chipsets that are known to not support it */
 -static void __devinit quirk_disable_msi(struct pci_dev *dev)
 +static void quirk_disable_msi(struct pci_dev *dev)
  {
        if (dev->subordinate) {
                dev_warn(&dev->dev, "MSI quirk detected; "
@@@ -2164,7 -2203,7 +2203,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
   * we use the possible vendor/device IDs of the host bridge for the
   * declared quirk, and search for the APC bridge by slot number.
   */
 -static void __devinit quirk_amd_780_apc_msi(struct pci_dev *host_bridge)
 +static void quirk_amd_780_apc_msi(struct pci_dev *host_bridge)
  {
        struct pci_dev *apc_bridge;
  
@@@ -2272,7 -2311,7 +2311,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * for the MCP55 NIC. It is not yet determined whether the msi problem
   * also affects other devices. As for now, turn off msi for this device.
   */
 -static void __devinit nvenet_msi_disable(struct pci_dev *dev)
 +static void nvenet_msi_disable(struct pci_dev *dev)
  {
        const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
  
@@@ -2298,7 -2337,7 +2337,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_N
   * we have it set correctly.
   * Note this is an undocumented register.
   */
 -static void __devinit nvbridge_check_legacy_irq_routing(struct pci_dev *dev)
 +static void nvbridge_check_legacy_irq_routing(struct pci_dev *dev)
  {
        u32 cfg;
  
@@@ -2534,11 -2573,11 +2573,11 @@@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VEND
  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all);
  DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all);
  
 -static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev)
 +static void quirk_msi_intx_disable_bug(struct pci_dev *dev)
  {
        dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;
  }
 -static void __devinit quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)
 +static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)
  {
        struct pci_dev *p;
  
@@@ -2612,7 -2651,7 +2651,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_A
   * kernel fails to allocate resources when hotplug device is 
   * inserted and PCI bus is rescanned.
   */
 -static void __devinit quirk_hotplug_bridge(struct pci_dev *dev)
 +static void quirk_hotplug_bridge(struct pci_dev *dev)
  {
        dev->is_hotplug_bridge = 1;
  }
@@@ -2752,7 -2791,7 +2791,7 @@@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_I
  DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors);
  #endif
  
 -static void __devinit fixup_ti816x_class(struct pci_dev* dev)
 +static void fixup_ti816x_class(struct pci_dev *dev)
  {
        /* TI 816x devices do not have class code set when in PCIe boot mode */
        dev_info(&dev->dev, "Setting PCI class for 816x PCIe device\n");
@@@ -2764,7 -2803,7 +2803,7 @@@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDO
  /* Some PCIe devices do not work reliably with the claimed maximum
   * payload size supported.
   */
 -static void __devinit fixup_mpss_256(struct pci_dev *dev)
 +static void fixup_mpss_256(struct pci_dev *dev)
  {
        dev->pcie_mpss = 1; /* 256 bytes */
  }
@@@ -2782,7 -2821,7 +2821,7 @@@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_
   * coalescing must be disabled.  Unfortunately, it cannot be re-enabled because
   * it is possible to hotplug a device with MPS of 256B.
   */
 -static void __devinit quirk_intel_mc_errata(struct pci_dev *dev)
 +static void quirk_intel_mc_errata(struct pci_dev *dev)
  {
        int err;
        u16 rcc;
@@@ -2888,7 -2927,7 +2927,7 @@@ static void fixup_debug_report(struct p
   * This resolves crashes often seen on monitor unplug.
   */
  #define I915_DEIER_REG 0x4400c
 -static void __devinit disable_igfx_irq(struct pci_dev *dev)
 +static void disable_igfx_irq(struct pci_dev *dev)
  {
        void __iomem *regs = pci_iomap(dev, 0, 0);
        if (regs == NULL) {
@@@ -2914,7 -2953,7 +2953,7 @@@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_I
   * PCI_COMMAND_INTX_DISABLE works though they actually do not properly
   * support this feature.
   */
 -static void __devinit quirk_broken_intx_masking(struct pci_dev *dev)
 +static void quirk_broken_intx_masking(struct pci_dev *dev)
  {
        dev->broken_intx_masking = 1;
  }
@@@ -412,7 -412,7 +412,7 @@@ static int pcifront_claim_resource(stru
        return 0;
  }
  
 -static int __devinit pcifront_scan_bus(struct pcifront_device *pdev,
 +static int pcifront_scan_bus(struct pcifront_device *pdev,
                                unsigned int domain, unsigned int bus,
                                struct pci_bus *b)
  {
        return 0;
  }
  
 -static int __devinit pcifront_scan_root(struct pcifront_device *pdev,
 +static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
  {
        struct pci_bus *b;
@@@ -503,7 -503,7 +503,7 @@@ err_out
        return err;
  }
  
 -static int __devinit pcifront_rescan_root(struct pcifront_device *pdev,
 +static int pcifront_rescan_root(struct pcifront_device *pdev,
                                   unsigned int domain, unsigned int bus)
  {
        int err;
@@@ -834,7 -834,7 +834,7 @@@ out
        return err;
  }
  
 -static int __devinit pcifront_try_connect(struct pcifront_device *pdev)
 +static int pcifront_try_connect(struct pcifront_device *pdev)
  {
        int err = -EFAULT;
        int i, num_roots, len;
@@@ -924,7 -924,7 +924,7 @@@ out
        return err;
  }
  
 -static int __devinit pcifront_attach_devices(struct pcifront_device *pdev)
 +static int pcifront_attach_devices(struct pcifront_device *pdev)
  {
        int err = -EFAULT;
        int i, num_roots, len;
@@@ -1068,13 -1068,16 +1068,16 @@@ static void __init_refok pcifront_backe
        case XenbusStateInitialising:
        case XenbusStateInitWait:
        case XenbusStateInitialised:
-       case XenbusStateClosed:
                break;
  
        case XenbusStateConnected:
                pcifront_try_connect(pdev);
                break;
  
+       case XenbusStateClosed:
+               if (xdev->state == XenbusStateClosed)
+                       break;
+               /* Missed the backend's CLOSING state -- fallthrough */
        case XenbusStateClosing:
                dev_warn(&xdev->dev, "backend going away!\n");
                pcifront_try_disconnect(pdev);
diff --combined include/linux/efi.h
@@@ -196,6 -196,77 +196,77 @@@ typedef struct 
        void *create_event_ex;
  } efi_boot_services_t;
  
+ typedef enum {
+       EfiPciIoWidthUint8,
+       EfiPciIoWidthUint16,
+       EfiPciIoWidthUint32,
+       EfiPciIoWidthUint64,
+       EfiPciIoWidthFifoUint8,
+       EfiPciIoWidthFifoUint16,
+       EfiPciIoWidthFifoUint32,
+       EfiPciIoWidthFifoUint64,
+       EfiPciIoWidthFillUint8,
+       EfiPciIoWidthFillUint16,
+       EfiPciIoWidthFillUint32,
+       EfiPciIoWidthFillUint64,
+       EfiPciIoWidthMaximum
+ } EFI_PCI_IO_PROTOCOL_WIDTH;
+ typedef enum {
+       EfiPciIoAttributeOperationGet,
+       EfiPciIoAttributeOperationSet,
+       EfiPciIoAttributeOperationEnable,
+       EfiPciIoAttributeOperationDisable,
+       EfiPciIoAttributeOperationSupported,
+     EfiPciIoAttributeOperationMaximum
+ } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
+ typedef struct {
+       void *read;
+       void *write;
+ } efi_pci_io_protocol_access_t;
+ typedef struct {
+       void *poll_mem;
+       void *poll_io;
+       efi_pci_io_protocol_access_t mem;
+       efi_pci_io_protocol_access_t io;
+       efi_pci_io_protocol_access_t pci;
+       void *copy_mem;
+       void *map;
+       void *unmap;
+       void *allocate_buffer;
+       void *free_buffer;
+       void *flush;
+       void *get_location;
+       void *attributes;
+       void *get_bar_attributes;
+       void *set_bar_attributes;
+       uint64_t romsize;
+       void *romimage;
+ } efi_pci_io_protocol;
+ #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
+ #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
+ #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
+ #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
+ #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
+ #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
+ #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
+ #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
+ #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
+ #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
+ #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
+ #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
+ #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
+ #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
+ #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
+ #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
+ #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
+ #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
+ #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
  /*
   * Types and defines for EFI ResetSystem
   */
@@@ -643,7 -714,6 +714,7 @@@ struct efivar_operations 
        efi_get_variable_t *get_variable;
        efi_get_next_variable_t *get_next_variable;
        efi_set_variable_t *set_variable;
 +      efi_query_variable_info_t *query_variable_info;
  };
  
  struct efivars {
diff --combined include/linux/pci.h
@@@ -333,6 -333,8 +333,8 @@@ struct pci_dev 
        };
        struct pci_ats  *ats;   /* Address Translation Service */
  #endif
+       phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
+       size_t romlen; /* Length of ROM if it's not from the BAR */
  };
  
  static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@@ -538,6 -540,9 +540,9 @@@ enum pci_ers_result 
  
        /* Device driver is fully recovered and operational */
        PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
+       /* No AER capabilities registered for the driver */
+       PCI_ERS_RESULT_NO_AER_DRIVER = (__force pci_ers_result_t) 6,
  };
  
  /* PCI bus error event callbacks */
@@@ -573,6 -578,7 +578,7 @@@ struct pci_driver 
        int  (*resume_early) (struct pci_dev *dev);
        int  (*resume) (struct pci_dev *dev);                   /* Device woken up */
        void (*shutdown) (struct pci_dev *dev);
+       int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */
        const struct pci_error_handlers *err_handler;
        struct device_driver    driver;
        struct pci_dynids dynids;
   * in a generic manner.
   */
  #define DEFINE_PCI_DEVICE_TABLE(_table) \
 -      const struct pci_device_id _table[] __devinitconst
 +      const struct pci_device_id _table[]
  
  /**
   * PCI_DEVICE - macro used to describe a specific pci device
        .vendor = (vend), .device = (dev), \
        .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
  
 +/**
 + * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
 + * @vend: the 16 bit PCI Vendor ID
 + * @dev: the 16 bit PCI Device ID
 + * @subvend: the 16 bit PCI Subvendor ID
 + * @subdev: the 16 bit PCI Subdevice ID
 + *
 + * This macro is used to create a struct pci_device_id that matches a
 + * specific device with subsystem information.
 + */
 +#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
 +      .vendor = (vend), .device = (dev), \
 +      .subvendor = (subvend), .subdevice = (subdev)
 +
  /**
   * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
   * @dev_class: the class, subclass, prog-if triple for this device
@@@ -700,7 -692,7 +706,7 @@@ struct pci_bus *pci_create_root_bus(str
  int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax);
  int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax);
  void pci_bus_release_busn_res(struct pci_bus *b);
 -struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,
 +struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,
                                             struct pci_ops *ops, void *sysdata,
                                             struct list_head *resources);
  struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
@@@ -726,6 -718,8 +732,8 @@@ extern struct pci_dev *pci_dev_get(stru
  extern void pci_dev_put(struct pci_dev *dev);
  extern void pci_remove_bus(struct pci_bus *b);
  extern void pci_stop_and_remove_bus_device(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);
  extern void pci_sort_breadthfirst(void);
  #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
@@@ -955,8 -949,10 +963,8 @@@ void set_pcie_hotplug_bridge(struct pci
  
  /* Functions for PCI Hotplug drivers to use */
  int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
 -#ifdef CONFIG_HOTPLUG
  unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge);
  unsigned int pci_rescan_bus(struct pci_bus *bus);
 -#endif
  
  /* Vital product data routines */
  ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
@@@ -970,6 -966,7 +978,7 @@@ void pci_bus_size_bridges(struct pci_bu
  int pci_claim_resource(struct pci_dev *, int);
  void pci_assign_unassigned_resources(void);
  void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge);
+ void pci_assign_unassigned_bus_resources(struct pci_bus *bus);
  void pdev_enable_device(struct pci_dev *);
  int pci_enable_resources(struct pci_dev *, int mask);
  void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
@@@ -1592,7 -1589,7 +1601,7 @@@ extern int pci_pci_problems
  
  extern unsigned long pci_cardbus_io_size;
  extern unsigned long pci_cardbus_mem_size;
 -extern u8 __devinitdata pci_dfl_cache_line_size;
 +extern u8 pci_dfl_cache_line_size;
  extern u8 pci_cache_line_size;
  
  extern unsigned long pci_hotplug_io_size;
@@@ -1604,6 -1601,7 +1613,7 @@@ void pcibios_disable_device(struct pci_
  void pcibios_set_master(struct pci_dev *dev);
  int pcibios_set_pcie_reset_state(struct pci_dev *dev,
                                 enum pcie_reset_state state);
+ int pcibios_add_device(struct pci_dev *dev);
  
  #ifdef CONFIG_PCI_MMCONFIG
  extern void __init pci_mmcfg_early_init(void);
@@@ -1613,7 -1611,7 +1623,7 @@@ static inline void pci_mmcfg_early_init
  static inline void pci_mmcfg_late_init(void) { }
  #endif
  
- int pci_ext_cfg_avail(struct pci_dev *dev);
+ int pci_ext_cfg_avail(void);
  
  void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
  
@@@ -1622,6 -1620,8 +1632,8 @@@ extern int pci_enable_sriov(struct pci_
  extern void pci_disable_sriov(struct pci_dev *dev);
  extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
  extern int pci_num_vf(struct pci_dev *dev);
+ extern int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
+ extern int pci_sriov_get_totalvfs(struct pci_dev *dev);
  #else
  static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
  {
@@@ -1638,6 -1638,14 +1650,14 @@@ static inline int pci_num_vf(struct pci
  {
        return 0;
  }
+ static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
+ {
+       return 0;
+ }
+ static inline int pci_sriov_get_totalvfs(struct pci_dev *dev)
+ {
+       return 0;
+ }
  #endif
  
  #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)