linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Wei Gong <gongwei833x@gmail.com>,
	linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v2] pci: fix device presence detection for VFs
Date: Wed, 9 Nov 2022 11:30:29 -0600	[thread overview]
Message-ID: <20221109173029.GA554381@bhelgaas> (raw)
In-Reply-To: <20221109020614-mutt-send-email-mst@kernel.org>

On Wed, Nov 09, 2022 at 02:10:30AM -0500, Michael S. Tsirkin wrote:
> On Tue, Nov 08, 2022 at 11:12:34PM -0600, Bjorn Helgaas wrote:
> > On Wed, Nov 09, 2022 at 04:36:17AM +0000, Wei Gong wrote:
> > > O Tue, Nov 08, 2022 at 01:02:35PM -0500, Michael S. Tsirkin wrote:
> > > > On Tue, Nov 08, 2022 at 11:58:53AM -0600, Bjorn Helgaas wrote:
> > > > > On Tue, Nov 08, 2022 at 10:19:07AM -0500, Michael S. Tsirkin wrote:
> > > > > > On Tue, Nov 08, 2022 at 09:02:28AM -0600, Bjorn Helgaas wrote:
> > > > > > > On Tue, Nov 08, 2022 at 08:53:00AM -0600, Bjorn Helgaas wrote:
> > > > > > > > On Wed, Oct 26, 2022 at 02:11:21AM -0400, Michael S. Tsirkin wrote:
> > > > > > > > > virtio uses the same driver for VFs and PFs.
> > > > > > > > > Accordingly, pci_device_is_present is used to detect
> > > > > > > > > device presence. This function isn't currently working
> > > > > > > > > properly for VFs since it attempts reading device and
> > > > > > > > > vendor ID.
> > > > > > > > 
> > > > > > > > > As VFs are present if and only if PF is present,
> > > > > > > > > just return the value for that device.
> > > > > > > > 
> > > > > > > > VFs are only present when the PF is present *and* the PF
> > > > > > > > has VF Enable set.  Do you care about the possibility that
> > > > > > > > VF Enable has been cleared?
> > > > > 
> > > > > I think you missed this question.
> > > > 
> > > > I was hoping Wei will answer that, I don't have the hardware.
> > > 
> > > In my case I don't care that VF Enable has been cleared.
> > 
> > OK, let me rephrase that :)
> > 
> > I think pci_device_is_present(VF) should return "false" if the PF is
> > present but VFs are disabled.
> > 
> > If you think it should return "true" when the PF is present and VFs
> > are disabled, we should explain why.
> > 
> > We would also need to fix the commit log, because "VFs are present if
> > and only if PF is present" is not actually true.  "VFs are present
> > only if PF is present" is true, but "VFs are present if PF is present"
> > is not.
> 
> Bjorn, I don't really understand the question.
> 
> How does one get a vf pointer without enabling sriov?
> They are only created by sriov_add_vfs after calling
> pcibios_sriov_enable.

Oh, I think I see where you're coming from.  The fact that we have a
VF pointer means VFs were enabled in the past, and as long as the PF
is still present, the VFs should still be enabled.

Since the continued existence of the VF device depends on VF Enable, I
guess my question is whether we need to worry about VF Enable being
cleared, e.g., via sysfs reset or a buggy PF driver.

Taking a step back, I don't understand the
"if (!pci_device_is_present()) virtio_break_device()" strategy because
checking for device presence is always unreliable.  I assume the
consumer of vq->broken, e.g., virtnet_send_command(), would see a
failed PCI read that probably returns ~0 data.  Could it not check for
that and then figure out whether that's valid data or an error
indication?

It looks like today, virtnet_send_command() might sit in that "while"
loop calling virtqueue_get_buf() repeatedly until virtio_pci_remove()
notices the device is gone and marks it broken.  Something must be
failing in virtqueue_get_buf() in that interval between the device
disappearing and virtio_pci_remove() noticing it.

Bjorn

  reply	other threads:[~2022-11-09 17:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26  6:11 [PATCH v2] pci: fix device presence detection for VFs Michael S. Tsirkin
2022-10-26 13:46 ` Wei Gong
2022-11-08  4:52 ` Wei Gong
2022-11-08  4:58   ` Michael S. Tsirkin
2022-11-08  5:06     ` Bjorn Helgaas
2022-11-10 19:35   ` Bjorn Helgaas
2022-11-10 20:15     ` Michael S. Tsirkin
2022-11-11 23:42       ` Bjorn Helgaas
2022-11-13  8:46         ` Michael S. Tsirkin
2022-11-15 16:24           ` Bjorn Helgaas
2022-11-16 11:16           ` Lukas Wunner
2022-11-17  5:36             ` Parav Pandit
2022-12-19  5:56               ` Michael S. Tsirkin
2022-12-19  8:22                 ` Lukas Wunner
2022-11-11  4:00     ` Wei Gong
2022-11-08 14:53 ` Bjorn Helgaas
2022-11-08 15:02   ` Bjorn Helgaas
2022-11-08 15:19     ` Michael S. Tsirkin
2022-11-08 17:58       ` Bjorn Helgaas
2022-11-08 18:02         ` Michael S. Tsirkin
2022-11-09  4:36           ` Wei Gong
2022-11-09  5:12             ` Bjorn Helgaas
2022-11-09  7:00               ` Wei Gong
2022-11-09  7:10               ` Michael S. Tsirkin
2022-11-09 17:30                 ` Bjorn Helgaas [this message]
2022-11-09 17:49                   ` Michael S. Tsirkin
2022-11-11 23:39 ` Bjorn Helgaas

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=20221109173029.GA554381@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gongwei833x@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mst@redhat.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).