git: b28670018dbc - main - pci_host_generic: Enumerate resource ranges under bootverbose

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 01 Mar 2024 22:20:30 UTC
The branch main has been updated by jhb:

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

commit b28670018dbcc7d6ebc0d05584189d6d04aa079f
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-01 22:20:10 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-03-01 22:20:10 +0000

    pci_host_generic: Enumerate resource ranges under bootverbose
    
    Previously ranges were only enumerated for the FDT attachment but not
    ACPI.  This commit moves the enumeration to the shared attach routine
    so it is done for both.  While here, don't list empty ranges but do
    include the resource type for each range.
    
    Reviewed by:    andrew
    Differential Revision:  https://reviews.freebsd.org/D44132
---
 sys/dev/pci/pci_host_generic.c     |  8 ++++++++
 sys/dev/pci/pci_host_generic_fdt.c | 11 -----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 520462972a66..67b329b58685 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -83,6 +83,7 @@ pci_host_generic_core_attach(device_t dev)
 	uint64_t phys_base;
 	uint64_t pci_base;
 	uint64_t size;
+	const char *range_descr;
 	char buf[64];
 	int domain, error;
 	int flags, rid, tuple, type;
@@ -179,18 +180,21 @@ pci_host_generic_core_attach(device_t dev)
 		switch (FLAG_TYPE(sc->ranges[tuple].flags)) {
 		case FLAG_TYPE_PMEM:
 			sc->has_pmem = true;
+			range_descr = "prefetch";
 			flags = RF_PREFETCHABLE;
 			type = SYS_RES_MEMORY;
 			error = rman_manage_region(&sc->pmem_rman,
 			   pci_base, pci_base + size - 1);
 			break;
 		case FLAG_TYPE_MEM:
+			range_descr = "memory";
 			flags = 0;
 			type = SYS_RES_MEMORY;
 			error = rman_manage_region(&sc->mem_rman,
 			   pci_base, pci_base + size - 1);
 			break;
 		case FLAG_TYPE_IO:
+			range_descr = "I/O port";
 			flags = 0;
 			type = SYS_RES_IOPORT;
 			error = rman_manage_region(&sc->io_rman,
@@ -219,6 +223,10 @@ pci_host_generic_core_attach(device_t dev)
 			error = ENXIO;
 			goto err_rman_manage;
 		}
+		if (bootverbose)
+			device_printf(dev,
+			    "PCI addr: 0x%jx, CPU addr: 0x%jx, Size: 0x%jx, Type: %s\n",
+			    pci_base, phys_base, size, range_descr);
 	}
 
 	return (0);
diff --git a/sys/dev/pci/pci_host_generic_fdt.c b/sys/dev/pci/pci_host_generic_fdt.c
index bcee6057ff3c..854ec0be8dfa 100644
--- a/sys/dev/pci/pci_host_generic_fdt.c
+++ b/sys/dev/pci/pci_host_generic_fdt.c
@@ -183,7 +183,6 @@ parse_pci_mem_ranges(device_t dev, struct generic_pcie_core_softc *sc)
 	int nbase_ranges;
 	phandle_t node;
 	int i, j, k;
-	int tuple;
 
 	node = ofw_bus_get_node(dev);
 
@@ -239,16 +238,6 @@ parse_pci_mem_ranges(device_t dev, struct generic_pcie_core_softc *sc)
 		sc->ranges[i].size = 0;
 	}
 
-	if (bootverbose) {
-		for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) {
-			device_printf(dev,
-			    "\tPCI addr: 0x%jx, CPU addr: 0x%jx, Size: 0x%jx\n",
-			    sc->ranges[tuple].pci_base,
-			    sc->ranges[tuple].phys_base,
-			    sc->ranges[tuple].size);
-		}
-	}
-
 	free(base_ranges, M_DEVBUF);
 	return (0);
 }