git: 2297a1633d86 - main - Add NO_LEGACY_PCIB kernel option to i386, amd64

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Tue, 18 Oct 2022 06:03:12 UTC
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=2297a1633d86fa098c4ed7b3e5ac5c7c708fbe8a

commit 2297a1633d86fa098c4ed7b3e5ac5c7c708fbe8a
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2022-07-13 00:44:47 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2022-10-18 06:02:22 +0000

    Add NO_LEGACY_PCIB kernel option to i386, amd64
    
    On systems without a PCI bus, legacy_pcib_identify by default creates
    one anyway:
        legacy_pcib_identify: no bridge found, adding pcib0 anyway
    
    This commit adds a kernel option NO_LEGACY_PCIB which disables this,
    allowing systems to be fully PCI-free.
    
    Reviewed by:    imp
    Sponsored by:   https://www.patreon.com/cperciva
    Differential Revision:  https://reviews.freebsd.org/D35798
---
 sys/conf/options.amd64 | 3 +++
 sys/conf/options.i386  | 3 +++
 sys/x86/pci/pci_bus.c  | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/sys/conf/options.amd64 b/sys/conf/options.amd64
index 8b98aa405953..66ccfb7bbddb 100644
--- a/sys/conf/options.amd64
+++ b/sys/conf/options.amd64
@@ -60,3 +60,6 @@ ISCI_LOGGING	opt_isci.h
 
 # EFI Runtime services support
 EFIRT			opt_efirt.h
+
+# Don't create a "legacy" PCI bridge if none is found.
+NO_LEGACY_PCIB		opt_cpu.h
diff --git a/sys/conf/options.i386 b/sys/conf/options.i386
index f65592653a82..03e88b985107 100644
--- a/sys/conf/options.i386
+++ b/sys/conf/options.i386
@@ -104,3 +104,6 @@ XENHVM			opt_global.h
 
 # options for the Intel C600 SAS driver (isci)
 ISCI_LOGGING	opt_isci.h
+
+# Don't create a "legacy" PCI bridge if none is found.
+NO_LEGACY_PCIB		opt_cpu.h
diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c
index f2a919989f02..51679675ffb6 100644
--- a/sys/x86/pci/pci_bus.c
+++ b/sys/x86/pci/pci_bus.c
@@ -488,11 +488,13 @@ legacy_pcib_identify(driver_t *driver, device_t parent)
 	 * Note that pci_cfgregopen() thinks we have PCI devices..
 	 */
 	if (!found) {
+#ifndef NO_LEGACY_PCIB
 		if (bootverbose)
 			printf(
 	"legacy_pcib_identify: no bridge found, adding pcib0 anyway\n");
 		child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
 		legacy_set_pcibus(child, 0);
+#endif
 	}
 }