From: Lukas Wunner <lukas@wunner.de>
To: Keith Busch <keith.busch@intel.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Ralf Baechle <ralf@linux-mips.org>, Wei Zhang <wzhang@fb.com>,
Andreas Noever <andreas.noever@gmail.com>
Subject: Re: [PATCHv3 2/5] pci: Add is_removed state
Date: Fri, 21 Oct 2016 18:20:10 +0200 [thread overview]
Message-ID: <20161021162010.GB4221@wunner.de> (raw)
In-Reply-To: <1475007815-28354-3-git-send-email-keith.busch@intel.com>
On Tue, Sep 27, 2016 at 04:23:32PM -0400, Keith Busch wrote:
> This adds a new state for devices that were once in the system, but
> unexpectedly removed. This is so device tear down functions can observe
> the device is not accessible so it may skip attempting to initialize
> the hardware.
[...]
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -337,6 +337,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 */
The tg3 driver (as well as many other drivers) already check reachability
of a device before accessing its mmio space by calling pci_channel_offline().
I've found that the following simple change on top of your series is
already sufficient to make hot-removal of the Apple Gigabit Ethernet
adapter "just work" (no more soft lockups, which is a giant improvement):
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5c43012..cc8b234 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -406,7 +406,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus);
static inline int pci_channel_offline(struct pci_dev *pdev)
{
- return (pdev->error_state != pci_channel_io_normal);
+ return pdev->error_state != pci_channel_io_normal || pdev->is_removed;
}
struct pci_host_bridge {
This got me thinking: We've got three pci_channel_state values defined
in include/linux/pci.h, "normal", "frozen" and "perm_failure". Instead
of adding a new "is_removed" bit to struct pci_dev, would it perhaps
make more sense to just add a new type of pci_channel_state for removed
devices? Then the above change to pci_channel_offline() wouldn't even
be necessary. The pciehp and dpc drivers would just change the channel
status to "removed" and all the drivers already querying it with
pci_channel_offline() would pick up the change automatically.
Thoughts?
Thanks,
Lukas
next prev parent reply other threads:[~2016-10-21 16:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 20:23 [PATCHv3 0/5] PCI access on removed devices Keith Busch
2016-09-27 20:23 ` [PATCHv3 1/5] mips/pci: Reduce stack frame usage Keith Busch
2016-09-28 13:43 ` Atsushi Nemoto
2016-09-27 20:23 ` [PATCHv3 2/5] pci: Add is_removed state Keith Busch
2016-10-21 15:37 ` Lukas Wunner
2016-10-21 16:15 ` Keith Busch
2016-10-21 16:36 ` Lukas Wunner
2016-10-21 16:20 ` Lukas Wunner [this message]
2016-10-21 17:08 ` Keith Busch
2016-10-21 16:58 ` Lukas Wunner
2016-10-21 17:30 ` Keith Busch
2016-09-27 20:23 ` [PATCHv3 3/5] pci: No config access for removed devices Keith Busch
2016-09-27 20:23 ` [PATCHv3 4/5] pcie/aer: Cache capability position Keith Busch
2016-09-27 21:05 ` Bjorn Helgaas
2016-09-27 20:23 ` [PATCHv3 5/5] pci/msix: Skip disabling removed devices 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=20161021162010.GB4221@wunner.de \
--to=lukas@wunner.de \
--cc=andreas.noever@gmail.com \
--cc=bhelgaas@google.com \
--cc=keith.busch@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=ralf@linux-mips.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.