From nobody Wed Jan 03 22:02:46 2024 X-Original-To: dev-commits-src-all@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 4T53cR2lbTz56nwB; Wed, 3 Jan 2024 22:02:47 +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 4T53cQ66y3z4YZK; Wed, 3 Jan 2024 22:02:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704319366; 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=3FQgezOnrBxNdb3hzT1wEzIba5n5D0Ao0Y90tElrVFw=; b=WvrJAwDUWKUPhcC0Hof7CpNJxtruaH3HsFzIEtgHI/TRb4DDER9BUt9wmq/GXCMxuxp9qV 4ClmQMOMSh/4Xyviey0c4xLrnwlqNZ5Rxy+4zPGXJ2WAaEpCDzHCVkaETiWsZU866QK7rR 2jqTRMKuZUQ4+ulRRn/bSYRSIidTWmnWAxIOgZXAUYEL5xDda42E0+u8aXMOTA4Z7xR+0l AANu4HdgPbHFBIOdeD/iijEHZ7pAb/LowvyPUIy1hlWPWpiNhJO1ZoFFHqr/Yzwl7E6MhY 2GrCMZ0TC6D1Dkso989eNSkELwp6fwPz+pJFam/Sqx72lAq9WoAF1aFLhoTVvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704319366; 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=3FQgezOnrBxNdb3hzT1wEzIba5n5D0Ao0Y90tElrVFw=; b=clL6W390Lacp6wfZaU9z1szt3XTtCwbg0zGvYaR+esQUjQFyfFncm1kuo7+lUlSjy/U5hx Mp8qxWpyzOF2NHX7IneGPa0LL3JjoyLGR95u/xw0MEPJLlcxIdUnH9oW9iYs6sU3ZqjPX/ Z4HBqp5YmdyxReNTLv4cr0FWXVt2E9wg+K7Xpczs1qtcU7K7Bp2al2lBM9zrdi2NRib9n5 clAEdw1vnCaE4ePeeknbAowKkrYewho+W4jONZnIVaBz5g6cNQZIh6QhU7RnBeGDs/AvS4 5KfTSVvlykkN/5VPotmXkwmGHXAY8EgrSlcajbbqj2a4buckX+qroJxzVmFVzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704319366; a=rsa-sha256; cv=none; b=EUoL5GZqx3ZcyZ7ExP4ReRCZJBdrNxT3nY4F5JY43eU9OEs4o0Ov6o6LH5drJsf4XbIJ93 7KLhYtQ9hY6Ua9vrSj1Ooo50FSojkURb93560VhoBNEgZTZ6gZefYAuMVDMAcEpOPipA0T Ld2O/clPSNOStqRbNjt1YQTMHwdFYIH9kd0WiH8IY5/DzaXnSmu3Fbz/Zo6sXAQJ7ETBbu pxLueo6gH8Wk2aEo7TTJ6D04YZyyUZecvRMTKfilQCB57kvO9zs71RLdtV9boNyBtez+c9 LUyNjXrcadK+xqncrIDHmGTdXLLZjt7pI5vFJ27tZGQnVT/24pFm828S17Mf5g== 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 4T53cQ5F4Jz1371; Wed, 3 Jan 2024 22:02:46 +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 403M2kDh072679; Wed, 3 Jan 2024 22:02:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 403M2kJN072676; Wed, 3 Jan 2024 22:02:46 GMT (envelope-from git) Date: Wed, 3 Jan 2024 22:02:46 GMT Message-Id: <202401032202.403M2kJN072676@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 9d2b2ab93cac - stable/14 - x86 nexus: Use bus_generic_rman_*_resource List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 9d2b2ab93cac73dff24a461fe130738fa928347a Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9d2b2ab93cac73dff24a461fe130738fa928347a commit 9d2b2ab93cac73dff24a461fe130738fa928347a Author: John Baldwin AuthorDate: 2023-11-24 17:28:10 +0000 Commit: John Baldwin CommitDate: 2024-01-03 20:48:20 +0000 x86 nexus: Use bus_generic_rman_*_resource Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42740 (cherry picked from commit a03a335a801246dfb95ccf35ec3f64b9fe968874) --- sys/x86/x86/nexus.c | 110 +++++----------------------------------------------- 1 file changed, 9 insertions(+), 101 deletions(-) diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c index 54c655c4fafd..9b05758a6cbf 100644 --- a/sys/x86/x86/nexus.c +++ b/sys/x86/x86/nexus.c @@ -97,13 +97,10 @@ static device_attach_t nexus_attach; static bus_add_child_t nexus_add_child; static bus_print_child_t nexus_print_child; -static bus_activate_resource_t nexus_activate_resource; -static bus_adjust_resource_t nexus_adjust_resource; static bus_alloc_resource_t nexus_alloc_resource; -static bus_deactivate_resource_t nexus_deactivate_resource; static bus_get_resource_list_t nexus_get_reslist; +static bus_get_rman_t nexus_get_rman; static bus_map_resource_t nexus_map_resource; -static bus_release_resource_t nexus_release_resource; static bus_unmap_resource_t nexus_unmap_resource; #ifdef SMP @@ -138,15 +135,16 @@ static device_method_t nexus_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, nexus_print_child), DEVMETHOD(bus_add_child, nexus_add_child), - DEVMETHOD(bus_activate_resource, nexus_activate_resource), - DEVMETHOD(bus_adjust_resource, nexus_adjust_resource), + DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_rman_adjust_resource), DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), - DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_get_resource_list, nexus_get_reslist), + DEVMETHOD(bus_get_rman, nexus_get_rman), DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), DEVMETHOD(bus_map_resource, nexus_map_resource), - DEVMETHOD(bus_release_resource, nexus_release_resource), + DEVMETHOD(bus_release_resource, bus_generic_rman_release_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_unmap_resource, nexus_unmap_resource), #ifdef SMP @@ -328,7 +326,7 @@ nexus_add_child(device_t bus, u_int order, const char *name, int unit) } static struct rman * -nexus_rman(int type) +nexus_get_rman(device_t bus, int type, u_int flags) { switch (type) { case SYS_RES_IRQ: @@ -354,10 +352,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, u_int flags) { struct nexus_device *ndev = DEVTONX(child); - struct resource *rv; struct resource_list_entry *rle; - struct rman *rm; - int needactivate = flags & RF_ACTIVE; /* * If this is an allocation of the "default" range for a given @@ -376,81 +371,8 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, count = rle->count; } - flags &= ~RF_ACTIVE; - rm = nexus_rman(type); - if (rm == NULL) - return (NULL); - - rv = rman_reserve_resource(rm, start, end, count, flags, child); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv)) { - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); -} - -static int -nexus_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - struct rman *rm; - - rm = nexus_rman(type); - if (rm == NULL) - return (ENXIO); - if (!rman_is_region_manager(r, rm)) - return (EINVAL); - return (rman_adjust_resource(r, start, end)); -} - -static int -nexus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct resource_map map; - int error; - - error = rman_activate_resource(r); - if (error != 0) - return (error); - - if (!(rman_get_flags(r) & RF_UNMAPPED) && - (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { - error = nexus_map_resource(bus, child, type, r, NULL, &map); - if (error) { - rman_deactivate_resource(r); - return (error); - } - - rman_set_mapping(r,&map); - } - return (0); -} - -static int -nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct resource_map map; - int error; - - error = rman_deactivate_resource(r); - if (error) - return (error); - - if (!(rman_get_flags(r) & RF_UNMAPPED) && - (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) { - rman_get_mapping(r, &map); - nexus_unmap_resource(bus, child, type, r, &map); - } - return (0); + return (bus_generic_rman_alloc_resource(bus, child, type, rid, + start, end, count, flags)); } static int @@ -523,20 +445,6 @@ nexus_unmap_resource(device_t bus, device_t child, int type, struct resource *r, return (0); } -static int -nexus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - int error; - - if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); - if (error != 0) - return (error); - } - return (rman_release_resource(r)); -} - /* * Currently this uses the really grody interface from kern/kern_intr.c * (which really doesn't belong in kern/anything.c). Eventually, all of