linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Peter Wu <peter@lekensteyn.nl>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Lukas Wunner <lukas@wunner.de>,
	linux-pci@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH] PCI: Power on bridges before scanning new devices
Date: Mon, 23 May 2016 15:00:42 -0500	[thread overview]
Message-ID: <20160523200042.GB24375@localhost> (raw)
In-Reply-To: <1463991648-85051-1-git-send-email-mika.westerberg@linux.intel.com>

On Mon, May 23, 2016 at 11:20:48AM +0300, Mika Westerberg wrote:
> When a PCI device is removed through sysfs interface the upstream bridge
> (PCIe port) can be runtime suspended if it was the last device on that bus.
> Now, if the bridge is in D3 we cannot find devices below the bridge
> anymore. For example following fails to find the removed device again:
> 
>    # echo 1 > /sys/bus/pci/devices/0000:00:01.0/0000:01:00.0/remove
>    # echo 1 > /sys/bus/pci/devices/0000:00:01.0/rescan
> 
> Where 0000:00:01.0 is the bridge device.
> 
> In order to be able to rescan devices below the bridge add
> pm_runtime_get_sync()/pm_runtime_put() calls to pci_scan_bridge(). This
> should keep bridges powered on while their children devices are being
> scanned.
> 
> Reported-by: Peter Wu <peter@lekensteyn.nl>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

This looks like basically the same idea as "ACPI / hotplug / PCI:
Runtime resume bridge before rescan".

The hotplug_event() path modified by that patch eventually calls
pci_scan_bridge():

  hotplug_event
    enable_slot
      pci_scan_bridge

so this patch looks a little more general.  Does it make "ACPI /
hotplug / PCI: Runtime resume bridge before rescan" unnecessary?  
Can I just replace that patch with this one?

> ---
>  drivers/pci/probe.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8004f67c57ec..15e77c92311e 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -16,6 +16,7 @@
>  #include <linux/aer.h>
>  #include <linux/acpi.h>
>  #include <linux/irqdomain.h>
> +#include <linux/pm_runtime.h>
>  #include "pci.h"
>  
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
> @@ -832,6 +833,12 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
>  	u8 primary, secondary, subordinate;
>  	int broken = 0;
>  
> +	/*
> +	 * Make sure the bridge is powered on to be able to access config
> +	 * space of devices below it.
> +	 */
> +	pm_runtime_get_sync(&dev->dev);
> +
>  	pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
>  	primary = buses & 0xFF;
>  	secondary = (buses >> 8) & 0xFF;
> @@ -1012,6 +1019,8 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
>  out:
>  	pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl);
>  
> +	pm_runtime_put(&dev->dev);
> +
>  	return max;
>  }
>  EXPORT_SYMBOL(pci_scan_bridge);
> -- 
> 2.8.1
> 
> --
> 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

  reply	other threads:[~2016-05-23 20:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 17:14 Rescanning is broken with runtime PM for PCIe ports Peter Wu
2016-05-19  7:42 ` Mika Westerberg
2016-05-19 11:36   ` Mika Westerberg
2016-05-20  8:45     ` Peter Wu
2016-05-23  8:20       ` [PATCH] PCI: Power on bridges before scanning new devices Mika Westerberg
2016-05-23 20:00         ` Bjorn Helgaas [this message]
2016-05-23 21:50           ` Bjorn Helgaas
2016-05-24 12:23             ` Bjorn Helgaas
2016-05-24 12:52               ` Lukas Wunner
2016-05-24 12:53               ` Mika Westerberg
2016-05-24 14:27                 ` Peter Wu
2016-05-24 15:06                   ` Lukas Wunner
2016-05-24 16:38                   ` Bjorn Helgaas
2016-05-24 23:46                     ` Peter Wu
2016-05-24 16:28                 ` Bjorn Helgaas
2016-05-25 15:04                   ` [PATCH] PCI: Wait for 50ms after bridge is powered up Mika Westerberg
2016-05-25 20:44                     ` Rafael J. Wysocki
2016-05-26 10:10                     ` Lukas Wunner
2016-05-26 10:25                       ` Mika Westerberg
2016-05-26 10:45                         ` Lukas Wunner
2016-05-26 11:03                           ` Mika Westerberg
2016-05-28 12:29                             ` Rafael J. Wysocki
2016-05-30  9:33                               ` Mika Westerberg
2016-05-30 14:44                                 ` Mika Westerberg
2016-05-30 15:19                                   ` Andreas Noever
2016-05-31  8:33                                     ` Mika Westerberg
2016-05-31  8:58                                       ` Mika Westerberg
2016-05-31 10:40                                         ` Lukas Wunner
2016-05-31 10:47                                           ` Mika Westerberg
2016-05-31 11:07                                             ` Lukas Wunner
2016-06-01  9:11                                               ` Mika Westerberg
2016-06-01 11:42                                                 ` Lukas Wunner
2016-05-24 21:13                 ` [PATCH] PCI: Power on bridges before scanning new devices Mika Westerberg
2016-05-25  0:03                   ` Rafael J. Wysocki
2016-05-25 13:19                   ` Mika Westerberg
2016-05-25 20:45                     ` Rafael J. Wysocki
2016-05-26  8:16                       ` Mika Westerberg
2016-05-28 12:21                         ` Rafael J. Wysocki
2016-05-30  9:35                           ` Mika Westerberg
2016-05-25 12:16                 ` Lukas Wunner
2016-05-25 13:25                   ` Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160523200042.GB24375@localhost \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mika.westerberg@linux.intel.com \
    --cc=peter@lekensteyn.nl \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).