aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/random
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>2013-10-08 18:48:11 +0000
committerMark Murray <markm@FreeBSD.org>2013-10-08 18:48:11 +0000
commit623f70165fdf2fcc0770954a266fdcd27ec53384 (patch)
tree227ff07188b4335eacde8a227125faba40c934b2 /sys/dev/random
parentdb3fcaf97086f96ddb4299115efe887680475e82 (diff)
downloadsrc-623f70165fdf2fcc0770954a266fdcd27ec53384.tar.gz
src-623f70165fdf2fcc0770954a266fdcd27ec53384.zip
Time to eat crow for me.
I replaced the sx_* locks that Arthur used with regular mutexes; this turned out the be the wrong thing to do as the locks need to be sleepable. Revert this folly. Submitted by: Arthur Mesh <arthurmesh@gmail.com> (In original diff)
Notes
Notes: svn path=/projects/random_number_generator/; revision=256159
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/live_entropy_sources.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sys/dev/random/live_entropy_sources.c b/sys/dev/random/live_entropy_sources.c
index d9af30b732de..d406ebd20861 100644
--- a/sys/dev/random/live_entropy_sources.c
+++ b/sys/dev/random/live_entropy_sources.c
@@ -53,10 +53,9 @@ LIST_HEAD(les_head, live_entropy_sources);
static struct les_head sources = LIST_HEAD_INITIALIZER(sources);
/*
- * The harvest mutex protects the consistency of the entropy fifos and
- * empty fifo and other associated structures.
+ * The live_lock protects the consistency of the "struct les_head sources"
*/
-struct mtx live_mtx;
+static struct sx les_lock; /* need a sleepable lock */
void
live_entropy_source_register(struct random_hardware_source *rsource)
@@ -68,9 +67,9 @@ live_entropy_source_register(struct random_hardware_source *rsource)
les = malloc(sizeof(struct live_entropy_sources), M_ENTROPY, M_WAITOK);
les->rsource = rsource;
- mtx_lock(&live_mtx);
+ sx_xlock(&les_lock);
LIST_INSERT_HEAD(&sources, les, entries);
- mtx_unlock(&live_mtx);
+ sx_xunlock(&les_lock);
}
void
@@ -80,13 +79,13 @@ live_entropy_source_deregister(struct random_hardware_source *rsource)
KASSERT(rsource != NULL, ("invalid input to %s", __func__));
- mtx_lock(&live_mtx);
+ sx_xlock(&les_lock);
LIST_FOREACH(les, &sources, entries)
if (les->rsource == rsource) {
LIST_REMOVE(les, entries);
break;
}
- mtx_unlock(&live_mtx);
+ sx_xunlock(&les_lock);
if (les != NULL)
free(les, M_ENTROPY);
}
@@ -99,7 +98,7 @@ live_entropy_source_handler(SYSCTL_HANDLER_ARGS)
count = error = 0;
- mtx_lock(&live_mtx);
+ sx_slock(&les_lock);
if (LIST_EMPTY(&sources))
error = SYSCTL_OUT(req, "", 0);
@@ -116,7 +115,7 @@ live_entropy_source_handler(SYSCTL_HANDLER_ARGS)
}
}
- mtx_unlock(&live_mtx);
+ sx_sunlock(&les_lock);
return (error);
}
@@ -130,7 +129,7 @@ live_entropy_sources_init(void *unused)
NULL, 0, live_entropy_source_handler, "",
"List of Active Live Entropy Sources");
- mtx_init(&live_mtx, "live entropy source mutex", NULL, MTX_DEF);
+ sx_init(&les_lock, "live_entropy_sources");
}
/*
@@ -151,7 +150,7 @@ live_entropy_sources_feed(int rounds, event_proc_f entropy_processor)
struct live_entropy_sources *les;
int i, n;
- mtx_lock(&live_mtx);
+ sx_slock(&les_lock);
/*
* Walk over all of live entropy sources, and feed their output
@@ -180,14 +179,14 @@ live_entropy_sources_feed(int rounds, event_proc_f entropy_processor)
}
- mtx_unlock(&live_mtx);
+ sx_sunlock(&les_lock);
}
static void
live_entropy_sources_deinit(void *unused)
{
- mtx_destroy(&live_mtx);
+ sx_destroy(&les_lock);
}
SYSINIT(random_adaptors, SI_SUB_DRIVERS, SI_ORDER_FIRST,