All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI / hotplug / ACPI: Check ignore_hotplug for all downstream devices
@ 2015-05-20  0:14 Rafael J. Wysocki
  2015-05-22 21:44 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-05-20  0:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Linux PCI, Linux Kernel Mailing List, ACPI Devel Maling List,
	Mika Westerberg

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

If the ignore_hotplug flag is set for a PCI device without an ACPI
companion and a bus check notification is received for an ancestor
bridge that is not the device's parent, ACPIPHP will ignore that
flag.

Namely, in that case acpiphp_check_bridge() is called for the target
bridge and if all of the devices immediately below the bridge are
still present, trim_stale_devices() will be called for each of them.
That function recursively walks the hierarchy downwards and removes
device objects corresponding to devices that don't appear to be
present any more.  Unfortunately, it only checks ignore_hotplug
for devices having ACPI companions, so it will remove the others
(if they don't respond) regardless of the ignore_hotplug value.

Fix the problem by making trim_stale_devices() take ignore_hotplug
into consideration regardless of whether or not an ACPI companion
is present for the device it has been called for.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This may fix BZ61891, but even if it doesn't, the bug is quite obvious to me.

Should be applicable since commit b440bde74f04 (PCI: Add pci_ignore_hotplug()
to ignore hotplug events for a device) which shipped in 3.17.

---
 drivers/pci/hotplug/acpiphp_glue.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux-pm/drivers/pci/hotplug/acpiphp_glue.c
@@ -632,15 +632,14 @@ static void trim_stale_devices(struct pc
 {
 	struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
 	struct pci_bus *bus = dev->subordinate;
-	bool alive = false;
+	bool alive = dev->ignore_hotplug;
 
 	if (adev) {
 		acpi_status status;
 		unsigned long long sta;
 
 		status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
-		alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
-			|| dev->ignore_hotplug;
+		alive = alive || (ACPI_SUCCESS(status) && device_status_valid(sta));
 	}
 	if (!alive)
 		alive = pci_device_is_present(dev);


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

* Re: [PATCH] PCI / hotplug / ACPI: Check ignore_hotplug for all downstream devices
  2015-05-20  0:14 [PATCH] PCI / hotplug / ACPI: Check ignore_hotplug for all downstream devices Rafael J. Wysocki
@ 2015-05-22 21:44 ` Bjorn Helgaas
  2015-05-22 22:16   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2015-05-22 21:44 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux PCI, Linux Kernel Mailing List, ACPI Devel Maling List,
	Mika Westerberg, lorenzo.stanco, tiagdtd-lava

[+cc Lorenzo, tiagdtd-lava]

On Wed, May 20, 2015 at 02:14:13AM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> If the ignore_hotplug flag is set for a PCI device without an ACPI
> companion and a bus check notification is received for an ancestor
> bridge that is not the device's parent, ACPIPHP will ignore that
> flag.
> 
> Namely, in that case acpiphp_check_bridge() is called for the target
> bridge and if all of the devices immediately below the bridge are
> still present, trim_stale_devices() will be called for each of them.
> That function recursively walks the hierarchy downwards and removes
> device objects corresponding to devices that don't appear to be
> present any more.  Unfortunately, it only checks ignore_hotplug
> for devices having ACPI companions, so it will remove the others
> (if they don't respond) regardless of the ignore_hotplug value.
> 
> Fix the problem by making trim_stale_devices() take ignore_hotplug
> into consideration regardless of whether or not an ACPI companion
> is present for the device it has been called for.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Applied to pci/hotplug for v4.2, thanks!

I cc'd Lorenzo and tiagdtd-lava in hopes they can test this patch and see
whether it resolves https://bugzilla.kernel.org/show_bug.cgi?id=61891 .

The branch with this patch applied is here:
https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/hotplug

> ---
> 
> This may fix BZ61891, but even if it doesn't, the bug is quite obvious to me.
> 
> Should be applicable since commit b440bde74f04 (PCI: Add pci_ignore_hotplug()
> to ignore hotplug events for a device) which shipped in 3.17.
> 
> ---
>  drivers/pci/hotplug/acpiphp_glue.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
> ===================================================================
> --- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c
> +++ linux-pm/drivers/pci/hotplug/acpiphp_glue.c
> @@ -632,15 +632,14 @@ static void trim_stale_devices(struct pc
>  {
>  	struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
>  	struct pci_bus *bus = dev->subordinate;
> -	bool alive = false;
> +	bool alive = dev->ignore_hotplug;
>  
>  	if (adev) {
>  		acpi_status status;
>  		unsigned long long sta;
>  
>  		status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
> -		alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
> -			|| dev->ignore_hotplug;
> +		alive = alive || (ACPI_SUCCESS(status) && device_status_valid(sta));
>  	}
>  	if (!alive)
>  		alive = pci_device_is_present(dev);
> 

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

* Re: [PATCH] PCI / hotplug / ACPI: Check ignore_hotplug for all downstream devices
  2015-05-22 21:44 ` Bjorn Helgaas
@ 2015-05-22 22:16   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2015-05-22 22:16 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Linux PCI, Linux Kernel Mailing List, ACPI Devel Maling List,
	Mika Westerberg, lorenzo.stanco, tiagdtd-lava

On Friday, May 22, 2015 04:44:16 PM Bjorn Helgaas wrote:
> [+cc Lorenzo, tiagdtd-lava]
> 
> On Wed, May 20, 2015 at 02:14:13AM +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > If the ignore_hotplug flag is set for a PCI device without an ACPI
> > companion and a bus check notification is received for an ancestor
> > bridge that is not the device's parent, ACPIPHP will ignore that
> > flag.
> > 
> > Namely, in that case acpiphp_check_bridge() is called for the target
> > bridge and if all of the devices immediately below the bridge are
> > still present, trim_stale_devices() will be called for each of them.
> > That function recursively walks the hierarchy downwards and removes
> > device objects corresponding to devices that don't appear to be
> > present any more.  Unfortunately, it only checks ignore_hotplug
> > for devices having ACPI companions, so it will remove the others
> > (if they don't respond) regardless of the ignore_hotplug value.
> > 
> > Fix the problem by making trim_stale_devices() take ignore_hotplug
> > into consideration regardless of whether or not an ACPI companion
> > is present for the device it has been called for.
> > 
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Applied to pci/hotplug for v4.2, thanks!
> 
> I cc'd Lorenzo and tiagdtd-lava in hopes they can test this patch and see
> whether it resolves https://bugzilla.kernel.org/show_bug.cgi?id=61891 .
> 
> The branch with this patch applied is here:
> https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/hotplug

Thanks!

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

end of thread, other threads:[~2015-05-22 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-20  0:14 [PATCH] PCI / hotplug / ACPI: Check ignore_hotplug for all downstream devices Rafael J. Wysocki
2015-05-22 21:44 ` Bjorn Helgaas
2015-05-22 22:16   ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.