* [RFC PATCH 0/3] Pass resources to pci_create_bus() and fix MIPS PCI resources
@ 2011-08-24 6:24 Deng-Cheng Zhu
2011-08-24 6:24 ` [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources Deng-Cheng Zhu
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Deng-Cheng Zhu @ 2011-08-24 6:24 UTC (permalink / raw)
To: jbarnes, ralf
Cc: linux-pci, linux-kernel, linux-mips, eyal, zenon, dengcheng.zhu
For MIPS PCI, use the resources-list style to set up root resources rather than
filling in pci_bus->resource[] array directly. This will hide some ugly
implementation details.
In addition, change the pci_create_bus() interface to pass in available
resources to get them settled down early. This is to avoid possible resource
conflicts while doing pci_scan_slot() in pci_scan_child_bus(). Note that
pcibios_fixup_bus() can get rid of such conflicts, but it's done AFTER scanning
slots.
Deng-Cheng Zhu (3):
MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to
set up root resources
PCI: Pass available resources into pci_create_bus()
MIPS: PCI: Pass controller's resources to pci_create_bus() in
pcibios_scanbus()
arch/microblaze/pci/pci-common.c | 3 +-
arch/mips/pci/pci.c | 49 +++++++++++++++++++++++++++++++++++--
arch/powerpc/kernel/pci-common.c | 3 +-
arch/sparc/kernel/pci.c | 3 +-
arch/x86/pci/acpi.c | 2 +-
drivers/pci/probe.c | 15 ++++++++---
include/linux/pci.h | 3 +-
7 files changed, 66 insertions(+), 12 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-24 6:24 [RFC PATCH 0/3] Pass resources to pci_create_bus() and fix MIPS PCI resources Deng-Cheng Zhu @ 2011-08-24 6:24 ` Deng-Cheng Zhu 2011-08-24 14:35 ` Bjorn Helgaas 2011-08-24 6:24 ` [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 3/3] MIPS: PCI: Pass controller's resources to pci_create_bus() in pcibios_scanbus() Deng-Cheng Zhu 2 siblings, 1 reply; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-24 6:24 UTC (permalink / raw) To: jbarnes, ralf Cc: linux-pci, linux-kernel, linux-mips, eyal, zenon, dengcheng.zhu Use this new style (instead of filling in the pci_bus->resource[] array directly) to hide some ugly implementation details. Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> --- arch/mips/pci/pci.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 33bba7b..7473214 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c @@ -261,6 +261,14 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev, } } +static void __devinit +pcibios_setup_root_resources(struct pci_bus *bus, struct pci_controller *ctrl) +{ + pci_bus_remove_resources(bus); + pci_bus_add_resource(bus, ctrl->io_resource, 0); + pci_bus_add_resource(bus, ctrl->mem_resource, 0); +} + void __devinit pcibios_fixup_bus(struct pci_bus *bus) { /* Propagate hose info into the subordinate devices. */ @@ -270,8 +278,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) struct pci_dev *dev = bus->self; if (!dev) { - bus->resource[0] = hose->io_resource; - bus->resource[1] = hose->mem_resource; + pcibios_setup_root_resources(bus, hose); } else if (pci_probe_only && (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { pci_read_bridge_bases(bus); -- 1.7.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-24 6:24 ` [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources Deng-Cheng Zhu @ 2011-08-24 14:35 ` Bjorn Helgaas 2011-08-25 6:41 ` Deng-Cheng Zhu 0 siblings, 1 reply; 11+ messages in thread From: Bjorn Helgaas @ 2011-08-24 14:35 UTC (permalink / raw) To: Deng-Cheng Zhu Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon On Wed, Aug 24, 2011 at 12:24 AM, Deng-Cheng Zhu <dengcheng.zhu@gmail.com> wrote: > Use this new style (instead of filling in the pci_bus->resource[] array > directly) to hide some ugly implementation details. > > Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> > --- > arch/mips/pci/pci.c | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c > index 33bba7b..7473214 100644 > --- a/arch/mips/pci/pci.c > +++ b/arch/mips/pci/pci.c > @@ -261,6 +261,14 @@ static void pcibios_fixup_device_resources(struct pci_dev *dev, > } > } > > +static void __devinit > +pcibios_setup_root_resources(struct pci_bus *bus, struct pci_controller *ctrl) > +{ > + pci_bus_remove_resources(bus); > + pci_bus_add_resource(bus, ctrl->io_resource, 0); > + pci_bus_add_resource(bus, ctrl->mem_resource, 0); > +} > + > void __devinit pcibios_fixup_bus(struct pci_bus *bus) > { > /* Propagate hose info into the subordinate devices. */ > @@ -270,8 +278,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus) > struct pci_dev *dev = bus->self; > > if (!dev) { > - bus->resource[0] = hose->io_resource; > - bus->resource[1] = hose->mem_resource; > + pcibios_setup_root_resources(bus, hose); > } else if (pci_probe_only && > (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { > pci_read_bridge_bases(bus); I don't understand this patch. Wouldn't it be enough to have [PATCH 2/3], which adds the pci_create_bus() argument with nobody using it yet, then [PATCH 3/3], which makes mips supply the new argument, and add a hunk to [PATCH 3/3] that completely removes the bus->resource fixups in pcibios_fixup_bus() at the same time? Bjorn ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-24 14:35 ` Bjorn Helgaas @ 2011-08-25 6:41 ` Deng-Cheng Zhu 2011-08-25 15:34 ` Bjorn Helgaas 0 siblings, 1 reply; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-25 6:41 UTC (permalink / raw) To: Bjorn Helgaas Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon 2011/8/24 Bjorn Helgaas <bhelgaas@google.com>: > Wouldn't it be enough to have [PATCH 2/3], which adds the > pci_create_bus() argument with nobody using it yet, then [PATCH 3/3], > which makes mips supply the new argument, and add a hunk to [PATCH > 3/3] that completely removes the bus->resource fixups in > pcibios_fixup_bus() at the same time? > > Bjorn > Do you mean to merge this patch to [PATCH 3/3]? OK, that's good! Deng-Cheng ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-25 6:41 ` Deng-Cheng Zhu @ 2011-08-25 15:34 ` Bjorn Helgaas 2011-08-25 23:14 ` Deng-Cheng Zhu 0 siblings, 1 reply; 11+ messages in thread From: Bjorn Helgaas @ 2011-08-25 15:34 UTC (permalink / raw) To: Deng-Cheng Zhu Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon On Thu, Aug 25, 2011 at 12:41 AM, Deng-Cheng Zhu <dengcheng.zhu@gmail.com> wrote: > 2011/8/24 Bjorn Helgaas <bhelgaas@google.com>: >> Wouldn't it be enough to have [PATCH 2/3], which adds the >> pci_create_bus() argument with nobody using it yet, then [PATCH 3/3], >> which makes mips supply the new argument, and add a hunk to [PATCH >> 3/3] that completely removes the bus->resource fixups in >> pcibios_fixup_bus() at the same time? >> >> Bjorn >> > > Do you mean to merge this patch to [PATCH 3/3]? OK, that's good! No, I just mean that I don't see why you need this patch at all. If you pass the list of bus resources to pci_create_bus(), there's no need to fix anything up later. Or am I missing something? Bjorn ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-25 15:34 ` Bjorn Helgaas @ 2011-08-25 23:14 ` Deng-Cheng Zhu 2011-08-25 23:23 ` Bjorn Helgaas 0 siblings, 1 reply; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-25 23:14 UTC (permalink / raw) To: Bjorn Helgaas Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon 2011/8/25 Bjorn Helgaas <bhelgaas@google.com>: > No, I just mean that I don't see why you need this patch at all. If > you pass the list of bus resources to pci_create_bus(), there's no > need to fix anything up later. Or am I missing something? Well, doing the root resource fixups in here is a *paranoid* way. It's to deal with the 'unlikely' circumstance where controller_resources() returns the NULL pointer in pcibios_scanbus() due to memory allocation failure. Most of the time (always) it's nothing more than repeating the resource list setup. But maybe we can do something like this: if (unlikely(!dev && list_empty(&bus->resources)) pcibios_setup_root_resources(bus, hose); What do you think? Deng-Cheng ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources 2011-08-25 23:14 ` Deng-Cheng Zhu @ 2011-08-25 23:23 ` Bjorn Helgaas 0 siblings, 0 replies; 11+ messages in thread From: Bjorn Helgaas @ 2011-08-25 23:23 UTC (permalink / raw) To: Deng-Cheng Zhu Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon On Thu, Aug 25, 2011 at 5:14 PM, Deng-Cheng Zhu <dengcheng.zhu@gmail.com> wrote: > 2011/8/25 Bjorn Helgaas <bhelgaas@google.com>: >> No, I just mean that I don't see why you need this patch at all. If >> you pass the list of bus resources to pci_create_bus(), there's no >> need to fix anything up later. Or am I missing something? > > Well, doing the root resource fixups in here is a *paranoid* way. It's to > deal with the 'unlikely' circumstance where controller_resources() returns > the NULL pointer in pcibios_scanbus() due to memory allocation failure. > Most of the time (always) it's nothing more than repeating the resource > list setup. But maybe we can do something like this: > > if (unlikely(!dev && list_empty(&bus->resources)) > pcibios_setup_root_resources(bus, hose); > > > What do you think? I don't think it's worth it. Just check for failure of controller_resources(), and if it fails, skip the pci_create_bus() call. You've already printed a message (you might add the PCI domain/bus number). Bjorn ^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() 2011-08-24 6:24 [RFC PATCH 0/3] Pass resources to pci_create_bus() and fix MIPS PCI resources Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources Deng-Cheng Zhu @ 2011-08-24 6:24 ` Deng-Cheng Zhu 2011-08-24 14:28 ` Bjorn Helgaas 2011-08-24 6:24 ` [RFC PATCH 3/3] MIPS: PCI: Pass controller's resources to pci_create_bus() in pcibios_scanbus() Deng-Cheng Zhu 2 siblings, 1 reply; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-24 6:24 UTC (permalink / raw) To: jbarnes, ralf Cc: linux-pci, linux-kernel, linux-mips, eyal, zenon, dengcheng.zhu Currently, after pci_create_bus(), resources available on the bus could be handled by pci_scan_child_bus(). The problem is that, in pci_scan_child_bus(), before calling arch-dependent pcibios_fixup_bus(), PCI quirks will probably conflict (while doing pci_claim_resource()) with resources like system controller's I/O resource that have not yet been added to the bus. So, add those resources right before returning the newly created bus in pci_create_bus(). A related discussion thread can be found here: http://www.spinics.net/lists/mips/msg41654.html Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> --- arch/microblaze/pci/pci-common.c | 3 ++- arch/powerpc/kernel/pci-common.c | 3 ++- arch/sparc/kernel/pci.c | 3 ++- arch/x86/pci/acpi.c | 2 +- drivers/pci/probe.c | 15 +++++++++++---- include/linux/pci.h | 3 ++- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 4cfae20..9c35aa6 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -1581,7 +1581,8 @@ static void __devinit pcibios_scan_phb(struct pci_controller *hose) node ? node->full_name : "<NO NAME>"); /* Create an empty bus for the toplevel */ - bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); + bus = pci_create_bus(hose->parent, hose->first_busno, + hose->ops, hose, NULL); if (bus == NULL) { printk(KERN_ERR "Failed to create bus for PCI domain %04x\n", hose->global_number); diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 32656f1..2ede26a 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1703,7 +1703,8 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose) node ? node->full_name : "<NO NAME>"); /* Create an empty bus for the toplevel */ - bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); + bus = pci_create_bus(hose->parent, hose->first_busno, + hose->ops, hose, NULL); if (bus == NULL) { pr_err("Failed to create bus for PCI domain %04x\n", hose->global_number); diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 1e94f94..77c38bb 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -689,7 +689,8 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm, printk("PCI: Scanning PBM %s\n", node->full_name); - bus = pci_create_bus(parent, pbm->pci_first_busno, pbm->pci_ops, pbm); + bus = pci_create_bus(parent, pbm->pci_first_busno, + pbm->pci_ops, pbm, NULL); if (!bus) { printk(KERN_ERR "Failed to create bus for %s\n", node->full_name); diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index c953302..bab2113 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -353,7 +353,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) memcpy(bus->sysdata, sd, sizeof(*sd)); kfree(sd); } else { - bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd); + bus = pci_create_bus(NULL, busnum, &pci_root_ops, sd, NULL); if (bus) { get_current_resources(device, busnum, domain, bus); bus->subordinate = pci_scan_child_bus(bus); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 8473727..7735fe7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1516,7 +1516,8 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) } struct pci_bus * pci_create_bus(struct device *parent, - int bus, struct pci_ops *ops, void *sysdata) + int bus, struct pci_ops *ops, void *sysdata, + struct pci_bus_resource *bus_res) { int error; struct pci_bus *b, *b2; @@ -1570,8 +1571,14 @@ struct pci_bus * pci_create_bus(struct device *parent, pci_create_legacy_files(b); b->number = b->secondary = bus; - b->resource[0] = &ioport_resource; - b->resource[1] = &iomem_resource; + + /* Add initial resources to the bus */ + if (bus_res != NULL) { + list_add_tail(&b->resources, &bus_res->list); + } else { + pci_bus_add_resource(b, &ioport_resource, 0); + pci_bus_add_resource(b, &iomem_resource, 0); + } return b; @@ -1592,7 +1599,7 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, { struct pci_bus *b; - b = pci_create_bus(parent, bus, ops, sysdata); + b = pci_create_bus(parent, bus, ops, sysdata, NULL); if (b) b->subordinate = pci_scan_child_bus(b); return b; diff --git a/include/linux/pci.h b/include/linux/pci.h index 8c230cb..5e1bacd 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -666,7 +666,8 @@ static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *o return root_bus; } struct pci_bus *pci_create_bus(struct device *parent, int bus, - struct pci_ops *ops, void *sysdata); + struct pci_ops *ops, void *sysdata, + struct pci_bus_resource *bus_res); struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); void pcie_update_link_speed(struct pci_bus *bus, u16 link_status); -- 1.7.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() 2011-08-24 6:24 ` [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() Deng-Cheng Zhu @ 2011-08-24 14:28 ` Bjorn Helgaas 2011-08-25 6:56 ` Deng-Cheng Zhu 0 siblings, 1 reply; 11+ messages in thread From: Bjorn Helgaas @ 2011-08-24 14:28 UTC (permalink / raw) To: Deng-Cheng Zhu Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon On Wed, Aug 24, 2011 at 12:24 AM, Deng-Cheng Zhu <dengcheng.zhu@gmail.com> wrote: > Currently, after pci_create_bus(), resources available on the bus could be > handled by pci_scan_child_bus(). The problem is that, in > pci_scan_child_bus(), before calling arch-dependent pcibios_fixup_bus(), > PCI quirks will probably conflict (while doing pci_claim_resource()) with > resources like system controller's I/O resource that have not yet been > added to the bus. So, add those resources right before returning the newly > created bus in pci_create_bus(). I like this approach a lot. Thanks for working it up. It's a nice small change with very little impact to other architectures, and you have a nice clear changelog. You might mention something about the fact that by default, the bus starts out with all of ioport_resource and iomem_resource -- that will mean something to people who know how host bridges work. > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 8473727..7735fe7 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -1516,7 +1516,8 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) > } > > struct pci_bus * pci_create_bus(struct device *parent, > - int bus, struct pci_ops *ops, void *sysdata) > + int bus, struct pci_ops *ops, void *sysdata, > + struct pci_bus_resource *bus_res) > { > int error; > struct pci_bus *b, *b2; > @@ -1570,8 +1571,14 @@ struct pci_bus * pci_create_bus(struct device *parent, > pci_create_legacy_files(b); > > b->number = b->secondary = bus; > - b->resource[0] = &ioport_resource; > - b->resource[1] = &iomem_resource; > + > + /* Add initial resources to the bus */ > + if (bus_res != NULL) { > + list_add_tail(&b->resources, &bus_res->list); > + } else { > + pci_bus_add_resource(b, &ioport_resource, 0); > + pci_bus_add_resource(b, &iomem_resource, 0); > + } Using pci_bus_add_resource() here *seems* like it should be the right thing, but I don't think it will work correctly. The problem is that struct pci_bus has both a table of resources (bus->resource[]) *and* a list (bus->resources). pci_bus_add_resource() always puts the new resource on the list, but various arch code still references the table directly, e.g., sparc has "pbus->resource[0] = &pbm->io_space" in pcibios_fixup_bus(). As written, I think this patch will break sparc because the host bridge will end up with both pbm->io_space (in the table) and ioport_resource (in the list). I think something like this would work, though: if (bus_res) list_add_tail(&b->resources, &bus_res->list); else { b->resource[0] = &ioport_resource; b->resource[1] = &iomem_resource; } Bjorn ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() 2011-08-24 14:28 ` Bjorn Helgaas @ 2011-08-25 6:56 ` Deng-Cheng Zhu 0 siblings, 0 replies; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-25 6:56 UTC (permalink / raw) To: Bjorn Helgaas Cc: jbarnes, ralf, linux-pci, linux-kernel, linux-mips, eyal, zenon 2011/8/24 Bjorn Helgaas <bhelgaas@google.com>: > I like this approach a lot. Thanks for working it up. It's a nice > small change with very little impact to other architectures, and you > have a nice clear changelog. You might mention something about the > fact that by default, the bus starts out with all of ioport_resource > and iomem_resource -- that will mean something to people who know how > host bridges work. Thanks! And I'll add this info to the patch description. > Using pci_bus_add_resource() here *seems* like it should be the right > thing, but I don't think it will work correctly. > > The problem is that struct pci_bus has both a table of resources > (bus->resource[]) *and* a list (bus->resources). > pci_bus_add_resource() always puts the new resource on the list, but > various arch code still references the table directly, e.g., sparc has > "pbus->resource[0] = &pbm->io_space" in pcibios_fixup_bus(). > > As written, I think this patch will break sparc because the host > bridge will end up with both pbm->io_space (in the table) and > ioport_resource (in the list). Good catch! I overlooked this point. > I think something like this would work, though: > > if (bus_res) > list_add_tail(&b->resources, &bus_res->list); > else { > b->resource[0] = &ioport_resource; > b->resource[1] = &iomem_resource; > } Yes, it should work. Thanks again for your time, Deng-Cheng ^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC PATCH 3/3] MIPS: PCI: Pass controller's resources to pci_create_bus() in pcibios_scanbus() 2011-08-24 6:24 [RFC PATCH 0/3] Pass resources to pci_create_bus() and fix MIPS PCI resources Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() Deng-Cheng Zhu @ 2011-08-24 6:24 ` Deng-Cheng Zhu 2 siblings, 0 replies; 11+ messages in thread From: Deng-Cheng Zhu @ 2011-08-24 6:24 UTC (permalink / raw) To: jbarnes, ralf Cc: linux-pci, linux-kernel, linux-mips, eyal, zenon, dengcheng.zhu Use the new interface of pci_create_bus() so that system controller's resources are added to the root bus upon bus creation, thereby avoiding conflicts with PCI quirks before pcibios_fixup_bus() gets the chance to do right things in pci_scan_child_bus(). Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> --- arch/mips/pci/pci.c | 38 +++++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-) diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 7473214..a5ff6bc 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c @@ -76,11 +76,41 @@ pcibios_align_resource(void *data, const struct resource *res, return start; } +static struct pci_bus_resource * +controller_resources(const struct pci_controller *ctrl) +{ + struct pci_bus_resource *mem_res, *io_res; + + mem_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL); + if (!mem_res) + goto err_out; + + mem_res->res = ctrl->mem_resource; + mem_res->flags = 0; + INIT_LIST_HEAD(&mem_res->list); + + io_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL); + if (!io_res) { + kfree(mem_res); + goto err_out; + } + + io_res->res = ctrl->io_resource; + io_res->flags = 0; + list_add(&io_res->list, &mem_res->list); + + return mem_res; +err_out: + printk(KERN_ERR "Can't allocate PCI bus resource.\n"); + return NULL; +} + static void __devinit pcibios_scanbus(struct pci_controller *hose) { static int next_busno; static int need_domain_info; struct pci_bus *bus; + struct pci_bus_resource *bus_res; if (!hose->iommu) PCI_DMA_BUS_IS_PHYS = 1; @@ -88,7 +118,13 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose) if (hose->get_busno && pci_probe_only) next_busno = (*hose->get_busno)(); - bus = pci_scan_bus(next_busno, hose->pci_ops, hose); + bus_res = controller_resources(hose); + bus = pci_create_bus(NULL, next_busno, hose->pci_ops, hose, bus_res); + if (bus) { + bus->subordinate = pci_scan_child_bus(bus); + pci_bus_add_devices(bus); + } + hose->bus = bus; need_domain_info = need_domain_info || hose->index; -- 1.7.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-08-25 23:23 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-24 6:24 [RFC PATCH 0/3] Pass resources to pci_create_bus() and fix MIPS PCI resources Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 1/3] MIPS: PCI: Use pci_bus_remove_resources()/pci_bus_add_resource() to set up root resources Deng-Cheng Zhu 2011-08-24 14:35 ` Bjorn Helgaas 2011-08-25 6:41 ` Deng-Cheng Zhu 2011-08-25 15:34 ` Bjorn Helgaas 2011-08-25 23:14 ` Deng-Cheng Zhu 2011-08-25 23:23 ` Bjorn Helgaas 2011-08-24 6:24 ` [RFC PATCH 2/3] PCI: Pass available resources into pci_create_bus() Deng-Cheng Zhu 2011-08-24 14:28 ` Bjorn Helgaas 2011-08-25 6:56 ` Deng-Cheng Zhu 2011-08-24 6:24 ` [RFC PATCH 3/3] MIPS: PCI: Pass controller's resources to pci_create_bus() in pcibios_scanbus() Deng-Cheng Zhu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®