All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Niklas Schnelle" <schnelle@linux.ibm.com>
Cc: linux-s390 <linux-s390@vger.kernel.org>,
	linux-pci@vger.kernel.org, virtualization@lists.linux.dev,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v6 3/4] PCI: Fix isolated PCI function probing with ARI and SR-IOV
Date: Fri, 04 Dec 2026 15:02:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-250050@kernel.org> (raw)
In-Reply-To: <20261204-ari_no_bus_dev-v6-3-855e75237600@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] pci: next_fn() skips ARI functions 8..255 on downstream ports
- [Medium] PCI: unconditional hypervisor_isolated_pci_functions() adds
  scan overhead
--

commit ae63abdc9ce8242a0676132ebc8d8a1f2843aa23
Author: Niklas Schnelle <schnelle@linux.ibm.com>

PCI: Fix isolated PCI function probing with ARI and SR-IOV

This commit updates pci_scan_slot() and next_fn() to probe all functions
sequentially when hypervisor_isolated_pci_functions() is true, bypassing
the ARI next-function chain and multifunction checks.

Link: https://lore.kernel.org/linux-pci/d3f11e8562f589ddb2c1c83e74161bd8948084c3.camel@linux.ibm.com/

> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index bbce3756f8f8a..404dce0a4f80f 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2825,16 +2825,19 @@ static int next_ari_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
>  	return next_fn;
>  }
>  
> -static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
> +static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn,
> +		   bool probe_all_fns)
>  {
> -	if (pci_ari_enabled(bus))
> -		return next_ari_fn(bus, dev, fn);
> +	if (!probe_all_fns) {
> +		if (pci_ari_enabled(bus))
> +			return next_ari_fn(bus, dev, fn);
>  
> +		/* only multifunction devices may have more functions */
> +		if (dev && !dev->multifunction)
> +			return -ENODEV;
> +	}
>  	if (fn >= 7)
>  		return -ENODEV;
> -	/* only multifunction devices may have more functions */
> -	if (dev && !dev->multifunction)
> -		return -ENODEV;
>  
>  	return fn + 1;
>  }

[Severity: High]
Does capping fn at 7 when probe_all_fns is true break enumeration of ARI
functions 8..255 behind a PCIe Downstream Port?

For a PCIe Downstream Port, only_one_child(bus) returns 1 unless
PCI_SCAN_ALL_PCIE_DEVS is set.  During bus enumeration, devfn 0 now stops
at fn 7 and pci_scan_slot() immediately returns 0 for devfn 8..248,
assuming devfn 0 already scanned all 256 ARI functions.

Similarly, pciehp_configure_device() only calls
pci_scan_slot(parent, PCI_DEVFN(0, 0)) once.  This is a regression for
intact ARI chains when hypervisor_isolated_pci_functions() is true, and it
leaves isolated ARI or SR-IOV functions at devfn >= 8 undiscovered.

When function 0 is missing behind a Downstream Port, pci_configure_ari()
also skips setting ari_enabled while only_one_child(bus) still skips
devfn > 0.

[ ... ]

> @@ -2887,11 +2888,12 @@ static bool pci_stop_at_missing_fn0(struct pci_bus *bus)
>  int pci_scan_slot(struct pci_bus *bus, int devfn)
>  {
>  	struct pci_dev *dev;
> +	bool probe_all_fns;
>  	int fn = 0, nr = 0;
>  
>  	if (only_one_child(bus) && (devfn > 0))
>  		return 0; /* Already scanned the entire slot */
> -
> +	probe_all_fns = hypervisor_isolated_pci_functions();

[Severity: Medium]
Can calling hypervisor_isolated_pci_functions() unconditionally here add
noticeable scan and hotplug overhead on non-s390 platforms?

Previously it only ran when function 0 was missing, so populated PCI
slots, PCIe Downstream Ports, and pciehp_configure_device() skipped it.
Now every call invokes jailhouse_paravirt(), which is uncached.

On non-x86 CONFIG_OF systems, jailhouse_paravirt() calls
of_find_compatible_node(), taking devtree_lock with IRQs disabled to walk
the full device tree and causing IRQ latency spikes during hotplug.

On x86 guests with CONFIG_JAILHOUSE_GUEST under other hypervisors such as
KVM, jailhouse_paravirt() executes 256 CPUID VM-exits per call.  Caching
the result at boot would avoid this overhead.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-ari_no_bus_dev-v6-0-855e75237600@linux.ibm.com?part=3

  reply	other threads:[~2026-12-04 15:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 14:14 [PATCH v6 0/4] PCI: Fix isolated function probing and enable ARI for s390 Niklas Schnelle
2026-12-04 14:14 ` [PATCH v6 1/4] jailhouse: Fix leak of device node in jailhouse_paravirt() on non-x86 Niklas Schnelle
2026-12-04 14:14 ` [PATCH v6 2/4] PCI: loongson: Handle missing function 0 explicitly not via isolated functions Niklas Schnelle
2026-12-04 14:45   ` sashiko-bot
2026-12-04 14:14 ` [PATCH v6 3/4] PCI: Fix isolated PCI function probing with ARI and SR-IOV Niklas Schnelle
2026-12-04 15:02   ` sashiko-bot [this message]
2026-12-04 14:14 ` [PATCH v6 4/4] PCI: s390: Handle ARI on bus without associated struct pci_dev Niklas Schnelle
2026-12-04 15:25   ` sashiko-bot
2026-12-04 15:25 ` [PATCH v6 0/4] PCI: Fix isolated function probing and enable ARI for s390 sashiko-bot
2026-12-05 17:32   ` Bjorn Helgaas

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=sashiko-outbox-250050@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=eperezma@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=schnelle@linux.ibm.com \
    --cc=virtualization@lists.linux.dev \
    /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.