From nobody Tue Jan 23 17:45:58 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 4TKDyv17H8z57mYb; Tue, 23 Jan 2024 17:45:59 +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 4TKDyt55Hkz47Bt; Tue, 23 Jan 2024 17:45:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706031958; 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=HKZl+ex1tIJ+svVANHWCh4NPue3WlUKEghgAD4DyUOU=; b=MSxnY7Hobjf0z7yQAFmNeoGn+7/pc/nY3og+H7EcPoam1x3v6h9VwWeXsiUIMBIBCE+T3O hYzzlP7ZSDijREZoEV4ZaS4ybjjgTr1SmvTW4/3uvOY5ZR6Ge8lOTi8ibPLMCqQiL2kM0P ktLc8oQOBcx/rHi4tDWkT4ZjkPQ++e1eLVZI9mmq+r8xeatU3KxQgkwJ3BPt4i+D46TyJS qVl0rI80r0IjbtjTYmjlK0fs6AzjSsHAc44zltRRkTV50y+P5VaWtzfVA4xAz1ZtO4ECTe XPPTdTyIrExtDAx4+OeSoXWng8fVK3dSdxz4SWIGakzHGSpVN/K9Fj7UoPkTxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706031958; 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=HKZl+ex1tIJ+svVANHWCh4NPue3WlUKEghgAD4DyUOU=; b=Hh4upiEcdej5obOdoPfMzBTAi26nUNMKqiK4upeO/dUdMX+6xbLCJMuq4Cx6OB+/AOxuGU V8AbikewDM7QeEpSi+6vftYV4Vj6Q77W8ltMi+vVliyvr8S/LdvpAnMNK9zTcLLITEmaW/ dfs/YYGdg/iXFVW/hnVSfbw4XNeEAIB6/yXs8NKqR5FL4xSowe5uVb8pP0gMomaUP9KvVh qVDKYwaJMTXscX8WY884wTblplZX/zH9V1b2da2Cesn9cTJ/zQMaYW4b9c42lA0+xXRNs0 D6Y4OJnXwka0VKyy2+30ny0NCK3p/hk7OPvTVkc0tAa3ZfqQLV2/5HPFZHBtvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706031958; a=rsa-sha256; cv=none; b=GrDE3R9w1r29ACFJOzsxUkRA5LlwGnue4Ml0erb6k3Xd/0qCoETtaS2ETGezPaRoCkYcZG AwnkUXZoeRx/ZCuR0cfZojcYwbqe9PlKQ1NNRus7l/xGVG2NpzetzAUEL636syAHi36epw yu9d0J0201fjwJX5DkOSV3/0g4sYrRRGO7DRL1ZBHkrJAtDKKLxXEfRNhkWsOAKj8j6IP4 JHkvz4KnigdkFc9jfZ37MUMbuzzl6wYo9lmWfjsRmMZIVzfmEZpvM+Mn76oLrZcIvT77VH jrNjxi4aosYvHRnUJbh4v+vSntXOplA9NzlzRiEL5Qbd4yZO+64fZ9VafNUZeA== 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 4TKDyt4B2HzfyB; Tue, 23 Jan 2024 17:45:58 +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 40NHjwXV075918; Tue, 23 Jan 2024 17:45:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40NHjwg0075915; Tue, 23 Jan 2024 17:45:58 GMT (envelope-from git) Date: Tue, 23 Jan 2024 17:45:58 GMT Message-Id: <202401231745.40NHjwg0075915@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: 7b5a5e4eef50 - main - powerpc nexus: 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: 7b5a5e4eef504d2972b6b5f6abfff8058be6371e Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7b5a5e4eef504d2972b6b5f6abfff8058be6371e commit 7b5a5e4eef504d2972b6b5f6abfff8058be6371e Author: John Baldwin AuthorDate: 2024-01-23 17:37:02 +0000 Commit: John Baldwin CommitDate: 2024-01-23 17:37:02 +0000 powerpc nexus: Use bus_generic_rman_* Reviewed by: imp, jhibbits Differential Revision: https://reviews.freebsd.org/D43436 --- sys/powerpc/powerpc/nexus.c | 129 ++++---------------------------------------- 1 file changed, 11 insertions(+), 118 deletions(-) diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c index b9c2755dd983..3c71e1e79e3b 100644 --- a/sys/powerpc/powerpc/nexus.c +++ b/sys/powerpc/powerpc/nexus.c @@ -67,12 +67,8 @@ static struct rman mem_rman; static device_probe_t nexus_probe; static device_attach_t nexus_attach; -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_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 @@ -93,12 +89,13 @@ static device_method_t nexus_methods[] = { /* Bus interface */ DEVMETHOD(bus_add_child, bus_generic_add_child), - DEVMETHOD(bus_adjust_resource, nexus_adjust_resource), - DEVMETHOD(bus_activate_resource, nexus_activate_resource), - DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), - DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_rman_adjust_resource), + DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource), + DEVMETHOD(bus_alloc_resource, bus_generic_rman_alloc_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource), + DEVMETHOD(bus_get_rman, nexus_get_rman), 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_unmap_resource, nexus_unmap_resource), #ifdef SMP DEVMETHOD(bus_bind_intr, nexus_bind_intr), @@ -231,121 +228,17 @@ nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells, return (intr); } -/* - * Allocate a resource on behalf of child. NB: child is usually going to be a - * child of one of our descendants, not a direct child of nexus0. - */ -static struct resource * -nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) +static struct rman * +nexus_get_rman(device_t bus, int type, u_int flags) { - struct rman *rm; - struct resource *rv; - switch (type) { case SYS_RES_IRQ: - rm = &intr_rman; - break; + return (&intr_rman); case SYS_RES_MEMORY: - rm = &mem_rman; - break; + return (&mem_rman); default: return (NULL); } - - rv = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE, - child); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - - if ((flags & RF_ACTIVE) != 0) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); -} - -static int -nexus_activate_resource(device_t bus __unused, device_t child __unused, - int type, int rid __unused, struct resource *r) -{ - - if (type == SYS_RES_MEMORY) { - vm_paddr_t start; - void *p; - - start = (vm_paddr_t) rman_get_start(r); - if (bootverbose) - printf("nexus mapdev: start %jx, len %jd\n", - (uintmax_t)start, rman_get_size(r)); - - p = pmap_mapdev(start, (vm_size_t) rman_get_size(r)); - if (p == NULL) - return (ENOMEM); - rman_set_virtual(r, p); - rman_set_bustag(r, &bs_be_tag); - rman_set_bushandle(r, (u_long)p); - } - return (rman_activate_resource(r)); -} - -static int -nexus_deactivate_resource(device_t bus __unused, device_t child __unused, - int type __unused, int rid __unused, struct resource *r) -{ - - /* - * If this is a memory resource, unmap it. - */ - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - bus_size_t psize; - - psize = rman_get_size(r); - pmap_unmapdev(rman_get_virtual(r), psize); - } - - return (rman_deactivate_resource(r)); -} - -static int -nexus_adjust_resource(device_t bus, device_t child __unused, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - struct rman *rm; - - switch (type) { - case SYS_RES_IRQ: - rm = &intr_rman; - break; - case SYS_RES_MEMORY: - rm = &mem_rman; - break; - default: - return (EINVAL); - } - if (rm == NULL) - return (ENXIO); - if (rman_is_region_manager(r, rm) == 0) - return (EINVAL); - return (rman_adjust_resource(r, start, end)); -} - -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) != 0) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - return (rman_release_resource(r)); } static int