linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Cc: linux-pci@vger.kernel.org, tbroch@google.com, rajatja@google.com,
	gwendal@google.com, bhelgaas@google.com, ravisadineni@google.com,
	keith.busch@intel.com, paul.gortmaker@windriver.com
Subject: Re: [PATCH] pciehp_resume: don't add existing device
Date: Wed, 9 Nov 2016 20:58:12 +0100	[thread overview]
Message-ID: <20161109195812.GA7528@wunner.de> (raw)
In-Reply-To: <1478714735-134347-1-git-send-email-ravisadineni@chromium.org>

On Wed, Nov 09, 2016 at 10:05:35AM -0800, Ravi Chandra Sadineni wrote:
> If a slot was occupied before supend, and nothing has changed after
> resume, we call pciehp_enable_slot() although it fails a little
> later with the message:
>    Device XXXX:XX:XX.X already exists at XXXX:XX:XX, cannot hot-add
>    Cannot add device at XXXX:XX:XX
> 
> This was partly discussed here: https://lkml.org/lkml/2013/7/9/452
> and I'm pulling only the part4 of that patch, since it does not change
> anything functionally (or atleast does not seem to make it worse), but
> prevents uncomfortable messages pointed above.
> ---
>  drivers/pci/hotplug/pciehp_core.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
> index 612b21a..873cff8 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -290,6 +290,7 @@ static int pciehp_resume(struct pcie_device *dev)
>  {
>  	struct controller *ctrl;
>  	struct slot *slot;
> +	struct pci_bus *pbus = dev->port->subordinate;
>  	u8 status;
>  
>  	ctrl = get_service_data(dev);
> @@ -302,10 +303,13 @@ static int pciehp_resume(struct pcie_device *dev)
>  	/* Check if slot is occupied */
>  	pciehp_get_adapter_status(slot, &status);
>  	mutex_lock(&slot->hotplug_lock);
> -	if (status)
> -		pciehp_enable_slot(slot);
> -	else
> +	if (status) {
> +		if (list_empty(&pbus->devices))
> +			pciehp_enable_slot(slot);
> +	}
> +	else {
>  		pciehp_disable_slot(slot);
> +	}

What if the device plugged in after suspend is a different one
and requires e.g. an entirely different driver or different resource
allocations?

What if the device is the same but child devices have been plugged
in during system sleep? (E.g. additional devices attached to a
Thunderbolt daisy chain.)

At the very least you need to rescan the bus here.

Thanks,

Lukas

>  	mutex_unlock(&slot->hotplug_lock);
>  	return 0;
>  }
> -- 
> 2.6.6

  reply	other threads:[~2016-11-09 19:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 18:05 [PATCH] pciehp_resume: don't add existing device Ravi Chandra Sadineni
2016-11-09 19:58 ` Lukas Wunner [this message]
2016-11-09 20:59   ` Rajat Jain
2016-11-11  7:23     ` Lukas Wunner
2016-11-09 21:15 ` Rajat Jain

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=20161109195812.GA7528@wunner.de \
    --to=lukas@wunner.de \
    --cc=bhelgaas@google.com \
    --cc=gwendal@google.com \
    --cc=keith.busch@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=rajatja@google.com \
    --cc=ravisadineni@chromium.org \
    --cc=ravisadineni@google.com \
    --cc=tbroch@google.com \
    /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).