From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Michał Winiarski" <michal.winiarski@intel.com>
Cc: linux-pci@vger.kernel.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
LKML <linux-kernel@vger.kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Christian König" <christian.koenig@amd.com>,
"Krzysztof Wilczyński" <kw@linux.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 v7 4/6] PCI/IOV: Check that VF BAR fits within the reservation
Date: Thu, 3 Apr 2025 12:54:47 +0300 (EEST) [thread overview]
Message-ID: <308209c2-508e-19d1-a5aa-9c8a8af68b23@linux.intel.com> (raw)
In-Reply-To: <20250402141122.2818478-5-michal.winiarski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]
On Wed, 2 Apr 2025, Michał Winiarski wrote:
> When the resource representing VF MMIO BAR reservation is created, its
> size is always large enough to accommodate the BAR of all SR-IOV Virtual
> Functions that can potentially be created (total VFs). If for whatever
> reason it's not possible to accommodate all VFs - the resource is not
> assigned and no VFs can be created.
>
> An upcoming change will allow VF BAR size to be modified by drivers at
> a later point in time, which means that the check for resource
> assignment is no longer sufficient.
>
> 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 | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> index fee99e15a943f..2fafbd6a998f0 100644
> --- a/drivers/pci/iov.c
> +++ b/drivers/pci/iov.c
> @@ -668,9 +668,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> nres = 0;
> for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> int idx = pci_resource_num_from_vf_bar(i);
> + resource_size_t vf_bar_sz = pci_iov_resource_size(dev, idx);
>
> bars |= (1 << idx);
> res = &dev->resource[idx];
> + if (vf_bar_sz * nr_virtfn > resource_size(res))
> + continue;
> if (res->parent)
> nres++;
> }
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2025-04-03 9:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 14:11 [PATCH v7 0/6] PCI: VF resizable BAR Michał Winiarski
2025-04-02 14:11 ` [PATCH v7 1/6] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2025-04-02 14:11 ` [PATCH v7 2/6] PCI: Add a helper to convert between VF BAR number and IOV resource Michał Winiarski
2025-04-03 9:24 ` Ilpo Järvinen
2025-04-02 14:11 ` [PATCH v7 3/6] PCI: Allow IOV resources to be resized in pci_resize_resource() Michał Winiarski
2025-04-03 9:45 ` Ilpo Järvinen
2025-04-02 14:11 ` [PATCH v7 4/6] PCI/IOV: Check that VF BAR fits within the reservation Michał Winiarski
2025-04-03 9:54 ` Ilpo Järvinen [this message]
2025-04-02 14:11 ` [PATCH v7 5/6] PCI: Allow drivers to control VF BAR size Michał Winiarski
2025-04-03 10:20 ` Ilpo Järvinen
2025-05-26 21:54 ` Michał Winiarski
2025-04-02 14:11 ` [PATCH v7 6/6] drm/xe/pf: Set VF LMEM " Michał Winiarski
2025-04-02 14:18 ` ✗ CI.Patch_applied: failure for PCI: VF resizable BAR (rev6) Patchwork
2025-04-03 8:23 ` 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=308209c2-508e-19d1-a5aa-9c8a8af68b23@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=airlied@gmail.com \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--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 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.