From nobody Tue May 21 23:56:22 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 4VkWYL2ZSZz5L6j5; Tue, 21 May 2024 23:56:22 +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 4VkWYL1NVMz4jBy; Tue, 21 May 2024 23:56:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716335782; 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=qk+QV4ZJEXXsnzWZ0gn38HEuvna1F64nrJftwfGg7XA=; b=YpGjhJBT96AvyIVp11ho84IdfS/TN6DdvnNiB5kM8/WSf2//zwEiRE9ly5FdT9ITrIjRUa m46I9RhlngHvRkKPv2lVrXxieTBfrTpRgWt4JaBL891FgUmkjl7lgrdb7uGgFJM+cx5u9R P0MxvXhM3DxFoLvxSl2C3W692cs1aqMmUk2+p+3hYG5MbD5t3H3QEcTZHJz3rnMlxqpcim 49HW9bb2+QcCWUB77Ale+uzYtydRvV85ZctOiCSXEMmYjvVa7BkOtqBnwIKYYSyLhLz+4H PegZbPqk9wmH00sZ4s27ph2CzVKeAhzH8JE4EJ9eLhuqvezguDWBiGtk8pVIRw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716335782; a=rsa-sha256; cv=none; b=b+3e4TOqz/Co8rJBjFRzhm/MRTb3qSsYSOwqEgktWW8pgeCqsf7lwNGcjj6qneziEzob7h 4NQG2ngzde+3JEd2eWGj1l3bJddFYnx8K2WIn6j18ftVigDQlbZDUPg+QWRlr36cowdwiw 0uFydVOVHAWHSqAujwPvKH9I7J77EgMGPobUhArn5JoDCTzB5oxKi+JoM0CsKddf9T8L69 B3SMleujDjSU5FWxQ0ay+AkQPx2e1MBHar1xVb6ilZYRU8p0mO5gvw70UECXbii39FqhcD TPTRbK87W+FDWLCPF/6wmAKf72lkTMqBcl8me2+haiShzgd9OSp3Dgt7IEzSGg== 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=1716335782; 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=qk+QV4ZJEXXsnzWZ0gn38HEuvna1F64nrJftwfGg7XA=; b=YT+JlaSIhycrFOFJPQjWa7ffoENxHgGahtNR96mkVI25dvj932XnhMTYO1CqygD+1yad5l H+etbu2FtoySInU2Sd3tPRFqd7woMq7A/mk8emday+FVyMaQoFBOh5YTZl2o0tzIoW7eUK YYLIL/qHlQxLIgrJpN6U8UseEGskD8Dil27WWgFwn7UMtLQ8482uyqx+/KWkyYUi1mP0sn olYx8jZRitYPM13JgHqgA2D2C28ajDJcAGOjqZExk0wWTFU21hbmx3JnrKQPzITUHzBaL4 O9BYLDuH09UC+eYWuOff1okII+IkLsfRTbdHNWvHLrwStLTn45v/WiprUNLEoQ== 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 4VkWYL0zmZzjKC; Tue, 21 May 2024 23:56:22 +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 44LNuMEI032219; Tue, 21 May 2024 23:56:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44LNuMsn032216; Tue, 21 May 2024 23:56:22 GMT (envelope-from git) Date: Tue, 21 May 2024 23:56:22 GMT Message-Id: <202405212356.44LNuMsn032216@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 037946dc9b07 - main - kern/rman: remove rman_reserve_resource_bound(), partially revert 13fb6657723 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 037946dc9b07f7e0085e71798f5b397c5d9597db Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=037946dc9b07f7e0085e71798f5b397c5d9597db commit 037946dc9b07f7e0085e71798f5b397c5d9597db Author: Elliott Mitchell AuthorDate: 2024-05-09 04:55:28 +0000 Commit: Warner Losh CommitDate: 2024-05-21 23:52:24 +0000 kern/rman: remove rman_reserve_resource_bound(), partially revert 13fb6657723 Not once has rman_reserve_resource_bound() ever been used. There are though several uses of RF_ALIGNMENT. In light of this remove this extra and leave the actually used portion in place. This partially reverts commit 13fb6657723c1e9cb47bbd286942b432a4306b96. Reviewed by: imp,jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1224 --- share/man/man9/rman.9 | 35 +++++++++-------------------------- sys/kern/subr_rman.c | 23 ++++------------------- sys/sys/rman.h | 3 --- 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/share/man/man9/rman.9 b/share/man/man9/rman.9 index 35a2d176233c..d175b60b4010 100644 --- a/share/man/man9/rman.9 +++ b/share/man/man9/rman.9 @@ -40,7 +40,6 @@ .Nm rman_last_free_region , .Nm rman_release_resource , .Nm rman_reserve_resource , -.Nm rman_reserve_resource_bound , .Nm rman_make_alignment_flags , .Nm rman_get_start , .Nm rman_get_end , @@ -90,11 +89,6 @@ .Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count" .Fa "u_int flags" "device_t dev" .Fc -.Ft "struct resource *" -.Fo rman_reserve_resource_bound -.Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count" -.Fa "rman_res_t bound" "u_int flags" "device_t dev" -.Fc .Ft uint32_t .Fn rman_make_alignment_flags "uint32_t size" .Ft rman_res_t @@ -266,7 +260,7 @@ and are set to the bounds of the free region and zero is returned. .Pp The -.Fn rman_reserve_resource_bound +.Fn rman_reserve_resource function is where the bulk of the .Nm logic is located. @@ -279,7 +273,7 @@ The caller can specify the and .Fa end of an acceptable range, -as well as a boundary restriction and required alignment, +required alignment, and the code will attempt to find a free segment which fits. The .Fa start @@ -296,15 +290,13 @@ The alignment requirement .Pq if any is specified in .Fa flags . -The -.Fa bound -argument may be set to specify a boundary restriction such that an -allocated region may cross an address that is a multiple of the -boundary. -The -.Fa bound -argument must be a power of two. -It may be set to zero to specify no boundary restriction. +Often the +.Dv RF_ALIGNMENT_LOG2 +macro is used to specify alignment to a power-of-2 size, or +.Fn rman_make_alignment_flags +can be used to compute the +.Fa flags +value at runtime. A shared segment will be allocated if the .Dv RF_SHAREABLE flag is set, otherwise an exclusive segment will be allocated. @@ -312,15 +304,6 @@ If this shared segment already exists, the caller has its device added to the list of consumers. .Pp The -.Fn rman_reserve_resource -function is used to reserve resources within a previously established region. -It is a simplified interface to -.Fn rman_reserve_resource_bound -which passes 0 for the -.Fa bound -argument. -.Pp -The .Fn rman_make_alignment_flags function returns the flag mask corresponding to the desired alignment .Fa size . diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index d4da67b2f16f..2019e19090c0 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -429,13 +429,12 @@ rman_adjust_resource(struct resource *rr, rman_res_t start, rman_res_t end) #define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_PREFETCHABLE)) struct resource * -rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, - rman_res_t count, rman_res_t bound, u_int flags, - device_t dev) +rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end, + rman_res_t count, u_int flags, device_t dev) { u_int new_rflags; struct resource_i *r, *s, *rv; - rman_res_t rstart, rend, amask, bmask; + rman_res_t rstart, rend, amask; rv = NULL; @@ -472,8 +471,6 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, KASSERT(start <= RM_MAX_END - amask, ("start (%#jx) + amask (%#jx) would wrap around", start, amask)); - /* If bound is 0, bmask will also be 0 */ - bmask = ~(bound - 1); /* * First try to find an acceptable totally-unshared region. */ @@ -505,8 +502,6 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, */ do { rstart = (rstart + amask) & ~amask; - if (((rstart ^ (rstart + count - 1)) & bmask) != 0) - rstart += bound - (rstart & ~bmask); } while ((rstart & amask) != 0 && rstart < end && rstart < s->r_end); rend = ummin(s->r_end, ummax(rstart + count - 1, end)); @@ -607,8 +602,7 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end, if (SHARE_TYPE(s->r_flags) == SHARE_TYPE(flags) && s->r_start >= start && (s->r_end - s->r_start + 1) == count && - (s->r_start & amask) == 0 && - ((s->r_start ^ s->r_end) & bmask) == 0) { + (s->r_start & amask) == 0) { rv = int_alloc_resource(M_NOWAIT); if (rv == NULL) goto out; @@ -644,15 +638,6 @@ out: return (rv == NULL ? NULL : &rv->r_r); } -struct resource * -rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end, - rman_res_t count, u_int flags, device_t dev) -{ - - return (rman_reserve_resource_bound(rm, start, end, count, 0, flags, - dev)); -} - int rman_activate_resource(struct resource *re) { diff --git a/sys/sys/rman.h b/sys/sys/rman.h index b8b2016cc94a..70655339183b 100644 --- a/sys/sys/rman.h +++ b/sys/sys/rman.h @@ -148,9 +148,6 @@ int rman_release_resource(struct resource *r); struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags, device_t dev); -struct resource *rman_reserve_resource_bound(struct rman *rm, rman_res_t start, - rman_res_t end, rman_res_t count, rman_res_t bound, - u_int flags, device_t dev); void rman_set_bushandle(struct resource *_r, bus_space_handle_t _h); void rman_set_bustag(struct resource *_r, bus_space_tag_t _t); void rman_set_device(struct resource *_r, device_t _dev);