From: Lukas Wunner <lukas@wunner.de>
To: Keith Busch <keith.busch@intel.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Jon Derrick <jonathan.derrick@intel.com>,
Wei Zhang <wzhang@fb.com>
Subject: Re: [PATCHv2 1/4] pci: Add is_removed state
Date: Sat, 17 Sep 2016 10:35:06 +0200 [thread overview]
Message-ID: <20160917083506.GA1235@wunner.de> (raw)
In-Reply-To: <1473199219-3369-2-git-send-email-keith.busch@intel.com>
On Tue, Sep 06, 2016 at 04:00:16PM -0600, Keith Busch wrote:
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4924,7 +4924,14 @@ bool pci_device_is_present(struct pci_dev *pdev)
> {
> u32 v;
>
> - return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
> + if (pdev->is_removed)
> + return false;
> +
> + if (!pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0)) {
> + pdev->is_removed = 1;
> + return false;
> + }
> + return true;
> }
> EXPORT_SYMBOL_GPL(pci_device_is_present);
I've kept this series on my development branch and found a bug now:
In the above hunk, it's okay to return false if pdev->is_removed is set,
but it's not okay to set pdev->is_removed if pci_bus_read_dev_vendor_id()
returns false. That's because pci_bus_read_dev_vendor_id() can fail for
other reasons, such as the device being powered down to D3cold, or
currently unreachable because a PCIe port above it was suspended to D3hot
so that the link is down. Those are transient issues, the device isn't
removed in those cases.
IOW the hunk should look like this:
{
u32 v;
+ if (pdev->is_removed)
+ return false;
+
return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
}
And this should then probably be moved to patch [2/4].
Best regards,
Lukas
next prev parent reply other threads:[~2016-09-17 8:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 22:00 [PATCHv2 0/4] Limiting pci access requsets Keith Busch
2016-09-06 22:00 ` [PATCHv2 1/4] pci: Add is_removed state Keith Busch
2016-09-07 11:14 ` Lukas Wunner
2016-09-17 8:35 ` Lukas Wunner [this message]
2016-09-19 17:47 ` Keith Busch
2016-09-06 22:00 ` [PATCHv2 2/4] pci: No config access for removed devices Keith Busch
2016-09-07 12:03 ` kbuild test robot
2016-09-07 16:28 ` Keith Busch
2016-09-06 22:00 ` [PATCHv2 3/4] pcie/aer: Cache capability position Keith Busch
2016-09-07 11:30 ` Lukas Wunner
2016-09-13 22:07 ` Bjorn Helgaas
2016-09-06 22:00 ` [PATCHv2 4/4] pci/msix: Skip disabling removed devices Keith Busch
2016-09-07 13:28 ` [PATCHv2 0/4] Limiting pci access requsets Lukas Wunner
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=20160917083506.GA1235@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=jonathan.derrick@intel.com \
--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 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).