* Re: [PATCH v3 00/34] Create PCI root buses with correct resources
[not found] ` <CAErSpo5X00LFs6XUcnqoogZEZhR2H4G7AJvh9+FAsvr3vMHkeA@mail.gmail.com>
@ 2011-11-11 16:40 ` Bjorn Helgaas
2011-11-28 18:58 ` Bjorn Helgaas
0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2011-11-11 16:40 UTC (permalink / raw)
To: linux-pci
Cc: linux-arch, James Bottomley, Benjamin Herrenschmidt, Russell King,
Deng-Cheng Zhu
On Sat, Oct 29, 2011 at 10:25 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Fri, Oct 28, 2011 at 4:25 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> The most generic way to create a PCI root bus is with pci_scan_bus(), but that
>> doesn't allow you to specify what resources are available on the bus, i.e.,
>> what the host bridge apertures are. This series fixes the problem by adding
>> a new pci_scan_root_bus() interface that takes a list of bus resources.
>
> These patches are also available here:
> git://github.com/bjorn-helgaas/linux.git on
> the "pci-scan-v3" branch.
This series touches 13 architectures. Most of the changes are fairly
simple, but some (arm, parisc, powerpc) are more involved, so I'd
appreciate any feedback you have.
Since the 3.2 merge window is closed, I'm targeting these for 3.3.
They don't all have to be merged at once, though we can't remove
pci_create_bus() (patch 34/34) until all the arch patches are in.
Bjorn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 00/34] Create PCI root buses with correct resources
2011-11-11 16:40 ` [PATCH v3 00/34] Create PCI root buses with correct resources Bjorn Helgaas
@ 2011-11-28 18:58 ` Bjorn Helgaas
0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2011-11-28 18:58 UTC (permalink / raw)
To: linux-pci
Cc: linux-arch, James Bottomley, Benjamin Herrenschmidt, Russell King,
Deng-Cheng Zhu
On Fri, Nov 11, 2011 at 8:40 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Sat, Oct 29, 2011 at 10:25 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> On Fri, Oct 28, 2011 at 4:25 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> The most generic way to create a PCI root bus is with pci_scan_bus(), but that
>>> doesn't allow you to specify what resources are available on the bus, i.e.,
>>> what the host bridge apertures are. This series fixes the problem by adding
>>> a new pci_scan_root_bus() interface that takes a list of bus resources.
>>
>> These patches are also available here:
>> git://github.com/bjorn-helgaas/linux.git on
>> the "pci-scan-v3" branch.
>
> This series touches 13 architectures. Most of the changes are fairly
> simple, but some (arm, parisc, powerpc) are more involved, so I'd
> appreciate any feedback you have.
>
> Since the 3.2 merge window is closed, I'm targeting these for 3.3.
> They don't all have to be merged at once, though we can't remove
> pci_create_bus() (patch 34/34) until all the arch patches are in.
Jesse, would you consider putting these in your branch for linux-next?
They've been floating in the ether for a month, so it seems like it's
time for the next step.
The "pci-scan-v3" github branch is still current. Let me know if
you'd like any updates or rework.
Bjorn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 01/34] PCI: add helpers for building PCI bus resource lists
[not found] ` <20111028222535.30729.73281.stgit@bhelgaas.mtv.corp.google.com>
@ 2011-12-05 19:54 ` Jesse Barnes
0 siblings, 0 replies; 9+ messages in thread
From: Jesse Barnes @ 2011-12-05 19:54 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, linux-arch
[-- Attachment #1: Type: text/plain, Size: 744 bytes --]
On Fri, 28 Oct 2011 16:25:35 -0600
Bjorn Helgaas <bhelgaas@google.com> wrote:
> We'd like to supply a list of resources when we create a new PCI bus,
> e.g., the root bus under a PCI host bridge. These are helpers for
> constructing that list.
>
> These are exported because the plan is to replace this exported interface:
> pci_scan_bus_parented()
> with this one:
> pci_add_resource(resources, ...)
> pci_scan_root_bus(..., resources)
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
Applied this series. Arch maintainers, please check these out and give
a shout if there's an issue. Current bits are in my linux-next branch.
Thanks,
--
Jesse Barnes, Intel Open Source Technology Center
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 25/34] powerpc/PCI: split PHB part out of pcibios_map_io_space()
[not found] ` <20111028222738.30729.96314.stgit@bhelgaas.mtv.corp.google.com>
@ 2011-12-06 18:07 ` Bjorn Helgaas
0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2011-12-06 18:07 UTC (permalink / raw)
To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt
[-- Attachment #1: Type: text/plain, Size: 2853 bytes --]
On Fri, Oct 28, 2011 at 4:27 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> No functional change. This is so we can use pcibios_phb_map_io_space()
> before we have a struct pci_bus.
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> arch/powerpc/kernel/pci_64.c | 40 +++++++++++++++++++++-------------------
> 1 files changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index ab34046..4401425 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -130,30 +130,13 @@ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
>
> #endif /* CONFIG_HOTPLUG */
>
> -int __devinit pcibios_map_io_space(struct pci_bus *bus)
> +static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
> {
> struct vm_struct *area;
> unsigned long phys_page;
> unsigned long size_page;
> unsigned long io_virt_offset;
> - struct pci_controller *hose;
> -
> - WARN_ON(bus == NULL);
> -
> - /* If this not a PHB, nothing to do, page tables still exist and
> - * thus HPTEs will be faulted in when needed
> - */
> - if (bus->self) {
> - pr_debug("IO mapping for PCI-PCI bridge %s\n",
> - pci_name(bus->self));
> - pr_debug(" virt=0x%016llx...0x%016llx\n",
> - bus->resource[0]->start + _IO_BASE,
> - bus->resource[0]->end + _IO_BASE);
> - return 0;
> - }
>
> - /* Get the host bridge */
> - hose = pci_bus_to_host(bus);
> phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
> size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
>
> @@ -197,11 +180,30 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
>
> return 0;
> }
> +
> +int __devinit pcibios_map_io_space(struct pci_bus *bus)
> +{
> + WARN_ON(bus == NULL);
> +
> + /* If this not a PHB, nothing to do, page tables still exist and
> + * thus HPTEs will be faulted in when needed
> + */
> + if (bus->self) {
> + pr_debug("IO mapping for PCI-PCI bridge %s\n",
> + pci_name(bus->self));
> + pr_debug(" virt=0x%016llx...0x%016llx\n",
> + bus->resource[0]->start + _IO_BASE,
> + bus->resource[0]->end + _IO_BASE);
> + return 0;
> + }
> +
> + return pcibios_phb_map_phb_io_space(pci_bus_to_host(bus));
Typo here broke the build, corrected patch attached. (Also available
at git://github.com/bjorn-helgaas/linux.git on the "pci-scan-v4"
branch as b6550f8d5a6470dd113249c00eacc922f9062450)
[-- Attachment #2: patch.split-phb-part-out --]
[-- Type: application/octet-stream, Size: 2375 bytes --]
commit b6550f8d5a6470dd113249c00eacc922f9062450
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon Oct 10 16:17:23 2011 -0600
powerpc/PCI: split PHB part out of pcibios_map_io_space()
No functional change. This is so we can use pcibios_phb_map_io_space()
before we have a struct pci_bus.
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index bcf4bf9..3318d39 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -131,30 +131,13 @@ EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
#endif /* CONFIG_HOTPLUG */
-int __devinit pcibios_map_io_space(struct pci_bus *bus)
+static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
{
struct vm_struct *area;
unsigned long phys_page;
unsigned long size_page;
unsigned long io_virt_offset;
- struct pci_controller *hose;
-
- WARN_ON(bus == NULL);
-
- /* If this not a PHB, nothing to do, page tables still exist and
- * thus HPTEs will be faulted in when needed
- */
- if (bus->self) {
- pr_debug("IO mapping for PCI-PCI bridge %s\n",
- pci_name(bus->self));
- pr_debug(" virt=0x%016llx...0x%016llx\n",
- bus->resource[0]->start + _IO_BASE,
- bus->resource[0]->end + _IO_BASE);
- return 0;
- }
- /* Get the host bridge */
- hose = pci_bus_to_host(bus);
phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
@@ -198,11 +181,30 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
return 0;
}
+
+int __devinit pcibios_map_io_space(struct pci_bus *bus)
+{
+ WARN_ON(bus == NULL);
+
+ /* If this not a PHB, nothing to do, page tables still exist and
+ * thus HPTEs will be faulted in when needed
+ */
+ if (bus->self) {
+ pr_debug("IO mapping for PCI-PCI bridge %s\n",
+ pci_name(bus->self));
+ pr_debug(" virt=0x%016llx...0x%016llx\n",
+ bus->resource[0]->start + _IO_BASE,
+ bus->resource[0]->end + _IO_BASE);
+ return 0;
+ }
+
+ return pcibios_map_phb_io_space(pci_bus_to_host(bus));
+}
EXPORT_SYMBOL_GPL(pcibios_map_io_space);
void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
{
- pcibios_map_io_space(hose->bus);
+ pcibios_map_phb_io_space(hose);
}
#define IOBASE_BRIDGE_NUMBER 0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 26/34] powerpc/PCI: convert to pci_create_root_bus()
[not found] ` <20111028222743.30729.97632.stgit@bhelgaas.mtv.corp.google.com>
@ 2011-12-06 18:09 ` Bjorn Helgaas
0 siblings, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2011-12-06 18:09 UTC (permalink / raw)
To: linux-pci; +Cc: linux-arch, Benjamin Herrenschmidt
[-- Attachment #1: Type: text/plain, Size: 3711 bytes --]
On Fri, Oct 28, 2011 at 4:27 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> Convert from pci_create_bus() to pci_create_root_bus(). This way the root
> bus resources are correct immediately. This patch doesn't fix a problem
> because powerpc fixed the resources before scanning the bus, but it makes
> powerpc more consistent with other architectures.
>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> arch/powerpc/kernel/pci-common.c | 25 ++++++++++++++-----------
> 1 files changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 942ced2..8c47c57 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1554,14 +1554,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
> return pci_enable_resources(dev, mask);
> }
>
> -static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
> +static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
> {
> - struct pci_bus *bus = hose->bus;
> struct resource *res;
> int i;
>
> /* Hookup PHB IO resource */
> - bus->resource[0] = res = &hose->io_resource;
> + res = &hose->io_resource;
>
> if (!res->flags) {
> printk(KERN_WARNING "PCI: I/O resource not set for host"
> @@ -1579,6 +1578,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
> (unsigned long long)res->start,
> (unsigned long long)res->end,
> (unsigned long)res->flags);
> + pci_add_resource(resources, res);
>
> /* Hookup PHB Memory resources */
> for (i = 0; i < 3; ++i) {
> @@ -1596,12 +1596,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
> res->flags = IORESOURCE_MEM;
> #endif /* CONFIG_PPC32 */
> }
> - bus->resource[i+1] = res;
>
> pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
> (unsigned long long)res->start,
> (unsigned long long)res->end,
> (unsigned long)res->flags);
> + pci_add_resource(resources, res);
> }
>
> pr_debug("PCI: PHB MEM offset = %016llx\n",
> @@ -1695,6 +1695,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
> */
> void __devinit pcibios_scan_phb(struct pci_controller *hose)
> {
> + LIST_HEAD(resources);
> struct pci_bus *bus;
> struct device_node *node = hose->dn;
> int mode;
> @@ -1702,22 +1703,24 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
> pr_debug("PCI: Scanning PHB %s\n",
> node ? node->full_name : "<NO NAME>");
>
> + /* Get some IO space for the new PHB */
> + pcibios_setup_phb_io_space(hose);
> +
> + /* Wire up PHB bus resources */
> + pcibios_setup_phb_resources(hose, &resources);
> +
> /* Create an empty bus for the toplevel */
> - bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
> + bus = pci_create_root_bus(hose->parent, hose->first_busno,
> + hose->ops, hose, resources);
Typo here ("resources" should be "&resources") broke the build,
corrected patch attached. (Also available
at git://github.com/bjorn-helgaas/linux.git on the "pci-scan-v4"
branch as 481c96ef546fd0a1ebd9254771f24d136aaff7cc)
[-- Attachment #2: patch.convert-to-pci_create_root_bus --]
[-- Type: application/octet-stream, Size: 3410 bytes --]
commit 481c96ef546fd0a1ebd9254771f24d136aaff7cc
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon Oct 10 16:17:46 2011 -0600
powerpc/PCI: convert to pci_create_root_bus()
Convert from pci_create_bus() to pci_create_root_bus(). This way the root
bus resources are correct immediately. This patch doesn't fix a problem
because powerpc fixed the resources before scanning the bus, but it makes
powerpc more consistent with other architectures.
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 248b788..2aa707b 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1555,14 +1555,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
return pci_enable_resources(dev, mask);
}
-static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
+static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
{
- struct pci_bus *bus = hose->bus;
struct resource *res;
int i;
/* Hookup PHB IO resource */
- bus->resource[0] = res = &hose->io_resource;
+ res = &hose->io_resource;
if (!res->flags) {
printk(KERN_WARNING "PCI: I/O resource not set for host"
@@ -1580,6 +1579,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
(unsigned long long)res->start,
(unsigned long long)res->end,
(unsigned long)res->flags);
+ pci_add_resource(resources, res);
/* Hookup PHB Memory resources */
for (i = 0; i < 3; ++i) {
@@ -1597,12 +1597,12 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
res->flags = IORESOURCE_MEM;
#endif /* CONFIG_PPC32 */
}
- bus->resource[i+1] = res;
pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
(unsigned long long)res->start,
(unsigned long long)res->end,
(unsigned long)res->flags);
+ pci_add_resource(resources, res);
}
pr_debug("PCI: PHB MEM offset = %016llx\n",
@@ -1696,6 +1696,7 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
*/
void __devinit pcibios_scan_phb(struct pci_controller *hose)
{
+ LIST_HEAD(resources);
struct pci_bus *bus;
struct device_node *node = hose->dn;
int mode;
@@ -1703,22 +1704,24 @@ void __devinit pcibios_scan_phb(struct pci_controller *hose)
pr_debug("PCI: Scanning PHB %s\n",
node ? node->full_name : "<NO NAME>");
+ /* Get some IO space for the new PHB */
+ pcibios_setup_phb_io_space(hose);
+
+ /* Wire up PHB bus resources */
+ pcibios_setup_phb_resources(hose, &resources);
+
/* Create an empty bus for the toplevel */
- bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
+ bus = pci_create_root_bus(hose->parent, hose->first_busno,
+ hose->ops, hose, &resources);
if (bus == NULL) {
pr_err("Failed to create bus for PCI domain %04x\n",
hose->global_number);
+ pci_free_resource_list(&resources);
return;
}
bus->secondary = hose->first_busno;
hose->bus = bus;
- /* Get some IO space for the new PHB */
- pcibios_setup_phb_io_space(hose);
-
- /* Wire up PHB bus resources */
- pcibios_setup_phb_resources(hose);
-
/* Get probe mode and perform scan */
mode = PCI_PROBE_NORMAL;
if (node && ppc_md.pci_probe_mode)
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 08/34] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
[not found] ` <20111028222611.30729.46284.stgit@bhelgaas.mtv.corp.google.com>
@ 2011-12-16 21:24 ` Bjorn Helgaas
2012-01-04 17:38 ` Jesse Barnes
0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2011-12-16 21:24 UTC (permalink / raw)
To: linux-pci, Jesse Barnes; +Cc: linux-arch, linux-alpha
[-- Attachment #1: Type: text/plain, Size: 3124 bytes --]
On Fri, Oct 28, 2011 at 4:26 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
> resource fixups. This fixes the problem of "early" and "header" quirks
> seeing incorrect root bus resources.
>
> CC: linux-alpha@vger.kernel.org
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> arch/alpha/kernel/pci.c | 37 ++++++++++++++++++++-----------------
> 1 files changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> index c9ab94e..e9e78a2 100644
> --- a/arch/alpha/kernel/pci.c
> +++ b/arch/alpha/kernel/pci.c
> @@ -286,22 +286,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
> struct pci_controller *hose = bus->sysdata;
> struct pci_dev *dev = bus->self;
>
> - if (!dev) {
> - /* Root bus. */
> - u32 pci_mem_end;
> - u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
> - unsigned long end;
> -
> - bus->resource[0] = hose->io_space;
> - bus->resource[1] = hose->mem_space;
> -
> - /* Adjust hose mem_space limit to prevent PCI allocations
> - in the iommu windows. */
> - pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
> - end = hose->mem_space->start + pci_mem_end;
> - if (hose->mem_space->end > end)
> - hose->mem_space->end = end;
> - } else if (pci_probe_only &&
> + if (pci_probe_only && dev &&
> (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
> pci_read_bridge_bases(bus);
> pcibios_fixup_device_resources(dev, bus);
> @@ -414,13 +399,31 @@ void __init
> common_init_pci(void)
> {
> struct pci_controller *hose;
> + struct list_head resources;
> struct pci_bus *bus;
> int next_busno;
> int need_domain_info = 0;
> + u32 pci_mem_end;
> + u32 sg_base;
> + unsigned long end;
>
> /* Scan all of the recorded PCI controllers. */
> for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
> - bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
> + sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
> +
> + /* Adjust hose mem_space limit to prevent PCI allocations
> + in the iommu windows. */
> + pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
> + end = hose->mem_space->start + pci_mem_end;
> + if (hose->mem_space->end > end)
> + hose->mem_space->end = end;
> +
> + INIT_LIST_HEAD(&resources);
> + pci_add_resource(&resources, &hose->io_space);
> + pci_add_resource(&resources, &hose->mem_space);
These two lines are errors: hose->io_space is already a struct
resource pointer, so we shouldn't take the pointer's address. Updated
patch and incremental patch attached.
Bjorn
[-- Attachment #2: patch.alpha-pci-convert-to-pci_scan_root_bus --]
[-- Type: application/octet-stream, Size: 2703 bytes --]
commit 4ceba2fbfd72f331a20c6638c9db926b95da73b1
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Tue Oct 11 17:07:48 2011 -0600
alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups. This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.
CC: linux-alpha@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index c9ab94e..fcb4b91 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -281,27 +281,9 @@ pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus)
void __devinit
pcibios_fixup_bus(struct pci_bus *bus)
{
- /* Propagate hose info into the subordinate devices. */
-
- struct pci_controller *hose = bus->sysdata;
struct pci_dev *dev = bus->self;
- if (!dev) {
- /* Root bus. */
- u32 pci_mem_end;
- u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
- unsigned long end;
-
- bus->resource[0] = hose->io_space;
- bus->resource[1] = hose->mem_space;
-
- /* Adjust hose mem_space limit to prevent PCI allocations
- in the iommu windows. */
- pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
- end = hose->mem_space->start + pci_mem_end;
- if (hose->mem_space->end > end)
- hose->mem_space->end = end;
- } else if (pci_probe_only &&
+ if (pci_probe_only && dev &&
(dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
pci_read_bridge_bases(bus);
pcibios_fixup_device_resources(dev, bus);
@@ -414,13 +396,31 @@ void __init
common_init_pci(void)
{
struct pci_controller *hose;
+ struct list_head resources;
struct pci_bus *bus;
int next_busno;
int need_domain_info = 0;
+ u32 pci_mem_end;
+ u32 sg_base;
+ unsigned long end;
/* Scan all of the recorded PCI controllers. */
for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
- bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
+ sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
+
+ /* Adjust hose mem_space limit to prevent PCI allocations
+ in the iommu windows. */
+ pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
+ end = hose->mem_space->start + pci_mem_end;
+ if (hose->mem_space->end > end)
+ hose->mem_space->end = end;
+
+ INIT_LIST_HEAD(&resources);
+ pci_add_resource(&resources, hose->io_space);
+ pci_add_resource(&resources, hose->mem_space);
+
+ bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
+ hose, &resources);
hose->bus = bus;
hose->need_domain_info = need_domain_info;
next_busno = bus->subordinate + 1;
[-- Attachment #3: patch.alpha-incremental --]
[-- Type: application/octet-stream, Size: 781 bytes --]
v2: fix resource pointer error
diff -u b/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
--- b/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -281,9 +281,6 @@
void __devinit
pcibios_fixup_bus(struct pci_bus *bus)
{
- /* Propagate hose info into the subordinate devices. */
-
- struct pci_controller *hose = bus->sysdata;
struct pci_dev *dev = bus->self;
if (pci_probe_only && dev &&
@@ -419,8 +416,8 @@
hose->mem_space->end = end;
INIT_LIST_HEAD(&resources);
- pci_add_resource(&resources, &hose->io_space);
- pci_add_resource(&resources, &hose->mem_space);
+ pci_add_resource(&resources, hose->io_space);
+ pci_add_resource(&resources, hose->mem_space);
bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
hose, &resources);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 09/34] arm/PCI: convert to pci_scan_root_bus() for correct root bus resources
[not found] ` <20111028222616.30729.96687.stgit@bhelgaas.mtv.corp.google.com>
@ 2011-12-23 1:10 ` Bjorn Helgaas
2012-01-04 17:28 ` Jesse Barnes
0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2011-12-23 1:10 UTC (permalink / raw)
To: linux-pci, Jesse Barnes; +Cc: linux-arch, Russell King
[-- Attachment #1: Type: text/plain, Size: 288 bytes --]
Working through this with a cross-compiler, I found a build bug in
this patch. Updated patch and incremental patch (from commit
9a1d98b3a0d8621 in your linux-next branch) attached.
My cross-compiler can only build about half of the ARM configs, but
better than nothing, I guess.
Bjorn
[-- Attachment #2: patch.arm-pci-convert-to-pci_scan_root_bus --]
[-- Type: application/octet-stream, Size: 24512 bytes --]
commit 66be6a8c4b603c78801467de8b1ee3e3f1c602b8
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Tue Oct 11 18:03:53 2011 -0600
arm/PCI: convert to pci_scan_root_bus() for correct root bus resources
Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
resource fixups. This fixes the problem of "early" and "header" quirks
seeing incorrect root bus resources.
CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c
index b539ec8..a9ff867 100644
--- a/arch/arm/common/it8152.c
+++ b/arch/arm/common/it8152.c
@@ -299,8 +299,8 @@ int __init it8152_pci_setup(int nr, struct pci_sys_data *sys)
goto err1;
}
- sys->resource[0] = &it8152_io;
- sys->resource[1] = &it8152_mem;
+ pci_add_resource(&sys->resources, &it8152_io);
+ pci_add_resource(&sys->resources, &it8152_mem);
if (platform_notify || platform_notify_remove) {
printk(KERN_ERR "PCI: Can't use platform_notify\n");
@@ -352,7 +352,7 @@ void pcibios_set_master(struct pci_dev *dev)
struct pci_bus * __init it8152_pci_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(nr, &it8152_ops, sys);
+ return pci_scan_root_bus(NULL, nr, &it8152_ops, sys, &sys->resources);
}
EXPORT_SYMBOL(dma_set_coherent_mask);
diff --git a/arch/arm/common/via82c505.c b/arch/arm/common/via82c505.c
index 8421d39..67dd2af 100644
--- a/arch/arm/common/via82c505.c
+++ b/arch/arm/common/via82c505.c
@@ -86,7 +86,8 @@ int __init via82c505_setup(int nr, struct pci_sys_data *sys)
struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
{
if (nr == 0)
- return pci_scan_bus(0, &via82c505_ops, sysdata);
+ return pci_scan_root_bus(NULL, 0, &via82c505_ops, sysdata,
+ &sysdata->resources);
return NULL;
}
diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index 186efd4..d943b7d 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -40,7 +40,7 @@ struct pci_sys_data {
u64 mem_offset; /* bus->cpu memory mapping offset */
unsigned long io_offset; /* bus->cpu IO mapping offset */
struct pci_bus *bus; /* PCI bus */
- struct resource *resource[3]; /* Primary PCI bus resources */
+ struct list_head resources; /* root bus resources (apertures) */
/* Bridge swizzling */
u8 (*swizzle)(struct pci_dev *, u8 *);
/* IRQ mapping */
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index b530e91..bf4439a 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -316,21 +316,6 @@ pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
}
}
-static void __devinit
-pbus_assign_bus_resources(struct pci_bus *bus, struct pci_sys_data *root)
-{
- struct pci_dev *dev = bus->self;
- int i;
-
- if (!dev) {
- /*
- * Assign root bus resources.
- */
- for (i = 0; i < 3; i++)
- bus->resource[i] = root->resource[i];
- }
-}
-
/*
* pcibios_fixup_bus - Called after each bus is probed,
* but before its children are examined.
@@ -341,8 +326,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
struct pci_dev *dev;
u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_FAST_BACK;
- pbus_assign_bus_resources(bus, root);
-
/*
* Walk the devices on this bus, working out what we can
* and can't support.
@@ -508,12 +491,18 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
sys->busnr = busnr;
sys->swizzle = hw->swizzle;
sys->map_irq = hw->map_irq;
- sys->resource[0] = &ioport_resource;
- sys->resource[1] = &iomem_resource;
+ INIT_LIST_HEAD(&sys->resources);
ret = hw->setup(nr, sys);
if (ret > 0) {
+ if (list_empty(&sys->resources)) {
+ pci_add_resource(&sys->resources,
+ &ioport_resource);
+ pci_add_resource(&sys->resources,
+ &iomem_resource);
+ }
+
sys->bus = hw->scan(nr, sys);
if (!sys->bus)
diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c
index 0f8fca4..e159d69 100644
--- a/arch/arm/mach-cns3xxx/pcie.c
+++ b/arch/arm/mach-cns3xxx/pcie.c
@@ -151,13 +151,12 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
struct cns3xxx_pcie *cnspci = sysdata_to_cnspci(sys);
struct resource *res_io = &cnspci->res_io;
struct resource *res_mem = &cnspci->res_mem;
- struct resource **sysres = sys->resource;
BUG_ON(request_resource(&iomem_resource, res_io) ||
request_resource(&iomem_resource, res_mem));
- sysres[0] = res_io;
- sysres[1] = res_mem;
+ pci_add_resource(&sys->resources, res_io);
+ pci_add_resource(&sys->resources, res_mem);
return 1;
}
@@ -169,7 +168,8 @@ static struct pci_ops cns3xxx_pcie_ops = {
static struct pci_bus *cns3xxx_pci_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &cns3xxx_pcie_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &cns3xxx_pcie_ops, sys,
+ &sys->resources);
}
static int cns3xxx_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index aa2b3a0..d5b5dce 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -69,7 +69,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
pp->res[0].flags = IORESOURCE_IO;
if (request_resource(&ioport_resource, &pp->res[0]))
panic("Request PCIe IO resource failed\n");
- sys->resource[0] = &pp->res[0];
+ pci_add_resource(&sys->resources, &pp->res[0]);
/*
* IORESOURCE_MEM
@@ -88,9 +88,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
pp->res[1].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource, &pp->res[1]))
panic("Request PCIe Memory resource failed\n");
- sys->resource[1] = &pp->res[1];
-
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &pp->res[1]);
return 1;
}
@@ -184,7 +182,8 @@ dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
struct pci_bus *bus;
if (nr < num_pcie_ports) {
- bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+ bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+ &sys->resources);
} else {
bus = NULL;
BUG();
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index 18c32a5..f685650 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -275,9 +275,9 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
allocate_resource(&iomem_resource, &res[0], 0x40000000,
0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
- sys->resource[0] = &ioport_resource;
- sys->resource[1] = &res[0];
- sys->resource[2] = &res[1];
+ pci_add_resource(&sys->resources, &ioport_resource);
+ pci_add_resource(&sys->resources, &res[0]);
+ pci_add_resource(&sys->resources, &res[1]);
sys->mem_offset = DC21285_PCI_MEM;
return 1;
@@ -285,7 +285,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
struct pci_bus * __init dc21285_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(0, &dc21285_ops, sys);
+ return pci_scan_root_bus(NULL, 0, &dc21285_ops, sys, &sys->resources);
}
#define dc21285_request_irq(_a, _b, _c, _d, _e) \
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
index b4d8f8b..3c82566 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -359,7 +359,7 @@ static struct resource pre_mem = {
.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
};
-static int __init pci_v3_setup_resources(struct resource **resource)
+static int __init pci_v3_setup_resources(struct pci_sys_data *sys)
{
if (request_resource(&iomem_resource, &non_mem)) {
printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
@@ -374,13 +374,13 @@ static int __init pci_v3_setup_resources(struct resource **resource)
}
/*
- * bus->resource[0] is the IO resource for this bus
- * bus->resource[1] is the mem resource for this bus
- * bus->resource[2] is the prefetch mem resource for this bus
+ * the IO resource for this bus
+ * the mem resource for this bus
+ * the prefetch mem resource for this bus
*/
- resource[0] = &ioport_resource;
- resource[1] = &non_mem;
- resource[2] = &pre_mem;
+ pci_add_resource(&sys->resources, &ioport_resource);
+ pci_add_resource(&sys->resources, &non_mem);
+ pci_add_resource(&sys->resources, &pre_mem);
return 1;
}
@@ -481,7 +481,7 @@ int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
if (nr == 0) {
sys->mem_offset = PHYS_PCI_MEM_BASE;
- ret = pci_v3_setup_resources(sys->resource);
+ ret = pci_v3_setup_resources(sys);
}
return ret;
@@ -489,7 +489,8 @@ int __init pci_v3_setup(int nr, struct pci_sys_data *sys)
struct pci_bus * __init pci_v3_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &pci_v3_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &pci_v3_ops, sys,
+ &sys->resources);
}
/*
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
index db012fa..b8f5a87 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -537,14 +537,14 @@ struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *sys)
while(time_before(jiffies, atux_trhfa_timeout))
udelay(100);
- bus = pci_bus_atux = pci_scan_bus(sys->busnr,
- &iop13xx_atux_ops,
- sys);
+ bus = pci_bus_atux = pci_scan_root_bus(NULL, sys->busnr,
+ &iop13xx_atux_ops,
+ sys, &sys->resources);
break;
case IOP13XX_INIT_ATU_ATUE:
- bus = pci_bus_atue = pci_scan_bus(sys->busnr,
- &iop13xx_atue_ops,
- sys);
+ bus = pci_bus_atue = pci_scan_root_bus(NULL, sys->busnr,
+ &iop13xx_atue_ops,
+ sys, &sys->resources);
break;
}
@@ -1084,9 +1084,8 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
request_resource(&ioport_resource, &res[0]);
request_resource(&iomem_resource, &res[1]);
- sys->resource[0] = &res[0];
- sys->resource[1] = &res[1];
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &res[0]);
+ pci_add_resource(&sys->resources, &res[1]);
return 1;
}
diff --git a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c
index af99945..39c08a1 100644
--- a/arch/arm/mach-ixp2000/enp2611.c
+++ b/arch/arm/mach-ixp2000/enp2611.c
@@ -145,7 +145,8 @@ static struct pci_ops enp2611_pci_ops = {
static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &enp2611_pci_ops, sys,
+ &sys->resources);
}
static int __init enp2611_pci_map_irq(const struct pci_dev *dev, u8 slot,
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index f5098b3..626fda4 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -132,7 +132,8 @@ static struct pci_ops ixp2000_pci_ops = {
struct pci_bus *ixp2000_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
{
- return pci_scan_bus(sysdata->busnr, &ixp2000_pci_ops, sysdata);
+ return pci_scan_root_bus(NULL, sysdata->busnr, &ixp2000_pci_ops,
+ sysdata, &sysdata->resources);
}
@@ -242,9 +243,8 @@ int ixp2000_pci_setup(int nr, struct pci_sys_data *sys)
if (nr >= 1)
return 0;
- sys->resource[0] = &ixp2000_pci_io_space;
- sys->resource[1] = &ixp2000_pci_mem_space;
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &ixp2000_pci_io_space);
+ pci_add_resource(&sys->resources, &ixp2000_pci_mem_space);
return 1;
}
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index e6be571..25b5c46 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -143,7 +143,8 @@ struct pci_ops ixp23xx_pci_ops = {
struct pci_bus *ixp23xx_pci_scan_bus(int nr, struct pci_sys_data *sysdata)
{
- return pci_scan_bus(sysdata->busnr, &ixp23xx_pci_ops, sysdata);
+ return pci_scan_root_bus(NULL, sysdata->busnr, &ixp23xx_pci_ops,
+ sysdata, &sysdata->resources);
}
int ixp23xx_pci_abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
@@ -280,9 +281,8 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
if (nr >= 1)
return 0;
- sys->resource[0] = &ixp23xx_pci_io_space;
- sys->resource[1] = &ixp23xx_pci_mem_space;
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &ixp23xx_pci_io_space);
+ pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space);
return 1;
}
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 8325058..5eff15f 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -472,9 +472,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
request_resource(&ioport_resource, &res[0]);
request_resource(&iomem_resource, &res[1]);
- sys->resource[0] = &res[0];
- sys->resource[1] = &res[1];
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &res[0]);
+ pci_add_resource(&sys->resources, &res[1]);
platform_notify = ixp4xx_pci_platform_notify;
platform_notify_remove = ixp4xx_pci_platform_notify_remove;
@@ -484,7 +483,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
struct pci_bus * __devinit ixp4xx_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &ixp4xx_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &ixp4xx_ops, sys,
+ &sys->resources);
}
int dma_set_coherent_mask(struct device *dev, u64 mask)
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index 74b992d..9ca38de 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -198,9 +198,8 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
if (request_resource(&iomem_resource, &pp->res[1]))
panic("Request PCIe%d Memory resource failed\n", index);
- sys->resource[0] = &pp->res[0];
- sys->resource[1] = &pp->res[1];
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &pp->res[0]);
+ pci_add_resource(&sys->resources, &pp->res[1]);
sys->io_offset = 0;
/*
@@ -236,7 +235,8 @@ kirkwood_pcie_scan_bus(int nr, struct pci_sys_data *sys)
struct pci_bus *bus;
if (nr < num_pcie_ports) {
- bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+ bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+ &sys->resources);
} else {
bus = NULL;
BUG();
diff --git a/arch/arm/mach-ks8695/pci.c b/arch/arm/mach-ks8695/pci.c
index c7c9a18..b26f992 100644
--- a/arch/arm/mach-ks8695/pci.c
+++ b/arch/arm/mach-ks8695/pci.c
@@ -143,7 +143,8 @@ static struct pci_ops ks8695_pci_ops = {
static struct pci_bus* __init ks8695_pci_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &ks8695_pci_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &ks8695_pci_ops, sys,
+ &sys->resources);
}
static struct resource pci_mem = {
@@ -168,9 +169,8 @@ static int __init ks8695_pci_setup(int nr, struct pci_sys_data *sys)
request_resource(&iomem_resource, &pci_mem);
request_resource(&ioport_resource, &pci_io);
- sys->resource[0] = &pci_io;
- sys->resource[1] = &pci_mem;
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &pci_io);
+ pci_add_resource(&sys->resources, &pci_mem);
/* Assign and enable processor bridge */
ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index c51af1c..c701135 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -155,9 +155,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
orion_pcie_setup(pp->base, &mv78xx0_mbus_dram_info);
- sys->resource[0] = &pp->res[0];
- sys->resource[1] = &pp->res[1];
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &pp->res[0]);
+ pci_add_resource(&sys->resources, &pp->res[1]);
return 1;
}
@@ -251,7 +250,8 @@ mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
struct pci_bus *bus;
if (nr < num_pcie_ports) {
- bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+ bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+ &sys->resources);
} else {
bus = NULL;
BUG();
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c
index bc4a920..4eb9364 100644
--- a/arch/arm/mach-orion5x/pci.c
+++ b/arch/arm/mach-orion5x/pci.c
@@ -176,7 +176,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
if (request_resource(&ioport_resource, &res[0]))
panic("Request PCIe IO resource failed\n");
- sys->resource[0] = &res[0];
+ pci_add_resource(&sys->resources, &res[0]);
/*
* IORESOURCE_MEM
@@ -187,9 +187,8 @@ static int __init pcie_setup(struct pci_sys_data *sys)
res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
if (request_resource(&iomem_resource, &res[1]))
panic("Request PCIe Memory resource failed\n");
- sys->resource[1] = &res[1];
+ pci_add_resource(&sys->resources, &res[1]);
- sys->resource[2] = NULL;
sys->io_offset = 0;
return 1;
@@ -505,7 +504,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
if (request_resource(&ioport_resource, &res[0]))
panic("Request PCI IO resource failed\n");
- sys->resource[0] = &res[0];
+ pci_add_resource(&sys->resources, &res[0]);
/*
* IORESOURCE_MEM
@@ -516,9 +515,8 @@ static int __init pci_setup(struct pci_sys_data *sys)
res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
if (request_resource(&iomem_resource, &res[1]))
panic("Request PCI Memory resource failed\n");
- sys->resource[1] = &res[1];
+ pci_add_resource(&sys->resources, &res[1]);
- sys->resource[2] = NULL;
sys->io_offset = 0;
return 1;
@@ -579,9 +577,11 @@ struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys
struct pci_bus *bus;
if (nr == 0) {
- bus = pci_scan_bus(sys->busnr, &pcie_ops, sys);
+ bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys,
+ &sys->resources);
} else if (nr == 1 && !orion5x_pci_disabled) {
- bus = pci_scan_bus(sys->busnr, &pci_ops, sys);
+ bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys,
+ &sys->resources);
} else {
bus = NULL;
BUG();
diff --git a/arch/arm/mach-sa1100/pci-nanoengine.c b/arch/arm/mach-sa1100/pci-nanoengine.c
index dd39fee..0d01ca7 100644
--- a/arch/arm/mach-sa1100/pci-nanoengine.c
+++ b/arch/arm/mach-sa1100/pci-nanoengine.c
@@ -131,7 +131,8 @@ static int __init pci_nanoengine_map_irq(const struct pci_dev *dev, u8 slot,
struct pci_bus * __init pci_nanoengine_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &pci_nano_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &pci_nano_ops, sys,
+ &sys->resources);
}
static struct resource pci_io_ports = {
@@ -226,7 +227,7 @@ static struct resource pci_prefetchable_memory = {
.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
};
-static int __init pci_nanoengine_setup_resources(struct resource **resource)
+static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
{
if (request_resource(&ioport_resource, &pci_io_ports)) {
printk(KERN_ERR "PCI: unable to allocate io port region\n");
@@ -243,9 +244,9 @@ static int __init pci_nanoengine_setup_resources(struct resource **resource)
printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
return -EBUSY;
}
- resource[0] = &pci_io_ports;
- resource[1] = &pci_non_prefetchable_memory;
- resource[2] = &pci_prefetchable_memory;
+ pci_add_resource(&sys->resources, &pci_io_ports);
+ pci_add_resource(&sys->resources, &pci_non_prefetchable_memory);
+ pci_add_resource(&sys->resources, &pci_prefetchable_memory);
return 1;
}
@@ -260,7 +261,7 @@ int __init pci_nanoengine_setup(int nr, struct pci_sys_data *sys)
if (nr == 0) {
sys->mem_offset = NANO_PCI_MEM_RW_PHYS;
sys->io_offset = 0x400;
- ret = pci_nanoengine_setup_resources(sys->resource);
+ ret = pci_nanoengine_setup_resources(sys);
/* Enable alternate memory bus master mode, see
* "Intel StrongARM SA1110 Developer's Manual",
* section 10.8, "Alternate Memory Bus Master Mode". */
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c
index 97ef3e5..92947d8 100644
--- a/arch/arm/mach-tegra/pcie.c
+++ b/arch/arm/mach-tegra/pcie.c
@@ -409,7 +409,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
pp->res[0].flags = IORESOURCE_IO;
if (request_resource(&ioport_resource, &pp->res[0]))
panic("Request PCIe IO resource failed\n");
- sys->resource[0] = &pp->res[0];
+ pci_add_resource(&sys->resources, &pp->res[0]);
/*
* IORESOURCE_MEM
@@ -428,7 +428,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
pp->res[1].flags = IORESOURCE_MEM;
if (request_resource(&iomem_resource, &pp->res[1]))
panic("Request PCIe Memory resource failed\n");
- sys->resource[1] = &pp->res[1];
+ pci_add_resource(&sys->resources, &pp->res[1]);
/*
* IORESOURCE_MEM | IORESOURCE_PREFETCH
@@ -447,7 +447,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
if (request_resource(&iomem_resource, &pp->res[2]))
panic("Request PCIe Prefetch Memory resource failed\n");
- sys->resource[2] = &pp->res[2];
+ pci_add_resource(&sys->resources, &pp->res[2]);
return 1;
}
@@ -468,7 +468,8 @@ static struct pci_bus __init *tegra_pcie_scan_bus(int nr,
pp = tegra_pcie.port + nr;
pp->root_bus_nr = sys->busnr;
- return pci_scan_bus(sys->busnr, &tegra_pcie_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &tegra_pcie_ops, sys,
+ &sys->resources);
}
static struct hw_pci tegra_pcie_hw __initdata = {
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index c898deb..90069bc 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -191,7 +191,7 @@ static struct resource pre_mem = {
.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
};
-static int __init pci_versatile_setup_resources(struct resource **resource)
+static int __init pci_versatile_setup_resources(struct list_head *resources)
{
int ret = 0;
@@ -215,13 +215,13 @@ static int __init pci_versatile_setup_resources(struct resource **resource)
}
/*
- * bus->resource[0] is the IO resource for this bus
- * bus->resource[1] is the mem resource for this bus
- * bus->resource[2] is the prefetch mem resource for this bus
+ * the IO resource for this bus
+ * the mem resource for this bus
+ * the prefetch mem resource for this bus
*/
- resource[0] = &io_mem;
- resource[1] = &non_mem;
- resource[2] = &pre_mem;
+ pci_add_resource(resources, &io_mem);
+ pci_add_resource(resources, &non_mem);
+ pci_add_resource(resources, &pre_mem);
goto out;
@@ -250,7 +250,7 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
if (nr == 0) {
sys->mem_offset = 0;
- ret = pci_versatile_setup_resources(sys->resource);
+ ret = pci_versatile_setup_resources(&sys->resources);
if (ret < 0) {
printk("pci_versatile_setup: resources... oops?\n");
goto out;
@@ -306,7 +306,8 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
struct pci_bus * __init pci_versatile_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &pci_versatile_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &pci_versatile_ops, sys,
+ &sys->resources);
}
void __init pci_versatile_preinit(void)
diff --git a/arch/arm/plat-iop/pci.c b/arch/arm/plat-iop/pci.c
index 845549c..f4d40a2 100644
--- a/arch/arm/plat-iop/pci.c
+++ b/arch/arm/plat-iop/pci.c
@@ -215,16 +215,16 @@ int iop3xx_pci_setup(int nr, struct pci_sys_data *sys)
sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0;
sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR;
- sys->resource[0] = &res[0];
- sys->resource[1] = &res[1];
- sys->resource[2] = NULL;
+ pci_add_resource(&sys->resources, &res[0]);
+ pci_add_resource(&sys->resources, &res[1]);
return 1;
}
struct pci_bus *iop3xx_pci_scan_bus(int nr, struct pci_sys_data *sys)
{
- return pci_scan_bus(sys->busnr, &iop3xx_ops, sys);
+ return pci_scan_root_bus(NULL, sys->busnr, &iop3xx_ops, sys,
+ &sys->resources);
}
void __init iop3xx_atu_setup(void)
[-- Attachment #3: patch.arm-interdiff --]
[-- Type: application/octet-stream, Size: 1984 bytes --]
diff -u b/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
--- b/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -359,7 +359,7 @@
.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
};
-static int __init pci_v3_setup_resources(struct list_head *resources)
+static int __init pci_v3_setup_resources(struct pci_sys_data *sys)
{
if (request_resource(&iomem_resource, &non_mem)) {
printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
@@ -378,9 +378,9 @@
* the mem resource for this bus
* the prefetch mem resource for this bus
*/
- pci_add_resource(resources, &ioport_resource);
- pci_add_resource(resources, &non_mem);
- pci_add_resource(resources, &pre_mem);
+ pci_add_resource(&sys->resources, &ioport_resource);
+ pci_add_resource(&sys->resources, &non_mem);
+ pci_add_resource(&sys->resources, &pre_mem);
return 1;
}
@@ -481,7 +481,7 @@
if (nr == 0) {
sys->mem_offset = PHYS_PCI_MEM_BASE;
- ret = pci_v3_setup_resources(&sys->resources);
+ ret = pci_v3_setup_resources(sys);
}
return ret;
diff -u b/arch/arm/mach-sa1100/pci-nanoengine.c b/arch/arm/mach-sa1100/pci-nanoengine.c
--- b/arch/arm/mach-sa1100/pci-nanoengine.c
+++ b/arch/arm/mach-sa1100/pci-nanoengine.c
@@ -227,7 +227,7 @@
.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
};
-static int __init pci_nanoengine_setup_resources(struct resource **resource)
+static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
{
if (request_resource(&ioport_resource, &pci_io_ports)) {
printk(KERN_ERR "PCI: unable to allocate io port region\n");
@@ -261,7 +261,7 @@
if (nr == 0) {
sys->mem_offset = NANO_PCI_MEM_RW_PHYS;
sys->io_offset = 0x400;
- ret = pci_nanoengine_setup_resources(sys->resource);
+ ret = pci_nanoengine_setup_resources(sys);
/* Enable alternate memory bus master mode, see
* "Intel StrongARM SA1110 Developer's Manual",
* section 10.8, "Alternate Memory Bus Master Mode". */
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 09/34] arm/PCI: convert to pci_scan_root_bus() for correct root bus resources
2011-12-23 1:10 ` [PATCH v3 09/34] arm/PCI: " Bjorn Helgaas
@ 2012-01-04 17:28 ` Jesse Barnes
0 siblings, 0 replies; 9+ messages in thread
From: Jesse Barnes @ 2012-01-04 17:28 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, Russell King
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
On Thu, 22 Dec 2011 18:10:43 -0700
Bjorn Helgaas <bhelgaas@google.com> wrote:
> Working through this with a cross-compiler, I found a build bug in
> this patch. Updated patch and incremental patch (from commit
> 9a1d98b3a0d8621 in your linux-next branch) attached.
>
> My cross-compiler can only build about half of the ARM configs, but
> better than nothing, I guess.
Merged this into the existing ARM patch, thanks.
--
Jesse Barnes, Intel Open Source Technology Center
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 08/34] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources
2011-12-16 21:24 ` [PATCH v3 08/34] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
@ 2012-01-04 17:38 ` Jesse Barnes
0 siblings, 0 replies; 9+ messages in thread
From: Jesse Barnes @ 2012-01-04 17:38 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, linux-arch, linux-alpha
[-- Attachment #1: Type: text/plain, Size: 3446 bytes --]
On Fri, 16 Dec 2011 14:24:01 -0700
Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Fri, Oct 28, 2011 at 4:26 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > Convert from pci_scan_bus() to pci_scan_root_bus() and remove root bus
> > resource fixups. This fixes the problem of "early" and "header" quirks
> > seeing incorrect root bus resources.
> >
> > CC: linux-alpha@vger.kernel.org
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> > ---
> > arch/alpha/kernel/pci.c | 37 ++++++++++++++++++++-----------------
> > 1 files changed, 20 insertions(+), 17 deletions(-)
> >
> > diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
> > index c9ab94e..e9e78a2 100644
> > --- a/arch/alpha/kernel/pci.c
> > +++ b/arch/alpha/kernel/pci.c
> > @@ -286,22 +286,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
> > struct pci_controller *hose = bus->sysdata;
> > struct pci_dev *dev = bus->self;
> >
> > - if (!dev) {
> > - /* Root bus. */
> > - u32 pci_mem_end;
> > - u32 sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
> > - unsigned long end;
> > -
> > - bus->resource[0] = hose->io_space;
> > - bus->resource[1] = hose->mem_space;
> > -
> > - /* Adjust hose mem_space limit to prevent PCI allocations
> > - in the iommu windows. */
> > - pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
> > - end = hose->mem_space->start + pci_mem_end;
> > - if (hose->mem_space->end > end)
> > - hose->mem_space->end = end;
> > - } else if (pci_probe_only &&
> > + if (pci_probe_only && dev &&
> > (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
> > pci_read_bridge_bases(bus);
> > pcibios_fixup_device_resources(dev, bus);
> > @@ -414,13 +399,31 @@ void __init
> > common_init_pci(void)
> > {
> > struct pci_controller *hose;
> > + struct list_head resources;
> > struct pci_bus *bus;
> > int next_busno;
> > int need_domain_info = 0;
> > + u32 pci_mem_end;
> > + u32 sg_base;
> > + unsigned long end;
> >
> > /* Scan all of the recorded PCI controllers. */
> > for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
> > - bus = pci_scan_bus(next_busno, alpha_mv.pci_ops, hose);
> > + sg_base = hose->sg_pci ? hose->sg_pci->dma_base : ~0;
> > +
> > + /* Adjust hose mem_space limit to prevent PCI allocations
> > + in the iommu windows. */
> > + pci_mem_end = min((u32)__direct_map_base, sg_base) - 1;
> > + end = hose->mem_space->start + pci_mem_end;
> > + if (hose->mem_space->end > end)
> > + hose->mem_space->end = end;
> > +
> > + INIT_LIST_HEAD(&resources);
> > + pci_add_resource(&resources, &hose->io_space);
> > + pci_add_resource(&resources, &hose->mem_space);
>
> These two lines are errors: hose->io_space is already a struct
> resource pointer, so we shouldn't take the pointer's address. Updated
> patch and incremental patch attached.
Squashed into the original alpha patch, thanks.
--
Jesse Barnes, Intel Open Source Technology Center
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-01-04 17:38 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20111028222432.30729.8431.stgit@bhelgaas.mtv.corp.google.com>
[not found] ` <CAErSpo5X00LFs6XUcnqoogZEZhR2H4G7AJvh9+FAsvr3vMHkeA@mail.gmail.com>
2011-11-11 16:40 ` [PATCH v3 00/34] Create PCI root buses with correct resources Bjorn Helgaas
2011-11-28 18:58 ` Bjorn Helgaas
[not found] ` <20111028222535.30729.73281.stgit@bhelgaas.mtv.corp.google.com>
2011-12-05 19:54 ` [PATCH v3 01/34] PCI: add helpers for building PCI bus resource lists Jesse Barnes
[not found] ` <20111028222738.30729.96314.stgit@bhelgaas.mtv.corp.google.com>
2011-12-06 18:07 ` [PATCH v3 25/34] powerpc/PCI: split PHB part out of pcibios_map_io_space() Bjorn Helgaas
[not found] ` <20111028222743.30729.97632.stgit@bhelgaas.mtv.corp.google.com>
2011-12-06 18:09 ` [PATCH v3 26/34] powerpc/PCI: convert to pci_create_root_bus() Bjorn Helgaas
[not found] ` <20111028222611.30729.46284.stgit@bhelgaas.mtv.corp.google.com>
2011-12-16 21:24 ` [PATCH v3 08/34] alpha/PCI: convert to pci_scan_root_bus() for correct root bus resources Bjorn Helgaas
2012-01-04 17:38 ` Jesse Barnes
[not found] ` <20111028222616.30729.96687.stgit@bhelgaas.mtv.corp.google.com>
2011-12-23 1:10 ` [PATCH v3 09/34] arm/PCI: " Bjorn Helgaas
2012-01-04 17:28 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).