From nobody Thu Feb 27 14:16:38 2025 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 4Z3YLH1LD2z5qFx5; Thu, 27 Feb 2025 14:16:39 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z3YLH0gtzz3wyr; Thu, 27 Feb 2025 14:16:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740665799; 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=G4y9gMueCn/4POpmx+NrrIZZ3wzDf/obajeS7G5nsGM=; b=KwV9ZA9Te0P+oXx/7z2IHI6+vi2uoc8eZFnA59dGuWoGq362+5aZcLdwNtsF7awyoJrEBq RFnMRe/UQHIdlDs6eBftzfGnbGhE+LIYmEPEGe0dlO++QxG5hR++94jlUsicuMX/R/U1F9 YdnefCbY1l4FeKHDv1qcIawFHjMJKvDq/o7AueAyWOlfxVnOB8w8CYdCF9ZbOAygCkOk+p /yE1N1WSlXr40TUSf0USgVOskWCDiIKSZ7zOEDsN20QQFBHcYGvdvgLRB/VxrTLclOnJZb oax2WMVjxzE6WCE3e6l17kqf2+bRz8WInyTfgxW3nbzhQvch94nDwvM0Ns2Hbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740665799; a=rsa-sha256; cv=none; b=bTudMSn2kJhl/uo64oqXqhBsQSoLqaZuf9fXPCrYwHu/UVAKCg/ZPevn2R9FToSUcOUFhn MA+a4ufXXG3u+0m502iavB6cF1PmoqSmN5dVxOE3bSyZYg1w4O07YYl034iE3uJmBrIZDI 7jdgeeuMwT6bsIMiIWS+leUiFoDe5qVQfu+S1Npu6OQrFBc0481YtGilQ1TAt0U0TXiXrW vRO8wcBvzRD6S+aYUolCp5Tke3mT3iqUAL6ZXMJeFAJ11G4N1O0uENimMijWoGu51MzZdd dUhmcy7EGW/hj40otjWKZXza0CPgJo/EAilANjxtJm8iBazulkj9VonB7Y1rAA== 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=1740665799; 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=G4y9gMueCn/4POpmx+NrrIZZ3wzDf/obajeS7G5nsGM=; b=dyn75OpIII6m4mg6nE2FYsMa7v1zccYPMoDLRrSTjvOvhqQIAFkdp2qofpJBhkX6g3XGf6 +lpEIPY8vttYS9Qbf393+1ZLGV9ajPpAnvb+zYmEkL3QQ1aKqzw8qc+o8Eh5Ecx1J8n/1x aDGLeFj7/JNm6aVVvq8xbbDU4lA2g11q/A7lrdH1cSW6AJKKBTk3qe626eqJonc6/zV+8z 5DTlT4PsRIOdkRx3DpX+MFl6oDC7F2j6q4k0HeRvDMpOvgrbZD1acUCfTYPXFXbdym/p5D qaXJAsToUzlxnjDhOkNcrwempqFVW6AXY5zio/3wwXer0hjC7+rHUfc4gFEfdA== 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 4Z3YLH0CR7zmZN; Thu, 27 Feb 2025 14:16:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51REGcsT015879; Thu, 27 Feb 2025 14:16:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51REGcoA015876; Thu, 27 Feb 2025 14:16:38 GMT (envelope-from git) Date: Thu, 27 Feb 2025 14:16:38 GMT Message-Id: <202502271416.51REGcoA015876@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: 64ab61b1284a - stable/14 - powerpc nexus: Use bus_generic_rman_* 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: 64ab61b1284a1e9d578c1df61a63cff7f2004b5f Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=64ab61b1284a1e9d578c1df61a63cff7f2004b5f commit 64ab61b1284a1e9d578c1df61a63cff7f2004b5f Author: John Baldwin AuthorDate: 2024-01-23 17:37:02 +0000 Commit: John Baldwin CommitDate: 2025-02-27 13:09:20 +0000 powerpc nexus: Use bus_generic_rman_* Reviewed by: imp, jhibbits Differential Revision: https://reviews.freebsd.org/D43436 (cherry picked from commit 7b5a5e4eef504d2972b6b5f6abfff8058be6371e) --- 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 c5f460baf44e..a2043c3cfdf9 100644 --- a/sys/powerpc/powerpc/nexus.c +++ b/sys/powerpc/powerpc/nexus.c @@ -68,12 +68,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 @@ -94,12 +90,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), @@ -232,121 +229,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