These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / pci / xen-pcifront.c
index 7cfd2db..5f70fee 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <linux/time.h>
+#include <linux/ktime.h>
 #include <xen/platform_pci.h>
 
 #include <asm/xen/swiotlb-xen.h>
@@ -52,7 +53,7 @@ struct pcifront_device {
 };
 
 struct pcifront_sd {
-       int domain;
+       struct pci_sysdata sd;
        struct pcifront_device *pdev;
 };
 
@@ -66,7 +67,9 @@ static inline void pcifront_init_sd(struct pcifront_sd *sd,
                                    unsigned int domain, unsigned int bus,
                                    struct pcifront_device *pdev)
 {
-       sd->domain = domain;
+       /* Because we do not expose that information via XenBus. */
+       sd->sd.node = first_online_node;
+       sd->sd.domain = domain;
        sd->pdev = pdev;
 }
 
@@ -115,7 +118,6 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
        evtchn_port_t port = pdev->evtchn;
        unsigned irq = pdev->irq;
        s64 ns, ns_timeout;
-       struct timeval tv;
 
        spin_lock_irqsave(&pdev->sh_info_lock, irq_flags);
 
@@ -132,8 +134,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
         * (in the latter case we end up continually re-executing poll() with a
         * timeout in the past). 1s difference gives plenty of slack for error.
         */
-       do_gettimeofday(&tv);
-       ns_timeout = timeval_to_ns(&tv) + 2 * (s64)NSEC_PER_SEC;
+       ns_timeout = ktime_get_ns() + 2 * (s64)NSEC_PER_SEC;
 
        xen_clear_irq_pending(irq);
 
@@ -141,8 +142,7 @@ static int do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
                        (unsigned long *)&pdev->sh_info->flags)) {
                xen_poll_irq_timeout(irq, jiffies + 3*HZ);
                xen_clear_irq_pending(irq);
-               do_gettimeofday(&tv);
-               ns = timeval_to_ns(&tv);
+               ns = ktime_get_ns();
                if (ns > ns_timeout) {
                        dev_err(&pdev->xdev->dev,
                                "pciback not responding!!!\n");
@@ -267,7 +267,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
        }
 
        i = 0;
-       list_for_each_entry(entry, &dev->msi_list, list) {
+       for_each_pci_msi_entry(entry, dev) {
                op.msix_entries[i].entry = entry->msi_attrib.entry_nr;
                /* Vector is useless at this point. */
                op.msix_entries[i].vector = -1;
@@ -446,9 +446,15 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
                                 unsigned int domain, unsigned int bus)
 {
        struct pci_bus *b;
+       LIST_HEAD(resources);
        struct pcifront_sd *sd = NULL;
        struct pci_bus_entry *bus_entry = NULL;
        int err = 0;
+       static struct resource busn_res = {
+               .start = 0,
+               .end = 255,
+               .flags = IORESOURCE_BUS,
+       };
 
 #ifndef CONFIG_PCI_DOMAINS
        if (domain != 0) {
@@ -464,23 +470,27 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
        dev_info(&pdev->xdev->dev, "Creating PCI Frontend Bus %04x:%02x\n",
                 domain, bus);
 
-       bus_entry = kmalloc(sizeof(*bus_entry), GFP_KERNEL);
-       sd = kmalloc(sizeof(*sd), GFP_KERNEL);
+       bus_entry = kzalloc(sizeof(*bus_entry), GFP_KERNEL);
+       sd = kzalloc(sizeof(*sd), GFP_KERNEL);
        if (!bus_entry || !sd) {
                err = -ENOMEM;
                goto err_out;
        }
+       pci_add_resource(&resources, &ioport_resource);
+       pci_add_resource(&resources, &iomem_resource);
+       pci_add_resource(&resources, &busn_res);
        pcifront_init_sd(sd, domain, bus, pdev);
 
        pci_lock_rescan_remove();
 
-       b = pci_scan_bus_parented(&pdev->xdev->dev, bus,
-                                 &pcifront_bus_ops, sd);
+       b = pci_scan_root_bus(&pdev->xdev->dev, bus,
+                                 &pcifront_bus_ops, sd, &resources);
        if (!b) {
                dev_err(&pdev->xdev->dev,
                        "Error creating PCI Frontend Bus!\n");
                err = -ENOMEM;
                pci_unlock_rescan_remove();
+               pci_free_resource_list(&resources);
                goto err_out;
        }
 
@@ -488,7 +498,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
 
        list_add(&bus_entry->list, &pdev->root_buses);
 
-       /* pci_scan_bus_parented skips devices which do not have a have
+       /* pci_scan_root_bus skips devices which do not have a
        * devfn==0. The pcifront_scan_bus enumerates all devfn. */
        err = pcifront_scan_bus(pdev, domain, bus, b);