summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/man/man9/rman.913
-rw-r--r--sys/kern/subr_rman.c112
-rw-r--r--sys/sys/rman.h4
3 files changed, 16 insertions, 113 deletions
diff --git a/share/man/man9/rman.9 b/share/man/man9/rman.9
index d9a2092..4c8ef29 100644
--- a/share/man/man9/rman.9
+++ b/share/man/man9/rman.9
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 29, 2011
+.Dd July 15, 2014
.Dt RMAN 9
.Os
.Sh NAME
@@ -141,13 +141,11 @@ represented by a 16-bit flag register, as follows.
#define RF_ALLOCATED 0x0001 /* resource has been reserved */
#define RF_ACTIVE 0x0002 /* resource allocation has been activated */
#define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */
-#define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */
-#define RF_WANTED 0x0010 /* somebody is waiting for this resource */
#define RF_FIRSTSHARE 0x0020 /* first in sharing list */
#define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */
.Ed
.Pp
-The remainder of the flag bits are used to represent the desired alignment
+Bits 15:10 of the flag register are used to represent the desired alignment
of the resource within the region.
.Pp
The
@@ -299,12 +297,9 @@ The
.Fa bound
argument must be a power of two.
It may be set to zero to specify no boundary restriction.
-The default behavior is to allocate an exclusive segment, unless the
+A shared segment will be allocated if the
.Dv RF_SHAREABLE
-or
-.Dv RF_TIMESHARE
-flags are set, in which case a shared
-segment will be allocated.
+flag is set, otherwise an exclusive segment will be allocated.
If this shared segment already exists, the caller has its device
added to the list of consumers.
.Pp
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index cc41e29..568f566 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -110,9 +110,6 @@ static MALLOC_DEFINE(M_RMAN, "rman", "Resource manager");
struct rman_head rman_head;
static struct mtx rman_mtx; /* mutex to protect rman_head */
-static int int_rman_activate_resource(struct rman *rm, struct resource_i *r,
- struct resource_i **whohas);
-static int int_rman_deactivate_resource(struct resource_i *r);
static int int_rman_release_resource(struct rman *rm, struct resource_i *r);
static __inline struct resource_i *
@@ -322,7 +319,7 @@ rman_adjust_resource(struct resource *rr, u_long start, u_long end)
/* Not supported for shared resources. */
r = rr->__r_i;
- if (r->r_flags & (RF_TIMESHARE | RF_SHAREABLE))
+ if (r->r_flags & RF_SHAREABLE)
return (EINVAL);
/*
@@ -435,7 +432,7 @@ rman_adjust_resource(struct resource *rr, u_long start, u_long end)
return (0);
}
-#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_TIMESHARE | RF_PREFETCHABLE))
+#define SHARE_TYPE(f) (f & (RF_SHAREABLE | RF_PREFETCHABLE))
struct resource *
rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
@@ -452,10 +449,9 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
"length %#lx, flags %u, device %s\n", rm->rm_descr, start, end,
count, flags,
dev == NULL ? "<null>" : device_get_nameunit(dev)));
- KASSERT((flags & (RF_WANTED | RF_FIRSTSHARE)) == 0,
+ KASSERT((flags & RF_FIRSTSHARE) == 0,
("invalid flags %#x", flags));
- new_rflags = (flags & ~(RF_ACTIVE | RF_WANTED | RF_FIRSTSHARE)) |
- RF_ALLOCATED;
+ new_rflags = (flags & ~RF_FIRSTSHARE) | RF_ALLOCATED;
mtx_lock(rm->rm_mtx);
@@ -601,7 +597,7 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
* additional work, but this does not seem warranted.)
*/
DPRINTF(("no unshared regions found\n"));
- if ((flags & (RF_SHAREABLE | RF_TIMESHARE)) == 0)
+ if ((flags & RF_SHAREABLE) == 0)
goto out;
for (s = r; s && s->r_end <= end; s = TAILQ_NEXT(s, r_link)) {
@@ -636,25 +632,11 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
goto out;
}
}
-
/*
* We couldn't find anything.
*/
-out:
- /*
- * If the user specified RF_ACTIVE in flags, we attempt to atomically
- * activate the resource. If this fails, we release the resource
- * and indicate overall failure. (This behavior probably doesn't
- * make sense for RF_TIMESHARE-type resources.)
- */
- if (rv && (flags & RF_ACTIVE) != 0) {
- struct resource_i *whohas;
- if (int_rman_activate_resource(rm, rv, &whohas)) {
- int_rman_release_resource(rm, rv);
- rv = NULL;
- }
- }
+out:
mtx_unlock(rm->rm_mtx);
return (rv == NULL ? NULL : &rv->r_r);
}
@@ -668,91 +650,17 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count,
dev));
}
-static int
-int_rman_activate_resource(struct rman *rm, struct resource_i *r,
- struct resource_i **whohas)
-{
- struct resource_i *s;
- int ok;
-
- /*
- * If we are not timesharing, then there is nothing much to do.
- * If we already have the resource, then there is nothing at all to do.
- * If we are not on a sharing list with anybody else, then there is
- * little to do.
- */
- if ((r->r_flags & RF_TIMESHARE) == 0
- || (r->r_flags & RF_ACTIVE) != 0
- || r->r_sharehead == NULL) {
- r->r_flags |= RF_ACTIVE;
- return 0;
- }
-
- ok = 1;
- for (s = LIST_FIRST(r->r_sharehead); s && ok;
- s = LIST_NEXT(s, r_sharelink)) {
- if ((s->r_flags & RF_ACTIVE) != 0) {
- ok = 0;
- *whohas = s;
- }
- }
- if (ok) {
- r->r_flags |= RF_ACTIVE;
- return 0;
- }
- return EBUSY;
-}
-
int
rman_activate_resource(struct resource *re)
{
- int rv;
- struct resource_i *r, *whohas;
+ struct resource_i *r;
struct rman *rm;
r = re->__r_i;
rm = r->r_rm;
mtx_lock(rm->rm_mtx);
- rv = int_rman_activate_resource(rm, r, &whohas);
+ r->r_flags |= RF_ACTIVE;
mtx_unlock(rm->rm_mtx);
- return rv;
-}
-
-int
-rman_await_resource(struct resource *re, int pri, int timo)
-{
- int rv;
- struct resource_i *r, *whohas;
- struct rman *rm;
-
- r = re->__r_i;
- rm = r->r_rm;
- mtx_lock(rm->rm_mtx);
- for (;;) {
- rv = int_rman_activate_resource(rm, r, &whohas);
- if (rv != EBUSY)
- return (rv); /* returns with mutex held */
-
- if (r->r_sharehead == NULL)
- panic("rman_await_resource");
- whohas->r_flags |= RF_WANTED;
- rv = msleep(r->r_sharehead, rm->rm_mtx, pri, "rmwait", timo);
- if (rv) {
- mtx_unlock(rm->rm_mtx);
- return (rv);
- }
- }
-}
-
-static int
-int_rman_deactivate_resource(struct resource_i *r)
-{
-
- r->r_flags &= ~RF_ACTIVE;
- if (r->r_flags & RF_WANTED) {
- r->r_flags &= ~RF_WANTED;
- wakeup(r->r_sharehead);
- }
return 0;
}
@@ -763,7 +671,7 @@ rman_deactivate_resource(struct resource *r)
rm = r->__r_i->r_rm;
mtx_lock(rm->rm_mtx);
- int_rman_deactivate_resource(r->__r_i);
+ r->__r_i->r_flags &= ~RF_ACTIVE;
mtx_unlock(rm->rm_mtx);
return 0;
}
@@ -774,7 +682,7 @@ int_rman_release_resource(struct rman *rm, struct resource_i *r)
struct resource_i *s, *t;
if (r->r_flags & RF_ACTIVE)
- int_rman_deactivate_resource(r);
+ r->r_flags &= ~RF_ACTIVE;
/*
* Check for a sharing list first. If there is one, then we don't
diff --git a/sys/sys/rman.h b/sys/sys/rman.h
index 1914a72..d98dac7 100644
--- a/sys/sys/rman.h
+++ b/sys/sys/rman.h
@@ -42,8 +42,8 @@
#define RF_ALLOCATED 0x0001 /* resource has been reserved */
#define RF_ACTIVE 0x0002 /* resource allocation has been activated */
#define RF_SHAREABLE 0x0004 /* resource permits contemporaneous sharing */
-#define RF_TIMESHARE 0x0008 /* resource permits time-division sharing */
-#define RF_WANTED 0x0010 /* somebody is waiting for this resource */
+#define RF_SPARE1 0x0008
+#define RF_SPARE2 0x0010
#define RF_FIRSTSHARE 0x0020 /* first in sharing list */
#define RF_PREFETCHABLE 0x0040 /* resource is prefetchable */
#define RF_OPTIONAL 0x0080 /* for bus_alloc_resources() */
OpenPOWER on IntegriCloud