From nobody Tue Feb 27 19:45:04 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tkny90KPwz5CK3S; Tue, 27 Feb 2024 19:45:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tkny86fjHz56wP; Tue, 27 Feb 2024 19:45:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709063104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7NOXUT3Fx35O7OsybsuC6cwfctFYd8BI7LXG7BUp/3U=; b=pEpFxapPVu795KPTAKE2FB1MUxNyx2g7CBado3ErGACWooFNXksym+3G4F7JZpEU6h+PeF uNzruic0yhZyqIN8KX6nBP3+sW+PYA6IYxjE2pnR7+BkXutqQ3BFcse/IDWqtN3qPOT1Rt wfiYWyLpxUk2rYAg+42nkkdakmFjOK89CPZ25HD0KxgjjgUXdvzB+SXQrFaG+gfA1Vy19b /o5DV7IFNS8F+vNJvMpcdVMZLsnrzDwZ4s174/sfDWTzlcnacpbyF9n/GRHfHdqAyvJ+Dg xNn/5oyLo9FyVkrOD9QPvzkVqwUmVN9gAWFDHCPLS1RPkdRtdsGJb+VhvdaqvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709063104; a=rsa-sha256; cv=none; b=amWCF+VIoEcBbCSNi9eZ07LXgCAcRcMLVnPB/MmYEp6fE/V/JYhZkfL/qOkYAtcclNx88u a/FX2mXkoYeEadbaNCqC4tM9Ixd8inBYM3ZC9rXr7t1P/TRs08yniQaMZakOpvdJBPNkZk V6dU51fh4GkKyML3ixI7n576U9Jwsyl9ZRiBlkI+tSFHBGtUTo+ckP7JH18+16QEDTiX/p 1pwSkinpGA+nCtvDKOVHEALTqhk2lLJkOul9o0/1K11a7U4Wec729PfOYlZHOARCLY/O7D TAuOPs5A7oay9WtsKImKikcPGwQTN/+7VdtvSSx6RD7TMV8lSclU61rxsvWvhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709063104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7NOXUT3Fx35O7OsybsuC6cwfctFYd8BI7LXG7BUp/3U=; b=G5DPBt995K8MGW6OOnqlYK0wSc1Mk7qnzxGF1y/c4aw+hdGkqSX5VchXulQ/bCldKn79Re xH7ybBHmLdQvXmR7W/MRUtusHJWxvZr/N0b6wlaOVwlV4+S9aOeC4Bl4pS91uu7cbKResP s5TDA5BFrVxaB+zQmgJzES7b3qwGZYyucmO3LuqeAS6dAwzcxZcoU+TEivEHIvukpYWeaY fNRnaoPuLndTfsSz/KWgEyvac8LpvMYDt5SKRIW7dexbxOGxgVpM/jgvhBEw8kfPxS/bUc JbtNDMq7hnUkAHQmArzdITQV3vJxTSMx18rBJMSnKiiNiwj+0EIn7asVzxEKFg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tkny85kpkzQQ7; Tue, 27 Feb 2024 19:45:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41RJj4cl092967; Tue, 27 Feb 2024 19:45:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41RJj4Cd092964; Tue, 27 Feb 2024 19:45:04 GMT (envelope-from git) Date: Tue, 27 Feb 2024 19:45:04 GMT Message-Id: <202402271945.41RJj4Cd092964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 9b619f0e9082 - main - dpaa2: Use bus_generic_rman_* List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9b619f0e9082b8f97f0e20ec5176fe40ba8565f8 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9b619f0e9082b8f97f0e20ec5176fe40ba8565f8 commit 9b619f0e9082b8f97f0e20ec5176fe40ba8565f8 Author: John Baldwin AuthorDate: 2024-02-27 19:43:50 +0000 Commit: John Baldwin CommitDate: 2024-02-27 19:43:50 +0000 dpaa2: Use bus_generic_rman_* Reviewed by: dsl Differential Revision: https://reviews.freebsd.org/D43937 --- sys/dev/dpaa2/dpaa2_mc.c | 76 +++++++++++++++++-------------------------- sys/dev/dpaa2/dpaa2_mc.h | 1 + sys/dev/dpaa2/dpaa2_mc_acpi.c | 1 + sys/dev/dpaa2/dpaa2_mc_fdt.c | 1 + 4 files changed, 33 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; diff --git a/sys/dev/dpaa2/dpaa2_mc.h b/sys/dev/dpaa2/dpaa2_mc.h index 9a21c9724b82..40b318c4c9e7 100644 --- a/sys/dev/dpaa2/dpaa2_mc.h +++ b/sys/dev/dpaa2/dpaa2_mc.h @@ -179,6 +179,7 @@ int dpaa2_mc_detach(device_t dev); /* For bus interface. */ +struct rman *dpaa2_mc_rman(device_t mcdev, int type, u_int flags); struct resource * dpaa2_mc_alloc_resource(device_t mcdev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags); diff --git a/sys/dev/dpaa2/dpaa2_mc_acpi.c b/sys/dev/dpaa2/dpaa2_mc_acpi.c index 388bb764afff..2007c18bec67 100644 --- a/sys/dev/dpaa2/dpaa2_mc_acpi.c +++ b/sys/dev/dpaa2/dpaa2_mc_acpi.c @@ -352,6 +352,7 @@ static device_method_t dpaa2_mc_acpi_methods[] = { DEVMETHOD(device_detach, dpaa2_mc_detach), /* Bus interface */ + DEVMETHOD(bus_get_rman, dpaa2_mc_rman), DEVMETHOD(bus_alloc_resource, dpaa2_mc_alloc_resource), DEVMETHOD(bus_adjust_resource, dpaa2_mc_adjust_resource), DEVMETHOD(bus_release_resource, dpaa2_mc_release_resource), diff --git a/sys/dev/dpaa2/dpaa2_mc_fdt.c b/sys/dev/dpaa2/dpaa2_mc_fdt.c index 8e9ab10dec9d..a6babfc89ca9 100644 --- a/sys/dev/dpaa2/dpaa2_mc_fdt.c +++ b/sys/dev/dpaa2/dpaa2_mc_fdt.c @@ -355,6 +355,7 @@ static device_method_t dpaa2_mc_fdt_methods[] = { DEVMETHOD(device_detach, dpaa2_mc_detach), /* Bus interface */ + DEVMETHOD(bus_get_rman, dpaa2_mc_rman), DEVMETHOD(bus_alloc_resource, dpaa2_mc_alloc_resource), DEVMETHOD(bus_adjust_resource, dpaa2_mc_adjust_resource), DEVMETHOD(bus_release_resource, dpaa2_mc_release_resource),