mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Michael Kelley <mhklinux@outlook.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 12/13] PCI: hv: Convert to pci_assign_unassigned_bus_resources()
Date: Fri, 20 Nov 2026 14:55:20 +0200 (EET)	[thread overview]
Message-ID: <a1520d14-ad7d-c9cf-5a7d-628d04ede311@linux.intel.com> (raw)
In-Reply-To: <MN2PR02MB68637F500EFB95B333A87429D47A2@MN2PR02MB6863.namprd02.prod.outlook.com>

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

On Wed, 18 Nov 2026, Michael Kelley wrote:

> From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Sent: Monday, November 16, 2026 7:24 AM
> > 
> > The pci-hyperv driver scans the bus and assigns resources using
> > pci_bus_assign_resources(). That function makes bridge window sizing
> > disjoint from the assignment phase and is going to be removed.
> > 
> > Convert pci_bus_assign_resources() to
> > pci_assign_unassigned_bus_resources(). If no other bridges are involved,
> > the extra sizing should be no-op.
> 
> I tested this series on an x86 VM in the Azure public cloud that has
> 5 NVMe devices and a Mellanox VF NIC. All 6 devices are PCI pass-thru
> devices in the VM that are initially set up using the pci-hyperv.c driver,
> so each device has its own root bus and bridge. No issues were seen in
> a basic smoke test.
> 
> I added some debug code to pci_assign_unassigned_bus_resources(),
> and indeed the "for_each_pci_bridge()" loop found nothing as each
> device was setup. So __pci_bus_assign_resources() was called with an
> empty add_list, and as expected, the new execution path is equivalent
> to the old pci_bus_assign_resources() call.
> 
> Question: Your cover letter says drivers that call pci_assign_resources()
> directly are not covered by this series. pci-hyperv.c *does* call
> pci_assign_resources() directly in hv_pci_allocate_bridge_windows().
> Is that a problem? I don't understand all the details of the PCI resource
> assignment well enough to judge for myself. :-(

There's a small name mixup here.

pci_assign_resources() is to graft a device's resource (or a window) into 
resource tree, whereas that calls pci_add_resource() adding windows to the 
root bus and that seems to occur before there is anything underneath. At 
this point, there's nothing to do for the resource fitting and assignment 
algorithm (it iterates the devices underneath).

...So I don't see a race here related to pci_assign_resources().

Most entrypoints of the fitting and assignment algorith input bus, and I 
don't think anything in kernel would as to assign resources underneath 
that root bus. Only pci_assign_unassigned_resources() looks for all root 
buses, and that is only called from arch init code so I don't think vfio 
setting up it host bridges matters with that call.

There seems to be, in general (not just hyperv), some races that are 
unrelated to resource setup in host bridge setup and scanning. I'll see 
what I can do but it'll be in a separate series and those seems to fall 
under can-shoot-oneself's-own-foot category.

Thanks for taking a look.

-- 
 i.

> In any case,
> 
> Tested-by: Michael Kelley <mhklinux@outlook.com>
> 
> And at least to some degree,
> 
> Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> 
> > 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/pci/controller/pci-hyperv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
> > index 824cf27e85e6..8eff3e9b325f 100644
> > --- a/drivers/pci/controller/pci-hyperv.c
> > +++ b/drivers/pci/controller/pci-hyperv.c
> > @@ -2549,7 +2549,7 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)
> > 
> >  	pci_lock_rescan_remove();
> >  	hv_pci_assign_numa_node(hbus);
> > -	pci_bus_assign_resources(bridge->bus);
> > +	pci_assign_unassigned_bus_resources(bridge->bus);
> >  	hv_pci_assign_slots(hbus);
> >  	pci_bus_add_devices(bridge->bus);
> >  	pci_unlock_rescan_remove();
> > --
> > 2.47.3
> > 
> 
> 

-- 
 i.

  reply	other threads:[~2026-11-20 12:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 15:23 [PATCH 00/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 01/13] PCI: Add pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-20 12:46   ` Rafael J. Wysocki (Intel)
2026-11-16 15:23 ` [PATCH 02/13] alpha/PCI: Convert to pci_bus_size_and_assign_resources() Ilpo Järvinen
2026-11-16 19:50   ` Magnus Lindholm
2026-11-16 20:15     ` Ilpo Järvinen
2026-11-16 22:11       ` Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 03/13] PCI: Use guard(&pci_bus_sem) in pci_do_resource_release_and_resize() Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 04/13] PCI: Hold pci_bus_sem across sizing and assignment entrypoints Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 05/13] PCI: Serialize bridge window sizing and resource assignment Ilpo Järvinen
2026-11-20 12:48   ` Rafael J. Wysocki (Intel)
2026-11-16 15:23 ` [PATCH 06/13] i82875p_edac: Convert to pci_assign_unassigned_bus_resources() Ilpo Järvinen
2026-11-16 15:40   ` Borislav Petkov
2026-11-16 17:11     ` Luck, Tony
2026-11-17 19:54       ` Borislav Petkov
2026-11-17 20:14         ` Luck, Tony
2026-11-18  0:46           ` Borislav Petkov
2026-11-18  6:19             ` Borislav Petkov
2026-11-16 15:23 ` [PATCH 07/13] platform/x86: asus-wmi: " Ilpo Järvinen
2026-11-17  2:43   ` Denis Benato
2026-11-16 15:23 ` [PATCH 08/13] platform/x86: eeepc-laptop: " Ilpo Järvinen
2026-11-17  2:52   ` Denis Benato
2026-11-16 15:23 ` [PATCH 09/13] parisc/PCI: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 10/13] PCI: hotplug: octep: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 11/13] PCI: ftpci100: " Ilpo Järvinen
2026-11-16 15:23 ` [PATCH 12/13] PCI: hv: " Ilpo Järvinen
2026-11-18 19:07   ` Michael Kelley
2026-11-20 12:55     ` Ilpo Järvinen [this message]
2026-11-16 15:23 ` [PATCH 13/13] PCI: Remove pci_bus_assign_resources() Ilpo Järvinen

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=a1520d14-ad7d-c9cf-5a7d-628d04ede311@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kw@linux.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=robh@kernel.org \
    --cc=wei.liu@kernel.org \
    /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

all inboxes | Powered by JetHome®