From: Samiullah Khawaja <skhawaja@google.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Alex Williamson <alex.williamson@nvidia.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Nicolin Chen <nicolinc@nvidia.com>, kvm <kvm@vger.kernel.org>,
Alex Williamson <alex@shazbot.org>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-pci <linux-pci@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [RFC PATCH 1/5] PCI: Refuse function reset of an SR-IOV PF with enabled VFs
Date: Tue, 22 Sep 2026 01:47:28 +0000 [thread overview]
Message-ID: <arHP3Sj19YX-J-vx@google.com> (raw)
In-Reply-To: <CO1PR11MB4835146C50242D76568724DE8CAD2@CO1PR11MB4835.namprd11.prod.outlook.com>
On Thu, Aug 27, 2026 at 05:35:17AM +0000, Tian, Kevin wrote:
>> From: Alex Williamson <alex.williamson@nvidia.com>
>> Sent: Wednesday, August 19, 2026 4:39 AM
>>
>> On Tue, 18 Aug 2026 11:03:04 -0300
>> Jason Gunthorpe <jgg@ziepe.ca> wrote:
>>
>> > On Tue, Aug 18, 2026 at 07:07:20AM +0000, Tian, Kevin wrote:
>> > > 3) resetting a PF due to ad-hoc FW error
>> > >
>> > > e.g. pdsc_check_pci_health() calls pci_reset_function() when FW
>> > > reports broken PCI. Sounds a similar condition to AER.
>> > >
>> > > but as it calls pci_reset_function() this series causes a regression
>> > > in case of active VFs. Is it desired?
>> >
>> > mlx5 does something similar. RAS flows require detecting the PF has
>> > blown up and resetting it to bring it back.
>> >
>> > This has to work while VFs exist and bound to kernel drivers or vfio.
>> >
>> > In the VFIO KVM case I would expect the VM to experiance a RAS error
>> > on its vPCI device and trigger a VF flr
>>
>> This would need to be a device level RAS flow as we're sorely lacking
>> on forwarding reset notification to VF drivers or providing any
>> mechanism for recovery from the vfio error eventfd.
>>
>> > But we have to sort all this out through the hypervisor to not crash
>> > the machine or otherwise :)
>>
>> In general guarding the high level pci_reset_function() family on
>> (pci_num_vfs() == 0) seems to have more pros than cons and the
>> restriction matches the scoped intent of the interface.
>>
>> The low level __pci_reset_function_locked() interface remains
>> untouched, and as the prefix implies, relies on the caller to do
>> necessary verification and preparation. A "reset the PF regardless of
>> VFs" seems like an underscore prefix sort of operation. We'll need to
>> export the pci_dev_save_and_disable() and pci_dev_restore() functions
>> to provide handlers the full suite of tools they need to replace the
>> existing function and port those we find (maybe also questioning the
>> author's intent on VF reset and recovery).
>>
>> Of course making the guard parameterized with wrappers to expand this
>> family of calls is also an option,
>> pci_reset_function_locked_with_vfs()...
>
>+1 for wrappers. Maybe call it pci_force_reset_function_locked() which
>is slightly forward-looking if in future other conditions may reject the
>reset request using the base function.
>
>>
>> The mlx5 driver doesn't actually seem to be affected by these changes,
>> doing its own link toggle or a PCI bus reset, not a
>> pci_reset_function() call.
>>
>> On the other improvements, triggering a pci_reset_function_locked() on
>> unbind after SR-IOV is disabled, when needs_reset is indicated, looks
>> pretty trivial.
>>
>> The blocking domain operation looks like it might be simplest to
>> implement in the IOMMU core. We can set a flag for a default blocking
>> domain on the IOMMU group when we take_dma_ownership of the group.
>> Then
>> release_dma_ownership picks the blocking rather than default domain.
>
>IMHO we should change release_dma_ownership() to always picks the
>blocking. No new flag.
>
>this take/release interfaces are invented for drivers which manage dma
>on their own, so it sounds reasonable to not assume the operated device
>is in a good shape after the ownership is released.
>
>Then only a clean reset can unwind it.
>
>>
>> This is then unwound in use_default_domain, called via dma_configure,
>> attaching the device to the default domain in probe of the next driver.
>> Therefore until probe by another driver, a device used by vfio would
>> remain in a blocking domain even while unused and unbound.
>>
>
>so unwinding it blindly at dma_configure time is also problematic, as the
>device may still have a bad state to hurt the kernel.
>
>Instead use_default_domain should fail in such case (in blocked with
>owner_cnt being '0') then a reset is expected to unwind it (Nicolin's
>work will carry the resetting status to pci_dev_reset_iommu_done())
Thinking about this more, it might be tricky in multiple ways,
- This will only work if drivers do reset after dma ownership is
released. Looking at the code, vfio currently resets the device first
and then dma ownership is released.
- For some devices with no reset mechanism, vfio-pci uses bus or slot
resets. This will need extra care to propagate the
reset_iommu_prepare/reset_iommu_done to subordinate devices to bring
the device out of blocking domain.
- AFAIU looking at vfio-pci code, some devices do not have proper reset
mechanism, not even slot/bus, so those devices would be stuck in the
blocking domain state. Probably need a mechanism to let IOMMU know
that there is no reset mechanism?
Thanks,
Sami
next prev parent reply other threads:[~2026-09-22 1:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 4:53 [RFC PATCH 0/5] PCI/vfio-pci: Guard resets against active SR-IOV VFs Alex Williamson
2026-08-12 4:53 ` [RFC PATCH 1/5] PCI: Refuse function reset of an SR-IOV PF with enabled VFs Alex Williamson
2026-08-13 23:22 ` Samiullah Khawaja
2026-08-14 14:37 ` Alex Williamson
2026-08-14 15:54 ` Samiullah Khawaja
2026-08-17 12:18 ` Jason Gunthorpe
2026-08-18 7:07 ` Tian, Kevin
2026-08-18 14:03 ` Jason Gunthorpe
2026-08-18 20:39 ` Alex Williamson
2026-08-20 22:38 ` Samiullah Khawaja
2026-08-20 23:37 ` Jason Gunthorpe
2026-08-21 2:20 ` Samiullah Khawaja
2026-09-04 19:06 ` Jason Gunthorpe
2026-08-27 5:35 ` Tian, Kevin
2026-09-22 1:47 ` Samiullah Khawaja [this message]
2026-08-25 23:55 ` Samiullah Khawaja
2026-08-12 4:53 ` [RFC PATCH 2/5] PCI: Add pci_reset_bus_cond() for a caller-gated slot or bus reset Alex Williamson
2026-08-12 4:53 ` [RFC PATCH 3/5] vfio/pci: Refuse to reset an SR-IOV PF with enabled VFs Alex Williamson
2026-08-12 4:53 ` [RFC PATCH 4/5] PCI: Export pci_reset_supported() Alex Williamson
2026-08-12 4:53 ` [RFC PATCH 5/5] vfio/pci: Use pci_reset_supported() in place of reset_works Alex Williamson
2026-08-12 21:45 ` [RFC PATCH 0/5] PCI/vfio-pci: Guard resets against active SR-IOV VFs Bjorn Helgaas
2026-08-12 22:53 ` Alex Williamson
2026-08-17 20:23 ` Tony Nguyen
2026-08-13 22:30 ` Samiullah Khawaja
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=arHP3Sj19YX-J-vx@google.com \
--to=skhawaja@google.com \
--cc=alex.williamson@nvidia.com \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=nicolinc@nvidia.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
all inboxes | Powered by JetHome®