Patchwork [v3,3/5] PCI: Skip IORESOURCE_MMIO allocation for root bus without MMIO range

login
register
mail settings
Submitter Yinghai Lu
Date May 7, 2013, 10:17 p.m.
Message ID <1367965054-9013-4-git-send-email-yinghai@kernel.org>
Download mbox | patch
Permalink /patch/242474/
State Superseded
Headers show

Comments

Yinghai Lu - May 7, 2013, 10:17 p.m.
For x86 8 sockets or 32 sockets system that will have one root bus per socket,
They may have some root buses do not have mmio non-pref range.

We should not fall into retry in this case, as root bus does
not mmio non-pref range.

We check if the root bus has mmio-nonpref range, and set bus_res_type_mask,
and pass it to assign_resources and don't add mmio-nonpref res to failed list
for root bus that does not have mmio-nonpref range.
So even BIOS set wrong value to pci devices and bridges will still
get cleared.

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

---
 drivers/pci/setup-bus.c |   32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benjamin Herrenschmidt - May 7, 2013, 10:28 p.m.
On Tue, 2013-05-07 at 15:17 -0700, Yinghai Lu wrote:
> For x86 8 sockets or 32 sockets system that will have one root bus per socket,
> They may have some root buses do not have mmio non-pref range.

That seems very odd. Most device registers are non-prefetchable. I know
of no adapter today that would work in a prefetchable-only environment.

Are you sure that isn't the other way around ?

Regarding your 3.10 patches, me and Gavin will test your v3 later today
(ASAP) and will give you an Ack if they work, in which case they should
hit Linus as soon as Bjorn is comfortable with :-)

Cheers,
Ben.

> We should not fall into retry in this case, as root bus does
> not mmio non-pref range.
> 
> We check if the root bus has mmio-nonpref range, and set bus_res_type_mask,
> and pass it to assign_resources and don't add mmio-nonpref res to failed list
> for root bus that does not have mmio-nonpref range.
> So even BIOS set wrong value to pci devices and bridges will still
> get cleared.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  drivers/pci/setup-bus.c |   32 ++++++++++++++++++++++++++------
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> Index: linux-2.6/drivers/pci/setup-bus.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/setup-bus.c
> +++ linux-2.6/drivers/pci/setup-bus.c
> @@ -299,9 +299,17 @@ static void assign_requested_resources_s
>  				bool is_ioport_res_without_bus_support =
>  					 (!(bus_res_type_mask & IORESOURCE_IO)) &&
>  					 (res->flags & IORESOURCE_IO);
> +				/*
> +				 * if the failed res is mmio, but bus does
> +				 * not have io port support, don't add it
> +				 */
> +				bool is_mmio_nonpref_res_without_bus_support =
> +					 (!(bus_res_type_mask & IORESOURCE_MEM)) &&
> +					 ((res->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == IORESOURCE_MEM);
>  
>  				if (!is_rom_res_not_enabled &&
> -				    !is_ioport_res_without_bus_support)
> +				    !is_ioport_res_without_bus_support &&
> +				    !is_mmio_nonpref_res_without_bus_support)
>  					add_to_list(fail_head,
>  						    dev_res->dev, res,
>  						    0 /* dont care */,
> @@ -1407,12 +1415,24 @@ static unsigned long pci_bus_res_type_ma
>  	int i;
>  	struct resource *r;
>  	unsigned long mask = 0;
> -	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
> -				  IORESOURCE_PREFETCH;
>  
> -	pci_bus_for_each_resource(bus, r, i)
> -		if (r)
> -			mask |= r->flags & type_mask;
> +	pci_bus_for_each_resource(bus, r, i) {
> +		if (!r)
> +			continue;
> +
> +		if (r->flags & IORESOURCE_IO) {
> +			mask |= IORESOURCE_IO;
> +			continue;
> +		}
> +		if (r->flags & IORESOURCE_PREFETCH) {
> +			mask |= IORESOURCE_PREFETCH;
> +			continue;
> +		}
> +		if ((r->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == IORESOURCE_MEM) {
> +			mask |= IORESOURCE_MEM; /* nonpref only */
> +			continue;
> +		}
> +	}
>  
>  	return mask;
>  }


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yinghai Lu - May 7, 2013, 10:44 p.m.
On Tue, May 7, 2013 at 3:28 PM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Tue, 2013-05-07 at 15:17 -0700, Yinghai Lu wrote:
>> For x86 8 sockets or 32 sockets system that will have one root bus per socket,
>> They may have some root buses do not have mmio non-pref range.
>
> That seems very odd. Most device registers are non-prefetchable. I know
> of no adapter today that would work in a prefetchable-only environment.

FC/10G/FCoE from Qlogic and Emulex can be used with 64bit mmio-pref only.

pci bridge will only support 32bit non-pref mmio, so we have them under 4G,
and it could be only 2G at most.

x86 32 socket system, we may need to leave more mmiol for only several
sockets to make them work with cards that does not support mmio 64 bit pref.

we can always have enough 64bit mmio pref above 4G....

>
> Are you sure that isn't the other way around ?
>
> Regarding your 3.10 patches, me and Gavin will test your v3 later today
> (ASAP) and will give you an Ack if they work, in which case they should
> hit Linus as soon as Bjorn is comfortable with :-)

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benjamin Herrenschmidt - May 8, 2013, 1:16 a.m.
On Tue, 2013-05-07 at 15:44 -0700, Yinghai Lu wrote:
> x86 32 socket system, we may need to leave more mmiol for only several
> sockets to make them work with cards that does not support mmio 64 bit
> pref.

Ok, while on POWER each root bridge has its own distinct 32-bit space
(mapped elsewhere in CPU space). So at least we don't have *that*
specific problem :-)

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yinghai Lu - May 8, 2013, 3:57 a.m.
On Tue, May 7, 2013 at 6:16 PM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Tue, 2013-05-07 at 15:44 -0700, Yinghai Lu wrote:
>> x86 32 socket system, we may need to leave more mmiol for only several
>> sockets to make them work with cards that does not support mmio 64 bit
>> pref.
>
> Ok, while on POWER each root bridge has its own distinct 32-bit space
> (mapped elsewhere in CPU space). So at least we don't have *that*
> specific problem :-)

Hope x86 could support that.

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -299,9 +299,17 @@  static void assign_requested_resources_s
 				bool is_ioport_res_without_bus_support =
 					 (!(bus_res_type_mask & IORESOURCE_IO)) &&
 					 (res->flags & IORESOURCE_IO);
+				/*
+				 * if the failed res is mmio, but bus does
+				 * not have io port support, don't add it
+				 */
+				bool is_mmio_nonpref_res_without_bus_support =
+					 (!(bus_res_type_mask & IORESOURCE_MEM)) &&
+					 ((res->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == IORESOURCE_MEM);
 
 				if (!is_rom_res_not_enabled &&
-				    !is_ioport_res_without_bus_support)
+				    !is_ioport_res_without_bus_support &&
+				    !is_mmio_nonpref_res_without_bus_support)
 					add_to_list(fail_head,
 						    dev_res->dev, res,
 						    0 /* dont care */,
@@ -1407,12 +1415,24 @@  static unsigned long pci_bus_res_type_ma
 	int i;
 	struct resource *r;
 	unsigned long mask = 0;
-	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
-				  IORESOURCE_PREFETCH;
 
-	pci_bus_for_each_resource(bus, r, i)
-		if (r)
-			mask |= r->flags & type_mask;
+	pci_bus_for_each_resource(bus, r, i) {
+		if (!r)
+			continue;
+
+		if (r->flags & IORESOURCE_IO) {
+			mask |= IORESOURCE_IO;
+			continue;
+		}
+		if (r->flags & IORESOURCE_PREFETCH) {
+			mask |= IORESOURCE_PREFETCH;
+			continue;
+		}
+		if ((r->flags & (IORESOURCE_MEM | IORESOURCE_PREFETCH)) == IORESOURCE_MEM) {
+			mask |= IORESOURCE_MEM; /* nonpref only */
+			continue;
+		}
+	}
 
 	return mask;
 }