Patchwork [v2,3/8] PCI: acpiphp: enable_device(): rescan even if no new devices on slot

login
register
mail settings
Submitter Mika Westerberg
Date July 3, 2013, 2:04 p.m.
Message ID <1372860295-8306-4-git-send-email-mika.westerberg@linux.intel.com>
Download mbox | patch
Permalink /patch/256646/
State Not Applicable
Headers show

Comments

Mika Westerberg - July 3, 2013, 2:04 p.m.
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>

pci_scan_slot() returns number of new devices connected *directly*
connected to the slot. Current enable_device() checks the return value
and stops if it doesn't see a new device.

In Thunderbolt chaining case the new device can be deeper in hierarchy, so
do the rescan anyway.

Because of that we must make sure that pcibios_resource_survey_bus() and
check_hotplug_bridge() get called only for a just found bus and not the
ones already added to the system. Failure to do so will lead to resource
conflicts.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
Rafael J. Wysocki - July 11, 2013, 12:25 a.m.
On Wednesday, July 03, 2013 05:04:50 PM Mika Westerberg wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> 
> pci_scan_slot() returns number of new devices connected *directly*
> connected to the slot. Current enable_device() checks the return value
> and stops if it doesn't see a new device.
> 
> In Thunderbolt chaining case the new device can be deeper in hierarchy, so
> do the rescan anyway.
> 
> Because of that we must make sure that pcibios_resource_survey_bus() and
> check_hotplug_bridge() get called only for a just found bus and not the
> ones already added to the system. Failure to do so will lead to resource
> conflicts.

Well, I wonder what we're doing to this end, because there's nothing in that
area in the patch?

> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/pci/hotplug/acpiphp_glue.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index b983e29..0f4da3b 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -685,18 +685,13 @@ static int __ref enable_device(struct acpiphp_slot *slot)
>  	struct pci_dev *dev;
>  	struct pci_bus *bus = slot->bridge->pci_bus;
>  	struct acpiphp_func *func;
> -	int num, max, pass;
> +	int max, pass;
>  	LIST_HEAD(add_list);
>  
>  	list_for_each_entry(func, &slot->funcs, sibling)
>  		acpiphp_bus_add(func);
>  
> -	num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
> -	if (num == 0) {
> -		/* Maybe only part of funcs are added. */
> -		dbg("No new device found\n");
> -		goto err_exit;
> -	}
> +	pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
>  	max = acpiphp_max_busnr(bus);
>  	for (pass = 0; pass < 2; pass++) {
> @@ -742,8 +737,6 @@ static int __ref enable_device(struct acpiphp_slot *slot)
>  		}
>  	}
>  
> -
> - err_exit:
>  	return 0;
>  }
>  
>
Mika Westerberg - July 11, 2013, 5:11 a.m.
On Thu, Jul 11, 2013 at 02:25:42AM +0200, Rafael J. Wysocki wrote:
> On Wednesday, July 03, 2013 05:04:50 PM Mika Westerberg wrote:
> > From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> > 
> > pci_scan_slot() returns number of new devices connected *directly*
> > connected to the slot. Current enable_device() checks the return value
> > and stops if it doesn't see a new device.
> > 
> > In Thunderbolt chaining case the new device can be deeper in hierarchy, so
> > do the rescan anyway.
> > 
> > Because of that we must make sure that pcibios_resource_survey_bus() and
> > check_hotplug_bridge() get called only for a just found bus and not the
> > ones already added to the system. Failure to do so will lead to resource
> > conflicts.
> 
> Well, I wonder what we're doing to this end, because there's nothing in that
> area in the patch?

We forgot to update the changelog of this patch. The last paragraph should
not be there.
--
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
Rafael J. Wysocki - July 11, 2013, 10:48 p.m.
On Thursday, July 11, 2013 08:11:44 AM Mika Westerberg wrote:
> On Thu, Jul 11, 2013 at 02:25:42AM +0200, Rafael J. Wysocki wrote:
> > On Wednesday, July 03, 2013 05:04:50 PM Mika Westerberg wrote:
> > > From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> > > 
> > > pci_scan_slot() returns number of new devices connected *directly*
> > > connected to the slot. Current enable_device() checks the return value
> > > and stops if it doesn't see a new device.
> > > 
> > > In Thunderbolt chaining case the new device can be deeper in hierarchy, so
> > > do the rescan anyway.
> > > 
> > > Because of that we must make sure that pcibios_resource_survey_bus() and
> > > check_hotplug_bridge() get called only for a just found bus and not the
> > > ones already added to the system. Failure to do so will lead to resource
> > > conflicts.
> > 
> > Well, I wonder what we're doing to this end, because there's nothing in that
> > area in the patch?
> 
> We forgot to update the changelog of this patch. The last paragraph should
> not be there.

Yeah, I noticed that later.  Never mind. :-)

Patch

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index b983e29..0f4da3b 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -685,18 +685,13 @@  static int __ref enable_device(struct acpiphp_slot *slot)
 	struct pci_dev *dev;
 	struct pci_bus *bus = slot->bridge->pci_bus;
 	struct acpiphp_func *func;
-	int num, max, pass;
+	int max, pass;
 	LIST_HEAD(add_list);
 
 	list_for_each_entry(func, &slot->funcs, sibling)
 		acpiphp_bus_add(func);
 
-	num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
-	if (num == 0) {
-		/* Maybe only part of funcs are added. */
-		dbg("No new device found\n");
-		goto err_exit;
-	}
+	pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
 
 	max = acpiphp_max_busnr(bus);
 	for (pass = 0; pass < 2; pass++) {
@@ -742,8 +737,6 @@  static int __ref enable_device(struct acpiphp_slot *slot)
 		}
 	}
 
-
- err_exit:
 	return 0;
 }