Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Michal Wajdeczko" <michal.wajdeczko@intel.com>,
	"Michał Winiarski" <michal.winiarski@intel.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: [PATCH v2 3/3] PCI/IOV: Restore initial VF ReBAR sizes on PF driver remove
Date: Mon,  3 Aug 2026 12:30:07 +0200	[thread overview]
Message-ID: <20260803103007.209625-4-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20260803103007.209625-1-marcin.bernatowicz@linux.intel.com>

sriov_disable() and sriov_enable() error paths restore the per-VF BAR
sizes saved at probe time. They do not cover the case where the PF
driver is detached while VF BARs were resized but SR-IOV was never
enabled (or was already disabled).

Restore the initial sizes from pci_iov_remove() as well. That hook runs
on driver detach while the device is still live, unlike sriov_release()
which runs later from the pci_dev release path.

Skip the restore when the PF driver leaves SR-IOV enabled; in that case
VF memory decoding is still active and pci_iov_vf_bar_set_size() cannot
safely change the VF BAR size.

Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
 drivers/pci/iov.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 999938163ce9..3739825c84e9 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -1085,8 +1085,12 @@ void pci_iov_remove(struct pci_dev *dev)
 		return;
 
 	iov->driver_max_VFs = iov->total_VFs;
-	if (iov->num_VFs)
+	if (iov->num_VFs) {
 		pci_warn(dev, "driver left SR-IOV enabled after remove\n");
+		return;
+	}
+
+	sriov_restore_vf_rebar_initial_sizes(dev);
 }
 
 /**
-- 
2.43.0


  parent reply	other threads:[~2026-08-03 10:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05 17:00 [PATCH 0/3] PCI/IOV: Restore initial VF BAR sizing after VF ReBAR Marcin Bernatowicz
2026-05-05 17:00 ` [PATCH 1/3] PCI/IOV: Remember initial VF BAR sizes Marcin Bernatowicz
2026-05-05 17:00 ` [PATCH 2/3] PCI/IOV: Restore initial VF ReBAR sizes on SR-IOV disable/failure Marcin Bernatowicz
2026-05-05 20:36   ` sashiko-bot
2026-05-05 17:00 ` [PATCH 3/3] PCI/IOV: Restore initial VF ReBAR sizes on PF release Marcin Bernatowicz
2026-05-05 21:17   ` sashiko-bot
2026-08-03 10:30 ` [PATCH v2 0/3] PCI/IOV: Restore initial VF BAR sizing after VF ReBAR Marcin Bernatowicz
2026-08-03 10:30   ` [PATCH v2 1/3] PCI/IOV: Remember initial VF BAR sizes Marcin Bernatowicz
2026-08-03 10:41     ` sashiko-bot
2026-08-03 10:30   ` [PATCH v2 2/3] PCI/IOV: Restore initial VF ReBAR sizes on SR-IOV disable/failure Marcin Bernatowicz
2026-08-03 10:46     ` sashiko-bot
2026-08-03 10:30   ` Marcin Bernatowicz [this message]
2026-08-03 10:41     ` [PATCH v2 3/3] PCI/IOV: Restore initial VF ReBAR sizes on PF driver remove sashiko-bot
2026-08-03 11:17   ` [PATCH v2 0/3] PCI/IOV: Restore initial VF BAR sizing after VF ReBAR Simon Richter

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=20260803103007.209625-4-marcin.bernatowicz@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=michal.wajdeczko@intel.com \
    --cc=michal.winiarski@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=thomas.hellstrom@linux.intel.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