From nobody Wed Mar 13 22:13:33 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 4Tw4XY2fqlz5DXVN; Wed, 13 Mar 2024 22:13:33 +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 4Tw4XY1sxvz4qV6; Wed, 13 Mar 2024 22:13:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710368013; 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=puSl6nrbJVw1SWBFUK0enim06ITsEJxde5lugFvIth4=; b=LIk/6qOHAQ6flqLfRE/newREreEoS07VswOcFFFBMQG/0jXxw7v38aoVHaj0mGov+A8rsN lablBaEYcSfU5tl++i8b2KQDm9Lk7bXJwDuHL8oXvW2dyY0kYMEWQwkXUflEFOXdryTzy3 nFyiY+dgydTFY1NFuYdXOzn7Db98zwADX6IsVfrJkzE5llpLLOMkhOn5Xvt6Ei9ei2n7R6 KcvNLSydOyB/n+L3EckHt69dxP+vwc25JPwzt+GWH1aTM8i4ey7rwIbpQbhvbPPNT1euuy DT6sw5Liw9dwcQxDLODdZ9Zfnh71RujX8jHG70f3Ujjq7kEZ7bg+AJu7FzqyRA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710368013; a=rsa-sha256; cv=none; b=UcEPz9RGCpYe37AbHVaLVEae7rUF8YWBFneJu8I6cUZspPrH+Yr2vihVFQK2TQ43TtBCqd vci6KHMEIipPtf0OzYAzzEVxM8RrzMN0qGGEJ+0tWWpAvQJhjtombO6GpTKuRiLa6oaS9r rqT+V5QnthgLCA1VqPY4gNMx3d/JjX4MYj00T+eksFG0KMLaJm+op8m+JBMmfgq6iV/1Oj OMkrj94peiaRXYjGLNiNaO007ZUSIVYpuR3Nm7D5XgVnO0SJTWA8dTUU90azRJxdnlj4MT 0vmgYWVhkyY1fzPjFeB9li9Ev9KhEDrX1XWLbefc1RuMAdDO2mD/57EE7p+5eQ== 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=1710368013; 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=puSl6nrbJVw1SWBFUK0enim06ITsEJxde5lugFvIth4=; b=xm6GUXZzyySuoTJCyBQhG5l+CxeuUrol57XJy6C008B2uTeFvgytLLH7JX8w00PKCdJAO+ VO4uqnP+EUoTwPU5u9ROi1w2KgGWhEkPGXqgxeGeHs+ujSPghZdipaxpb7btlvrOZIb8Jo SUhZ/K7ul55JSOzIfk6NlNcqwc5oiAH7fsD3x2JV85zf2mhUXwCZAeQrlHjGlaJDzHmMtK o8W9VsX7EgTLVH2pigPnpz/WYXUQPKa37FxBXO+U7TQ7tq5OOnsMwV9wpAeZHwrGC2C2Zb OLwB0uUbtaGvCqkC8nlCi7cBpwAqeSKWKCShLjm7B4cotIbNNjd1eK/yhps6QA== 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 4Tw4XY1TJ1z11nJ; Wed, 13 Mar 2024 22:13:33 +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 42DMDXrQ074744; Wed, 13 Mar 2024 22:13:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42DMDXdj074741; Wed, 13 Mar 2024 22:13:33 GMT (envelope-from git) Date: Wed, 13 Mar 2024 22:13:33 GMT Message-Id: <202403132213.42DMDXdj074741@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: b30a80b65587 - main - rman: Add rman_get/set_type 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: b30a80b65587fb9fd4a5f012d606dbd0c6239a46 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b30a80b65587fb9fd4a5f012d606dbd0c6239a46 commit b30a80b65587fb9fd4a5f012d606dbd0c6239a46 Author: John Baldwin AuthorDate: 2024-03-13 22:05:53 +0000 Commit: John Baldwin CommitDate: 2024-03-13 22:05:53 +0000 rman: Add rman_get/set_type This permits associating a resource type (e.g. SYS_RES_MEMORY) with a struct resource. I considered adding a new field to struct rman to store the type and only providing rman_get_type as an accessor. However, changing 'struct rman' is an ABI breakage. I might revisit this in main, but the current approach is MFC'able. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44122 --- share/man/man9/Makefile | 2 ++ share/man/man9/rman.9 | 18 ++++++++++++++++-- sys/kern/subr_rman.c | 13 +++++++++++++ sys/sys/rman.h | 2 ++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index c98849b42a7b..d6732a4e15f7 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1869,6 +1869,7 @@ MLINKS+=rman.9 rman_activate_resource.9 \ rman.9 rman_get_rid.9 \ rman.9 rman_get_size.9 \ rman.9 rman_get_start.9 \ + rman.9 rman_get_type.9 \ rman.9 rman_get_virtual.9 \ rman.9 rman_init.9 \ rman.9 rman_init_from_resource.9 \ @@ -1883,6 +1884,7 @@ MLINKS+=rman.9 rman_activate_resource.9 \ rman.9 rman_set_bustag.9 \ rman.9 rman_set_mapping.9 \ rman.9 rman_set_rid.9 \ + rman.9 rman_set_type.9 \ rman.9 rman_set_virtual.9 MLINKS+=rmlock.9 rm_assert.9 \ rmlock.9 rm_destroy.9 \ diff --git a/share/man/man9/rman.9 b/share/man/man9/rman.9 index 095cd2760b8c..35a2d176233c 100644 --- a/share/man/man9/rman.9 +++ b/share/man/man9/rman.9 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd May 20, 2016 +.Dd March 13, 2024 .Dt RMAN 9 .Os .Sh NAME @@ -56,7 +56,9 @@ .Nm rman_set_bushandle , .Nm rman_get_bushandle , .Nm rman_set_rid , -.Nm rman_get_rid +.Nm rman_get_rid , +.Nm rman_set_type , +.Nm rman_get_type .Nd resource management functions .Sh SYNOPSIS .In sys/types.h @@ -125,6 +127,10 @@ .Fn rman_set_rid "struct resource *r" "int rid" .Ft int .Fn rman_get_rid "struct resource *r" +.Ft void +.Fn rman_set_type "struct resource *r" "int type" +.Ft int +.Fn rman_get_type "struct resource *r" .Sh DESCRIPTION The .Nm @@ -457,6 +463,14 @@ The function retrieves this RID. .Pp The +.Fn rman_set_type +function associates a resource type with a resource +.Fa r . +The +.Fn rman_get_type +function retrieves this type. +.Pp +The .Fn rman_get_device function returns a pointer to the device which reserved the resource .Fa r . diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 792d03726c74..1393781a66fe 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -91,6 +91,7 @@ struct resource_i { device_t r_dev; /* device which has allocated this resource */ struct rman *r_rm; /* resource manager from whence this came */ int r_rid; /* optional rid for this resource. */ + int r_type; /* optional type for this resource. */ }; static int rman_debug = 0; @@ -927,6 +928,18 @@ rman_get_rid(struct resource *r) return (r->__r_i->r_rid); } +void +rman_set_type(struct resource *r, int type) +{ + r->__r_i->r_type = type; +} + +int +rman_get_type(struct resource *r) +{ + return (r->__r_i->r_type); +} + void rman_set_device(struct resource *r, device_t dev) { diff --git a/sys/sys/rman.h b/sys/sys/rman.h index 9e8e3b878c5a..b8b2016cc94a 100644 --- a/sys/sys/rman.h +++ b/sys/sys/rman.h @@ -134,6 +134,7 @@ void rman_get_mapping(struct resource *, struct resource_map *); int rman_get_rid(struct resource *); rman_res_t rman_get_size(struct resource *); rman_res_t rman_get_start(struct resource *); +int rman_get_type(struct resource *); void *rman_get_virtual(struct resource *); int rman_deactivate_resource(struct resource *r); int rman_fini(struct rman *rm); @@ -156,6 +157,7 @@ void rman_set_device(struct resource *_r, device_t _dev); void rman_set_irq_cookie(struct resource *_r, void *_c); void rman_set_mapping(struct resource *, struct resource_map *); void rman_set_rid(struct resource *_r, int _rid); +void rman_set_type(struct resource *_r, int _type); void rman_set_virtual(struct resource *_r, void *_v); extern struct rman_head rman_head;