Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes...
Linus Torvalds [Mon, 23 May 2011 22:39:34 +0000 (15:39 -0700)]
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (27 commits)
  PCI: Don't use dmi_name_in_vendors in quirk
  PCI: remove unused AER functions
  PCI/sysfs: move bus cpuaffinity to class dev_attrs
  PCI: add rescan to /sys/.../pci_bus/.../
  PCI: update bridge resources to get more big ranges when allocating space (again)
  KVM: Use pci_store/load_saved_state() around VM device usage
  PCI: Add interfaces to store and load the device saved state
  PCI: Track the size of each saved capability data area
  PCI/e1000e: Add and use pci_disable_link_state_locked()
  x86/PCI: derive pcibios_last_bus from ACPI MCFG
  PCI: add latency tolerance reporting enable/disable support
  PCI: add OBFF enable/disable support
  PCI: add ID-based ordering enable/disable support
  PCI hotplug: acpiphp: assume device is in state D0 after powering on a slot.
  PCI: Set PCIE maxpayload for card during hotplug insertion
  PCI/ACPI: Report _OSC control mask returned on failure to get control
  x86/PCI: irq and pci_ids patch for Intel Panther Point DeviceIDs
  PCI: handle positive error codes
  PCI: check pci_vpd_pci22_wait() return
  PCI: Use ICH6_GPIO_EN in ich6_lpc_acpi_gpio
  ...

Fix up trivial conflicts in include/linux/pci_ids.h: commit a6e5e2be4461
moved the intel SMBUS ID definitons to the i2c-i801.c driver.

1  2 
arch/x86/kernel/setup.c
drivers/i2c/busses/i2c-i801.c
drivers/net/e1000e/netdev.c
drivers/pci/pci.h
drivers/pci/setup-bus.c
include/linux/kvm_host.h
include/linux/pci_ids.h

diff --combined arch/x86/kernel/setup.c
@@@ -691,6 -691,8 +691,6 @@@ early_param("reservelow", parse_reserve
  
  void __init setup_arch(char **cmdline_p)
  {
 -      unsigned long flags;
 -
  #ifdef CONFIG_X86_32
        memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
        visws_early_detect();
  
        initmem_init();
        memblock_find_dma_reserve();
-       dma32_reserve_bootmem();
  
  #ifdef CONFIG_KVM_CLOCK
        kvmclock_init();
  
        mcheck_init();
  
 -      local_irq_save(flags);
 -      arch_init_ideal_nop5();
 -      local_irq_restore(flags);
 +      arch_init_ideal_nops();
  }
  
  #ifdef CONFIG_X86_32
                                 SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \
                                 SMBHSTSTS_INTR)
  
 +/* Older devices have their ID defined in <linux/pci_ids.h> */
 +#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22
 +#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS    0x1d22
++#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS        0x1e22
  /* Patsburg also has three 'Integrated Device Function' SMBus controllers */
  #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0       0x1d70
  #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1       0x1d71
  #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2       0x1d72
 +#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS    0x2330
 +#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS       0x3b30
  
  struct i801_priv {
        struct i2c_adapter adapter;
@@@ -49,7 -49,6 +49,7 @@@
  #include <linux/pm_qos_params.h>
  #include <linux/pm_runtime.h>
  #include <linux/aer.h>
 +#include <linux/prefetch.h>
  
  #include "e1000.h"
  
@@@ -59,8 -58,6 +59,8 @@@
  char e1000e_driver_name[] = "e1000e";
  const char e1000e_driver_version[] = DRV_VERSION;
  
 +static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
 +
  static const struct e1000_info *e1000_info_tbl[] = {
        [board_82571]           = &e1000_82571_info,
        [board_82572]           = &e1000_82572_info,
@@@ -462,13 -459,13 +462,13 @@@ static void e1000_receive_skb(struct e1
                              struct net_device *netdev, struct sk_buff *skb,
                              u8 status, __le16 vlan)
  {
 +      u16 tag = le16_to_cpu(vlan);
        skb->protocol = eth_type_trans(skb, netdev);
  
 -      if (adapter->vlgrp && (status & E1000_RXD_STAT_VP))
 -              vlan_gro_receive(&adapter->napi, adapter->vlgrp,
 -                               le16_to_cpu(vlan), skb);
 -      else
 -              napi_gro_receive(&adapter->napi, skb);
 +      if (status & E1000_RXD_STAT_VP)
 +              __vlan_hwaccel_put_tag(skb, tag);
 +
 +      napi_gro_receive(&adapter->napi, skb);
  }
  
  /**
@@@ -2436,8 -2433,6 +2436,8 @@@ static void e1000_vlan_rx_add_vid(struc
                vfta |= (1 << (vid & 0x1F));
                hw->mac.ops.write_vfta(hw, index, vfta);
        }
 +
 +      set_bit(vid, adapter->active_vlans);
  }
  
  static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
        struct e1000_hw *hw = &adapter->hw;
        u32 vfta, index;
  
 -      if (!test_bit(__E1000_DOWN, &adapter->state))
 -              e1000_irq_disable(adapter);
 -      vlan_group_set_device(adapter->vlgrp, vid, NULL);
 -
 -      if (!test_bit(__E1000_DOWN, &adapter->state))
 -              e1000_irq_enable(adapter);
 -
        if ((adapter->hw.mng_cookie.status &
             E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
            (vid == adapter->mng_vlan_id)) {
                vfta &= ~(1 << (vid & 0x1F));
                hw->mac.ops.write_vfta(hw, index, vfta);
        }
 +
 +      clear_bit(vid, adapter->active_vlans);
  }
  
 -static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
 +/**
 + * e1000e_vlan_filter_disable - helper to disable hw VLAN filtering
 + * @adapter: board private structure to initialize
 + **/
 +static void e1000e_vlan_filter_disable(struct e1000_adapter *adapter)
  {
        struct net_device *netdev = adapter->netdev;
 -      u16 vid = adapter->hw.mng_cookie.vlan_id;
 -      u16 old_vid = adapter->mng_vlan_id;
 -
 -      if (!adapter->vlgrp)
 -              return;
 +      struct e1000_hw *hw = &adapter->hw;
 +      u32 rctl;
  
 -      if (!vlan_group_get_device(adapter->vlgrp, vid)) {
 -              adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
 -              if (adapter->hw.mng_cookie.status &
 -                      E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
 -                      e1000_vlan_rx_add_vid(netdev, vid);
 -                      adapter->mng_vlan_id = vid;
 +      if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
 +              /* disable VLAN receive filtering */
 +              rctl = er32(RCTL);
 +              rctl &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN);
 +              ew32(RCTL, rctl);
 +
 +              if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
 +                      e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
 +                      adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
                }
        }
  }
  
 +/**
 + * e1000e_vlan_filter_enable - helper to enable HW VLAN filtering
 + * @adapter: board private structure to initialize
 + **/
 +static void e1000e_vlan_filter_enable(struct e1000_adapter *adapter)
 +{
 +      struct e1000_hw *hw = &adapter->hw;
 +      u32 rctl;
  
 -static void e1000_vlan_rx_register(struct net_device *netdev,
 -                                 struct vlan_group *grp)
 +      if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
 +              /* enable VLAN receive filtering */
 +              rctl = er32(RCTL);
 +              rctl |= E1000_RCTL_VFE;
 +              rctl &= ~E1000_RCTL_CFIEN;
 +              ew32(RCTL, rctl);
 +      }
 +}
 +
 +/**
 + * e1000e_vlan_strip_enable - helper to disable HW VLAN stripping
 + * @adapter: board private structure to initialize
 + **/
 +static void e1000e_vlan_strip_disable(struct e1000_adapter *adapter)
  {
 -      struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 -      u32 ctrl, rctl;
 +      u32 ctrl;
  
 -      if (!test_bit(__E1000_DOWN, &adapter->state))
 -              e1000_irq_disable(adapter);
 -      adapter->vlgrp = grp;
 +      /* disable VLAN tag insert/strip */
 +      ctrl = er32(CTRL);
 +      ctrl &= ~E1000_CTRL_VME;
 +      ew32(CTRL, ctrl);
 +}
  
 -      if (grp) {
 -              /* enable VLAN tag insert/strip */
 -              ctrl = er32(CTRL);
 -              ctrl |= E1000_CTRL_VME;
 -              ew32(CTRL, ctrl);
 +/**
 + * e1000e_vlan_strip_enable - helper to enable HW VLAN stripping
 + * @adapter: board private structure to initialize
 + **/
 +static void e1000e_vlan_strip_enable(struct e1000_adapter *adapter)
 +{
 +      struct e1000_hw *hw = &adapter->hw;
 +      u32 ctrl;
  
 -              if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
 -                      /* enable VLAN receive filtering */
 -                      rctl = er32(RCTL);
 -                      rctl &= ~E1000_RCTL_CFIEN;
 -                      ew32(RCTL, rctl);
 -                      e1000_update_mng_vlan(adapter);
 -              }
 -      } else {
 -              /* disable VLAN tag insert/strip */
 -              ctrl = er32(CTRL);
 -              ctrl &= ~E1000_CTRL_VME;
 -              ew32(CTRL, ctrl);
 +      /* enable VLAN tag insert/strip */
 +      ctrl = er32(CTRL);
 +      ctrl |= E1000_CTRL_VME;
 +      ew32(CTRL, ctrl);
 +}
  
 -              if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
 -                      if (adapter->mng_vlan_id !=
 -                          (u16)E1000_MNG_VLAN_NONE) {
 -                              e1000_vlan_rx_kill_vid(netdev,
 -                                                     adapter->mng_vlan_id);
 -                              adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
 -                      }
 -              }
 +static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
 +{
 +      struct net_device *netdev = adapter->netdev;
 +      u16 vid = adapter->hw.mng_cookie.vlan_id;
 +      u16 old_vid = adapter->mng_vlan_id;
 +
 +      if (adapter->hw.mng_cookie.status &
 +          E1000_MNG_DHCP_COOKIE_STATUS_VLAN) {
 +              e1000_vlan_rx_add_vid(netdev, vid);
 +              adapter->mng_vlan_id = vid;
        }
  
 -      if (!test_bit(__E1000_DOWN, &adapter->state))
 -              e1000_irq_enable(adapter);
 +      if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid))
 +              e1000_vlan_rx_kill_vid(netdev, old_vid);
  }
  
  static void e1000_restore_vlan(struct e1000_adapter *adapter)
  {
        u16 vid;
  
 -      e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
 -
 -      if (!adapter->vlgrp)
 -              return;
 +      e1000_vlan_rx_add_vid(adapter->netdev, 0);
  
 -      for (vid = 0; vid < VLAN_N_VID; vid++) {
 -              if (!vlan_group_get_device(adapter->vlgrp, vid))
 -                      continue;
 +      for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
                e1000_vlan_rx_add_vid(adapter->netdev, vid);
 -      }
  }
  
  static void e1000_init_manageability_pt(struct e1000_adapter *adapter)
@@@ -2912,7 -2902,7 +2912,7 @@@ static void e1000_configure_rx(struct e
        rctl = er32(RCTL);
        ew32(RCTL, rctl & ~E1000_RCTL_EN);
        e1e_flush();
 -      msleep(10);
 +      usleep_range(10000, 20000);
  
        if (adapter->flags2 & FLAG2_DMA_BURST) {
                /*
@@@ -3049,8 -3039,6 +3049,8 @@@ static void e1000_set_multi(struct net_
        if (netdev->flags & IFF_PROMISC) {
                rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
                rctl &= ~E1000_RCTL_VFE;
 +              /* Do not hardware filter VLANs in promisc mode */
 +              e1000e_vlan_filter_disable(adapter);
        } else {
                if (netdev->flags & IFF_ALLMULTI) {
                        rctl |= E1000_RCTL_MPE;
                } else {
                        rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
                }
 -              if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
 -                      rctl |= E1000_RCTL_VFE;
 +              e1000e_vlan_filter_enable(adapter);
        }
  
        ew32(RCTL, rctl);
                 */
                e1000_update_mc_addr_list(hw, NULL, 0);
        }
 +
 +      if (netdev->features & NETIF_F_HW_VLAN_RX)
 +              e1000e_vlan_strip_enable(adapter);
 +      else
 +              e1000e_vlan_strip_disable(adapter);
  }
  
  /**
@@@ -3399,7 -3383,7 +3399,7 @@@ void e1000e_down(struct e1000_adapter *
        ew32(TCTL, tctl);
        /* flush both disables and wait for them to finish */
        e1e_flush();
 -      msleep(10);
 +      usleep_range(10000, 20000);
  
        napi_disable(&adapter->napi);
        e1000_irq_disable(adapter);
@@@ -3434,7 -3418,7 +3434,7 @@@ void e1000e_reinit_locked(struct e1000_
  {
        might_sleep();
        while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
 -              msleep(1);
 +              usleep_range(1000, 2000);
        e1000e_down(adapter);
        e1000e_up(adapter);
        clear_bit(__E1000_RESETTING, &adapter->state);
@@@ -3737,8 -3721,10 +3737,8 @@@ static int e1000_close(struct net_devic
         * kill manageability vlan ID if supported, but not if a vlan with
         * the same ID is registered on the host OS (let 8021q kill it)
         */
 -      if ((adapter->hw.mng_cookie.status &
 -                        E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
 -           !(adapter->vlgrp &&
 -             vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id)))
 +      if (adapter->hw.mng_cookie.status &
 +          E1000_MNG_DHCP_COOKIE_STATUS_VLAN)
                e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
  
        /*
@@@ -4342,6 -4328,7 +4342,6 @@@ static void e1000_watchdog_task(struct 
  link_up:
        spin_lock(&adapter->stats64_lock);
        e1000e_update_stats(adapter);
 -      spin_unlock(&adapter->stats64_lock);
  
        mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
        adapter->tpt_old = adapter->stats.tpt;
        adapter->gorc_old = adapter->stats.gorc;
        adapter->gotc = adapter->stats.gotc - adapter->gotc_old;
        adapter->gotc_old = adapter->stats.gotc;
 +      spin_unlock(&adapter->stats64_lock);
  
        e1000e_update_adaptive(&adapter->hw);
  
@@@ -5042,7 -5028,7 +5042,7 @@@ static int e1000_change_mtu(struct net_
        }
  
        while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
 -              msleep(1);
 +              usleep_range(1000, 2000);
        /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
        adapter->max_frame_size = max_frame;
        e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
@@@ -5361,7 -5347,7 +5361,7 @@@ static void e1000_complete_shutdown(str
  #ifdef CONFIG_PCIEASPM
  static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
  {
-       pci_disable_link_state(pdev, state);
+       pci_disable_link_state_locked(pdev, state);
  }
  #else
  static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
        pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
  }
  #endif
 -void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
 +static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
  {
        dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
                 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
@@@ -5407,19 -5393,13 +5407,19 @@@ static int __e1000_resume(struct pci_de
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 +      u16 aspm_disable_flag = 0;
        u32 err;
  
 +      if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
 +              aspm_disable_flag = PCIE_LINK_STATE_L0S;
 +      if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
 +              aspm_disable_flag |= PCIE_LINK_STATE_L1;
 +      if (aspm_disable_flag)
 +              e1000e_disable_aspm(pdev, aspm_disable_flag);
 +
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
        pci_save_state(pdev);
 -      if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
 -              e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
  
        e1000e_set_interrupt_capability(adapter);
        if (netif_running(netdev)) {
@@@ -5663,17 -5643,11 +5663,17 @@@ static pci_ers_result_t e1000_io_slot_r
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 +      u16 aspm_disable_flag = 0;
        int err;
        pci_ers_result_t result;
  
 +      if (adapter->flags2 & FLAG2_DISABLE_ASPM_L0S)
 +              aspm_disable_flag = PCIE_LINK_STATE_L0S;
        if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
 -              e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
 +              aspm_disable_flag |= PCIE_LINK_STATE_L1;
 +      if (aspm_disable_flag)
 +              e1000e_disable_aspm(pdev, aspm_disable_flag);
 +
        err = pci_enable_device_mem(pdev);
        if (err) {
                dev_err(&pdev->dev,
@@@ -5740,7 -5714,7 +5740,7 @@@ static void e1000_print_device_info(str
        u8 pba_str[E1000_PBANUM_LENGTH];
  
        /* print bus type/speed/width info */
 -      e_info("(PCI Express:2.5GB/s:%s) %pM\n",
 +      e_info("(PCI Express:2.5GT/s:%s) %pM\n",
               /* bus width */
               ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
                "Width x1"),
@@@ -5785,6 -5759,7 +5785,6 @@@ static const struct net_device_ops e100
        .ndo_tx_timeout         = e1000_tx_timeout,
        .ndo_validate_addr      = eth_validate_addr,
  
 -      .ndo_vlan_rx_register   = e1000_vlan_rx_register,
        .ndo_vlan_rx_add_vid    = e1000_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid   = e1000_vlan_rx_kill_vid,
  #ifdef CONFIG_NET_POLL_CONTROLLER
@@@ -5814,17 -5789,12 +5814,17 @@@ static int __devinit e1000_probe(struc
        resource_size_t flash_start, flash_len;
  
        static int cards_found;
 +      u16 aspm_disable_flag = 0;
        int i, err, pci_using_dac;
        u16 eeprom_data = 0;
        u16 eeprom_apme_mask = E1000_EEPROM_APME;
  
 +      if (ei->flags2 & FLAG2_DISABLE_ASPM_L0S)
 +              aspm_disable_flag = PCIE_LINK_STATE_L0S;
        if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
 -              e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
 +              aspm_disable_flag |= PCIE_LINK_STATE_L1;
 +      if (aspm_disable_flag)
 +              e1000e_disable_aspm(pdev, aspm_disable_flag);
  
        err = pci_enable_device_mem(pdev);
        if (err)
        INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
        INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
        INIT_WORK(&adapter->print_hang_task, e1000_print_hw_hang);
 -      INIT_WORK(&adapter->led_blink_task, e1000e_led_blink_task);
  
        /* Initialize link parameters. User can change them with ethtool */
        adapter->hw.mac.autoneg = 1;
@@@ -6153,6 -6124,7 +6153,6 @@@ static void __devexit e1000_remove(stru
        cancel_work_sync(&adapter->watchdog_task);
        cancel_work_sync(&adapter->downshift_task);
        cancel_work_sync(&adapter->update_phy_task);
 -      cancel_work_sync(&adapter->led_blink_task);
        cancel_work_sync(&adapter->print_hang_task);
  
        if (!(netdev->flags & IFF_UP))
diff --combined drivers/pci/pci.h
@@@ -156,8 -156,7 +156,7 @@@ static inline int pci_no_d1d2(struct pc
  
  }
  extern struct device_attribute pci_dev_attrs[];
- extern struct device_attribute dev_attr_cpuaffinity;
- extern struct device_attribute dev_attr_cpulistaffinity;
+ extern struct device_attribute pcibus_dev_attrs[];
  #ifdef CONFIG_HOTPLUG
  extern struct bus_attribute pci_bus_attrs[];
  #else
@@@ -250,6 -249,15 +249,6 @@@ struct pci_sriov 
        u8 __iomem *mstate;     /* VF Migration State Array */
  };
  
 -/* Address Translation Service */
 -struct pci_ats {
 -      int pos;        /* capability position */
 -      int stu;        /* Smallest Translation Unit */
 -      int qdep;       /* Invalidate Queue Depth */
 -      int ref_cnt;    /* Physical Function reference count */
 -      unsigned int is_enabled:1;      /* Enable bit is set */
 -};
 -
  #ifdef CONFIG_PCI_IOV
  extern int pci_iov_init(struct pci_dev *dev);
  extern void pci_iov_release(struct pci_dev *dev);
@@@ -260,6 -268,19 +259,6 @@@ extern resource_size_t pci_sriov_resour
  extern void pci_restore_iov_state(struct pci_dev *dev);
  extern int pci_iov_bus_range(struct pci_bus *bus);
  
 -extern int pci_enable_ats(struct pci_dev *dev, int ps);
 -extern void pci_disable_ats(struct pci_dev *dev);
 -extern int pci_ats_queue_depth(struct pci_dev *dev);
 -/**
 - * pci_ats_enabled - query the ATS status
 - * @dev: the PCI device
 - *
 - * Returns 1 if ATS capability is enabled, or 0 if not.
 - */
 -static inline int pci_ats_enabled(struct pci_dev *dev)
 -{
 -      return dev->ats && dev->ats->is_enabled;
 -}
  #else
  static inline int pci_iov_init(struct pci_dev *dev)
  {
@@@ -282,6 -303,21 +281,6 @@@ static inline int pci_iov_bus_range(str
        return 0;
  }
  
 -static inline int pci_enable_ats(struct pci_dev *dev, int ps)
 -{
 -      return -ENODEV;
 -}
 -static inline void pci_disable_ats(struct pci_dev *dev)
 -{
 -}
 -static inline int pci_ats_queue_depth(struct pci_dev *dev)
 -{
 -      return -ENODEV;
 -}
 -static inline int pci_ats_enabled(struct pci_dev *dev)
 -{
 -      return 0;
 -}
  #endif /* CONFIG_PCI_IOV */
  
  static inline resource_size_t pci_resource_alignment(struct pci_dev *dev,
diff --combined drivers/pci/setup-bus.c
@@@ -579,7 -579,7 +579,7 @@@ static void pbus_size_io(struct pci_bu
        }
        size0 = calculate_iosize(size, min_size, size1,
                        resource_size(b_res), 4096);
 -      size1 = !add_size? size0:
 +      size1 = (!add_head || (add_head && !add_size)) ? size0 :
                calculate_iosize(size, min_size+add_size, size1,
                        resource_size(b_res), 4096);
        if (!size0 && !size1) {
@@@ -677,7 -677,7 +677,7 @@@ static int pbus_size_mem(struct pci_bu
                align += aligns[order];
        }
        size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
 -      size1 = !add_size ? size :
 +      size1 = (!add_head || (add_head && !add_size)) ? size0 :
                calculate_memsize(size, min_size+add_size, 0,
                                resource_size(b_res), min_align);
        if (!size0 && !size1) {
@@@ -991,30 -991,139 +991,139 @@@ static void pci_bus_dump_resources(stru
        }
  }
  
+ static int __init pci_bus_get_depth(struct pci_bus *bus)
+ {
+       int depth = 0;
+       struct pci_dev *dev;
+       list_for_each_entry(dev, &bus->devices, bus_list) {
+               int ret;
+               struct pci_bus *b = dev->subordinate;
+               if (!b)
+                       continue;
+               ret = pci_bus_get_depth(b);
+               if (ret + 1 > depth)
+                       depth = ret + 1;
+       }
+       return depth;
+ }
+ static int __init pci_get_max_depth(void)
+ {
+       int depth = 0;
+       struct pci_bus *bus;
+       list_for_each_entry(bus, &pci_root_buses, node) {
+               int ret;
+               ret = pci_bus_get_depth(bus);
+               if (ret > depth)
+                       depth = ret;
+       }
+       return depth;
+ }
+ /*
+  * first try will not touch pci bridge res
+  * second  and later try will clear small leaf bridge res
+  * will stop till to the max  deepth if can not find good one
+  */
  void __init
  pci_assign_unassigned_resources(void)
  {
        struct pci_bus *bus;
        struct resource_list_x add_list; /* list of resources that
                                        want additional resources */
+       int tried_times = 0;
+       enum release_type rel_type = leaf_only;
+       struct resource_list_x head, *list;
+       unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
+                                 IORESOURCE_PREFETCH;
+       unsigned long failed_type;
+       int max_depth = pci_get_max_depth();
+       int pci_try_num;
+       head.next = NULL;
        add_list.next = NULL;
+       pci_try_num = max_depth + 1;
+       printk(KERN_DEBUG "PCI: max bus depth: %d pci_try_num: %d\n",
+                max_depth, pci_try_num);
+ again:
        /* Depth first, calculate sizes and alignments of all
           subordinate buses. */
-       list_for_each_entry(bus, &pci_root_buses, node) {
+       list_for_each_entry(bus, &pci_root_buses, node)
                __pci_bus_size_bridges(bus, &add_list);
-       }
  
        /* Depth last, allocate resources and update the hardware. */
-       list_for_each_entry(bus, &pci_root_buses, node) {
-               __pci_bus_assign_resources(bus, &add_list, NULL);
-               pci_enable_bridges(bus);
-       }
+       list_for_each_entry(bus, &pci_root_buses, node)
+               __pci_bus_assign_resources(bus, &add_list, &head);
        BUG_ON(add_list.next);
+       tried_times++;
+       /* any device complain? */
+       if (!head.next)
+               goto enable_and_dump;
+       failed_type = 0;
+       for (list = head.next; list;) {
+               failed_type |= list->flags;
+               list = list->next;
+       }
+       /*
+        * io port are tight, don't try extra
+        * or if reach the limit, don't want to try more
+        */
+       failed_type &= type_mask;
+       if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) {
+               free_list(resource_list_x, &head);
+               goto enable_and_dump;
+       }
+       printk(KERN_DEBUG "PCI: No. %d try to assign unassigned res\n",
+                        tried_times + 1);
+       /* third times and later will not check if it is leaf */
+       if ((tried_times + 1) > 2)
+               rel_type = whole_subtree;
+       /*
+        * Try to release leaf bridge's resources that doesn't fit resource of
+        * child device under that bridge
+        */
+       for (list = head.next; list;) {
+               bus = list->dev->bus;
+               pci_bus_release_bridge_resources(bus, list->flags & type_mask,
+                                                 rel_type);
+               list = list->next;
+       }
+       /* restore size and flags */
+       for (list = head.next; list;) {
+               struct resource *res = list->res;
+               res->start = list->start;
+               res->end = list->end;
+               res->flags = list->flags;
+               if (list->dev->subordinate)
+                       res->flags = 0;
+               list = list->next;
+       }
+       free_list(resource_list_x, &head);
+       goto again;
+ enable_and_dump:
+       /* Depth last, update the hardware. */
+       list_for_each_entry(bus, &pci_root_buses, node)
+               pci_enable_bridges(bus);
  
        /* dump the resource on buses */
-       list_for_each_entry(bus, &pci_root_buses, node) {
+       list_for_each_entry(bus, &pci_root_buses, node)
                pci_bus_dump_resources(bus);
-       }
  }
  
  void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
diff --combined include/linux/kvm_host.h
  
  #include <asm/kvm_host.h>
  
 +#ifndef KVM_MMIO_SIZE
 +#define KVM_MMIO_SIZE 8
 +#endif
 +
  /*
   * vcpu->requests bit members
   */
@@@ -47,6 -43,7 +47,6 @@@
  #define KVM_REQ_DEACTIVATE_FPU    10
  #define KVM_REQ_EVENT             11
  #define KVM_REQ_APF_HALT          12
 -#define KVM_REQ_NMI               13
  
  #define KVM_USERSPACE_IRQ_SOURCE_ID   0
  
@@@ -136,8 -133,7 +136,8 @@@ struct kvm_vcpu 
        int mmio_read_completed;
        int mmio_is_write;
        int mmio_size;
 -      unsigned char mmio_data[8];
 +      int mmio_index;
 +      unsigned char mmio_data[KVM_MMIO_SIZE];
        gpa_t mmio_phys_addr;
  #endif
  
@@@ -296,10 -292,9 +296,10 @@@ static inline struct kvm_vcpu *kvm_get_
  }
  
  #define kvm_for_each_vcpu(idx, vcpup, kvm) \
 -      for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \
 -           idx < atomic_read(&kvm->online_vcpus) && vcpup; \
 -           vcpup = kvm_get_vcpu(kvm, ++idx))
 +      for (idx = 0; \
 +           idx < atomic_read(&kvm->online_vcpus) && \
 +           (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
 +           idx++)
  
  int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
  void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
@@@ -370,6 -365,7 +370,6 @@@ pfn_t gfn_to_pfn_prot(struct kvm *kvm, 
                      bool *writable);
  pfn_t gfn_to_pfn_memslot(struct kvm *kvm,
                         struct kvm_memory_slot *slot, gfn_t gfn);
 -int memslot_id(struct kvm *kvm, gfn_t gfn);
  void kvm_release_pfn_dirty(pfn_t);
  void kvm_release_pfn_clean(pfn_t pfn);
  void kvm_set_pfn_dirty(pfn_t pfn);
@@@ -517,6 -513,7 +517,7 @@@ struct kvm_assigned_dev_kernel 
        struct kvm *kvm;
        spinlock_t intx_lock;
        char irq_name[32];
+       struct pci_saved_state *pci_saved_state;
  };
  
  struct kvm_irq_mask_notifier {
@@@ -591,17 -588,8 +592,17 @@@ static inline int kvm_deassign_device(s
  
  static inline void kvm_guest_enter(void)
  {
 +      BUG_ON(preemptible());
        account_system_vtime(current);
        current->flags |= PF_VCPU;
 +      /* KVM does not hold any references to rcu protected data when it
 +       * switches CPU into a guest mode. In fact switching to a guest mode
 +       * is very similar to exiting to userspase from rcu point of view. In
 +       * addition CPU may stay in a guest mode for quite a long time (up to
 +       * one time slice). Lets treat guest mode as quiescent state, just like
 +       * we do with user-mode execution.
 +       */
 +      rcu_virt_note_context_switch(smp_processor_id());
  }
  
  static inline void kvm_guest_exit(void)
        current->flags &= ~PF_VCPU;
  }
  
 +static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
 +{
 +      return gfn_to_memslot(kvm, gfn)->id;
 +}
 +
  static inline unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot,
                                               gfn_t gfn)
  {
diff --combined include/linux/pci_ids.h
  #define PCI_DEVICE_ID_MATROX_G550     0x2527
  #define PCI_DEVICE_ID_MATROX_VIA      0x4536
  
 +#define PCI_VENDOR_ID_MOBILITY_ELECTRONICS    0x14f2
 +
  #define PCI_VENDOR_ID_CT              0x102c
  #define PCI_DEVICE_ID_CT_69000                0x00c0
  #define PCI_DEVICE_ID_CT_65545                0x00d8
  #define PCI_DEVICE_ID_INTEL_82840_HB  0x1a21
  #define PCI_DEVICE_ID_INTEL_82845_HB  0x1a30
  #define PCI_DEVICE_ID_INTEL_IOAT      0x1a38
 -#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22
  #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN       0x1c41
  #define PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX       0x1c5f
 -#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS        0x1e22
 -#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MIN      0x1e40
 -#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MAX      0x1e5f
 -#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS    0x1d22
  #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_0    0x1d40
  #define PCI_DEVICE_ID_INTEL_PATSBURG_LPC_1    0x1d41
++#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MIN      0x1e40
++#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MAX      0x1e5f
  #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MIN  0x2310
  #define PCI_DEVICE_ID_INTEL_DH89XXCC_LPC_MAX  0x231f
 -#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS    0x2330
  #define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
  #define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
  #define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
  #define PCI_DEVICE_ID_INTEL_ICH10_5   0x3a60
  #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MIN     0x3b00
  #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MAX     0x3b1f
 -#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS       0x3b30
  #define PCI_DEVICE_ID_INTEL_IOAT_SNB  0x402f
  #define PCI_DEVICE_ID_INTEL_5100_16   0x65f0
  #define PCI_DEVICE_ID_INTEL_5100_21   0x65f5