From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Keith Busch <keith.busch@intel.com>,
linux-pci@vger.kernel.org, Wei Zhang <wzhang@fb.com>
Subject: Re: [PATCHv4 next 1/3] pci: Add is_removed state
Date: Wed, 14 Dec 2016 00:54:33 +0100 [thread overview]
Message-ID: <20161213235433.GA11088@wunner.de> (raw)
In-Reply-To: <20161213205614.GA30106@bhelgaas-glaptop.roam.corp.google.com>
On Tue, Dec 13, 2016 at 02:56:14PM -0600, Bjorn Helgaas wrote:
> On Fri, Oct 28, 2016 at 06:58:15PM -0400, Keith Busch wrote:
[snip]
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index 0e49f70..2115d19 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -341,6 +341,7 @@ struct pci_dev {
> > unsigned int multifunction:1;/* Part of multi-function device */
> > /* keep track of device state */
> > unsigned int is_added:1;
> > + unsigned int is_removed:1; /* device was surprise removed */
> > unsigned int is_busmaster:1; /* device is busmaster */
> > unsigned int no_msi:1; /* device may not use msi */
> > unsigned int no_64bit_msi:1; /* device may only use 32-bit MSIs */
> > @@ -417,6 +418,12 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
> > return (pdev->error_state != pci_channel_io_normal);
> > }
> >
> > +static inline int pci_set_removed(struct pci_dev *pdev, void *unused)
> > +{
> > + pdev->is_removed = 1;
>
> This makes me slightly worried because this is a bitfield and there's
> no locking. A concurrent write to some nearby field can corrupt
> things. It doesn't look *likely*, but it's a lot of work to be
> convinced that this is completely safe, especially since the writer is
> running on behalf of the bridge, and the target is a child of the
> bridge.
>
> The USB HCD_FLAG_DEAD and HCD_FLAG_HW_ACCESSIBLE flags are somewhat
> similar. Maybe we can leverage some of that design?
Back in October I suggested leveraging the error_state field in struct
pci_dev. That's an enum defined at the top of include/linux/pci.h
with values pci_channel_io_normal, pci_channel_io_frozen and
pci_channel_io_perm_failure. I suggested adding a removed state.
The benefit is that lots of drivers already check pci_channel_offline()
before accessing a device, so without any further changes they would
treat surprise-removed devices properly.
However Keith responded:
"I'd be happy if we can reuse that, but concerned about overloading
error_state's intended purpose for AER. The conditions under which an
'is_removed' may be set can also create AER events, and the aer driver
overrides the error_state."
(http://www.spinics.net/lists/linux-pci/msg55417.html)
So it would seem to require at least a modification of the AER driver
to not overwrite a pci_channel_io_removed state.
Best regards,
Lukas
next prev parent reply other threads:[~2016-12-13 23:54 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-28 22:58 [PATCHv4 next 0/3] Limiting pci access Keith Busch
2016-10-28 22:58 ` [PATCHv4 next 1/3] pci: Add is_removed state Keith Busch
2016-10-31 10:41 ` Lukas Wunner
2016-12-13 20:56 ` Bjorn Helgaas
2016-12-13 23:07 ` Keith Busch
2016-12-14 2:50 ` Bjorn Helgaas
2016-12-14 2:54 ` Bjorn Helgaas
2016-12-13 23:54 ` Lukas Wunner [this message]
2016-10-28 22:58 ` [PATCHv4 next 2/3] pci: No config access for removed devices Keith Busch
2016-10-31 12:18 ` Lukas Wunner
2016-10-28 22:58 ` [PATCHv4 next 3/3] pci/msix: Skip disabling " Keith Busch
2016-10-31 11:00 ` Lukas Wunner
2016-10-31 13:54 ` Keith Busch
2016-12-13 21:18 ` Bjorn Helgaas
2016-12-13 23:01 ` Keith Busch
2016-11-18 23:25 ` [PATCHv4 next 0/3] Limiting pci access Keith Busch
2016-11-23 16:09 ` Bjorn Helgaas
2016-11-28 9:14 ` Wei Zhang
2016-11-28 10:22 ` Lukas Wunner
2016-11-28 18:02 ` Keith Busch
2016-12-08 17:54 ` Bjorn Helgaas
2016-12-08 19:32 ` Keith Busch
2016-12-12 23:42 ` Bjorn Helgaas
2016-12-13 0:55 ` Keith Busch
2016-12-13 20:50 ` Bjorn Helgaas
2016-12-13 23:18 ` Keith Busch
[not found] ` <B58D82457FDA0744A320A2FC5AC253B93D82F37D@fmsmsx104.amr.corp.intel.com>
[not found] ` <20170120213550.GA16618@localhost.localdomain>
2017-01-21 7:31 ` Lukas Wunner
2017-01-21 8:42 ` Greg Kroah-Hartman
2017-01-21 14:22 ` Lukas Wunner
2017-01-25 11:47 ` Greg Kroah-Hartman
2017-01-23 16:04 ` Keith Busch
2017-01-25 0:44 ` Austin.Bolen
2017-01-25 21:17 ` Bjorn Helgaas
2017-01-26 1:12 ` Austin.Bolen
2017-02-01 16:04 ` Bjorn Helgaas
2017-02-03 20:30 ` Austin.Bolen
2017-02-03 20:39 ` Greg KH
2017-02-03 21:43 ` Austin.Bolen
2017-01-25 11:48 ` Greg Kroah-Hartman
2017-01-28 7:36 ` Christoph Hellwig
2018-11-13 6:05 ` Bjorn Helgaas
2018-11-13 14:59 ` Keith Busch
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=20161213235433.GA11088@wunner.de \
--to=lukas@wunner.de \
--cc=helgaas@kernel.org \
--cc=keith.busch@intel.com \
--cc=linux-pci@vger.kernel.org \
--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 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.