public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 v6 4/6] PCI/IOV: Check that VF BAR fits within the reservation
Date: Fri, 28 Mar 2025 18:39:29 +0200 (EET)	[thread overview]
Message-ID: <77a5558f-fe6f-cba1-4515-c8597ae3c9bb@linux.intel.com> (raw)
In-Reply-To: <4959d675-edd8-a296-661c-6a7bd22fbc0d@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3246 bytes --]

On Wed, 26 Mar 2025, Ilpo Järvinen wrote:

> On Thu, 20 Mar 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.
> > 
> > The following patch will allow VF BAR size to be modified by drivers at
> 
> "The following patch" sounds to be like you're referring to patch that 
> follows this description, ie., the patch below. "An upcoming change" is 
> alternative that doesn't suffer from the same problem.
> 
> > 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.
> 
> So this does not solve the case where the initial size was too large to 
> fix and such VF BARs remain unassigned, right?
> 
> > Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> > ---
> >  drivers/pci/iov.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index cbf335725d4fb..861273ad9a580 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -646,8 +646,13 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
> >  
> >  	nres = 0;
> >  	for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
> > +		resource_size_t vf_bar_sz =
> > +			pci_iov_resource_size(dev,
> > +					      pci_resource_num_from_vf_bar(i));
> 
> Please add int idx = pci_resource_num_from_vf_bar(i);
> 
> >  		bars |= (1 << pci_resource_num_from_vf_bar(i));
> >  		res = &dev->resource[pci_resource_num_from_vf_bar(i)];
> > +		if (vf_bar_sz * nr_virtfn > resource_size(res))
> > +			continue;
> 
> Not directly related to this patch, I suspect this could actually try to 
> assign an unassigned resource by doing something like this (perhaps in own 
> patch, it doesn't even need to be part of this series but can be sent 
> later if you find the suggestion useful):
> 
> 		/* Retry assignment if the initial size didn't fit */
> 		if (!res->parent && pci_assign_resource(res, idx))
> 			continue;
> 
> Although I suspect reset_resource() might have been called for the 
> resource and IIRC it breaks the resource somehow but it could have been 
> that IOV resources can be resummoned from that state though thanks to 
> their size not being stored into the resource itself but comes from iov 
> structures.

I realized reset_resource() will zero the flags so it won't work without 
getting rid of reset_resource() calls first which I've not yet completed. 

And once I get the rebar sizes included into bridge window sizing 
algorithm, the default size could possibly be shrunk by the resource
fitting/assignment code so the resource assignment should no longer fail 
just because the initial size was too large. So it shouldn't be necessary 
after that.

> >  		if (res->parent)
> >  			nres++;
> >  	}
> > 
> 
> 

-- 
 i.

  reply	other threads:[~2025-03-28 16:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 11:08 [PATCH v6 0/6] PCI: VF resizable BAR Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 1/6] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2025-03-26 14:42   ` Ilpo Järvinen
2025-03-26 14:52     ` Ilpo Järvinen
2025-04-02 10:20       ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 2/6] PCI: Add a helper to convert between VF BAR number and IOV resource Michał Winiarski
2025-03-26 14:46   ` Ilpo Järvinen
2025-04-02 10:23     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 3/6] PCI: Allow IOV resources to be resized in pci_resize_resource() Michał Winiarski
2025-03-26 14:58   ` Ilpo Järvinen
2025-04-02 10:25     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 4/6] PCI/IOV: Check that VF BAR fits within the reservation Michał Winiarski
2025-03-26 15:11   ` Ilpo Järvinen
2025-03-28 16:39     ` Ilpo Järvinen [this message]
2025-04-02 10:33       ` Michał Winiarski
2025-04-02 10:31     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 5/6] PCI: Allow drivers to control VF BAR size Michał Winiarski
2025-03-26 15:22   ` Ilpo Järvinen
2025-04-02 10:43     ` Michał Winiarski
2025-04-02 12:04       ` Ilpo Järvinen
2025-03-20 11:08 ` [PATCH v6 6/6] drm/xe/pf: Set VF LMEM " Michał Winiarski
2025-03-26 15:29   ` Ilpo Järvinen
2025-04-02 10:44     ` Michał Winiarski

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=77a5558f-fe6f-cba1-4515-c8597ae3c9bb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox