linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/pci: save P2P bridge resource if possible
@ 2012-06-04  8:15 Gavin Shan
  2012-06-04  8:55 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Gavin Shan @ 2012-06-04  8:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: michael, paulus, Gavin Shan

When PCI probe flag PCI_REASSIGN_ALL_RSRC has been passed into PCI
core, it's hoped that all resources to be reassigned by PCI core.
As to particular P2P (PCI-to-PCI) bridge, the size of the corresponding
BAR (I/O, MMIO, prefetchable MMIO) is calculated by the resources
required by the PCI devices behind the P2P bridge. That means that
the information like start/end address retrieved from the hardware
registers of the P2P bridge is meainingless in the case. However,
we still count that in and the BARs might have been configured by
firmware with non-zero size. That leads to space waste.

The patch explicitly sets the size of P2P bridge BARs to zero in
case that resource reassignment is expected with PCI probe flag
PCI_REASSIGN_ALL_RSRC. In the result, it will save overall resource
required by the system without waste.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/pci-common.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 8e78e93..0fe214d 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -966,13 +966,14 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
 		if (i >= 3 && bus->self->transparent)
 			continue;
 
-		/* If we are going to re-assign everything, mark the resource
-		 * as unset and move it down to 0
+		/* If we're going to reassign everything, we can
+		 * shrink the P2P resource to have size as being
+		 * of 0 in order to save space.
 		 */
 		if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
 			res->flags |= IORESOURCE_UNSET;
-			res->end -= res->start;
 			res->start = 0;
+			res->end = -1;
 			continue;
 		}
 
@@ -1234,7 +1235,14 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
 		pr_warning("PCI: Cannot allocate resource region "
 			   "%d of PCI bridge %d, will remap\n", i, bus->number);
 	clear_resource:
-		res->start = res->end = 0;
+		/* The resource might be figured out when doing
+		 * reassignment based on the resources required
+		 * by the downstream PCI devices. Here we set
+		 * the size of the resource to be 0 in order to
+		 * save more space.
+		 */
+		res->start = 0;
+		res->end = -1;
 		res->flags = 0;
 	}
 
-- 
1.7.9.5

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

* Re: [PATCH] powerpc/pci: save P2P bridge resource if possible
  2012-06-04  8:15 [PATCH] powerpc/pci: save P2P bridge resource if possible Gavin Shan
@ 2012-06-04  8:55 ` Benjamin Herrenschmidt
  2012-06-04  9:18   ` Gavin Shan
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2012-06-04  8:55 UTC (permalink / raw)
  To: Gavin Shan; +Cc: michael, paulus, linuxppc-dev

On Mon, 2012-06-04 at 16:15 +0800, Gavin Shan wrote:
> When PCI probe flag PCI_REASSIGN_ALL_RSRC has been passed into PCI
> core, it's hoped that all resources to be reassigned by PCI core.
> As to particular P2P (PCI-to-PCI) bridge, the size of the corresponding
> BAR (I/O, MMIO, prefetchable MMIO) is calculated by the resources
> required by the PCI devices behind the P2P bridge. That means that
> the information like start/end address retrieved from the hardware
> registers of the P2P bridge is meainingless in the case. However,
> we still count that in and the BARs might have been configured by
> firmware with non-zero size. That leads to space waste.
> 
> The patch explicitly sets the size of P2P bridge BARs to zero in
> case that resource reassignment is expected with PCI probe flag
> PCI_REASSIGN_ALL_RSRC. In the result, it will save overall resource
> required by the system without waste.

Hrm... there was a reason I wasn't doing that .... but I can't
remember what it was, it's possible it no longer applies. I'll
have to make sure this patch is tested on various 4xx and FSL
configs.

Cheers,
Ben.

> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/pci-common.c |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 8e78e93..0fe214d 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -966,13 +966,14 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
>  		if (i >= 3 && bus->self->transparent)
>  			continue;
>  
> -		/* If we are going to re-assign everything, mark the resource
> -		 * as unset and move it down to 0
> +		/* If we're going to reassign everything, we can
> +		 * shrink the P2P resource to have size as being
> +		 * of 0 in order to save space.
>  		 */
>  		if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
>  			res->flags |= IORESOURCE_UNSET;
> -			res->end -= res->start;
>  			res->start = 0;
> +			res->end = -1;
>  			continue;
>  		}
>  
> @@ -1234,7 +1235,14 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
>  		pr_warning("PCI: Cannot allocate resource region "
>  			   "%d of PCI bridge %d, will remap\n", i, bus->number);
>  	clear_resource:
> -		res->start = res->end = 0;
> +		/* The resource might be figured out when doing
> +		 * reassignment based on the resources required
> +		 * by the downstream PCI devices. Here we set
> +		 * the size of the resource to be 0 in order to
> +		 * save more space.
> +		 */
> +		res->start = 0;
> +		res->end = -1;
>  		res->flags = 0;
>  	}
>  

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

* Re: [PATCH] powerpc/pci: save P2P bridge resource if possible
  2012-06-04  8:55 ` Benjamin Herrenschmidt
@ 2012-06-04  9:18   ` Gavin Shan
  0 siblings, 0 replies; 3+ messages in thread
From: Gavin Shan @ 2012-06-04  9:18 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: michael, linuxppc-dev, paulus

>> When PCI probe flag PCI_REASSIGN_ALL_RSRC has been passed into PCI
>> core, it's hoped that all resources to be reassigned by PCI core.
>> As to particular P2P (PCI-to-PCI) bridge, the size of the corresponding
>> BAR (I/O, MMIO, prefetchable MMIO) is calculated by the resources
>> required by the PCI devices behind the P2P bridge. That means that
>> the information like start/end address retrieved from the hardware
>> registers of the P2P bridge is meainingless in the case. However,
>> we still count that in and the BARs might have been configured by
>> firmware with non-zero size. That leads to space waste.
>> 
>> The patch explicitly sets the size of P2P bridge BARs to zero in
>> case that resource reassignment is expected with PCI probe flag
>> PCI_REASSIGN_ALL_RSRC. In the result, it will save overall resource
>> required by the system without waste.
>
>Hrm... there was a reason I wasn't doing that .... but I can't
>remember what it was, it's possible it no longer applies. I'll
>have to make sure this patch is tested on various 4xx and FSL
>configs.
>

Ok. Thanks, Ben. By the way, I've tested it on Firebird-L machine
while passing PCI_REASSIGN_ALL_RSRC into PCI core. Everything looks
fine :-)

>Cheers,
>Ben.

Thanks,
Gavin

>
>> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/kernel/pci-common.c |   16 ++++++++++++----
>>  1 file changed, 12 insertions(+), 4 deletions(-)
>> 
>> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
>> index 8e78e93..0fe214d 100644
>> --- a/arch/powerpc/kernel/pci-common.c
>> +++ b/arch/powerpc/kernel/pci-common.c
>> @@ -966,13 +966,14 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
>>  		if (i >= 3 && bus->self->transparent)
>>  			continue;
>>  
>> -		/* If we are going to re-assign everything, mark the resource
>> -		 * as unset and move it down to 0
>> +		/* If we're going to reassign everything, we can
>> +		 * shrink the P2P resource to have size as being
>> +		 * of 0 in order to save space.
>>  		 */
>>  		if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
>>  			res->flags |= IORESOURCE_UNSET;
>> -			res->end -= res->start;
>>  			res->start = 0;
>> +			res->end = -1;
>>  			continue;
>>  		}
>>  
>> @@ -1234,7 +1235,14 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
>>  		pr_warning("PCI: Cannot allocate resource region "
>>  			   "%d of PCI bridge %d, will remap\n", i, bus->number);
>>  	clear_resource:
>> -		res->start = res->end = 0;
>> +		/* The resource might be figured out when doing
>> +		 * reassignment based on the resources required
>> +		 * by the downstream PCI devices. Here we set
>> +		 * the size of the resource to be 0 in order to
>> +		 * save more space.
>> +		 */
>> +		res->start = 0;
>> +		res->end = -1;
>>  		res->flags = 0;
>>  	}
>>  
>
>
>_______________________________________________
>Linuxppc-dev mailing list
>Linuxppc-dev@lists.ozlabs.org
>https://lists.ozlabs.org/listinfo/linuxppc-dev
>

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-04  8:15 [PATCH] powerpc/pci: save P2P bridge resource if possible Gavin Shan
2012-06-04  8:55 ` Benjamin Herrenschmidt
2012-06-04  9:18   ` Gavin Shan

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