Merge branches 'stable/drivers-3.2', 'stable/drivers.bugfixes-3.2' and 'stable/pci...
[pandora-kernel.git] / arch / x86 / pci / xen.c
index 11a9301..492ade8 100644 (file)
@@ -252,6 +252,8 @@ error:
 }
 
 #ifdef CONFIG_XEN_DOM0
+static bool __read_mostly pci_seg_supported = true;
+
 static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
        int ret = 0;
@@ -269,10 +271,11 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 
                memset(&map_irq, 0, sizeof(map_irq));
                map_irq.domid = domid;
-               map_irq.type = MAP_PIRQ_TYPE_MSI;
+               map_irq.type = MAP_PIRQ_TYPE_MSI_SEG;
                map_irq.index = -1;
                map_irq.pirq = -1;
-               map_irq.bus = dev->bus->number;
+               map_irq.bus = dev->bus->number |
+                             (pci_domain_nr(dev->bus) << 16);
                map_irq.devfn = dev->devfn;
 
                if (type == PCI_CAP_ID_MSIX) {
@@ -289,7 +292,20 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
                        map_irq.entry_nr = msidesc->msi_attrib.entry_nr;
                }
 
-               ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
+               ret = -EINVAL;
+               if (pci_seg_supported)
+                       ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq,
+                                                   &map_irq);
+               if (ret == -EINVAL && !pci_domain_nr(dev->bus)) {
+                       map_irq.type = MAP_PIRQ_TYPE_MSI;
+                       map_irq.index = -1;
+                       map_irq.pirq = -1;
+                       map_irq.bus = dev->bus->number;
+                       ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq,
+                                                   &map_irq);
+                       if (ret != -EINVAL)
+                               pci_seg_supported = false;
+               }
                if (ret) {
                        dev_warn(&dev->dev, "xen map irq failed %d for %d domain\n",
                                 ret, domid);