git: 1b9bcffff39a - main - sys: Set the type of allocated bus resources

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 13 Mar 2024 22:13:34 UTC
The branch main has been updated by jhb:

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

commit 1b9bcffff39a817b77401d1b975f374781adfaf8
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-13 22:05:53 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-03-13 22:05:53 +0000

    sys: Set the type of allocated bus resources
    
    Use rman_set_type to set the type of allocated resources everywhere
    rman_set_rid is currently called.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D44123
---
 sys/dev/bhnd/bhndb/bhndb.c | 1 +
 sys/dev/dpaa/fman.c        | 1 +
 sys/dev/pci/pci_iov.c      | 1 +
 sys/dev/pci/pci_pci.c      | 2 ++
 sys/dev/pci/pci_subr.c     | 1 +
 sys/kern/subr_bus.c        | 1 +
 6 files changed, 7 insertions(+)

diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c
index 4e631f85b3b6..978ad9c3e62b 100644
--- a/sys/dev/bhnd/bhndb/bhndb.c
+++ b/sys/dev/bhnd/bhndb/bhndb.c
@@ -1005,6 +1005,7 @@ bhndb_alloc_resource(device_t dev, device_t child, int type,
 		return (NULL);
 
 	rman_set_rid(rv, *rid);
+	rman_set_type(rv, type);
 
 	/* Activate */
 	if (flags & RF_ACTIVE) {
diff --git a/sys/dev/dpaa/fman.c b/sys/dev/dpaa/fman.c
index 6f3e85636e95..7c8122a03ce7 100644
--- a/sys/dev/dpaa/fman.c
+++ b/sys/dev/dpaa/fman.c
@@ -191,6 +191,7 @@ fman_alloc_resource(device_t bus, device_t child, int type, int *rid,
 				if (res == NULL)
 					return (NULL);
 				rman_set_rid(res, *rid);
+				rman_set_type(res, type);
 				if ((flags & RF_ACTIVE) != 0 && bus_activate_resource(
 				    child, type, *rid, res) != 0) {
 					rman_release_resource(res);
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index ff3ac0e64271..d52e534b9ab5 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -1049,6 +1049,7 @@ pci_vf_alloc_mem_resource(device_t dev, device_t child, int *rid,
 	}
 
 	rman_set_rid(res, *rid);
+	rman_set_type(res, SYS_RES_MEMORY);
 
 	if (flags & RF_ACTIVE) {
 		error = bus_activate_resource(child, SYS_RES_MEMORY, *rid, res);
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index cda1597ac76e..68eab2a6633b 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -727,6 +727,7 @@ pcib_suballoc_bus(struct pcib_secbus *bus, device_t child, int *rid,
 		    rman_get_start(res), rman_get_end(res), *rid,
 		    pcib_child_name(child));
 	rman_set_rid(res, *rid);
+	rman_set_type(res, PCI_RES_BUS);
 	return (res);
 }
 
@@ -1930,6 +1931,7 @@ pcib_suballoc_resource(struct pcib_softc *sc, struct pcib_window *w,
 		    w->name, rman_get_start(res), rman_get_end(res), *rid,
 		    pcib_child_name(child));
 	rman_set_rid(res, *rid);
+	rman_set_type(res, type);
 
 	if (flags & RF_ACTIVE) {
 		if (bus_activate_resource(child, type, *rid, res) != 0) {
diff --git a/sys/dev/pci/pci_subr.c b/sys/dev/pci/pci_subr.c
index d0f6c9500b17..e2583a75e303 100644
--- a/sys/dev/pci/pci_subr.c
+++ b/sys/dev/pci/pci_subr.c
@@ -344,6 +344,7 @@ pci_domain_alloc_bus(int domain, device_t dev, int *rid, rman_res_t start,
 		return (NULL);
 
 	rman_set_rid(res, *rid);
+	rman_set_type(res, PCI_RES_BUS);
 	return (res);
 }
 
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index a485e6dd2641..ecd5ad44959d 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -4250,6 +4250,7 @@ bus_generic_rman_alloc_resource(device_t dev, device_t child, int type,
 	if (r == NULL)
 		return (NULL);
 	rman_set_rid(r, *rid);
+	rman_set_type(r, type);
 
 	if (flags & RF_ACTIVE) {
 		if (bus_activate_resource(child, type, *rid, r) != 0) {