linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
@ 2015-07-21 21:35 Murali Karicheri
  2015-07-23 14:24 ` Murali Karicheri
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Murali Karicheri @ 2015-07-21 21:35 UTC (permalink / raw)
  To: linux, bhelgaas, linux-pci, linux-arm-kernel, linux-kernel

The MPS configuration should be done *before* pci_bus_add_devices().
After pci_bus_add_devices(), drivers may be bound to devices, and
the PCI core shouldn't touch device configuration while a driver
owns the device.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Reported-by: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/arm/kernel/bios32.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index fcbbbb1..17efde7 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
 	list_for_each_entry(sys, &head, node) {
 		struct pci_bus *bus = sys->bus;
 
-		if (!pci_has_flag(PCI_PROBE_ONLY)) {
+		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+			struct pci_bus *child;
 			/*
 			 * Size the bridge windows.
 			 */
@@ -530,25 +531,15 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
 			 * Assign resources.
 			 */
 			pci_bus_assign_resources(bus);
-		}
 
+			list_for_each_entry(child, &bus->children, node)
+				pcie_bus_configure_settings(child);
+		}
 		/*
 		 * Tell drivers about devices found.
 		 */
 		pci_bus_add_devices(bus);
 	}
-
-	list_for_each_entry(sys, &head, node) {
-		struct pci_bus *bus = sys->bus;
-
-		/* Configure PCI Express settings */
-		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
-			struct pci_bus *child;
-
-			list_for_each_entry(child, &bus->children, node)
-				pcie_bus_configure_settings(child);
-		}
-	}
 }
 
 #ifndef CONFIG_PCI_HOST_ITE8152
-- 
1.9.1


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

* Re: [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
  2015-07-21 21:35 [PATCH] ARM/PCI: set MPS before pci_bus_add_devices() Murali Karicheri
@ 2015-07-23 14:24 ` Murali Karicheri
  2015-07-23 14:59 ` Bjorn Helgaas
  2015-08-03 19:13 ` Russell King - ARM Linux
  2 siblings, 0 replies; 6+ messages in thread
From: Murali Karicheri @ 2015-07-23 14:24 UTC (permalink / raw)
  To: linux, bhelgaas, linux-pci, linux-arm-kernel, linux-kernel

On 07/21/2015 05:35 PM, Murali Karicheri wrote:
> The MPS configuration should be done *before* pci_bus_add_devices().
> After pci_bus_add_devices(), drivers may be bound to devices, and
> the PCI core shouldn't touch device configuration while a driver
> owns the device.
>
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Reported-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>   arch/arm/kernel/bios32.c | 19 +++++--------------
>   1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index fcbbbb1..17efde7 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>   	list_for_each_entry(sys, &head, node) {
>   		struct pci_bus *bus = sys->bus;
>
> -		if (!pci_has_flag(PCI_PROBE_ONLY)) {
> +		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
> +			struct pci_bus *child;
>   			/*
>   			 * Size the bridge windows.
>   			 */
> @@ -530,25 +531,15 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>   			 * Assign resources.
>   			 */
>   			pci_bus_assign_resources(bus);
> -		}
>
> +			list_for_each_entry(child, &bus->children, node)
> +				pcie_bus_configure_settings(child);
> +		}
>   		/*
>   		 * Tell drivers about devices found.
>   		 */
>   		pci_bus_add_devices(bus);
>   	}
> -
> -	list_for_each_entry(sys, &head, node) {
> -		struct pci_bus *bus = sys->bus;
> -
> -		/* Configure PCI Express settings */
> -		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
> -			struct pci_bus *child;
> -
> -			list_for_each_entry(child, &bus->children, node)
> -				pcie_bus_configure_settings(child);
> -		}
> -	}
>   }
>
>   #ifndef CONFIG_PCI_HOST_ITE8152
>
Bjorn,

When you get a chance, please review this. We discussed this change in a 
separate thread and agreed for a patch from me.

Thanks and regards

-- 
Murali Karicheri
Linux Kernel, Keystone

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

* Re: [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
  2015-07-21 21:35 [PATCH] ARM/PCI: set MPS before pci_bus_add_devices() Murali Karicheri
  2015-07-23 14:24 ` Murali Karicheri
@ 2015-07-23 14:59 ` Bjorn Helgaas
  2015-08-03 18:18   ` Murali Karicheri
  2015-08-03 19:13 ` Russell King - ARM Linux
  2 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2015-07-23 14:59 UTC (permalink / raw)
  To: Murali Karicheri; +Cc: linux, linux-pci, linux-arm-kernel, linux-kernel

On Tue, Jul 21, 2015 at 05:35:19PM -0400, Murali Karicheri wrote:
> The MPS configuration should be done *before* pci_bus_add_devices().
> After pci_bus_add_devices(), drivers may be bound to devices, and
> the PCI core shouldn't touch device configuration while a driver
> owns the device.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Reported-by: Bjorn Helgaas <bhelgaas@google.com>

Applied to pci/enumeration for v4.3, thanks!  I removed the "bus" test; let
me know if you think that's incorrect.

> ---
>  arch/arm/kernel/bios32.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index fcbbbb1..17efde7 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>  	list_for_each_entry(sys, &head, node) {
>  		struct pci_bus *bus = sys->bus;
>  
> -		if (!pci_has_flag(PCI_PROBE_ONLY)) {
> +		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {

I think the test for "bus" being non-NULL is superfluous here.  If "bus"
were NULL, we would already oops in pci_bus_add_devices().

> +			struct pci_bus *child;
>  			/*
>  			 * Size the bridge windows.
>  			 */
> @@ -530,25 +531,15 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>  			 * Assign resources.
>  			 */
>  			pci_bus_assign_resources(bus);
> -		}
>  
> +			list_for_each_entry(child, &bus->children, node)
> +				pcie_bus_configure_settings(child);
> +		}
>  		/*
>  		 * Tell drivers about devices found.
>  		 */
>  		pci_bus_add_devices(bus);
>  	}
> -
> -	list_for_each_entry(sys, &head, node) {
> -		struct pci_bus *bus = sys->bus;
> -
> -		/* Configure PCI Express settings */
> -		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
> -			struct pci_bus *child;
> -
> -			list_for_each_entry(child, &bus->children, node)
> -				pcie_bus_configure_settings(child);
> -		}
> -	}
>  }
>  
>  #ifndef CONFIG_PCI_HOST_ITE8152
> -- 
> 1.9.1
> 

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

* Re: [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
  2015-07-23 14:59 ` Bjorn Helgaas
@ 2015-08-03 18:18   ` Murali Karicheri
  0 siblings, 0 replies; 6+ messages in thread
From: Murali Karicheri @ 2015-08-03 18:18 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux, linux-kernel, linux-arm-kernel

On 07/23/2015 10:59 AM, Bjorn Helgaas wrote:
> On Tue, Jul 21, 2015 at 05:35:19PM -0400, Murali Karicheri wrote:
>> The MPS configuration should be done *before* pci_bus_add_devices().
>> After pci_bus_add_devices(), drivers may be bound to devices, and
>> the PCI core shouldn't touch device configuration while a driver
>> owns the device.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Reported-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Applied to pci/enumeration for v4.3, thanks!  I removed the "bus" test; let
> me know if you think that's incorrect.
Ok. Will do. Thanks.

Murali

>
>> ---
>>   arch/arm/kernel/bios32.c | 19 +++++--------------
>>   1 file changed, 5 insertions(+), 14 deletions(-)
>>
>> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
>> index fcbbbb1..17efde7 100644
>> --- a/arch/arm/kernel/bios32.c
>> +++ b/arch/arm/kernel/bios32.c
>> @@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>>   	list_for_each_entry(sys, &head, node) {
>>   		struct pci_bus *bus = sys->bus;
>>
>> -		if (!pci_has_flag(PCI_PROBE_ONLY)) {
>> +		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
>
> I think the test for "bus" being non-NULL is superfluous here.  If "bus"
> were NULL, we would already oops in pci_bus_add_devices().
>
>> +			struct pci_bus *child;
>>   			/*
>>   			 * Size the bridge windows.
>>   			 */
>> @@ -530,25 +531,15 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>>   			 * Assign resources.
>>   			 */
>>   			pci_bus_assign_resources(bus);
>> -		}
>>
>> +			list_for_each_entry(child, &bus->children, node)
>> +				pcie_bus_configure_settings(child);
>> +		}
>>   		/*
>>   		 * Tell drivers about devices found.
>>   		 */
>>   		pci_bus_add_devices(bus);
>>   	}
>> -
>> -	list_for_each_entry(sys, &head, node) {
>> -		struct pci_bus *bus = sys->bus;
>> -
>> -		/* Configure PCI Express settings */
>> -		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
>> -			struct pci_bus *child;
>> -
>> -			list_for_each_entry(child, &bus->children, node)
>> -				pcie_bus_configure_settings(child);
>> -		}
>> -	}
>>   }
>>
>>   #ifndef CONFIG_PCI_HOST_ITE8152
>> --
>> 1.9.1
>>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>


-- 
Murali Karicheri
Linux Kernel, Keystone

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

* Re: [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
  2015-07-21 21:35 [PATCH] ARM/PCI: set MPS before pci_bus_add_devices() Murali Karicheri
  2015-07-23 14:24 ` Murali Karicheri
  2015-07-23 14:59 ` Bjorn Helgaas
@ 2015-08-03 19:13 ` Russell King - ARM Linux
  2015-08-03 22:34   ` Bjorn Helgaas
  2 siblings, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux @ 2015-08-03 19:13 UTC (permalink / raw)
  To: Murali Karicheri; +Cc: bhelgaas, linux-pci, linux-arm-kernel, linux-kernel

On Tue, Jul 21, 2015 at 05:35:19PM -0400, Murali Karicheri wrote:
> The MPS configuration should be done *before* pci_bus_add_devices().
> After pci_bus_add_devices(), drivers may be bound to devices, and
> the PCI core shouldn't touch device configuration while a driver
> owns the device.
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
> Reported-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  arch/arm/kernel/bios32.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index fcbbbb1..17efde7 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>  	list_for_each_entry(sys, &head, node) {
>  		struct pci_bus *bus = sys->bus;
>  
> -		if (!pci_has_flag(PCI_PROBE_ONLY)) {
> +		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {

Let's get rid of that useless check.  bus can't be NULL here.

In the original code (below) if bus was NULL, then we would've already
oopsed before we got here.  As we don't oops here, no one is ever
seeing it being NULL, so the test is redundant.

> -	list_for_each_entry(sys, &head, node) {
> -		struct pci_bus *bus = sys->bus;
> -
> -		/* Configure PCI Express settings */
> -		if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {

Thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] ARM/PCI: set MPS before pci_bus_add_devices()
  2015-08-03 19:13 ` Russell King - ARM Linux
@ 2015-08-03 22:34   ` Bjorn Helgaas
  0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2015-08-03 22:34 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Murali Karicheri, linux-pci, linux-arm, linux-kernel

On Mon, Aug 3, 2015 at 2:13 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Tue, Jul 21, 2015 at 05:35:19PM -0400, Murali Karicheri wrote:
>> The MPS configuration should be done *before* pci_bus_add_devices().
>> After pci_bus_add_devices(), drivers may be bound to devices, and
>> the PCI core shouldn't touch device configuration while a driver
>> owns the device.
>>
>> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>> Reported-by: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  arch/arm/kernel/bios32.c | 19 +++++--------------
>>  1 file changed, 5 insertions(+), 14 deletions(-)
>>
>> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
>> index fcbbbb1..17efde7 100644
>> --- a/arch/arm/kernel/bios32.c
>> +++ b/arch/arm/kernel/bios32.c
>> @@ -520,7 +520,8 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>>       list_for_each_entry(sys, &head, node) {
>>               struct pci_bus *bus = sys->bus;
>>
>> -             if (!pci_has_flag(PCI_PROBE_ONLY)) {
>> +             if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
>
> Let's get rid of that useless check.  bus can't be NULL here.
>
> In the original code (below) if bus was NULL, then we would've already
> oopsed before we got here.  As we don't oops here, no one is ever
> seeing it being NULL, so the test is redundant.
>
>> -     list_for_each_entry(sys, &head, node) {
>> -             struct pci_bus *bus = sys->bus;
>> -
>> -             /* Configure PCI Express settings */
>> -             if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
>

Sorry, I had forgotten to push this branch, but I did already get rid
of the check for bus being NULL:

http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?id=808b27a5ae05

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

end of thread, other threads:[~2015-08-03 22:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 21:35 [PATCH] ARM/PCI: set MPS before pci_bus_add_devices() Murali Karicheri
2015-07-23 14:24 ` Murali Karicheri
2015-07-23 14:59 ` Bjorn Helgaas
2015-08-03 18:18   ` Murali Karicheri
2015-08-03 19:13 ` Russell King - ARM Linux
2015-08-03 22:34   ` Bjorn Helgaas

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