[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] backport Linux changeset of bf4162bcf82ebc3258d6bc0ddd6453132abde72d



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1239704267 -3600
# Node ID 366c31f3ab4bbaaa9baafb0832d0d9278647267c
# Parent  3a8677ef8fd0e7fbdbd79ef6924fe87deb5b8710
backport Linux changeset of bf4162bcf82ebc3258d6bc0ddd6453132abde72d

Without this patch, fakephp with reassigndev fails
to allocate memory resource.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

commit bf4162bcf82ebc3258d6bc0ddd6453132abde72d
Author: Darrick J. Wong <djwong@xxxxxxxxxx>
Date:   Tue Nov 25 13:51:44 2008 -0800

    PCI hotplug: fakephp: Allocate PCI resources before adding the
    device

    For PCI devices, pci_bus_assign_resources() must be called to set
    up the pci_device->resource array before pci_bus_add_devices() can
    be called, else attempts to load drivers results in BAR collision
    errors where there are none.
    This is not done in fakephp, so devices can be "unplugged" but
    scanning the
    parent bus won't bring the devices back due to resource
    unallocation.  Move the
    pci_bus_add_device-calling logic into pci_rescan_bus and preface
    it with a call
    to pci_bus_assign_resources so that we only have to (re)allocate
    resources once
    per bus where a new device is found.

    Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
    Acked-by: Alex Chiang <achiang@xxxxxx>
    Signed-off-by: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>
---
 drivers/pci/hotplug/fakephp.c |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff -r 3a8677ef8fd0 -r 366c31f3ab4b drivers/pci/hotplug/fakephp.c
--- a/drivers/pci/hotplug/fakephp.c     Tue Apr 14 11:16:26 2009 +0100
+++ b/drivers/pci/hotplug/fakephp.c     Tue Apr 14 11:17:47 2009 +0100
@@ -171,12 +171,14 @@ static void remove_slot(struct dummy_slo
  *
  * @param temp   Device template. Should be set: bus and devfn.
  */
-static void pci_rescan_slot(struct pci_dev *temp)
+static int pci_rescan_slot(struct pci_dev *temp)
 {
        struct pci_bus *bus = temp->bus;
        struct pci_dev *dev;
        int func;
        u8 hdr_type;
+       int count = 0;
+
        if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
                temp->hdr_type = hdr_type & 0x7f;
                if (!pci_find_slot(bus->number, temp->devfn)) {
@@ -185,13 +187,12 @@ static void pci_rescan_slot(struct pci_d
                                dbg("New device on %s function %x:%x\n",
                                        bus->name, temp->devfn >> 3,
                                        temp->devfn & 7);
-                               pci_bus_add_device(dev);
-                               add_slot(dev);
+                               count++;
                        }
                }
                /* multifunction device? */
                if (!(hdr_type & 0x80))
-                       return;
+                       return count;
 
                /* continue scanning for other functions */
                for (func = 1, temp->devfn++; func < 8; func++, temp->devfn++) {
@@ -205,12 +206,12 @@ static void pci_rescan_slot(struct pci_d
                                        dbg("New device on %s function %x:%x\n",
                                                bus->name, temp->devfn >> 3,
                                                temp->devfn & 7);
-                                       pci_bus_add_device(dev);
-                                       add_slot(dev);
+                                       count++;
                                }
                        }
                }
        }
+       return count;
 }
 
 
@@ -220,10 +221,11 @@ static void pci_rescan_slot(struct pci_d
  *
  * @param bus
  */
-static void pci_rescan_bus(const struct pci_bus *bus)
+static void pci_rescan_bus(struct pci_bus *bus)
 {
        unsigned int devfn;
        struct pci_dev *dev;
+       int found = 0;
        dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
        if (!dev)
                return;
@@ -232,7 +234,20 @@ static void pci_rescan_bus(const struct 
        dev->sysdata = bus->sysdata;
        for (devfn = 0; devfn < 0x100; devfn += 8) {
                dev->devfn = devfn;
-               pci_rescan_slot(dev);
+               found += pci_rescan_slot(dev);
+       }
+
+       if (found) {
+               struct pci_dev *tmp;
+               pci_bus_assign_resources(bus);
+               list_for_each_entry(tmp, &bus->devices, bus_list) {
+                       /* Skip already-added devices */
+                       if (!list_empty(&tmp->global_list))
+                               continue;
+                       pci_bus_add_device(tmp);
+                       add_slot(tmp);
+               }
+               pci_bus_add_devices(bus);
        }
        kfree(dev);
 }
@@ -242,7 +257,7 @@ static void pci_rescan_buses(const struc
 {
        const struct list_head *l;
        list_for_each(l,list) {
-               const struct pci_bus *b = pci_bus_b(l);
+               struct pci_bus *b = pci_bus_b(l);
                pci_rescan_bus(b);
                pci_rescan_buses(&b->children);
        }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.