mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
kern/rman: remove rman_reserve_resource_bound(), partially revert 13fb665772
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 13fb665772
.
Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
This commit is contained in:
parent
beb1165a01
commit
037946dc9b
|
@ -40,7 +40,6 @@
|
||||||
.Nm rman_last_free_region ,
|
.Nm rman_last_free_region ,
|
||||||
.Nm rman_release_resource ,
|
.Nm rman_release_resource ,
|
||||||
.Nm rman_reserve_resource ,
|
.Nm rman_reserve_resource ,
|
||||||
.Nm rman_reserve_resource_bound ,
|
|
||||||
.Nm rman_make_alignment_flags ,
|
.Nm rman_make_alignment_flags ,
|
||||||
.Nm rman_get_start ,
|
.Nm rman_get_start ,
|
||||||
.Nm rman_get_end ,
|
.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 "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count"
|
||||||
.Fa "u_int flags" "device_t dev"
|
.Fa "u_int flags" "device_t dev"
|
||||||
.Fc
|
.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
|
.Ft uint32_t
|
||||||
.Fn rman_make_alignment_flags "uint32_t size"
|
.Fn rman_make_alignment_flags "uint32_t size"
|
||||||
.Ft rman_res_t
|
.Ft rman_res_t
|
||||||
|
@ -266,7 +260,7 @@ and
|
||||||
are set to the bounds of the free region and zero is returned.
|
are set to the bounds of the free region and zero is returned.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn rman_reserve_resource_bound
|
.Fn rman_reserve_resource
|
||||||
function is where the bulk of the
|
function is where the bulk of the
|
||||||
.Nm
|
.Nm
|
||||||
logic is located.
|
logic is located.
|
||||||
|
@ -279,7 +273,7 @@ The caller can specify the
|
||||||
and
|
and
|
||||||
.Fa end
|
.Fa end
|
||||||
of an acceptable range,
|
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.
|
and the code will attempt to find a free segment which fits.
|
||||||
The
|
The
|
||||||
.Fa start
|
.Fa start
|
||||||
|
@ -296,15 +290,13 @@ The alignment requirement
|
||||||
.Pq if any
|
.Pq if any
|
||||||
is specified in
|
is specified in
|
||||||
.Fa flags .
|
.Fa flags .
|
||||||
The
|
Often the
|
||||||
.Fa bound
|
.Dv RF_ALIGNMENT_LOG2
|
||||||
argument may be set to specify a boundary restriction such that an
|
macro is used to specify alignment to a power-of-2 size, or
|
||||||
allocated region may cross an address that is a multiple of the
|
.Fn rman_make_alignment_flags
|
||||||
boundary.
|
can be used to compute the
|
||||||
The
|
.Fa flags
|
||||||
.Fa bound
|
value at runtime.
|
||||||
argument must be a power of two.
|
|
||||||
It may be set to zero to specify no boundary restriction.
|
|
||||||
A shared segment will be allocated if the
|
A shared segment will be allocated if the
|
||||||
.Dv RF_SHAREABLE
|
.Dv RF_SHAREABLE
|
||||||
flag is set, otherwise an exclusive segment will be allocated.
|
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.
|
added to the list of consumers.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
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
|
.Fn rman_make_alignment_flags
|
||||||
function returns the flag mask corresponding to the desired alignment
|
function returns the flag mask corresponding to the desired alignment
|
||||||
.Fa size .
|
.Fa size .
|
||||||
|
|
|
@ -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))
|
#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_PREFETCHABLE))
|
||||||
|
|
||||||
struct resource *
|
struct resource *
|
||||||
rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end,
|
rman_reserve_resource(struct rman *rm, rman_res_t start, rman_res_t end,
|
||||||
rman_res_t count, rman_res_t bound, u_int flags,
|
rman_res_t count, u_int flags, device_t dev)
|
||||||
device_t dev)
|
|
||||||
{
|
{
|
||||||
u_int new_rflags;
|
u_int new_rflags;
|
||||||
struct resource_i *r, *s, *rv;
|
struct resource_i *r, *s, *rv;
|
||||||
rman_res_t rstart, rend, amask, bmask;
|
rman_res_t rstart, rend, amask;
|
||||||
|
|
||||||
rv = NULL;
|
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,
|
KASSERT(start <= RM_MAX_END - amask,
|
||||||
("start (%#jx) + amask (%#jx) would wrap around", start, 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.
|
* 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 {
|
do {
|
||||||
rstart = (rstart + amask) & ~amask;
|
rstart = (rstart + amask) & ~amask;
|
||||||
if (((rstart ^ (rstart + count - 1)) & bmask) != 0)
|
|
||||||
rstart += bound - (rstart & ~bmask);
|
|
||||||
} while ((rstart & amask) != 0 && rstart < end &&
|
} while ((rstart & amask) != 0 && rstart < end &&
|
||||||
rstart < s->r_end);
|
rstart < s->r_end);
|
||||||
rend = ummin(s->r_end, ummax(rstart + count - 1, 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) &&
|
if (SHARE_TYPE(s->r_flags) == SHARE_TYPE(flags) &&
|
||||||
s->r_start >= start &&
|
s->r_start >= start &&
|
||||||
(s->r_end - s->r_start + 1) == count &&
|
(s->r_end - s->r_start + 1) == count &&
|
||||||
(s->r_start & amask) == 0 &&
|
(s->r_start & amask) == 0) {
|
||||||
((s->r_start ^ s->r_end) & bmask) == 0) {
|
|
||||||
rv = int_alloc_resource(M_NOWAIT);
|
rv = int_alloc_resource(M_NOWAIT);
|
||||||
if (rv == NULL)
|
if (rv == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -644,15 +638,6 @@ rman_reserve_resource_bound(struct rman *rm, rman_res_t start, rman_res_t end,
|
||||||
return (rv == NULL ? NULL : &rv->r_r);
|
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
|
int
|
||||||
rman_activate_resource(struct resource *re)
|
rman_activate_resource(struct resource *re)
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,9 +148,6 @@ int rman_release_resource(struct resource *r);
|
||||||
struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,
|
struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,
|
||||||
rman_res_t end, rman_res_t count,
|
rman_res_t end, rman_res_t count,
|
||||||
u_int flags, device_t dev);
|
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_bushandle(struct resource *_r, bus_space_handle_t _h);
|
||||||
void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
|
void rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
|
||||||
void rman_set_device(struct resource *_r, device_t _dev);
|
void rman_set_device(struct resource *_r, device_t _dev);
|
||||||
|
|
Loading…
Reference in a new issue