From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [PATCH] vfio/pci: Generate more relevant log messages for reset failures
Date: Wed, 5 Jan 2022 17:38:23 -0500 [thread overview]
Message-ID: <20220105173735-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220105151226.42cf6a06.alex.williamson@redhat.com>
On Wed, Jan 05, 2022 at 03:12:26PM -0700, Alex Williamson wrote:
> On Wed, 5 Jan 2022 16:05:45 -0500
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Wed, Jan 05, 2022 at 12:56:42PM -0700, Alex Williamson wrote:
> > > The VFIO_DEVICE_RESET ioctl might be backed by several different reset
> > > methods, including a device specific reset (ie. custom reset code in
> > > kernel), an ACPI reset (ie. custom reset code in firmware), FLR, PM,
> > > and bus resets. This listing is also the default priority order used
> > > by the kernel for trying reset methods. Traditionally we've had some
> > > FUD regarding the PM reset as the extent of a "Soft Reset" is not well
> > > defined in the PCI specification. Therefore we try to guess what type
> > > of reset a device might use for the VFIO_DEVICE_RESET and insert a bus
> > > reset via the vfio hot reset interface if we think it could be a PM
> > > reset.
> > >
> > > This results in a couple odd tests for PM reset in our hot reset code,
> > > as we assume if we don't detect has_pm_reset support that we can't
> > > reset the device otherwise. Starting with kernel v5.15, the kernel
> > > exposes a sysfs attribute for devices that can tell us the priority
> > > order for device resets, so long term (not implemented here) we no
> > > longer need to play this guessing game, and if permissions allow we
> > > could manipulate the order ourselves so that we don't need to inject
> > > our own hot reset.
> > >
> > > In the shorter term, implemented here, let's not assume we're out of
> > > reset methods if we can't perform a hot reset and the device doesn't
> > > support PM reset. We can use reset_works as the authority, which
> > > allows us to generate more comprehensible error messages for the case
> > > when it actually doesn't work.
> > >
> > > The impetus for this change is a result of commit d5daff7d3126 ("pcie:
> > > implement slot power control for pcie root ports"), where powering off
> > > a slot now results in a device reset. If the slot is powered off as a
> > > result of qdev_unplug() via the device request event, that device
> > > request is potentially the result of an unbind operation in the host.
> > > That unbind operation holds the kernel device lock, which causes the
> > > VFIO_DEVICE_RESET ioctl to fail (or in the case of some kernels, has
> > > cleared the flag indicating support of a device reset function). We
> > > can then end up with an SR-IOV VF device trying to trigger a hot reset,
> > > which finds that it needs ownership of the PF group to perform such a
> > > reset, resulting in confusing log messages.
> > >
> > > Ultimately the above commit still introduces a log message that we
> > > didn't have prior on such an unplug, but it's not unjustified to
> > > perform such a reset, though it might be considered unnecessary.
> > > Arguably failure to reset the device should always generate some sort
> > > of meaningful log message.
> > >
> > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> >
> > Looks reasonable. Just an extra idea: do we want to maybe validate the
> > return code from the ioctl? I assume it's something like EBUSY right?
>
> Ideally it'd be EAGAIN to denote the lock contention,
Or EBUSY?
> but for some
> reason there was a recent time when the kernel would clear the
> pci_dev.reset_fn flag as part of pci_stop_dev() before unbinding the
> driver from the device, in that case we get an ENOTTY.
>
> Hmm, I'm remembering now that an issue with this approach to log all
> device reset failures is that we're going to get false positives every
> time we reboot a VM where we need a bus reset for multiple devices. We
> handle multiple devices via a reset handler but we'll still get a
> redundant per device reset and we have no way to associate that per
> device reset to a VM reset where the reset handler multi-device
> mechanism may have been successful :-\ This would be very common with
> desktop GPUs. I'll plug away at this some more. Thanks,
>
> Alex
next prev parent reply other threads:[~2022-01-05 22:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 19:56 [PATCH] vfio/pci: Generate more relevant log messages for reset failures Alex Williamson
2022-01-05 21:05 ` Michael S. Tsirkin
2022-01-05 22:12 ` Alex Williamson
2022-01-05 22:38 ` Michael S. Tsirkin [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-01-05 19:56 Alex Williamson
2022-01-05 20:05 ` Alex Williamson
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=20220105173735-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).