git: 9c699850011b - stable/14 - pci_host_generic: Include the bridge's device name in rman descriptions

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 08 Apr 2024 19:04:31 UTC
The branch stable/14 has been updated by jhb:

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

commit 9c699850011b216ed98cd0de866739e834f083d6
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-02-14 22:07:32 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-04-08 17:54:50 +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
    
    (cherry picked from commit 51f8ac224f3b87555ea17c7e7c4015a2a2b8b191)
---
 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 90361a7258ed..082d083fc681 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);