linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Keith Busch <keith.busch@intel.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Lukas Wunner <lukas@wunner.de>, Wei Zhang <wzhang@fb.com>,
	Austin Bolen <Austin.Bolen@dell.com>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCHv5 2/5] pci: Add device disconnected state
Date: Fri, 3 Feb 2017 21:53:30 +0100	[thread overview]
Message-ID: <20170203205330.GA16487@kroah.com> (raw)
In-Reply-To: <1486144555-5526-3-git-send-email-keith.busch@intel.com>

On Fri, Feb 03, 2017 at 12:55:52PM -0500, Keith Busch wrote:
> This patch adds a new state to pci_dev to be set when it is unexpectedly
> disconnected. The pci driver tear down functions can observe this new
> device state so they may skip operations that will fail.
> 
> The pciehp and pcie-dpc drivers are aware when the link is down, so
> these set the flag when their handlers detect the device is disconnected.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
>  drivers/pci/hotplug/pciehp_pci.c |  5 +++++
>  drivers/pci/pci.h                | 14 ++++++++++++++
>  drivers/pci/pcie/pcie-dpc.c      |  4 ++++
>  include/linux/pci.h              |  2 ++
>  4 files changed, 25 insertions(+)
> 
> diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
> index 9e69403..9b2f41d 100644
> --- a/drivers/pci/hotplug/pciehp_pci.c
> +++ b/drivers/pci/hotplug/pciehp_pci.c
> @@ -109,6 +109,11 @@ int pciehp_unconfigure_device(struct slot *p_slot)
>  				break;
>  			}
>  		}
> +		if (!presence) {
> +			pci_dev_set_disconnected(dev, NULL);
> +			if (pci_has_subordinate(dev))
> +				pci_walk_bus(dev->subordinate, pci_dev_set_disconnected, NULL);
> +		}
>  		pci_stop_and_remove_bus_device(dev);
>  		/*
>  		 * Ensure that no new Requests will be generated from
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index cb17db2..81512bc 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -274,6 +274,20 @@ struct pci_sriov {
>  	resource_size_t barsz[PCI_SRIOV_NUM_BARS];	/* VF BAR size */
>  };
>  
> +/* pci_dev priv_flags */
> +#define PCI_DEV_DISCONNECTED 0
> +
> +static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused)
> +{
> +	set_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags);

Why a single bit?  Are you trying to do this without locking or
something?  And if you want a bit, what's wrong with a C bit type?  Or
just a boolean?

I applaud your attempt to make this "private" to the pci core, just
don't know if it really will work, or if it is worth it entirely...

Anyway, I'll let Bjorn judge this feature being worth it or not :)

thanks,

greg k-h

  reply	other threads:[~2017-02-03 20:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 17:55 [PATCHv5 0/5] Limiting PCI access Keith Busch
2017-02-03 17:55 ` [PATCHv5 1/5] pci: Export pci device config accessors Keith Busch
2017-02-06 17:30   ` Christoph Hellwig
2017-02-03 17:55 ` [PATCHv5 2/5] pci: Add device disconnected state Keith Busch
2017-02-03 20:53   ` Greg Kroah-Hartman [this message]
2017-02-06 17:32     ` Christoph Hellwig
2017-02-06 17:40       ` Greg Kroah-Hartman
2017-02-06 17:48         ` Christoph Hellwig
2017-02-06 17:54         ` Keith Busch
2017-02-06 17:33   ` Christoph Hellwig
2017-02-06 21:11     ` Keith Busch
2017-02-03 17:55 ` [PATCHv5 3/5] pci: No config access for disconnected devices Keith Busch
2017-02-06 17:34   ` Christoph Hellwig
2017-02-03 17:55 ` [PATCHv5 4/5] pci/msix: Skip disabling " Keith Busch
2017-02-06 17:35   ` Christoph Hellwig
2017-02-03 17:55 ` [PATCHv5 5/5] pci: Quick return for pci_device_is_present Keith Busch
2017-02-06 17:36   ` Christoph Hellwig

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=20170203205330.GA16487@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=Austin.Bolen@dell.com \
    --cc=bhelgaas@google.com \
    --cc=hch@infradead.org \
    --cc=keith.busch@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=wzhang@fb.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).