From: Bjorn Helgaas <helgaas@kernel.org>
To: "Michał Winiarski" <michal.winiarski@intel.com>
Cc: linux-pci@vger.kernel.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Christian König" <christian.koenig@amd.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Michal Wajdeczko" <michal.wajdeczko@intel.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Matt Roper" <matthew.d.roper@intel.com>
Subject: Re: [PATCH v4 5/7] PCI/IOV: Check that VF BAR fits within the reservation
Date: Mon, 28 Oct 2024 11:56:04 -0500 [thread overview]
Message-ID: <20241028165604.GA1105091@bhelgaas> (raw)
In-Reply-To: <20241025215038.3125626-6-michal.winiarski@intel.com>
On Fri, Oct 25, 2024 at 11:50:36PM +0200, Michał Winiarski wrote:
> VF MMIO resource reservation, either created by system firmware and
> inherited by Linux PCI subsystem or created by the subsystem itself,
> should contain enough space to fit the BAR of all SR-IOV Virtual
> Functions that can potentially be created (total VFs supported by the
> device).
I don't think "VF resource reservation ... should contain enough
space" is really accurate or actionable. It would be *nice* if the PF
BAR is large enough to accommodate the largest supported VF BARs for
all possible VFs, but if it doesn't, it's not really an error. It's
just a reflection of the fact that resource space is limited.
> However, that assumption only holds in an environment where VF BAR size
> can't be modified.
There's no reason to assume anything about how many VF BARs fit. The
existing code should avoid enabling the requested nr_virtfn VFs if the
PF doesn't have enough space -- I think that's what the "if
(res->parent)" is supposed to be checking.
The fact that you need a change here makes me suspect that we're
missing some resource claim (and corresponding res->parent update)
elsewhere when resizing the VF BAR.
> Add an additional check that verifies that VF BAR for all enabled VFs
> fits within the underlying reservation resource.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
> drivers/pci/iov.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index 79143c1bc7bb4..5de828e5a26ea 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -645,10 +645,14 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
>
> nres = 0;
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> + int vf_bar_sz = pci_iov_resource_size(dev,
> + pci_resource_to_iov(i));
> bars |= (1 << pci_resource_to_iov(i));
> res = &dev->resource[pci_resource_to_iov(i)];
> - if (res->parent)
> - nres++;
> + if (!res->parent || vf_bar_sz * nr_virtfn > resource_size(res))
> + continue;
> +
> + nres++;
> }
> if (nres != iov->nres) {
> pci_err(dev, "not enough MMIO resources for SR-IOV\n");
> --
> 2.47.0
>
next prev parent reply other threads:[~2024-10-28 16:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 21:50 [PATCH v4 0/7] PCI: VF resizable BAR Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 1/7] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2024-10-29 13:01 ` Christian König
2024-10-25 21:50 ` [PATCH v4 2/7] PCI: Add a helper to identify IOV resources Michał Winiarski
2024-10-29 13:18 ` Christian König
2024-10-25 21:50 ` [PATCH v4 3/7] PCI: Add a helper to convert between standard and " Michał Winiarski
2024-10-29 13:20 ` Christian König
2024-11-06 14:22 ` Ilpo Järvinen
2024-11-12 14:40 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 4/7] PCI: Allow IOV resources to be resized in pci_resize_resource() Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 5/7] PCI/IOV: Check that VF BAR fits within the reservation Michał Winiarski
2024-10-28 11:20 ` Michał Winiarski
2024-10-28 16:56 ` Bjorn Helgaas [this message]
2024-10-30 11:43 ` Michał Winiarski
2024-10-30 16:55 ` Bjorn Helgaas
2024-11-12 14:31 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 6/7] PCI: Allow drivers to control VF BAR size Michał Winiarski
2024-10-28 16:50 ` Bjorn Helgaas
2024-11-12 14:55 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 7/7] drm/xe/pf: Set VF LMEM " Michał Winiarski
2024-10-25 23:16 ` ✓ CI.Patch_applied: success for PCI: VF resizable BAR (rev3) Patchwork
2024-10-25 23:16 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-25 23:17 ` ✓ CI.KUnit: success " Patchwork
2024-10-25 23:29 ` ✓ CI.Build: " Patchwork
2024-10-25 23:31 ` ✓ CI.Hooks: " Patchwork
2024-10-25 23:33 ` ✗ CI.checksparse: warning " Patchwork
2024-10-25 23:57 ` ✗ CI.BAT: failure " Patchwork
2024-10-27 15:13 ` ✗ CI.FULL: " Patchwork
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=20241028165604.GA1105091@bhelgaas \
--to=helgaas@kernel.org \
--cc=airlied@gmail.com \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=mripard@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
/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