aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/dpaa2/dpaa2_mc.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2024-02-27 19:43:50 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2024-02-27 19:43:50 +0000
commit9b619f0e9082b8f97f0e20ec5176fe40ba8565f8 (patch)
treec86b3f0181afd48739ca283dee234c263da8391c /sys/dev/dpaa2/dpaa2_mc.c
parent04fc3fb8fcf631889ec9a181504e6ae1daebd3cd (diff)
Diffstat (limited to 'sys/dev/dpaa2/dpaa2_mc.c')
-rw-r--r--sys/dev/dpaa2/dpaa2_mc.c76
1 files changed, 30 insertions, 46 deletions
diff --git a/sys/dev/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c
index 0deebf7e8b24..6d11e50b1f98 100644
--- a/sys/dev/dpaa2/dpaa2_mc.c
+++ b/sys/dev/dpaa2/dpaa2_mc.c
@@ -115,7 +115,6 @@ static struct resource_spec dpaa2_mc_spec[] = {
static u_int dpaa2_mc_get_xref(device_t, device_t);
static u_int dpaa2_mc_map_id(device_t, device_t, uintptr_t *);
-static struct rman *dpaa2_mc_rman(device_t, int);
static int dpaa2_mc_alloc_msi_impl(device_t, device_t, int, int, int *);
static int dpaa2_mc_release_msi_impl(device_t, device_t, int, int *);
@@ -312,10 +311,10 @@ dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid,
struct rman *rm;
int error;
- rm = dpaa2_mc_rman(mcdev, type);
- if (!rm)
- return (BUS_ALLOC_RESOURCE(device_get_parent(mcdev), child,
- type, rid, start, end, count, flags));
+ rm = dpaa2_mc_rman(mcdev, type, flags);
+ if (rm == NULL)
+ return (bus_generic_alloc_resource(mcdev, child, type, rid,
+ start, end, count, flags));
/*
* Skip managing DPAA2-specific resource. It must be provided to MC by
@@ -331,24 +330,10 @@ dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid,
}
}
- res = rman_reserve_resource(rm, start, end, count, flags, child);
- if (!res) {
- device_printf(mcdev, "rman_reserve_resource() failed: "
- "start=%#jx, end=%#jx, count=%#jx\n", start, end, count);
+ res = bus_generic_rman_alloc_resource(mcdev, child, type, rid, start,
+ end, count, flags);
+ if (res == NULL)
goto fail;
- }
-
- rman_set_rid(res, *rid);
-
- if (flags & RF_ACTIVE) {
- if (bus_activate_resource(child, type, *rid, res)) {
- device_printf(mcdev, "bus_activate_resource() failed: "
- "rid=%d, res=%#jx\n", *rid, (uintmax_t) res);
- rman_release_resource(res);
- goto fail;
- }
- }
-
return (res);
fail:
device_printf(mcdev, "%s() failed: type=%d, rid=%d, start=%#jx, "
@@ -363,9 +348,10 @@ dpaa2_mc_adjust_resource(device_t mcdev, device_t child, int type,
{
struct rman *rm;
- rm = dpaa2_mc_rman(mcdev, type);
+ rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
if (rm)
- return (rman_adjust_resource(r, start, end));
+ return (bus_generic_rman_adjust_resource(mcdev, child, type, r,
+ start, end));
return (bus_generic_adjust_resource(mcdev, child, type, r, start, end));
}
@@ -375,12 +361,10 @@ dpaa2_mc_release_resource(device_t mcdev, device_t child, int type, int rid,
{
struct rman *rm;
- rm = dpaa2_mc_rman(mcdev, type);
- if (rm) {
- KASSERT(rman_is_region_manager(r, rm), ("rman mismatch"));
- rman_release_resource(r);
- }
-
+ rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
+ if (rm)
+ return (bus_generic_rman_release_resource(mcdev, child, type,
+ rid, r));
return (bus_generic_release_resource(mcdev, child, type, rid, r));
}
@@ -388,26 +372,26 @@ int
dpaa2_mc_activate_resource(device_t mcdev, device_t child, int type, int rid,
struct resource *r)
{
- int rc;
-
- if ((rc = rman_activate_resource(r)) != 0)
- return (rc);
+ struct rman *rm;
- return (BUS_ACTIVATE_RESOURCE(device_get_parent(mcdev), child, type,
- rid, r));
+ rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
+ if (rm)
+ return (bus_generic_rman_activate_resource(mcdev, child, type,
+ rid, r));
+ return (bus_generic_activate_resource(mcdev, child, type, rid, r));
}
int
dpaa2_mc_deactivate_resource(device_t mcdev, device_t child, int type, int rid,
struct resource *r)
{
- int rc;
-
- if ((rc = rman_deactivate_resource(r)) != 0)
- return (rc);
+ struct rman *rm;
- return (BUS_DEACTIVATE_RESOURCE(device_get_parent(mcdev), child, type,
- rid, r));
+ rm = dpaa2_mc_rman(mcdev, type, rman_get_flags(r));
+ if (rm)
+ return (bus_generic_rman_deactivate_resource(mcdev, child, type,
+ rid, r));
+ return (bus_generic_deactivate_resource(mcdev, child, type, rid, r));
}
/*
@@ -498,7 +482,7 @@ dpaa2_mc_manage_dev(device_t mcdev, device_t dpaa2_dev, uint32_t flags)
if (flags & DPAA2_MC_DEV_ALLOCATABLE) {
/* Select rman based on a type of the DPAA2 device. */
- rm = dpaa2_mc_rman(mcdev, dinfo->dtype);
+ rm = dpaa2_mc_rman(mcdev, dinfo->dtype, 0);
if (!rm)
return (ENOENT);
/* Manage DPAA2 device as an allocatable resource. */
@@ -523,7 +507,7 @@ dpaa2_mc_get_free_dev(device_t mcdev, device_t *dpaa2_dev,
return (EINVAL);
/* Select resource manager based on a type of the DPAA2 device. */
- rm = dpaa2_mc_rman(mcdev, devtype);
+ rm = dpaa2_mc_rman(mcdev, devtype, 0);
if (!rm)
return (ENOENT);
/* Find first free DPAA2 device of the given type. */
@@ -749,8 +733,8 @@ dpaa2_mc_map_id(device_t mcdev, device_t child, uintptr_t *id)
* @internal
* @brief Obtain a resource manager based on the given type of the resource.
*/
-static struct rman *
-dpaa2_mc_rman(device_t mcdev, int type)
+struct rman *
+dpaa2_mc_rman(device_t mcdev, int type, u_int flags)
{
struct dpaa2_mc_softc *sc;