linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Huacai Chen <chenhuacai@kernel.org>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-pci <linux-pci@vger.kernel.org>,
	jailhouse-dev@googlegroups.com,
	linux-s390 <linux-s390@vger.kernel.org>,
	loongarch@lists.linux.dev, Farhan Ali <alifm@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Tianrui Zhao <zhaotianrui@loongson.cn>,
	Gerd Bayer <gbayer@linux.ibm.com>
Subject: Potential issue with hypervisor_isolated_pci_functions() handling
Date: Wed, 22 Oct 2025 13:39:54 +0200	[thread overview]
Message-ID: <d3f11e8562f589ddb2c1c83e74161bd8948084c3.camel@linux.ibm.com> (raw)

Hi Huacai, Hi Jan, Hi Bjorn,

I noticed that with commit a02fd05661d7 ("PCI: Extend isolated function
probing to LoongArch") LoongArch now also makes use of the isolated
function probing. First, nice to see this sees more users and that the
interface is useful to you. 

Seeing this, I was reminded of an issue I ran into when using this
mechanism with SR-IOV capable devices. In that case VFs with devfn > 7
and PCI_SLOT(devfn) != 0 wouldn't get probed.
This is because if a device is found next_fn() will check whether dev-
>multifunction is set. So if for example devfn == 8 is found (fn == 0)
dev->multifunction won't be set in pci_scan_slot() and for VFs it's
also not set via PCI_HEADER_TYPE_MFD. So we won't check for devfn == 9
even though that could very well be there.

Now for s390 this currently doesn't cause issues because for all
multifunction devices we have, we either get a VF alone and then since
commit 25f39d3dcb48 ("s390/pci: Ignore RID for isolated VFs") use devfn
== 0, or we have the parent PF passed-through and then VFs always get
hot plugged after SR-IOV enable, which then uses
pci_scan_single_device(). And for non VFs we always have devfn == 0
and/or devfn == 1 and multifunction via the header. So in a sense the
above commit works around the issue, though that wasn't its primary
intention.

Did either of you also run into this issue or can reproduce it?

Somewhat related, if ARI is enabled this would also break the isolated
function case including on s390 where ARI is used by the platform
firmware, but detected as off by Linux because there is no struct
pci_dev associated with the PCI bus. If I patch Linux to correctly
detect ARI, it no longer finds an isolated PF with devfn == 1.

Thanks,
Niklas Schnelle

             reply	other threads:[~2025-10-22 11:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 11:39 Niklas Schnelle [this message]
2025-10-22 14:49 ` Potential issue with hypervisor_isolated_pci_functions() handling Huacai Chen
2025-10-22 17:33   ` Niklas Schnelle
2025-10-23 15:25   ` Niklas Schnelle
2025-10-24 10:05     ` Huacai Chen
2025-10-24 10:27       ` Niklas Schnelle

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=d3f11e8562f589ddb2c1c83e74161bd8948084c3.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=alifm@linux.ibm.com \
    --cc=chenhuacai@kernel.org \
    --cc=gbayer@linux.ibm.com \
    --cc=helgaas@kernel.org \
    --cc=jailhouse-dev@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mjrosato@linux.ibm.com \
    --cc=zhaotianrui@loongson.cn \
    /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;
as well as URLs for NNTP newsgroup(s).