From: Bjorn Helgaas <helgaas@kernel.org>
To: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
michal.winiarski@intel.com, djbw@kernel.org,
brett.creeley@amd.com, anthony.l.nguyen@intel.com,
przemyslaw.kitszel@intel.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, "Leon Romanovsky" <leon@kernel.org>,
"Alex Williamson" <alex@shazbot.org>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Vipin Sharma" <vipinsh@google.com>,
"David Matlack" <dmatlack@google.com>,
"Samiullah Khawaja" <skhawaja@google.com>
Subject: Re: [PATCH v2 04/13] PCI/IOV: Allow VF drivers to handle resets
Date: Tue, 27 Oct 2026 15:00:06 -0500 [thread overview]
Message-ID: <20261027200006.GA474913@bhelgaas> (raw)
In-Reply-To: <20261027160446.858300-5-lukasz.laguna@intel.com>
[+cc others interested in VF reset]
On Tue, Oct 27, 2026 at 05:04:37PM +0100, Lukasz Laguna wrote:
> From: Michał Winiarski <michal.winiarski@intel.com>
>
> While the kernel representation of VF device (think struct device) is
> preserved across PF FLR, and the PF IOV state (among other PCI CFG
> state) is saved and restored across reset, the actual VF state is lost,
> as from PCI perspective, VF didn't exist in the time between PF FLR and
> PF IOV state restore.
>
> Save / restore all subordinate VFs config state, and notify their
> drivers using .reset_prepare() / .reset_done() to make sure that both
> architected and unarchitected state can be preserved across FLR.
>
> VFs are disabled only after the PF driver's .reset_prepare() and their
> state is restored before PF driver's .reset_done(), so they can still
> communicate with the PF while it handles the reset.
>
> This also fixes VFs handling during bus and slot reset. Previously, VFs
> were handled like any other device found while walking bus->devices.
> Since that walk is top-down, the .reset_prepare() was triggered on PF
> before it was triggered on the VFs. Moreover, the walk recurses only
> through dev->subordinate, so it never reaches VFs on an SR-IOV virtual
> bus, as such a bus has no bridge. Those VFs were reset without being
> locked, without driver notification and without config space
> save/restore. Now, the bus walk skips VFs and they are locked, saved
> and restored together with their PF.
>
> As part of this, pci_reset_function_locked() now requires PF callers to
> hold the device locks for all enabled VFs as well.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Co-developed-by: Lukasz Laguna <lukasz.laguna@intel.com>
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
> @@ -5340,6 +5402,10 @@ void pci_init_reset_methods(struct pci_dev *dev)
> * from __pci_reset_function_locked() in that it saves and restores device state
> * over the reset and takes the PCI device lock.
> *
> + * If @dev is a PF with VFs enabled, the VFs are locked as well, their drivers
> + * are notified via reset_prepare() and reset_done(), and their state is saved
> + * and restored over the reset.
> + *
> * Returns 0 if the device function was successfully reset or negative if the
> * device doesn't support resetting a single function.
> */
> @@ -5360,11 +5426,13 @@ int pci_reset_function(struct pci_dev *dev)
> pci_dev_lock(bridge);
>
> pci_dev_lock(dev);
> + pci_dev_lock_vfs(dev);
> pci_dev_save_and_disable(dev);
>
> rc = __pci_reset_function_locked(dev);
Today we can call pci_reset_function() on a VF, can't we? I assume it
will do an FLR on just that VF? It looks like this expects to only be
called on a PF. Or maybe pci_dev_lock_vfs() is a no-op if called on a
VF, although that isn't obvious to me from the implementation?
> pci_dev_restore(dev);
> + pci_dev_unlock_vfs(dev);
> pci_dev_unlock(dev);
next prev parent reply other threads:[~2026-10-27 20:00 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 16:04 [PATCH v2 00/13] PCI/IOV: Improve reset handling with VFs enabled Lukasz Laguna
2026-10-27 16:04 ` [PATCH v2 01/13] PCI/IOV: Introduce pci_iov_get_virtfn() Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 02/13] PCI/IOV: Introduce VF iterators Lukasz Laguna
2026-10-27 16:21 ` sashiko-bot
2026-10-27 21:35 ` Bjorn Helgaas
2026-10-28 7:29 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 03/13] PCI/IOV: Introduce VF locking helpers Lukasz Laguna
2026-10-27 16:26 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 04/13] PCI/IOV: Allow VF drivers to handle resets Lukasz Laguna
2026-10-27 16:34 ` sashiko-bot
2026-10-27 16:51 ` Laguna, Lukasz
2026-10-28 8:52 ` Weili Qian
2026-10-28 14:05 ` Laguna, Lukasz
2026-10-27 20:00 ` Bjorn Helgaas [this message]
2026-10-28 6:39 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 05/13] ionic: Lock VFs around pci_reset_function_locked() Lukasz Laguna
2026-10-27 16:14 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 06/13] pds_core: " Lukasz Laguna
2026-10-27 16:12 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 07/13] i40e: Drop VF MSI state restore from PF reset_done Lukasz Laguna
2026-10-27 16:13 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 08/13] PCI/IOV: Allow bus reset_method for PF with VFs enabled Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 09/13] PCI/TSM: Use generic VF iterators Lukasz Laguna
2026-10-27 16:15 ` sashiko-bot
2026-10-27 20:08 ` Bjorn Helgaas
2026-10-28 7:25 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 10/13] ixgbe: Use generic VF iterator Lukasz Laguna
2026-10-27 16:17 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 11/13] ice: Use pci_iov_get_virtfn() Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 12/13] liquidio: " Lukasz Laguna
2026-10-27 16:19 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 13/13] drm/xe/pf: " Lukasz Laguna
2026-10-27 16:21 ` sashiko-bot
2026-10-27 19:49 ` [PATCH v2 00/13] PCI/IOV: Improve reset handling with VFs enabled Bjorn Helgaas
2026-10-28 7:03 ` Laguna, Lukasz
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=20261027200006.GA474913@bhelgaas \
--to=helgaas@kernel.org \
--cc=alex@shazbot.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=bhelgaas@google.com \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=djbw@kernel.org \
--cc=dmatlack@google.com \
--cc=edumazet@google.com \
--cc=jgg@ziepe.ca \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukasz.laguna@intel.com \
--cc=michal.winiarski@intel.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=skhawaja@google.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=vipinsh@google.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.