From nobody Fri Nov 24 17:28:55 2023 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 4ScMQw1nWdz51MFy; Fri, 24 Nov 2023 17:28:56 +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 4ScMQw1MqFz4JM5; Fri, 24 Nov 2023 17:28:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700846936; 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=qWyHihyDODaI5uhhDLkU9KUNmGYFPyuYMIRLbFTfuTk=; b=UVuNYMqnZtMpceVOR34n/gMZgvd0MqqHoaTeNi7XAGVPurelg3NyuRBF2gzhHkoOmHsuZD SUQ5v2Ok0eQNWTjU8VBr4KK7UCcl1jkK7LM/okCbu3ytoTgkQ5hyqS0Urb6npQ0lDPlUIB N8YZyrUh+zX+qpzhT4S1djyrjOl4PqadwIfj9R38ONAU1JCBQRXJjkNpIMLKKBojIs5YwI ySpJi8Lp+vngFUxs6PDXQ/ggFuAD6Ll6ppYpW7R/rlcTFv1ed6LFRw3Z57QJSNZ3ESCAJw zXVNgNLEEEUw1E2pa2JNna7SdZhiH/X+82ImTGdZ28jXRhQa4f/fuSqpkK8OvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700846936; 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=qWyHihyDODaI5uhhDLkU9KUNmGYFPyuYMIRLbFTfuTk=; b=WyTHS9frTX0DbefK+nhooBeSvWhx2esPFJyVgE7G2fhWk36pb1Gnlxr/LdqLwEvKhWkhKH 93zElMUZLgIBqhnZbUK28/UQ/qygqcSgpCW0iKzv11dnCRCXXfWVTmRbJM8fp1/hOYf1hr HJRA63BK+/G6F+oWG+49prBCQ/ofdPfHwzUVvvPM3X4gC8XtwroneNVwDjDwpBpu+g7JEd ae72ObFBW7CM+E34OCP8A8st8vc1zxrRVjCt2IPKbsmcZAOW0uBvmYplGifan1utzSFMMo EKZum/Oux8marcSFHxh1C54yAGM+wxgV+J4dA1v2iLNggX0XQIioNSX5FcUbkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700846936; a=rsa-sha256; cv=none; b=T7OTjGCyvo9qyO0EhdiMoWEpMa93RAozZq4IiDYbGhkC8QO+sVTXcygnViS7crQa6Hw3tQ 0EUb4THVip2FjNHW4cuZ5mSnldrCvOEDXEd0gN1+03mWlM1Rdq3Bxxhyddy/AQPCbRc02D 3oyKJkPDgrs2rgP9VFMNNE+8XX/JoJxw5uKlWg4hET3DjKqQKJsUdXb/E77oZxzxHsqjmZ wdnvRJz4hw6JW8jX7go2G1P6YEuxhgW5wISuGSHv/XUbM8sSiBgOi8U14Mr5c66z/fL9im V9/YQHa5/6NCDgYHVorREC7IK9CSXc1tzhi+oPAEZFCh+aOp+Bct4NaW7ytMuQ== 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 4ScMQw0CQWztZT; Fri, 24 Nov 2023 17:28:56 +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 3AOHStmA051666; Fri, 24 Nov 2023 17:28:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AOHStlO051663; Fri, 24 Nov 2023 17:28:55 GMT (envelope-from git) Date: Fri, 24 Nov 2023 17:28:55 GMT Message-Id: <202311241728.3AOHStlO051663@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: a03a335a8012 - main - 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/main X-Git-Reftype: branch X-Git-Commit: a03a335a801246dfb95ccf35ec3f64b9fe968874 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a03a335a801246dfb95ccf35ec3f64b9fe968874 commit a03a335a801246dfb95ccf35ec3f64b9fe968874 Author: John Baldwin AuthorDate: 2023-11-24 17:28:10 +0000 Commit: John Baldwin CommitDate: 2023-11-24 17:28:10 +0000 x86 nexus: Use bus_generic_rman_*_resource Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D42740 --- 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