Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Dec 2009 20:18:16 +0000 (12:18 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Dec 2009 20:18:16 +0000 (12:18 -0800)
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (109 commits)
  PCI: fix coding style issue in pci_save_state()
  PCI: add pci_request_acs
  PCI: fix BUG_ON triggered by logical PCIe root port removal
  PCI: remove ifdefed pci_cleanup_aer_correct_error_status
  PCI: unconditionally clear AER uncorr status register during cleanup
  x86/PCI: claim SR-IOV BARs in pcibios_allocate_resource
  PCI: portdrv: remove redundant definitions
  PCI: portdrv: remove unnecessary struct pcie_port_data
  PCI: portdrv: minor cleanup for pcie_port_device_register
  PCI: portdrv: add missing irq cleanup
  PCI: portdrv: enable device before irq initialization
  PCI: portdrv: cleanup service irqs initialization
  PCI: portdrv: check capabilities first
  PCI: portdrv: move PME capability check
  PCI: portdrv: remove redundant pcie type calculation
  PCI: portdrv: cleanup pcie_device registration
  PCI: portdrv: remove redundant pcie_port_device_probe
  PCI: Always set prefetchable base/limit upper32 registers
  PCI: read-modify-write the pcie device control register when initiating pcie flr
  PCI: show dma_mask bits in /sys
  ...

Fixed up conflicts in:
arch/x86/kernel/amd_iommu_init.c
drivers/pci/dmar.c
drivers/pci/hotplug/acpiphp_glue.c

13 files changed:
1  2 
arch/x86/kernel/amd_iommu_init.c
arch/x86/xen/enlighten.c
drivers/char/hvc_xen.c
drivers/pci/dmar.c
drivers/pci/hotplug/acpi_pcihp.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/intel-iommu.c
drivers/pci/intr_remapping.c
drivers/pcmcia/cardbus.c
drivers/video/xen-fbfront.c
drivers/xen/balloon.c
drivers/xen/cpu_hotplug.c
drivers/xen/xenbus/xenbus_probe.c

@@@ -1,5 -1,5 +1,5 @@@
  /*
 - * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
 + * Copyright (C) 2007-2009 Advanced Micro Devices, Inc.
   * Author: Joerg Roedel <joerg.roedel@amd.com>
   *         Leo Duran <leo.duran@amd.com>
   *
  #include <linux/interrupt.h>
  #include <linux/msi.h>
  #include <asm/pci-direct.h>
 +#include <asm/amd_iommu_proto.h>
  #include <asm/amd_iommu_types.h>
  #include <asm/amd_iommu.h>
  #include <asm/iommu.h>
  #include <asm/gart.h>
 +#include <asm/x86_init.h>
  
  /*
   * definitions for the ACPI scanning code
@@@ -125,24 -123,18 +125,24 @@@ u16 amd_iommu_last_bdf;                 /* largest PC
                                           to handle */
  LIST_HEAD(amd_iommu_unity_map);               /* a list of required unity mappings
                                           we find in ACPI */
 -#ifdef CONFIG_IOMMU_STRESS
 -bool amd_iommu_isolate = false;
 -#else
 -bool amd_iommu_isolate = true;                /* if true, device isolation is
 -                                         enabled */
 -#endif
 -
  bool amd_iommu_unmap_flush;           /* if true, flush on every unmap */
  
  LIST_HEAD(amd_iommu_list);            /* list of all AMD IOMMUs in the
                                           system */
  
 +/* Array to assign indices to IOMMUs*/
 +struct amd_iommu *amd_iommus[MAX_IOMMUS];
 +int amd_iommus_present;
 +
 +/* IOMMUs have a non-present cache? */
 +bool amd_iommu_np_cache __read_mostly;
 +
 +/*
 + * List of protection domains - used during resume
 + */
 +LIST_HEAD(amd_iommu_pd_list);
 +spinlock_t amd_iommu_pd_lock;
 +
  /*
   * Pointer to the device table which is shared by all AMD IOMMUs
   * it is indexed by the PCI device id or the HT unit id and contains
@@@ -165,6 -157,12 +165,6 @@@ u16 *amd_iommu_alias_table
  struct amd_iommu **amd_iommu_rlookup_table;
  
  /*
 - * The pd table (protection domain table) is used to find the protection domain
 - * data structure a device belongs to. Indexed with the PCI device id too.
 - */
 -struct protection_domain **amd_iommu_pd_table;
 -
 -/*
   * AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap
   * to know which ones are already in use.
   */
@@@ -242,7 -240,7 +242,7 @@@ static void iommu_feature_enable(struc
        writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET);
  }
  
 -static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
 +static void iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
  {
        u32 ctrl;
  
@@@ -521,26 -519,6 +521,26 @@@ static void set_dev_entry_bit(u16 devid
        amd_iommu_dev_table[devid].data[i] |= (1 << _bit);
  }
  
 +static int get_dev_entry_bit(u16 devid, u8 bit)
 +{
 +      int i = (bit >> 5) & 0x07;
 +      int _bit = bit & 0x1f;
 +
 +      return (amd_iommu_dev_table[devid].data[i] & (1 << _bit)) >> _bit;
 +}
 +
 +
 +void amd_iommu_apply_erratum_63(u16 devid)
 +{
 +      int sysmgt;
 +
 +      sysmgt = get_dev_entry_bit(devid, DEV_ENTRY_SYSMGT1) |
 +               (get_dev_entry_bit(devid, DEV_ENTRY_SYSMGT2) << 1);
 +
 +      if (sysmgt == 0x01)
 +              set_dev_entry_bit(devid, DEV_ENTRY_IW);
 +}
 +
  /* Writes the specific IOMMU for a device into the rlookup table */
  static void __init set_iommu_for_device(struct amd_iommu *iommu, u16 devid)
  {
@@@ -569,8 -547,6 +569,8 @@@ static void __init set_dev_entry_from_a
        if (flags & ACPI_DEVFLAG_LINT1)
                set_dev_entry_bit(devid, DEV_ENTRY_LINT1_PASS);
  
 +      amd_iommu_apply_erratum_63(devid);
 +
        set_iommu_for_device(iommu, devid);
  }
  
@@@ -840,18 -816,7 +840,18 @@@ static void __init free_iommu_all(void
  static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
  {
        spin_lock_init(&iommu->lock);
 +
 +      /* Add IOMMU to internal data structures */
        list_add_tail(&iommu->list, &amd_iommu_list);
 +      iommu->index             = amd_iommus_present++;
 +
 +      if (unlikely(iommu->index >= MAX_IOMMUS)) {
 +              WARN(1, "AMD-Vi: System has more IOMMUs than supported by this driver\n");
 +              return -ENOSYS;
 +      }
 +
 +      /* Index is fine - add IOMMU to the array */
 +      amd_iommus[iommu->index] = iommu;
  
        /*
         * Copy data from ACPI table entry to the iommu struct
        init_iommu_from_acpi(iommu, h);
        init_iommu_devices(iommu);
  
 +      if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE))
 +              amd_iommu_np_cache = true;
 +
        return pci_enable_device(iommu->dev);
  }
  
@@@ -941,7 -903,7 +941,7 @@@ static int __init init_iommu_all(struc
   *
   ****************************************************************************/
  
 -static int __init iommu_setup_msi(struct amd_iommu *iommu)
 +static int iommu_setup_msi(struct amd_iommu *iommu)
  {
        int r;
  
@@@ -1192,10 -1154,19 +1192,10 @@@ static struct sys_device device_amd_iom
   * functions. Finally it prints some information about AMD IOMMUs and
   * the driver state and enables the hardware.
   */
 -int __init amd_iommu_init(void)
 +static int __init amd_iommu_init(void)
  {
        int i, ret = 0;
  
 -
 -      if (no_iommu) {
 -              printk(KERN_INFO "AMD-Vi disabled by kernel command line\n");
 -              return 0;
 -      }
 -
 -      if (!amd_iommu_detected)
 -              return -ENODEV;
 -
        /*
         * First parse ACPI tables to find the largest Bus/Dev/Func
         * we need to handle. Upon this information the shared data
        if (amd_iommu_rlookup_table == NULL)
                goto free;
  
 -      /*
 -       * Protection Domain table - maps devices to protection domains
 -       * This table has the same size as the rlookup_table
 -       */
 -      amd_iommu_pd_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
 -                                   get_order(rlookup_table_size));
 -      if (amd_iommu_pd_table == NULL)
 -              goto free;
 -
        amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages(
                                            GFP_KERNEL | __GFP_ZERO,
                                            get_order(MAX_DOMAIN_ID/8));
         */
        amd_iommu_pd_alloc_bitmap[0] = 1;
  
 +      spin_lock_init(&amd_iommu_pd_lock);
 +
        /*
         * now the data structures are allocated and basically initialized
         * start the real acpi table scan
        if (iommu_pass_through)
                goto out;
  
 -      printk(KERN_INFO "AMD-Vi: device isolation ");
 -      if (amd_iommu_isolate)
 -              printk("enabled\n");
 -      else
 -              printk("disabled\n");
 -
        if (amd_iommu_unmap_flush)
                printk(KERN_INFO "AMD-Vi: IO/TLB flush on unmap enabled\n");
        else
                printk(KERN_INFO "AMD-Vi: Lazy IO/TLB flushing enabled\n");
  
 +      x86_platform.iommu_shutdown = disable_iommus;
  out:
        return ret;
  
@@@ -1299,6 -1282,9 +1299,6 @@@ free
        free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
                   get_order(MAX_DOMAIN_ID/8));
  
 -      free_pages((unsigned long)amd_iommu_pd_table,
 -                 get_order(rlookup_table_size));
 -
        free_pages((unsigned long)amd_iommu_rlookup_table,
                   get_order(rlookup_table_size));
  
        goto out;
  }
  
 -void amd_iommu_shutdown(void)
 -{
 -      disable_iommus();
 -}
 -
  /****************************************************************************
   *
   * Early detect code. This code runs at IOMMU detection time in the DMA
@@@ -1329,13 -1320,18 +1329,16 @@@ static int __init early_amd_iommu_detec
  
  void __init amd_iommu_detect(void)
  {
 -      if (swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture))
 +      if (no_iommu || (iommu_detected && !gart_iommu_aperture))
                return;
  
        if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
                iommu_detected = 1;
                amd_iommu_detected = 1;
 -#ifdef CONFIG_GART_IOMMU
 -              gart_iommu_aperture_disabled = 1;
 -              gart_iommu_aperture = 0;
 -#endif
 +              x86_init.iommu.iommu_init = amd_iommu_init;
++
+               /* Make sure ACS will be enabled */
+               pci_request_acs();
        }
  }
  
@@@ -1356,6 -1352,10 +1359,6 @@@ static int __init parse_amd_iommu_dump(
  static int __init parse_amd_iommu_options(char *str)
  {
        for (; *str; ++str) {
 -              if (strncmp(str, "isolate", 7) == 0)
 -                      amd_iommu_isolate = true;
 -              if (strncmp(str, "share", 5) == 0)
 -                      amd_iommu_isolate = false;
                if (strncmp(str, "fullflush", 9) == 0)
                        amd_iommu_unmap_flush = true;
        }
diff --combined arch/x86/xen/enlighten.c
@@@ -27,7 -27,9 +27,9 @@@
  #include <linux/page-flags.h>
  #include <linux/highmem.h>
  #include <linux/console.h>
+ #include <linux/pci.h>
  
+ #include <xen/xen.h>
  #include <xen/interface/xen.h>
  #include <xen/interface/version.h>
  #include <xen/interface/physdev.h>
@@@ -138,23 -140,24 +140,23 @@@ static void xen_vcpu_setup(int cpu
   */
  void xen_vcpu_restore(void)
  {
 -      if (have_vcpu_info_placement) {
 -              int cpu;
 +      int cpu;
  
 -              for_each_online_cpu(cpu) {
 -                      bool other_cpu = (cpu != smp_processor_id());
 +      for_each_online_cpu(cpu) {
 +              bool other_cpu = (cpu != smp_processor_id());
  
 -                      if (other_cpu &&
 -                          HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL))
 -                              BUG();
 +              if (other_cpu &&
 +                  HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL))
 +                      BUG();
  
 -                      xen_vcpu_setup(cpu);
 +              xen_setup_runstate_info(cpu);
  
 -                      if (other_cpu &&
 -                          HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL))
 -                              BUG();
 -              }
 +              if (have_vcpu_info_placement)
 +                      xen_vcpu_setup(cpu);
  
 -              BUG_ON(!have_vcpu_info_placement);
 +              if (other_cpu &&
 +                  HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL))
 +                      BUG();
        }
  }
  
@@@ -177,7 -180,6 +179,7 @@@ static __read_mostly unsigned int cpuid
  static void xen_cpuid(unsigned int *ax, unsigned int *bx,
                      unsigned int *cx, unsigned int *dx)
  {
 +      unsigned maskebx = ~0;
        unsigned maskecx = ~0;
        unsigned maskedx = ~0;
  
         * Mask out inconvenient features, to try and disable as many
         * unsupported kernel subsystems as possible.
         */
 -      if (*ax == 1) {
 +      switch (*ax) {
 +      case 1:
                maskecx = cpuid_leaf1_ecx_mask;
                maskedx = cpuid_leaf1_edx_mask;
 +              break;
 +
 +      case 0xb:
 +              /* Suppress extended topology stuff */
 +              maskebx = 0;
 +              break;
        }
  
        asm(XEN_EMULATE_PREFIX "cpuid"
                  "=d" (*dx)
                : "0" (*ax), "2" (*cx));
  
 +      *bx &= maskebx;
        *cx &= maskecx;
        *dx &= maskedx;
  }
@@@ -1092,8 -1086,10 +1094,8 @@@ asmlinkage void __init xen_start_kernel
  
        __supported_pte_mask |= _PAGE_IOMAP;
  
 -#ifdef CONFIG_X86_64
        /* Work out if we support NX */
 -      check_efer();
 -#endif
 +      x86_configure_nx();
  
        xen_setup_features();
  
                add_preferred_console("xenboot", 0, NULL);
                add_preferred_console("tty", 0, NULL);
                add_preferred_console("hvc", 0, NULL);
+       } else {
+               /* Make sure ACS will be enabled */
+               pci_request_acs();
        }
+               
  
        xen_raw_console_write("about to get started...\n");
  
 +      xen_setup_runstate_info(0);
 +
        /* Start the world */
  #ifdef CONFIG_X86_32
        i386_start_kernel();
diff --combined drivers/char/hvc_xen.c
@@@ -25,6 -25,8 +25,8 @@@
  #include <linux/types.h>
  
  #include <asm/xen/hypervisor.h>
+ #include <xen/xen.h>
  #include <xen/page.h>
  #include <xen/events.h>
  #include <xen/interface/io/console.h>
@@@ -55,7 -57,7 +57,7 @@@ static inline void notify_daemon(void
        notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
  }
  
 -static int write_console(uint32_t vtermno, const char *data, int len)
 +static int __write_console(const char *data, int len)
  {
        struct xencons_interface *intf = xencons_interface();
        XENCONS_RING_IDX cons, prod;
        return sent;
  }
  
 +static int write_console(uint32_t vtermno, const char *data, int len)
 +{
 +      int ret = len;
 +
 +      /*
 +       * Make sure the whole buffer is emitted, polling if
 +       * necessary.  We don't ever want to rely on the hvc daemon
 +       * because the most interesting console output is when the
 +       * kernel is crippled.
 +       */
 +      while (len) {
 +              int sent = __write_console(data, len);
 +              
 +              data += sent;
 +              len -= sent;
 +
 +              if (unlikely(len))
 +                      HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
 +      }
 +
 +      return ret;
 +}
 +
  static int read_console(uint32_t vtermno, char *buf, int len)
  {
        struct xencons_interface *intf = xencons_interface();
diff --combined drivers/pci/dmar.c
@@@ -175,6 -175,15 +175,6 @@@ dmar_parse_one_drhd(struct acpi_dmar_he
        int ret = 0;
  
        drhd = (struct acpi_dmar_hardware_unit *)header;
 -      if (!drhd->address) {
 -              /* Promote an attitude of violence to a BIOS engineer today */
 -              WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
 -                   "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
 -                   dmi_get_system_info(DMI_BIOS_VENDOR),
 -                   dmi_get_system_info(DMI_BIOS_VERSION),
 -                   dmi_get_system_info(DMI_PRODUCT_VERSION));
 -              return -ENODEV;
 -      }
        dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL);
        if (!dmaru)
                return -ENOMEM;
@@@ -320,7 -329,7 +320,7 @@@ found
        for (bus = dev->bus; bus; bus = bus->parent) {
                struct pci_dev *bridge = bus->self;
  
-               if (!bridge || !bridge->is_pcie ||
+               if (!bridge || !pci_is_pcie(bridge) ||
                    bridge->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE)
                        return 0;
  
@@@ -582,53 -591,12 +582,53 @@@ int __init dmar_table_init(void
        return 0;
  }
  
 +int __init check_zero_address(void)
 +{
 +      struct acpi_table_dmar *dmar;
 +      struct acpi_dmar_header *entry_header;
 +      struct acpi_dmar_hardware_unit *drhd;
 +
 +      dmar = (struct acpi_table_dmar *)dmar_tbl;
 +      entry_header = (struct acpi_dmar_header *)(dmar + 1);
 +
 +      while (((unsigned long)entry_header) <
 +                      (((unsigned long)dmar) + dmar_tbl->length)) {
 +              /* Avoid looping forever on bad ACPI tables */
 +              if (entry_header->length == 0) {
 +                      printk(KERN_WARNING PREFIX
 +                              "Invalid 0-length structure\n");
 +                      return 0;
 +              }
 +
 +              if (entry_header->type == ACPI_DMAR_TYPE_HARDWARE_UNIT) {
 +                      drhd = (void *)entry_header;
 +                      if (!drhd->address) {
 +                              /* Promote an attitude of violence to a BIOS engineer today */
 +                              WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
 +                                   "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
 +                                   dmi_get_system_info(DMI_BIOS_VENDOR),
 +                                   dmi_get_system_info(DMI_BIOS_VERSION),
 +                                   dmi_get_system_info(DMI_PRODUCT_VERSION));
 +#ifdef CONFIG_DMAR
 +                              dmar_disabled = 1;
 +#endif
 +                              return 0;
 +                      }
 +                      break;
 +              }
 +
 +              entry_header = ((void *)entry_header + entry_header->length);
 +      }
 +      return 1;
 +}
 +
  void __init detect_intel_iommu(void)
  {
        int ret;
  
        ret = dmar_table_detect();
 -
 +      if (ret)
 +              ret = check_zero_address();
        {
  #ifdef CONFIG_INTR_REMAP
                struct acpi_table_dmar *dmar;
                               "x2apic and Intr-remapping.\n");
  #endif
  #ifdef CONFIG_DMAR
-               if (ret && !no_iommu && !iommu_detected && !dmar_disabled)
 -              if (ret && !no_iommu && !iommu_detected && !swiotlb &&
 -                  !dmar_disabled) {
++              if (ret && !no_iommu && !iommu_detected && !dmar_disabled) {
                        iommu_detected = 1;
+                       /* Make sure ACS will be enabled */
+                       pci_request_acs();
+               }
  #endif
 +#ifdef CONFIG_X86
 +              if (ret)
 +                      x86_init.iommu.iommu_init = intel_iommu_init;
 +#endif
        }
        early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size);
        dmar_tbl = NULL;
@@@ -362,6 -362,8 +362,8 @@@ int acpi_get_hp_hw_control_from_firmwar
                status = acpi_pci_osc_control_set(handle, flags);
                if (ACPI_SUCCESS(status))
                        goto got_one;
+               if (status == AE_SUPPORT)
+                       goto no_control;
                kfree(string.pointer);
                string = (struct acpi_buffer){ ACPI_ALLOCATE_BUFFER, NULL };
        }
                if (ACPI_FAILURE(status))
                        break;
        }
+ no_control:
        dbg("Cannot get control of hotplug hardware for pci %s\n",
            pci_name(pdev));
        kfree(string.pointer);
        return -ENODEV;
  got_one:
@@@ -471,7 -472,7 +472,7 @@@ int acpi_pci_detect_ejectable(acpi_hand
                return found;
  
        acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
 -                          check_hotplug, (void *)&found, NULL);
 +                          check_hotplug, NULL, (void *)&found, NULL);
        return found;
  }
  EXPORT_SYMBOL_GPL(acpi_pci_detect_ejectable);
@@@ -52,8 -52,6 +52,6 @@@
  #include "acpiphp.h"
  
  static LIST_HEAD(bridge_list);
- static LIST_HEAD(ioapic_list);
- static DEFINE_SPINLOCK(ioapic_list_lock);
  
  #define MY_NAME "acpiphp_glue"
  
@@@ -266,7 -264,7 +264,7 @@@ static int detect_ejectable_slots(acpi_
        int found = acpi_pci_detect_ejectable(handle);
        if (!found) {
                acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
 -                                  is_pci_dock_device, (void *)&found, NULL);
 +                                  is_pci_dock_device, NULL, (void *)&found, NULL);
        }
        return found;
  }
@@@ -281,7 -279,7 +279,7 @@@ static void init_bridge_misc(struct acp
  
        /* register all slot objects under this bridge */
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1,
 -                                   register_slot, bridge, NULL);
 +                                   register_slot, NULL, bridge, NULL);
        if (ACPI_FAILURE(status)) {
                list_del(&bridge->list);
                return;
  /* find acpiphp_func from acpiphp_bridge */
  static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle)
  {
-       struct list_head *node, *l;
        struct acpiphp_bridge *bridge;
        struct acpiphp_slot *slot;
        struct acpiphp_func *func;
  
-       list_for_each(node, &bridge_list) {
-               bridge = list_entry(node, struct acpiphp_bridge, list);
+       list_for_each_entry(bridge, &bridge_list, list) {
                for (slot = bridge->slots; slot; slot = slot->next) {
-                       list_for_each(l, &slot->funcs) {
-                               func = list_entry(l, struct acpiphp_func,
-                                                       sibling);
+                       list_for_each_entry(func, &slot->funcs, sibling) {
                                if (func->handle == handle)
                                        return func;
                        }
@@@ -447,7 -441,7 +441,7 @@@ find_p2p_bridge(acpi_handle handle, u3
  
        /* search P2P bridges under this p2p bridge */
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
 -                                   find_p2p_bridge, NULL, NULL);
 +                                   find_p2p_bridge, NULL, NULL, NULL);
        if (ACPI_FAILURE(status))
                warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
  
@@@ -485,7 -479,7 +479,7 @@@ static int add_bridge(acpi_handle handl
  
        /* search P2P bridges under this host bridge */
        status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
 -                                   find_p2p_bridge, NULL, NULL);
 +                                   find_p2p_bridge, NULL, NULL, NULL);
  
        if (ACPI_FAILURE(status))
                warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
  
  static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
  {
-       struct list_head *head;
-       list_for_each(head, &bridge_list) {
-               struct acpiphp_bridge *bridge = list_entry(head,
-                                               struct acpiphp_bridge, list);
+       struct acpiphp_bridge *bridge;
+       list_for_each_entry(bridge, &bridge_list, list)
                if (bridge->handle == handle)
                        return bridge;
-       }
  
        return NULL;
  }
  
  static void cleanup_bridge(struct acpiphp_bridge *bridge)
  {
-       struct list_head *list, *tmp;
-       struct acpiphp_slot *slot;
+       struct acpiphp_slot *slot, *next;
+       struct acpiphp_func *func, *tmp;
        acpi_status status;
        acpi_handle handle = bridge->handle;
  
  
        slot = bridge->slots;
        while (slot) {
-               struct acpiphp_slot *next = slot->next;
-               list_for_each_safe (list, tmp, &slot->funcs) {
-                       struct acpiphp_func *func;
-                       func = list_entry(list, struct acpiphp_func, sibling);
+               next = slot->next;
+               list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) {
                        if (is_dock_device(func->handle)) {
                                unregister_hotplug_dock_device(func->handle);
                                unregister_dock_notifier(&func->nb);
                                if (ACPI_FAILURE(status))
                                        err("failed to remove notify handler\n");
                        }
-                       list_del(list);
+                       list_del(&func->sibling);
                        kfree(func);
                }
                acpiphp_unregister_hotplug_slot(slot);
@@@ -573,7 -563,7 +563,7 @@@ cleanup_p2p_bridge(acpi_handle handle, 
        /* cleanup p2p bridges under this P2P bridge
           in a depth-first manner */
        acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
 -                              cleanup_p2p_bridge, NULL, NULL);
 +                              cleanup_p2p_bridge, NULL, NULL, NULL);
  
        bridge = acpiphp_handle_to_bridge(handle);
        if (bridge)
@@@ -589,7 -579,7 +579,7 @@@ static void remove_bridge(acpi_handle h
        /* cleanup p2p bridges under this host bridge
           in a depth-first manner */
        acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
 -                              (u32)1, cleanup_p2p_bridge, NULL, NULL);
 +                              (u32)1, cleanup_p2p_bridge, NULL, NULL, NULL);
  
        /*
         * On root bridges with hotplug slots directly underneath (ie,
                                           handle_hotplug_event_bridge);
  }
  
- static struct pci_dev * get_apic_pci_info(acpi_handle handle)
- {
-       struct pci_dev *dev;
-       dev = acpi_get_pci_dev(handle);
-       if (!dev)
-               return NULL;
-       if ((dev->class != PCI_CLASS_SYSTEM_PIC_IOAPIC) &&
-           (dev->class != PCI_CLASS_SYSTEM_PIC_IOXAPIC))
-       {
-               pci_dev_put(dev);
-               return NULL;
-       }
-       return dev;
- }
- static int get_gsi_base(acpi_handle handle, u32 *gsi_base)
- {
-       acpi_status status;
-       int result = -1;
-       unsigned long long gsb;
-       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
-       union acpi_object *obj;
-       void *table;
-       status = acpi_evaluate_integer(handle, "_GSB", NULL, &gsb);
-       if (ACPI_SUCCESS(status)) {
-               *gsi_base = (u32)gsb;
-               return 0;
-       }
-       status = acpi_evaluate_object(handle, "_MAT", NULL, &buffer);
-       if (ACPI_FAILURE(status) || !buffer.length || !buffer.pointer)
-               return -1;
-       obj = buffer.pointer;
-       if (obj->type != ACPI_TYPE_BUFFER)
-               goto out;
-       table = obj->buffer.pointer;
-       switch (((struct acpi_subtable_header *)table)->type) {
-       case ACPI_MADT_TYPE_IO_SAPIC:
-               *gsi_base = ((struct acpi_madt_io_sapic *)table)->global_irq_base;
-               result = 0;
-               break;
-       case ACPI_MADT_TYPE_IO_APIC:
-               *gsi_base = ((struct acpi_madt_io_apic *)table)->global_irq_base;
-               result = 0;
-               break;
-       default:
-               break;
-       }
-  out:
-       kfree(buffer.pointer);
-       return result;
- }
- static acpi_status
- ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv)
- {
-       acpi_status status;
-       unsigned long long sta;
-       acpi_handle tmp;
-       struct pci_dev *pdev;
-       u32 gsi_base;
-       u64 phys_addr;
-       struct acpiphp_ioapic *ioapic;
-       /* Evaluate _STA if present */
-       status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
-       if (ACPI_SUCCESS(status) && sta != ACPI_STA_ALL)
-               return AE_CTRL_DEPTH;
-       /* Scan only PCI bus scope */
-       status = acpi_get_handle(handle, "_HID", &tmp);
-       if (ACPI_SUCCESS(status))
-               return AE_CTRL_DEPTH;
-       if (get_gsi_base(handle, &gsi_base))
-               return AE_OK;
-       ioapic = kmalloc(sizeof(*ioapic), GFP_KERNEL);
-       if (!ioapic)
-               return AE_NO_MEMORY;
-       pdev = get_apic_pci_info(handle);
-       if (!pdev)
-               goto exit_kfree;
-       if (pci_enable_device(pdev))
-               goto exit_pci_dev_put;
-       pci_set_master(pdev);
-       if (pci_request_region(pdev, 0, "I/O APIC(acpiphp)"))
-               goto exit_pci_disable_device;
-       phys_addr = pci_resource_start(pdev, 0);
-       if (acpi_register_ioapic(handle, phys_addr, gsi_base))
-               goto exit_pci_release_region;
-       ioapic->gsi_base = gsi_base;
-       ioapic->dev = pdev;
-       spin_lock(&ioapic_list_lock);
-       list_add_tail(&ioapic->list, &ioapic_list);
-       spin_unlock(&ioapic_list_lock);
-       return AE_OK;
-  exit_pci_release_region:
-       pci_release_region(pdev, 0);
-  exit_pci_disable_device:
-       pci_disable_device(pdev);
-  exit_pci_dev_put:
-       pci_dev_put(pdev);
-  exit_kfree:
-       kfree(ioapic);
-       return AE_OK;
- }
- static acpi_status
- ioapic_remove(acpi_handle handle, u32 lvl, void *context, void **rv)
- {
-       acpi_status status;
-       unsigned long long sta;
-       acpi_handle tmp;
-       u32 gsi_base;
-       struct acpiphp_ioapic *pos, *n, *ioapic = NULL;
-       /* Evaluate _STA if present */
-       status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
-       if (ACPI_SUCCESS(status) && sta != ACPI_STA_ALL)
-               return AE_CTRL_DEPTH;
-       /* Scan only PCI bus scope */
-       status = acpi_get_handle(handle, "_HID", &tmp);
-       if (ACPI_SUCCESS(status))
-               return AE_CTRL_DEPTH;
-       if (get_gsi_base(handle, &gsi_base))
-               return AE_OK;
-       acpi_unregister_ioapic(handle, gsi_base);
-       spin_lock(&ioapic_list_lock);
-       list_for_each_entry_safe(pos, n, &ioapic_list, list) {
-               if (pos->gsi_base != gsi_base)
-                       continue;
-               ioapic = pos;
-               list_del(&ioapic->list);
-               break;
-       }
-       spin_unlock(&ioapic_list_lock);
-       if (!ioapic)
-               return AE_OK;
-       pci_release_region(ioapic->dev, 0);
-       pci_disable_device(ioapic->dev);
-       pci_dev_put(ioapic->dev);
-       kfree(ioapic);
-       return AE_OK;
- }
- static int acpiphp_configure_ioapics(acpi_handle handle)
- {
-       ioapic_add(handle, 0, NULL, NULL);
-       acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
-                           ACPI_UINT32_MAX, ioapic_add, NULL, NULL, NULL);
-       return 0;
- }
- static int acpiphp_unconfigure_ioapics(acpi_handle handle)
- {
-       ioapic_remove(handle, 0, NULL, NULL);
-       acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
-                           ACPI_UINT32_MAX, ioapic_remove, NULL, NULL, NULL);
-       return 0;
- }
  static int power_on_slot(struct acpiphp_slot *slot)
  {
        acpi_status status;
        struct acpiphp_func *func;
-       struct list_head *l;
        int retval = 0;
  
        /* if already enabled, just skip */
        if (slot->flags & SLOT_POWEREDON)
                goto err_exit;
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling) {
                if (func->flags & FUNC_HAS_PS0) {
                        dbg("%s: executing _PS0\n", __func__);
                        status = acpi_evaluate_object(func->handle, "_PS0", NULL, NULL);
@@@ -829,7 -632,6 +632,6 @@@ static int power_off_slot(struct acpiph
  {
        acpi_status status;
        struct acpiphp_func *func;
-       struct list_head *l;
  
        int retval = 0;
  
        if ((slot->flags & SLOT_POWEREDON) == 0)
                goto err_exit;
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling) {
                if (func->flags & FUNC_HAS_PS3) {
                        status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL);
                        if (ACPI_FAILURE(status)) {
@@@ -966,7 -766,6 +766,6 @@@ static int __ref enable_device(struct a
  {
        struct pci_dev *dev;
        struct pci_bus *bus = slot->bridge->pci_bus;
-       struct list_head *l;
        struct acpiphp_func *func;
        int retval = 0;
        int num, max, pass;
                }
        }
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling)
                acpiphp_bus_add(func);
-       }
  
        pci_bus_assign_resources(bus);
        acpiphp_sanitize_bus(bus);
        acpiphp_set_hpp_values(bus);
-       list_for_each_entry(func, &slot->funcs, sibling)
-               acpiphp_configure_ioapics(func->handle);
        pci_enable_bridges(bus);
        pci_bus_add_devices(bus);
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling) {
                dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
                                                  func->function));
                if (!dev)
@@@ -1091,7 -885,6 +885,6 @@@ static int disable_device(struct acpiph
        }
  
        list_for_each_entry(func, &slot->funcs, sibling) {
-               acpiphp_unconfigure_ioapics(func->handle);
                acpiphp_bus_trim(func->handle);
        }
  
@@@ -1119,12 -912,9 +912,9 @@@ static unsigned int get_slot_status(str
        acpi_status status;
        unsigned long long sta = 0;
        u32 dvid;
-       struct list_head *l;
        struct acpiphp_func *func;
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling) {
                if (func->flags & FUNC_HAS_STA) {
                        status = acpi_evaluate_integer(func->handle, "_STA", NULL, &sta);
                        if (ACPI_SUCCESS(status) && sta)
@@@ -1152,13 -942,10 +942,10 @@@ int acpiphp_eject_slot(struct acpiphp_s
  {
        acpi_status status;
        struct acpiphp_func *func;
-       struct list_head *l;
        struct acpi_object_list arg_list;
        union acpi_object arg;
  
-       list_for_each (l, &slot->funcs) {
-               func = list_entry(l, struct acpiphp_func, sibling);
+       list_for_each_entry(func, &slot->funcs, sibling) {
                /* We don't want to call _EJ0 on non-existing functions. */
                if ((func->flags & FUNC_HAS_EJ0)) {
                        /* _EJ0 method take one argument */
@@@ -1275,7 -1062,6 +1062,6 @@@ static int acpiphp_configure_bridge (ac
        acpiphp_sanitize_bus(bus);
        acpiphp_set_hpp_values(bus);
        pci_enable_bridges(bus);
-       acpiphp_configure_ioapics(handle);
        return 0;
  }
  
@@@ -1367,7 -1153,7 +1153,7 @@@ static void handle_hotplug_event_bridge
        bridge = acpiphp_handle_to_bridge(handle);
        if (type == ACPI_NOTIFY_BUS_CHECK) {
                acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, ACPI_UINT32_MAX,
 -                      count_sub_bridges, &num_sub_bridges, NULL);
 +                      count_sub_bridges, NULL, &num_sub_bridges, NULL);
        }
  
        if (!bridge && !num_sub_bridges) {
                }
                if (num_sub_bridges)
                        acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
 -                              ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL);
 +                              ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL);
                break;
  
        case ACPI_NOTIFY_DEVICE_CHECK:
@@@ -1512,7 -1298,7 +1298,7 @@@ int __init acpiphp_glue_init(void
        int num = 0;
  
        acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
 -                      ACPI_UINT32_MAX, find_root_bridges, &num, NULL);
 +                      ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
  
        if (num <= 0)
                return -1;
@@@ -1542,7 -1328,7 +1328,7 @@@ int __init acpiphp_get_num_slots(void
        struct acpiphp_bridge *bridge;
        int num_slots = 0;
  
-       list_for_each_entry (bridge, &bridge_list, list) {
+       list_for_each_entry(bridge, &bridge_list, list) {
                dbg("Bus %04x:%02x has %d slot%s\n",
                                pci_domain_nr(bridge->pci_bus),
                                bridge->pci_bus->number, bridge->nr_slots,
@@@ -1611,7 -1611,7 +1611,7 @@@ domain_context_mapping(struct dmar_doma
                        return ret;
                parent = parent->bus->self;
        }
-       if (tmp->is_pcie) /* this is a PCIE-to-PCI bridge */
+       if (pci_is_pcie(tmp)) /* this is a PCIE-to-PCI bridge */
                return domain_context_mapping_one(domain,
                                        pci_domain_nr(tmp->subordinate),
                                        tmp->subordinate->number, 0,
@@@ -1651,7 -1651,7 +1651,7 @@@ static int domain_context_mapped(struc
                        return ret;
                parent = parent->bus->self;
        }
-       if (tmp->is_pcie)
+       if (pci_is_pcie(tmp))
                return device_context_mapped(iommu, tmp->subordinate->number,
                                             0);
        else
@@@ -1821,7 -1821,7 +1821,7 @@@ static struct dmar_domain *get_domain_f
  
        dev_tmp = pci_find_upstream_pcie_bridge(pdev);
        if (dev_tmp) {
-               if (dev_tmp->is_pcie) {
+               if (pci_is_pcie(dev_tmp)) {
                        bus = dev_tmp->subordinate->number;
                        devfn = 0;
                } else {
@@@ -2182,7 -2182,7 +2182,7 @@@ static int iommu_should_identity_map(st
         * the 1:1 domain, just in _case_ one of their siblings turns out
         * not to be able to map all of memory.
         */
-       if (!pdev->is_pcie) {
+       if (!pci_is_pcie(pdev)) {
                if (!pci_is_root_bus(pdev->bus))
                        return 0;
                if (pdev->class >> 8 == PCI_CLASS_BRIDGE_PCI)
@@@ -2767,15 -2767,7 +2767,15 @@@ static void *intel_alloc_coherent(struc
  
        size = PAGE_ALIGN(size);
        order = get_order(size);
 -      flags &= ~(GFP_DMA | GFP_DMA32);
 +
 +      if (!iommu_no_mapping(hwdev))
 +              flags &= ~(GFP_DMA | GFP_DMA32);
 +      else if (hwdev->coherent_dma_mask < dma_get_required_mask(hwdev)) {
 +              if (hwdev->coherent_dma_mask < DMA_BIT_MASK(32))
 +                      flags |= GFP_DMA;
 +              else
 +                      flags |= GFP_DMA32;
 +      }
  
        vaddr = (void *)__get_free_pages(flags, order);
        if (!vaddr)
@@@ -3215,33 -3207,6 +3215,33 @@@ static int __init init_iommu_sysfs(void
  }
  #endif        /* CONFIG_PM */
  
 +/*
 + * Here we only respond to action of unbound device from driver.
 + *
 + * Added device is not attached to its DMAR domain here yet. That will happen
 + * when mapping the device to iova.
 + */
 +static int device_notifier(struct notifier_block *nb,
 +                                unsigned long action, void *data)
 +{
 +      struct device *dev = data;
 +      struct pci_dev *pdev = to_pci_dev(dev);
 +      struct dmar_domain *domain;
 +
 +      domain = find_domain(pdev);
 +      if (!domain)
 +              return 0;
 +
 +      if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through)
 +              domain_remove_one_dev_info(domain, pdev);
 +
 +      return 0;
 +}
 +
 +static struct notifier_block device_nb = {
 +      .notifier_call = device_notifier,
 +};
 +
  int __init intel_iommu_init(void)
  {
        int ret = 0;
         * Check the need for DMA-remapping initialization now.
         * Above initialization will also be used by Interrupt-remapping.
         */
 -      if (no_iommu || swiotlb || dmar_disabled)
 +      if (no_iommu || dmar_disabled)
                return -ENODEV;
  
        iommu_init_mempool();
        "PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n");
  
        init_timer(&unmap_timer);
 -      force_iommu = 1;
 +#ifdef CONFIG_SWIOTLB
 +      swiotlb = 0;
 +#endif
        dma_ops = &intel_dma_ops;
  
        init_iommu_sysfs();
  
        register_iommu(&intel_iommu_ops);
  
 +      bus_register_notifier(&pci_bus_type, &device_nb);
 +
        return 0;
  }
  
@@@ -3319,7 -3280,7 +3319,7 @@@ static void iommu_detach_dependent_devi
                                         parent->devfn);
                        parent = parent->bus->self;
                }
-               if (tmp->is_pcie) /* this is a PCIE-to-PCI bridge */
+               if (pci_is_pcie(tmp)) /* this is a PCIE-to-PCI bridge */
                        iommu_detach_dev(iommu,
                                tmp->subordinate->number, 0);
                else /* this is a legacy PCI bridge */
@@@ -2,7 -2,6 +2,7 @@@
  #include <linux/dmar.h>
  #include <linux/spinlock.h>
  #include <linux/jiffies.h>
 +#include <linux/hpet.h>
  #include <linux/pci.h>
  #include <linux/irq.h>
  #include <asm/io_apic.h>
@@@ -15,8 -14,7 +15,8 @@@
  #include "pci.h"
  
  static struct ioapic_scope ir_ioapic[MAX_IO_APICS];
 -static int ir_ioapic_num;
 +static struct hpet_scope ir_hpet[MAX_HPET_TBS];
 +static int ir_ioapic_num, ir_hpet_num;
  int intr_remapping_enabled;
  
  static int disable_intremap;
@@@ -345,16 -343,6 +345,16 @@@ int flush_irte(int irq
        return rc;
  }
  
 +struct intel_iommu *map_hpet_to_ir(u8 hpet_id)
 +{
 +      int i;
 +
 +      for (i = 0; i < MAX_HPET_TBS; i++)
 +              if (ir_hpet[i].id == hpet_id)
 +                      return ir_hpet[i].iommu;
 +      return NULL;
 +}
 +
  struct intel_iommu *map_ioapic_to_ir(int apic)
  {
        int i;
@@@ -482,36 -470,6 +482,36 @@@ int set_ioapic_sid(struct irte *irte, i
        return 0;
  }
  
 +int set_hpet_sid(struct irte *irte, u8 id)
 +{
 +      int i;
 +      u16 sid = 0;
 +
 +      if (!irte)
 +              return -1;
 +
 +      for (i = 0; i < MAX_HPET_TBS; i++) {
 +              if (ir_hpet[i].id == id) {
 +                      sid = (ir_hpet[i].bus << 8) | ir_hpet[i].devfn;
 +                      break;
 +              }
 +      }
 +
 +      if (sid == 0) {
 +              pr_warning("Failed to set source-id of HPET block (%d)\n", id);
 +              return -1;
 +      }
 +
 +      /*
 +       * Should really use SQ_ALL_16. Some platforms are broken.
 +       * While we figure out the right quirks for these broken platforms, use
 +       * SQ_13_IGNORE_3 for now.
 +       */
 +      set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_13_IGNORE_3, sid);
 +
 +      return 0;
 +}
 +
  int set_msi_sid(struct irte *irte, struct pci_dev *dev)
  {
        struct pci_dev *bridge;
                return -1;
  
        /* PCIe device or Root Complex integrated PCI device */
-       if (dev->is_pcie || !dev->bus->parent) {
+       if (pci_is_pcie(dev) || !dev->bus->parent) {
                set_irte_sid(irte, SVT_VERIFY_SID_SQ, SQ_ALL_16,
                             (dev->bus->number << 8) | dev->devfn);
                return 0;
  
        bridge = pci_find_upstream_pcie_bridge(dev);
        if (bridge) {
-               if (bridge->is_pcie) /* this is a PCIE-to-PCI/PCIX bridge */
+               if (pci_is_pcie(bridge))/* this is a PCIE-to-PCI/PCIX bridge */
                        set_irte_sid(irte, SVT_VERIFY_BUS, SQ_ALL_16,
                                (bridge->bus->number << 8) | dev->bus->number);
                else /* this is a legacy PCI bridge */
@@@ -753,34 -711,6 +753,34 @@@ error
        return -1;
  }
  
 +static void ir_parse_one_hpet_scope(struct acpi_dmar_device_scope *scope,
 +                                    struct intel_iommu *iommu)
 +{
 +      struct acpi_dmar_pci_path *path;
 +      u8 bus;
 +      int count;
 +
 +      bus = scope->bus;
 +      path = (struct acpi_dmar_pci_path *)(scope + 1);
 +      count = (scope->length - sizeof(struct acpi_dmar_device_scope))
 +              / sizeof(struct acpi_dmar_pci_path);
 +
 +      while (--count > 0) {
 +              /*
 +               * Access PCI directly due to the PCI
 +               * subsystem isn't initialized yet.
 +               */
 +              bus = read_pci_config_byte(bus, path->dev, path->fn,
 +                                         PCI_SECONDARY_BUS);
 +              path++;
 +      }
 +      ir_hpet[ir_hpet_num].bus   = bus;
 +      ir_hpet[ir_hpet_num].devfn = PCI_DEVFN(path->dev, path->fn);
 +      ir_hpet[ir_hpet_num].iommu = iommu;
 +      ir_hpet[ir_hpet_num].id    = scope->enumeration_id;
 +      ir_hpet_num++;
 +}
 +
  static void ir_parse_one_ioapic_scope(struct acpi_dmar_device_scope *scope,
                                      struct intel_iommu *iommu)
  {
        ir_ioapic_num++;
  }
  
 -static int ir_parse_ioapic_scope(struct acpi_dmar_header *header,
 -                               struct intel_iommu *iommu)
 +static int ir_parse_ioapic_hpet_scope(struct acpi_dmar_header *header,
 +                                    struct intel_iommu *iommu)
  {
        struct acpi_dmar_hardware_unit *drhd;
        struct acpi_dmar_device_scope *scope;
                               drhd->address);
  
                        ir_parse_one_ioapic_scope(scope, iommu);
 +              } else if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_HPET) {
 +                      if (ir_hpet_num == MAX_HPET_TBS) {
 +                              printk(KERN_WARNING "Exceeded Max HPET blocks\n");
 +                              return -1;
 +                      }
 +
 +                      printk(KERN_INFO "HPET id %d under DRHD base"
 +                             " 0x%Lx\n", scope->enumeration_id,
 +                             drhd->address);
 +
 +                      ir_parse_one_hpet_scope(scope, iommu);
                }
                start += scope->length;
        }
@@@ -866,7 -785,7 +866,7 @@@ int __init parse_ioapics_under_ir(void
                struct intel_iommu *iommu = drhd->iommu;
  
                if (ecap_ir_support(iommu->ecap)) {
 -                      if (ir_parse_ioapic_scope(drhd->hdr, iommu))
 +                      if (ir_parse_ioapic_hpet_scope(drhd->hdr, iommu))
                                return -1;
  
                        ir_supported = 1;
diff --combined drivers/pcmcia/cardbus.c
@@@ -91,7 -91,7 +91,7 @@@ static u_int xlate_rom_addr(void __iome
  static void cb_release_cis_mem(struct pcmcia_socket * s)
  {
        if (s->cb_cis_virt) {
 -              cs_dbg(s, 1, "cb_release_cis_mem()\n");
 +              dev_dbg(&s->dev, "cb_release_cis_mem()\n");
                iounmap(s->cb_cis_virt);
                s->cb_cis_virt = NULL;
                s->cb_cis_res = NULL;
@@@ -132,7 -132,7 +132,7 @@@ int read_cb_mem(struct pcmcia_socket * 
        struct pci_dev *dev;
        struct resource *res;
  
 -      cs_dbg(s, 3, "read_cb_mem(%d, %#x, %u)\n", space, addr, len);
 +      dev_dbg(&s->dev, "read_cb_mem(%d, %#x, %u)\n", space, addr, len);
  
        dev = pci_get_slot(s->cb_dev->subordinate, 0);
        if (!dev)
@@@ -184,26 -184,33 +184,33 @@@ fail
      
  =====================================================================*/
  
- /*
-  * Since there is only one interrupt available to CardBus
-  * devices, all devices downstream of this device must
-  * be using this IRQ.
-  */
- static void cardbus_assign_irqs(struct pci_bus *bus, int irq)
+ static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq)
  {
        struct pci_dev *dev;
  
        list_for_each_entry(dev, &bus->devices, bus_list) {
                u8 irq_pin;
  
+               /*
+                * Since there is only one interrupt available to
+                * CardBus devices, all devices downstream of this
+                * device must be using this IRQ.
+                */
                pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin);
                if (irq_pin) {
                        dev->irq = irq;
                        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
                }
  
+               /*
+                * Some controllers transfer very slowly with 0 CLS.
+                * Configure it.  This may fail as CLS configuration
+                * is mandatory only for MWI.
+                */
+               pci_set_cacheline_size(dev);
                if (dev->subordinate)
-                       cardbus_assign_irqs(dev->subordinate, irq);
+                       cardbus_config_irq_and_cls(dev->subordinate, irq);
        }
  }
  
@@@ -228,7 -235,7 +235,7 @@@ int __ref cb_alloc(struct pcmcia_socke
         */
        pci_bus_size_bridges(bus);
        pci_bus_assign_resources(bus);
-       cardbus_assign_irqs(bus, s->pci_irq);
+       cardbus_config_irq_and_cls(bus, s->pci_irq);
  
        /* socket specific tune function */
        if (s->tune_bridge)
  #include <linux/module.h>
  #include <linux/vmalloc.h>
  #include <linux/mm.h>
  #include <asm/xen/hypervisor.h>
+ #include <xen/xen.h>
  #include <xen/events.h>
  #include <xen/page.h>
  #include <xen/interface/io/fbif.h>
@@@ -440,7 -443,7 +443,7 @@@ static int __devinit xenfb_probe(struc
        fb_info->fix.type = FB_TYPE_PACKED_PIXELS;
        fb_info->fix.accel = FB_ACCEL_NONE;
  
 -      fb_info->flags = FBINFO_FLAG_DEFAULT;
 +      fb_info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB;
  
        ret = fb_alloc_cmap(&fb_info->cmap, 256, 0);
        if (ret < 0) {
diff --combined drivers/xen/balloon.c
@@@ -52,6 -52,8 +52,8 @@@
  
  #include <asm/xen/hypervisor.h>
  #include <asm/xen/hypercall.h>
+ #include <xen/xen.h>
  #include <xen/interface/xen.h>
  #include <xen/interface/memory.h>
  #include <xen/xenbus.h>
@@@ -66,6 -68,8 +68,6 @@@ struct balloon_stats 
        /* We aim for 'current allocation' == 'target allocation'. */
        unsigned long current_pages;
        unsigned long target_pages;
 -      /* We may hit the hard limit in Xen. If we do then we remember it. */
 -      unsigned long hard_limit;
        /*
         * Drivers may alter the memory reservation independently, but they
         * must inform the balloon driver so we avoid hitting the hard limit.
@@@ -134,8 -138,6 +136,8 @@@ static void balloon_append(struct page 
                list_add(&page->lru, &ballooned_pages);
                balloon_stats.balloon_low++;
        }
 +
 +      totalram_pages--;
  }
  
  /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */
@@@ -156,8 -158,6 +158,8 @@@ static struct page *balloon_retrieve(vo
        else
                balloon_stats.balloon_low--;
  
 +      totalram_pages++;
 +
        return page;
  }
  
@@@ -183,7 -183,7 +185,7 @@@ static void balloon_alarm(unsigned lon
  
  static unsigned long current_target(void)
  {
 -      unsigned long target = min(balloon_stats.target_pages, balloon_stats.hard_limit);
 +      unsigned long target = balloon_stats.target_pages;
  
        target = min(target,
                     balloon_stats.current_pages +
@@@ -219,10 -219,23 +221,10 @@@ static int increase_reservation(unsigne
        set_xen_guest_handle(reservation.extent_start, frame_list);
        reservation.nr_extents = nr_pages;
        rc = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
 -      if (rc < nr_pages) {
 -              if (rc > 0) {
 -                      int ret;
 -
 -                      /* We hit the Xen hard limit: reprobe. */
 -                      reservation.nr_extents = rc;
 -                      ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 -                                                 &reservation);
 -                      BUG_ON(ret != rc);
 -              }
 -              if (rc >= 0)
 -                      balloon_stats.hard_limit = (balloon_stats.current_pages + rc -
 -                                                  balloon_stats.driver_pages);
 +      if (rc < 0)
                goto out;
 -      }
  
 -      for (i = 0; i < nr_pages; i++) {
 +      for (i = 0; i < rc; i++) {
                page = balloon_retrieve();
                BUG_ON(page == NULL);
  
                __free_page(page);
        }
  
 -      balloon_stats.current_pages += nr_pages;
 -      totalram_pages = balloon_stats.current_pages;
 +      balloon_stats.current_pages += rc;
  
   out:
        spin_unlock_irqrestore(&balloon_lock, flags);
  
 -      return 0;
 +      return rc < 0 ? rc : rc != nr_pages;
  }
  
  static int decrease_reservation(unsigned long nr_pages)
        BUG_ON(ret != nr_pages);
  
        balloon_stats.current_pages -= nr_pages;
 -      totalram_pages = balloon_stats.current_pages;
  
        spin_unlock_irqrestore(&balloon_lock, flags);
  
@@@ -354,6 -369,7 +356,6 @@@ static void balloon_process(struct work
  static void balloon_set_new_target(unsigned long target)
  {
        /* No need for lock. Not read-modify-write updates. */
 -      balloon_stats.hard_limit   = ~0UL;
        balloon_stats.target_pages = target;
        schedule_work(&balloon_worker);
  }
@@@ -408,10 -424,12 +410,10 @@@ static int __init balloon_init(void
        pr_info("xen_balloon: Initialising balloon driver.\n");
  
        balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn);
 -      totalram_pages   = balloon_stats.current_pages;
        balloon_stats.target_pages  = balloon_stats.current_pages;
        balloon_stats.balloon_low   = 0;
        balloon_stats.balloon_high  = 0;
        balloon_stats.driver_pages  = 0UL;
 -      balloon_stats.hard_limit    = ~0UL;
  
        init_timer(&balloon_timer);
        balloon_timer.data = 0;
@@@ -456,6 -474,9 +458,6 @@@ module_exit(balloon_exit)
  BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
  BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
  BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
 -BALLOON_SHOW(hard_limit_kb,
 -           (balloon_stats.hard_limit!=~0UL) ? "%lu\n" : "???\n",
 -           (balloon_stats.hard_limit!=~0UL) ? PAGES2KB(balloon_stats.hard_limit) : 0);
  BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(balloon_stats.driver_pages));
  
  static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr,
@@@ -525,6 -546,7 +527,6 @@@ static struct attribute *balloon_info_a
        &attr_current_kb.attr,
        &attr_low_kb.attr,
        &attr_high_kb.attr,
 -      &attr_hard_limit_kb.attr,
        &attr_driver_kb.attr,
        NULL
  };
@@@ -1,5 -1,6 +1,6 @@@
  #include <linux/notifier.h>
  
+ #include <xen/xen.h>
  #include <xen/xenbus.h>
  
  #include <asm/xen/hypervisor.h>
@@@ -86,7 -87,7 +87,7 @@@ static int setup_cpu_watcher(struct not
        for_each_possible_cpu(cpu) {
                if (vcpu_online(cpu) == 0) {
                        (void)cpu_down(cpu);
 -                      cpu_clear(cpu, cpu_present_map);
 +                      set_cpu_present(cpu, false);
                }
        }
  
@@@ -49,6 -49,8 +49,8 @@@
  #include <asm/page.h>
  #include <asm/pgtable.h>
  #include <asm/xen/hypervisor.h>
+ #include <xen/xen.h>
  #include <xen/xenbus.h>
  #include <xen/events.h>
  #include <xen/page.h>
@@@ -454,21 -456,21 +456,21 @@@ static ssize_t xendev_show_nodename(str
  {
        return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
  }
 -DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
 +static DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
  
  static ssize_t xendev_show_devtype(struct device *dev,
                                   struct device_attribute *attr, char *buf)
  {
        return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
  }
 -DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
 +static DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
  
  static ssize_t xendev_show_modalias(struct device *dev,
                                    struct device_attribute *attr, char *buf)
  {
        return sprintf(buf, "xen:%s\n", to_xenbus_device(dev)->devicetype);
  }
 -DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL);
 +static DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL);
  
  int xenbus_probe_node(struct xen_bus_type *bus,
                      const char *type,
@@@ -843,7 -845,7 +845,7 @@@ postcore_initcall(xenbus_probe_init)
  
  MODULE_LICENSE("GPL");
  
 -static int is_disconnected_device(struct device *dev, void *data)
 +static int is_device_connecting(struct device *dev, void *data)
  {
        struct xenbus_device *xendev = to_xenbus_device(dev);
        struct device_driver *drv = data;
                return 0;
  
        xendrv = to_xenbus_driver(dev->driver);
 -      return (xendev->state != XenbusStateConnected ||
 -              (xendrv->is_ready && !xendrv->is_ready(xendev)));
 +      return (xendev->state < XenbusStateConnected ||
 +              (xendev->state == XenbusStateConnected &&
 +               xendrv->is_ready && !xendrv->is_ready(xendev)));
  }
  
 -static int exists_disconnected_device(struct device_driver *drv)
 +static int exists_connecting_device(struct device_driver *drv)
  {
        return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
 -                              is_disconnected_device);
 +                              is_device_connecting);
  }
  
  static int print_device_status(struct device *dev, void *data)
                /* Information only: is this too noisy? */
                printk(KERN_INFO "XENBUS: Device with no driver: %s\n",
                       xendev->nodename);
 -      } else if (xendev->state != XenbusStateConnected) {
 +      } else if (xendev->state < XenbusStateConnected) {
 +              enum xenbus_state rstate = XenbusStateUnknown;
 +              if (xendev->otherend)
 +                      rstate = xenbus_read_driver_state(xendev->otherend);
                printk(KERN_WARNING "XENBUS: Timeout connecting "
 -                     "to device: %s (state %d)\n",
 -                     xendev->nodename, xendev->state);
 +                     "to device: %s (local state %d, remote state %d)\n",
 +                     xendev->nodename, xendev->state, rstate);
        }
  
        return 0;
  static int ready_to_wait_for_devices;
  
  /*
 - * On a 10 second timeout, wait for all devices currently configured.  We need
 + * On a 5-minute timeout, wait for all devices currently configured.  We need
   * to do this to guarantee that the filesystems and / or network devices
   * needed for boot are available, before we can allow the boot to proceed.
   *
   */
  static void wait_for_devices(struct xenbus_driver *xendrv)
  {
 -      unsigned long timeout = jiffies + 10*HZ;
 +      unsigned long start = jiffies;
        struct device_driver *drv = xendrv ? &xendrv->driver : NULL;
 +      unsigned int seconds_waited = 0;
  
        if (!ready_to_wait_for_devices || !xen_domain())
                return;
  
 -      while (exists_disconnected_device(drv)) {
 -              if (time_after(jiffies, timeout))
 -                      break;
 +      while (exists_connecting_device(drv)) {
 +              if (time_after(jiffies, start + (seconds_waited+5)*HZ)) {
 +                      if (!seconds_waited)
 +                              printk(KERN_WARNING "XENBUS: Waiting for "
 +                                     "devices to initialise: ");
 +                      seconds_waited += 5;
 +                      printk("%us...", 300 - seconds_waited);
 +                      if (seconds_waited == 300)
 +                              break;
 +              }
 +
                schedule_timeout_interruptible(HZ/10);
        }
  
 +      if (seconds_waited)
 +              printk("\n");
 +
        bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
                         print_device_status);
  }