git: 51f8ac224f3b - main - pci_host_generic: Include the bridge's device name in rman descriptions

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 14 Feb 2024 22:52:41 UTC
The branch main has been updated by jhb:

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

commit 51f8ac224f3b87555ea17c7e7c4015a2a2b8b191
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-02-14 22:07:32 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-02-14 22:07:32 +0000

    pci_host_generic: Include the bridge's device name in rman descriptions
    
    The rman description strings now match those used in the PCI-PCI
    bridge driver.  Using more specific names removes ambiguity in devinfo -u
    output on systems with multiple host to PCI bridges.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D43890
---
 sys/dev/pci/pci_host_generic.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 43b6d26e9217..02ca010a14d7 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;
+	char buf[64];
 	int domain, error;
 	int rid, tuple;
 
@@ -135,13 +136,19 @@ pci_host_generic_core_attach(device_t dev)
 
 	sc->has_pmem = false;
 	sc->pmem_rman.rm_type = RMAN_ARRAY;
-	sc->pmem_rman.rm_descr = "PCIe Prefetch Memory";
+	snprintf(buf, sizeof(buf), "%s prefetch window",
+	    device_get_nameunit(dev));
+	sc->pmem_rman.rm_descr = strdup(buf, M_DEVBUF);
 
 	sc->mem_rman.rm_type = RMAN_ARRAY;
-	sc->mem_rman.rm_descr = "PCIe Memory";
+	snprintf(buf, sizeof(buf), "%s memory window",
+	    device_get_nameunit(dev));
+	sc->mem_rman.rm_descr = strdup(buf, M_DEVBUF);
 
 	sc->io_rman.rm_type = RMAN_ARRAY;
-	sc->io_rman.rm_descr = "PCIe IO window";
+	snprintf(buf, sizeof(buf), "%s I/O port window",
+	    device_get_nameunit(dev));
+	sc->io_rman.rm_descr = strdup(buf, M_DEVBUF);
 
 	/* Initialize rman and allocate memory regions */
 	error = rman_init(&sc->pmem_rman);
@@ -201,6 +208,9 @@ err_io_rman:
 err_mem_rman:
 	rman_fini(&sc->pmem_rman);
 err_pmem_rman:
+	free(__DECONST(char *, sc->io_rman.rm_descr), M_DEVBUF);
+	free(__DECONST(char *, sc->mem_rman.rm_descr), M_DEVBUF);
+	free(__DECONST(char *, sc->pmem_rman.rm_descr), M_DEVBUF);
 	if (sc->res != NULL)
 		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
 err_resource:
@@ -223,6 +233,9 @@ pci_host_generic_core_detach(device_t dev)
 	rman_fini(&sc->io_rman);
 	rman_fini(&sc->mem_rman);
 	rman_fini(&sc->pmem_rman);
+	free(__DECONST(char *, sc->io_rman.rm_descr), M_DEVBUF);
+	free(__DECONST(char *, sc->mem_rman.rm_descr), M_DEVBUF);
+	free(__DECONST(char *, sc->pmem_rman.rm_descr), M_DEVBUF);
 	if (sc->res != NULL)
 		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->res);
 	bus_dma_tag_destroy(sc->dmat);