linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Resend] PCI: Limit islolated function probing on bus 0 for LoongArch
@ 2025-10-14  7:41 Huacai Chen
  2025-10-14 21:10 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Huacai Chen @ 2025-10-14  7:41 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring
  Cc: linux-pci, Jianmin Lv, Xuefeng Li, Huacai Chen, Jiaxun Yang,
	Huacai Chen, stable

We found some discrete AMD graphics devices hide funtion 0 and the whole
is not supposed to be probed.

Since our original purpose is to allow integrated devices (on bus 0) to
be probed without function 0, we can limit the islolated function probing
only on bus 0.

Cc: stable@vger.kernel.org
Fixes: a02fd05661d73a8 ("PCI: Extend isolated function probing to LoongArch")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
Resend to correct the subject line.

 drivers/pci/probe.c        | 2 +-
 include/linux/hypervisor.h | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c83e75a0ec12..da6a2aef823a 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2883,7 +2883,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
 			 * a hypervisor that passes through individual PCI
 			 * functions.
 			 */
-			if (!hypervisor_isolated_pci_functions())
+			if (!hypervisor_isolated_pci_functions(bus->number))
 				break;
 		}
 		fn = next_fn(bus, dev, fn);
diff --git a/include/linux/hypervisor.h b/include/linux/hypervisor.h
index be5417303ecf..30ece04a16d9 100644
--- a/include/linux/hypervisor.h
+++ b/include/linux/hypervisor.h
@@ -32,13 +32,15 @@ static inline bool jailhouse_paravirt(void)
 
 #endif /* !CONFIG_X86 */
 
-static inline bool hypervisor_isolated_pci_functions(void)
+static inline bool hypervisor_isolated_pci_functions(int bus)
 {
 	if (IS_ENABLED(CONFIG_S390))
 		return true;
 
-	if (IS_ENABLED(CONFIG_LOONGARCH))
-		return true;
+	if (IS_ENABLED(CONFIG_LOONGARCH)) {
+		if (bus == 0)
+			return true;
+	}
 
 	return jailhouse_paravirt();
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH Resend] PCI: Limit islolated function probing on bus 0 for LoongArch
  2025-10-14  7:41 [PATCH Resend] PCI: Limit islolated function probing on bus 0 for LoongArch Huacai Chen
@ 2025-10-14 21:10 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2025-10-14 21:10 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Rob Herring, linux-pci, Jianmin Lv, Xuefeng Li, Huacai Chen,
	Jiaxun Yang, stable

On Tue, Oct 14, 2025 at 03:41:00PM +0800, Huacai Chen wrote:
> We found some discrete AMD graphics devices hide funtion 0 and the whole
> is not supposed to be probed.
> 
> Since our original purpose is to allow integrated devices (on bus 0) to
> be probed without function 0, we can limit the islolated function probing
> only on bus 0.

s/islolated/isolated/ (multiple)
s/funtion/function/

I suppose this fixes some problem where:

  - An AMD GPU is on some bus other than 00
  - The GPU has no function 0
  - Without function 0, we normally don't probe other functions
  - a02fd05661d7 means we *do* probe other functions on LoongArch
  - Therefore we find some non-0 function we're not supposed to find

If that's the case, what bad thing happens?  Is there some dmesg hint
we can include in the commit log?

I suppose this means such devices are potentially broken for s390 and
jailhouse as well?

> Cc: stable@vger.kernel.org
> Fixes: a02fd05661d73a8 ("PCI: Extend isolated function probing to LoongArch")

a02fd05661d7 (12-char SHA1 is conventional)

> -static inline bool hypervisor_isolated_pci_functions(void)
> +static inline bool hypervisor_isolated_pci_functions(int bus)
>  {
>  	if (IS_ENABLED(CONFIG_S390))
>  		return true;
>  
> -	if (IS_ENABLED(CONFIG_LOONGARCH))
> -		return true;
> +	if (IS_ENABLED(CONFIG_LOONGARCH)) {
> +		if (bus == 0)

I don't really like this embedded assumption that the root bus is bus
00.  That's not necessarily the case; we have many host bridges that
lead to a bus other than 00.

> +			return true;
> +	}
>  
>  	return jailhouse_paravirt();
>  }
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-14 21:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14  7:41 [PATCH Resend] PCI: Limit islolated function probing on bus 0 for LoongArch Huacai Chen
2025-10-14 21:10 ` Bjorn Helgaas

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).