linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
@ 2012-06-25  3:10 Gavin Shan
  2012-06-25  3:10 ` [PATCH V3 2/2] PCI: minimal alignment for bars of P2P bridges Gavin Shan
  2012-06-25 17:30 ` [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Yinghai Lu
  0 siblings, 2 replies; 7+ messages in thread
From: Gavin Shan @ 2012-06-25  3:10 UTC (permalink / raw)
  To: linux-pci, linuxppc-dev; +Cc: bhelgaas, benh, Gavin Shan

With current implementation, there is one function to retrieve
the corresponding host bridge (struct pci_host_bridge) according
to the given PCI device (struct pci_dev) and that function has
been declared as "static". Further, we don't have the public
function to retrieve host bridge from PCI bus yet. The function
is useful somewhere.

The additional information like minimal resource alignment for I/O
and MMIO bars of p2p bridges will be put into the PCI host bridge.
The patch introduces the public function pci_bus_host_bridge() to
retrieve the corresponding PCI host bridge according to the specified
PCI bus, then accessing the information regarding the minimal resource
alignment for I/O and MMIO bars of p2p bridges.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Ram Pai <linuxram@us.ibm.com>
Reviewed-by: Richard Yang <weiyang@linux.vnet.ibm.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/pci/host-bridge.c |   13 +++++++++++++
 include/linux/pci.h       |    2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index a68dc61..b95f0ce 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -27,6 +27,19 @@ static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
 	return to_pci_host_bridge(bus->bridge);
 }
 
+struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus)
+{
+	struct pci_bus *b = bus;
+
+	/* Find the PCI root bus */
+	while (b->parent)
+		b = b->parent;
+
+	return to_pci_host_bridge(b->bridge);
+}
+
+EXPORT_SYMBOL(pci_bus_host_bridge);
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 				 void (*release_fn)(struct pci_host_bridge *),
 				 void *release_data)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fefb4e1..6d5bb1c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -656,7 +656,7 @@ void pcibios_update_irq(struct pci_dev *, int irq);
 void pci_fixup_cardbus(struct pci_bus *);
 
 /* Generic PCI functions used internally */
-
+struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus);
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			     struct resource *res);
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 2/2] PCI: minimal alignment for bars of P2P bridges
  2012-06-25  3:10 [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Gavin Shan
@ 2012-06-25  3:10 ` Gavin Shan
  2012-06-25 17:30 ` [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Yinghai Lu
  1 sibling, 0 replies; 7+ messages in thread
From: Gavin Shan @ 2012-06-25  3:10 UTC (permalink / raw)
  To: linux-pci, linuxppc-dev; +Cc: bhelgaas, benh, Gavin Shan

On some powerpc platforms, device BARs need to be assigned to separate
"segments" of the address space in order for the error isolation and HW
virtualization mechanisms (EEH) to work properly. Those "segments" have
a minimum size that can be fairly large (16M). In order to be able to
use the generic resource assignment code rather than re-inventing our
own, we chose to group devices by bus. That way, a simple change of the
minimum alignment requirements of resources assigned to PCI to PCI (P2P)
bridges is enough to ensure that all BARs for devices below those bridges
will fit into contiguous sets of segments and there will be no overlap.

This patch provides a way for the host bridge to override the default
alignment values used by the resource allocation code for that purpose.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Ram Pai <linuxram@us.ibm.com>
Reviewed-by: Richard Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/pci/probe.c     |    5 +++++
 drivers/pci/setup-bus.c |   28 +++++++++++++++++++++-------
 include/linux/pci.h     |    8 ++++++++
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 658ac97..a196529 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -431,6 +431,11 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
 	if (bridge) {
 		INIT_LIST_HEAD(&bridge->windows);
 		bridge->bus = b;
+
+		/* Set minimal alignment shift of P2P bridges */
+		bridge->io_align_shift = PCI_DEFAULT_IO_ALIGN_SHIFT;
+		bridge->mem_align_shift = PCI_DEFAULT_MEM_ALIGN_SHIFT;
+		bridge->pmem_align_shift = PCI_DEFAULT_PMEM_ALIGN_SHIFT;
 	}
 
 	return bridge;
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 8fa2d4b..7c3e90d 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -706,10 +706,12 @@ static resource_size_t calculate_memsize(resource_size_t size,
 static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 		resource_size_t add_size, struct list_head *realloc_head)
 {
+	struct pci_host_bridge *phb;
 	struct pci_dev *dev;
 	struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
 	unsigned long size = 0, size0 = 0, size1 = 0;
 	resource_size_t children_add_size = 0;
+	resource_size_t io_align;
 
 	if (!b_res)
  		return;
@@ -735,13 +737,17 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 				children_add_size += get_res_add_size(realloc_head, r);
 		}
 	}
+
+	phb = pci_bus_host_bridge(bus);
+	io_align = (1 << phb->io_align_shift);
+
 	size0 = calculate_iosize(size, min_size, size1,
-			resource_size(b_res), 4096);
+			resource_size(b_res), io_align);
 	if (children_add_size > add_size)
 		add_size = children_add_size;
 	size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
 		calculate_iosize(size, min_size, add_size + size1,
-			resource_size(b_res), 4096);
+			resource_size(b_res), io_align);
 	if (!size0 && !size1) {
 		if (b_res->start || b_res->end)
 			dev_info(&bus->self->dev, "disabling bridge window "
@@ -751,11 +757,11 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
 		return;
 	}
 	/* Alignment of the IO window is always 4K */
-	b_res->start = 4096;
+	b_res->start = io_align;
 	b_res->end = b_res->start + size0 - 1;
 	b_res->flags |= IORESOURCE_STARTALIGN;
 	if (size1 > size0 && realloc_head) {
-		add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096);
+		add_to_list(realloc_head, bus->self, b_res, size1-size0, io_align);
 		dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
 				 "%pR to [bus %02x-%02x] add_size %lx\n", b_res,
 				 bus->secondary, bus->subordinate, size1-size0);
@@ -778,6 +784,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 			resource_size_t add_size,
 			struct list_head *realloc_head)
 {
+	struct pci_host_bridge *phb;
 	struct pci_dev *dev;
 	resource_size_t min_align, align, size, size0, size1;
 	resource_size_t aligns[12];	/* Alignments from 1Mb to 2Gb */
@@ -785,10 +792,17 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 	struct resource *b_res = find_free_bus_resource(bus, type);
 	unsigned int mem64_mask = 0;
 	resource_size_t children_add_size = 0;
+	int mem_align_shift;
 
 	if (!b_res)
 		return 0;
 
+	phb = pci_bus_host_bridge(bus);
+	if (type & IORESOURCE_PREFETCH)
+		mem_align_shift = phb->pmem_align_shift;
+	else
+		mem_align_shift = phb->mem_align_shift;
+
 	memset(aligns, 0, sizeof(aligns));
 	max_order = 0;
 	size = 0;
@@ -818,8 +832,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 #endif
 			/* For bridges size != alignment */
 			align = pci_resource_alignment(dev, r);
-			order = __ffs(align) - 20;
-			if (order > 11) {
+			order = __ffs(align) - mem_align_shift;
+			if (order > (11 - (mem_align_shift - 20))) {
 				dev_warn(&dev->dev, "disabling BAR %d: %pR "
 					 "(bad alignment %#llx)\n", i, r,
 					 (unsigned long long) align);
@@ -846,7 +860,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 	for (order = 0; order <= max_order; order++) {
 		resource_size_t align1 = 1;
 
-		align1 <<= (order + 20);
+		align1 <<= (order + mem_align_shift);
 
 		if (!align)
 			min_align = align1;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6d5bb1c..ed55e58 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -376,9 +376,17 @@ struct pci_host_bridge_window {
 	resource_size_t offset;		/* bus address + offset = CPU address */
 };
 
+/* Default shits for P2P I/O and MMIO bar minimal alignment shifts */
+#define PCI_DEFAULT_IO_ALIGN_SHIFT	12	/* 4KB  */
+#define PCI_DEFAULT_MEM_ALIGN_SHIFT	20	/* 1MB  */
+#define PCI_DEFAULT_PMEM_ALIGN_SHIFT	20	/* 1MB */
+
 struct pci_host_bridge {
 	struct device dev;
 	struct pci_bus *bus;		/* root bus */
+	int io_align_shift;		/* P2P I/O bar minimal alignment shift  */
+	int mem_align_shift;		/* P2P MMIO bar minimal alignment shift */
+	int pmem_align_shift;		/* P2P prefetchable MMIO bar minimal alignment shift */
 	struct list_head windows;	/* pci_host_bridge_windows */
 	void (*release_fn)(struct pci_host_bridge *);
 	void *release_data;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
  2012-06-25  3:10 [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Gavin Shan
  2012-06-25  3:10 ` [PATCH V3 2/2] PCI: minimal alignment for bars of P2P bridges Gavin Shan
@ 2012-06-25 17:30 ` Yinghai Lu
  2012-06-26  0:30   ` Gavin Shan
  1 sibling, 1 reply; 7+ messages in thread
From: Yinghai Lu @ 2012-06-25 17:30 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linux-pci, linuxppc-dev, bhelgaas, benh

On Sun, Jun 24, 2012 at 8:10 PM, Gavin Shan <shangw@linux.vnet.ibm.com> wrote:
> With current implementation, there is one function to retrieve
> the corresponding host bridge (struct pci_host_bridge) according
> to the given PCI device (struct pci_dev) and that function has
> been declared as "static". Further, we don't have the public
> function to retrieve host bridge from PCI bus yet. The function
> is useful somewhere.
>
> The additional information like minimal resource alignment for I/O
> and MMIO bars of p2p bridges will be put into the PCI host bridge.
> The patch introduces the public function pci_bus_host_bridge() to
> retrieve the corresponding PCI host bridge according to the specified
> PCI bus, then accessing the information regarding the minimal resource
> alignment for I/O and MMIO bars of p2p bridges.
>
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> Reviewed-by: Ram Pai <linuxram@us.ibm.com>
> Reviewed-by: Richard Yang <weiyang@linux.vnet.ibm.com>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  drivers/pci/host-bridge.c |   13 +++++++++++++
>  include/linux/pci.h       |    2 +-
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index a68dc61..b95f0ce 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -27,6 +27,19 @@ static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
>        return to_pci_host_bridge(bus->bridge);
>  }
>
> +struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus)
> +{
> +       struct pci_bus *b = bus;
> +
> +       /* Find the PCI root bus */
> +       while (b->parent)
> +               b = b->parent;
> +
> +       return to_pci_host_bridge(b->bridge);
> +}
> +
> +EXPORT_SYMBOL(pci_bus_host_bridge);

why do you need to export it?

> +
>  void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>                                 void (*release_fn)(struct pci_host_bridge *),
>                                 void *release_data)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index fefb4e1..6d5bb1c 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -656,7 +656,7 @@ void pcibios_update_irq(struct pci_dev *, int irq);
>  void pci_fixup_cardbus(struct pci_bus *);
>
>  /* Generic PCI functions used internally */
> -
> +struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus);
>  void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
>                             struct resource *res);
>  void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,

have one patch will change parameter all to bus instead of bridge.

http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;h=3dc90c8f31e5e6153e1ac9a903189d3013690e80

in that case, we can just make find_pci_host_bridge() global.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
  2012-06-25 17:30 ` [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Yinghai Lu
@ 2012-06-26  0:30   ` Gavin Shan
  2012-06-26  2:50     ` Benjamin Herrenschmidt
  2012-06-26 18:29     ` Yinghai Lu
  0 siblings, 2 replies; 7+ messages in thread
From: Gavin Shan @ 2012-06-26  0:30 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Gavin Shan, linux-pci, linuxppc-dev, bhelgaas, benh

>> With current implementation, there is one function to retrieve
>> the corresponding host bridge (struct pci_host_bridge) according
>> to the given PCI device (struct pci_dev) and that function has
>> been declared as "static". Further, we don't have the public
>> function to retrieve host bridge from PCI bus yet. The function
>> is useful somewhere.
>>
>> The additional information like minimal resource alignment for I/O
>> and MMIO bars of p2p bridges will be put into the PCI host bridge.
>> The patch introduces the public function pci_bus_host_bridge() to
>> retrieve the corresponding PCI host bridge according to the specified
>> PCI bus, then accessing the information regarding the minimal resource
>> alignment for I/O and MMIO bars of p2p bridges.
>>
>> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>> Reviewed-by: Ram Pai <linuxram@us.ibm.com>
>> Reviewed-by: Richard Yang <weiyang@linux.vnet.ibm.com>
>> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> ---
>>  drivers/pci/host-bridge.c |   13 +++++++++++++
>>  include/linux/pci.h       |    2 +-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
>> index a68dc61..b95f0ce 100644
>> --- a/drivers/pci/host-bridge.c
>> +++ b/drivers/pci/host-bridge.c
>> @@ -27,6 +27,19 @@ static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
>>        return to_pci_host_bridge(bus->bridge);
>>  }
>>
>> +struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus)
>> +{
>> +       struct pci_bus *b = bus;
>> +
>> +       /* Find the PCI root bus */
>> +       while (b->parent)
>> +               b = b->parent;
>> +
>> +       return to_pci_host_bridge(b->bridge);
>> +}
>> +
>> +EXPORT_SYMBOL(pci_bus_host_bridge);

Yinghai, thanks for your time on this :-)

>
>why do you need to export it?
>

The reason is that we have introduced extra fields to "struct pci_host_bridge"
in [PATCH 2/2] and platform want to access those extra fields.

	int io_align_shift;             /* P2P I/O bar minimal alignment shift  */
	int mem_align_shift;            /* P2P MMIO bar minimal alignment shift */
	int pmem_align_shift;           /* P2P prefetchable MMIO bar minimal alignment shift */


>> +
>>  void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
>>                                 void (*release_fn)(struct pci_host_bridge *),
>>                                 void *release_data)
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index fefb4e1..6d5bb1c 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -656,7 +656,7 @@ void pcibios_update_irq(struct pci_dev *, int irq);
>>  void pci_fixup_cardbus(struct pci_bus *);
>>
>>  /* Generic PCI functions used internally */
>> -
>> +struct pci_host_bridge *pci_bus_host_bridge(struct pci_bus *bus);
>>  void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
>>                             struct resource *res);
>>  void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
>
>have one patch will change parameter all to bus instead of bridge.
>
>http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;h=3dc90c8f31e5e6153e1ac9a903189d3013690e80
>
>in that case, we can just make find_pci_host_bridge() global.
>

Yeah, I think your patch meets the requirement: access "struct pci_host_bridge",
and when will you merge your patch into mainline?

By the way, could you please take your a litle bit time to review [PATCH 2/2]?

>Thanks
>
>Yinghai
>

Thanks,
Gavin


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
  2012-06-26  0:30   ` Gavin Shan
@ 2012-06-26  2:50     ` Benjamin Herrenschmidt
  2012-06-26  3:01       ` Gavin Shan
  2012-06-26 18:29     ` Yinghai Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2012-06-26  2:50 UTC (permalink / raw)
  To: Gavin Shan; +Cc: Yinghai Lu, linux-pci, linuxppc-dev, bhelgaas

On Tue, 2012-06-26 at 08:30 +0800, Gavin Shan wrote:
> >> +EXPORT_SYMBOL(pci_bus_host_bridge);
> 
> Yinghai, thanks for your time on this :-)
> 
> >
> >why do you need to export it?
> >
> 
> The reason is that we have introduced extra fields to "struct
> pci_host_bridge"
> in [PATCH 2/2] and platform want to access those extra fields. 

But the platform code is built-in, not modular, so it doesn't need
EXPORT_SYMBOL (additionally even if we wanted to export it we probably
also want it _GPL only, so EXPORT_SYMBOL_GPL, but I don't think we need
to).

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
  2012-06-26  2:50     ` Benjamin Herrenschmidt
@ 2012-06-26  3:01       ` Gavin Shan
  0 siblings, 0 replies; 7+ messages in thread
From: Gavin Shan @ 2012-06-26  3:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Gavin Shan, Yinghai Lu, linux-pci, linuxppc-dev, bhelgaas

>> >> +EXPORT_SYMBOL(pci_bus_host_bridge);
>> 
>> Yinghai, thanks for your time on this :-)
>> 
>> >
>> >why do you need to export it?
>> >
>> 
>> The reason is that we have introduced extra fields to "struct
>> pci_host_bridge"
>> in [PATCH 2/2] and platform want to access those extra fields. 
>
>But the platform code is built-in, not modular, so it doesn't need
>EXPORT_SYMBOL (additionally even if we wanted to export it we probably
>also want it _GPL only, so EXPORT_SYMBOL_GPL, but I don't think we need
>to).
>

Ben, thanks for correcting me :-)

Let me remove EXPORT_SYMBOL() is next revision.

>Cheers,
>Ben.
>
>

Thanks,
Gavin


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus
  2012-06-26  0:30   ` Gavin Shan
  2012-06-26  2:50     ` Benjamin Herrenschmidt
@ 2012-06-26 18:29     ` Yinghai Lu
  1 sibling, 0 replies; 7+ messages in thread
From: Yinghai Lu @ 2012-06-26 18:29 UTC (permalink / raw)
  To: Gavin Shan; +Cc: linux-pci, linuxppc-dev, bhelgaas, benh

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

On Mon, Jun 25, 2012 at 5:30 PM, Gavin Shan <shangw@linux.vnet.ibm.com> wrote:
> Yeah, I think your patch meets the requirement: access "struct pci_host_bridge",
> and when will you merge your patch into mainline?

not sure.

but i extract that patch as attached.
and with that could make your first patch only make find_pci_host_bridge()
global.

>
> By the way, could you please take your a litle bit time to review [PATCH 2/2]?
>

ok, will look at that.

Thanks

Yinghai

[-- Attachment #2: pcibus_addr_converting_bus.patch --]
[-- Type: application/octet-stream, Size: 3793 bytes --]

Subject: [PATCH] PCI: pcibus address to resource converting take bus directly

For allocating resource under bus path, we do have dev pass along, and we
could just use bus instead.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/host-bridge.c |   34 +++++++++++++++++++++-------------
 include/linux/pci.h       |    3 +++
 2 files changed, 24 insertions(+), 13 deletions(-)

Index: linux-2.6/drivers/pci/host-bridge.c
===================================================================
--- linux-2.6.orig/drivers/pci/host-bridge.c
+++ linux-2.6/drivers/pci/host-bridge.c
@@ -9,22 +9,19 @@
 
 #include "pci.h"
 
-static struct pci_bus *find_pci_root_bus(struct pci_dev *dev)
+static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)
 {
-	struct pci_bus *bus;
-
-	bus = dev->bus;
 	while (bus->parent)
 		bus = bus->parent;
 
 	return bus;
 }
 
-static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev)
+static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus)
 {
-	struct pci_bus *bus = find_pci_root_bus(dev);
+	struct pci_bus *root_bus = find_pci_root_bus(bus);
 
-	return to_pci_host_bridge(bus->bridge);
+	return to_pci_host_bridge(root_bus->bridge);
 }
 
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
@@ -40,10 +37,11 @@ static bool resource_contains(struct res
 	return res1->start <= res2->start && res1->end >= res2->end;
 }
 
-void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-			     struct resource *res)
+void __pcibios_resource_to_bus(struct pci_bus *bus,
+				      struct pci_bus_region *region,
+				      struct resource *res)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
@@ -60,6 +58,11 @@ void pcibios_resource_to_bus(struct pci_
 	region->start = res->start - offset;
 	region->end = res->end - offset;
 }
+void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+			     struct resource *res)
+{
+	__pcibios_resource_to_bus(dev->bus, region, res);
+}
 EXPORT_SYMBOL(pcibios_resource_to_bus);
 
 static bool region_contains(struct pci_bus_region *region1,
@@ -68,10 +71,10 @@ static bool region_contains(struct pci_b
 	return region1->start <= region2->start && region1->end >= region2->end;
 }
 
-void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-			     struct pci_bus_region *region)
+static void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+				      struct pci_bus_region *region)
 {
-	struct pci_host_bridge *bridge = find_pci_host_bridge(dev);
+	struct pci_host_bridge *bridge = find_pci_host_bridge(bus);
 	struct pci_host_bridge_window *window;
 	resource_size_t offset = 0;
 
@@ -93,4 +96,9 @@ void pcibios_bus_to_resource(struct pci_
 	res->start = region->start + offset;
 	res->end = region->end + offset;
 }
+void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+			     struct pci_bus_region *region)
+{
+	__pcibios_bus_to_resource(dev->bus, res, region);
+}
 EXPORT_SYMBOL(pcibios_bus_to_resource);
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -686,6 +686,9 @@ void pci_fixup_cardbus(struct pci_bus *)
 
 /* Generic PCI functions used internally */
 
+void __pcibios_resource_to_bus(struct pci_bus *bus,
+			       struct pci_bus_region *region,
+			       struct resource *res);
 void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
 			     struct resource *res);
 void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-06-26 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25  3:10 [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Gavin Shan
2012-06-25  3:10 ` [PATCH V3 2/2] PCI: minimal alignment for bars of P2P bridges Gavin Shan
2012-06-25 17:30 ` [PATCH V3 1/2] PCI: retrieve host bridge by PCI bus Yinghai Lu
2012-06-26  0:30   ` Gavin Shan
2012-06-26  2:50     ` Benjamin Herrenschmidt
2012-06-26  3:01       ` Gavin Shan
2012-06-26 18:29     ` Yinghai Lu

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).