aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/aac/aac.c3
-rw-r--r--sys/dev/acpica/Osd/OsdSchedule.c1
-rw-r--r--sys/dev/amr/amr.c4
-rw-r--r--sys/dev/mly/mly.c4
-rw-r--r--sys/kern/subr_taskqueue.c43
-rw-r--r--sys/sys/taskqueue.h20
6 files changed, 13 insertions, 62 deletions
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c
index 535a78324c43..4eef4e757ab4 100644
--- a/sys/dev/aac/aac.c
+++ b/sys/dev/aac/aac.c
@@ -434,9 +434,6 @@ aac_free(struct aac_softc *sc)
if (sc->aac_regs_resource != NULL)
bus_release_resource(sc->aac_dev, SYS_RES_MEMORY,
sc->aac_regs_rid, sc->aac_regs_resource);
-#if __FreeBSD_version >= 500005
- TASK_DESTROY(&sc->aac_task_complete);
-#endif
}
/*
diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c
index 6dcc5212176a..8a952dff8f29 100644
--- a/sys/dev/acpica/Osd/OsdSchedule.c
+++ b/sys/dev/acpica/Osd/OsdSchedule.c
@@ -113,7 +113,6 @@ AcpiOsExecuteQueue(void *arg, int pending)
Function = (OSD_EXECUTION_CALLBACK)at->at_function;
Context = at->at_context;
- TASK_DESTROY(at);
free(at, M_ACPITASK);
Function(Context);
diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c
index 1e928c13225e..2b5eca1622ff 100644
--- a/sys/dev/amr/amr.c
+++ b/sys/dev/amr/amr.c
@@ -320,10 +320,6 @@ amr_free(struct amr_softc *sc)
TAILQ_REMOVE(&sc->amr_cmd_clusters, acc, acc_link);
amr_freecmd_cluster(acc);
}
-
-#if __FreeBSD_version >= 500005
- TASK_DESTROY(&sc->amr_task_complete);
-#endif
}
/*******************************************************************************
diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c
index 06115f3ba33a..e7b7a5c83379 100644
--- a/sys/dev/mly/mly.c
+++ b/sys/dev/mly/mly.c
@@ -732,10 +732,6 @@ mly_free(struct mly_softc *sc)
/* release the register window mapping */
if (sc->mly_regs_resource != NULL)
bus_release_resource(sc->mly_dev, SYS_RES_MEMORY, sc->mly_regs_rid, sc->mly_regs_resource);
-
-#if __FreeBSD_version >= 500005
- TASK_DESTROY(&sc->mly_task_complete);
-#endif
}
/********************************************************************************
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index e75a0c27001c..6052aeaf1b42 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -29,9 +29,9 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/lock.h>
-#include <sys/interrupt.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/taskqueue.h>
@@ -65,28 +65,6 @@ init_taskqueue_list(void *data __unused)
SYSINIT(taskqueue_list, SI_SUB_INTRINSIC, SI_ORDER_ANY, init_taskqueue_list,
NULL);
-void
-task_init(struct task *task, int priority, task_fn_t *func, void *context)
-{
-
- KASSERT(task != NULL, ("task == NULL"));
-
- mtx_init(&task->ta_mutex, "task", MTX_DEF);
- mtx_lock(&task->ta_mutex);
- task->ta_pending = 0;
- task->ta_priority = priority;
- task->ta_func = func;
- task->ta_context = context;
- mtx_unlock(&task->ta_mutex);
-}
-
-void
-task_destroy(struct task *task)
-{
-
- mtx_destroy(&task->ta_mutex);
-}
-
struct taskqueue *
taskqueue_create(const char *name, int mflags,
taskqueue_enqueue_fn enqueue, void *context)
@@ -156,10 +134,11 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
struct task *ins;
struct task *prev;
+ mtx_lock(&queue->tq_mutex);
+
/*
* Don't allow new tasks on a queue which is being freed.
*/
- mtx_lock(&queue->tq_mutex);
if (queue->tq_draining) {
mtx_unlock(&queue->tq_mutex);
return EPIPE;
@@ -168,10 +147,8 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
/*
* Count multiple enqueues.
*/
- mtx_lock(&task->ta_mutex);
if (task->ta_pending) {
task->ta_pending++;
- mtx_unlock(&task->ta_mutex);
mtx_unlock(&queue->tq_mutex);
return 0;
}
@@ -196,11 +173,11 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
}
task->ta_pending = 1;
- mtx_unlock(&task->ta_mutex);
-
if (queue->tq_enqueue)
queue->tq_enqueue(queue->tq_context);
+
mtx_unlock(&queue->tq_mutex);
+
return 0;
}
@@ -208,8 +185,6 @@ void
taskqueue_run(struct taskqueue *queue)
{
struct task *task;
- task_fn_t *saved_func;
- void *arg;
int pending;
mtx_lock(&queue->tq_mutex);
@@ -219,16 +194,12 @@ taskqueue_run(struct taskqueue *queue)
* zero its pending count.
*/
task = STAILQ_FIRST(&queue->tq_queue);
- mtx_lock(&task->ta_mutex);
STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link);
- mtx_unlock(&queue->tq_mutex);
pending = task->ta_pending;
task->ta_pending = 0;
- saved_func = task->ta_func;
- arg = task->ta_context;
- mtx_unlock(&task->ta_mutex);
+ mtx_unlock(&queue->tq_mutex);
- saved_func(arg, pending);
+ task->ta_func(task->ta_context, pending);
mtx_lock(&queue->tq_mutex);
}
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h
index dc940c94af8b..406a715380c4 100644
--- a/sys/sys/taskqueue.h
+++ b/sys/sys/taskqueue.h
@@ -34,8 +34,6 @@
#endif
#include <sys/queue.h>
-#include <sys/_lock.h>
-#include <sys/_mutex.h>
struct taskqueue;
@@ -62,12 +60,8 @@ struct task {
int ta_priority; /* priority of task in queue */
task_fn_t *ta_func; /* task handler */
void *ta_context; /* argument for handler */
- struct mtx ta_mutex; /* lock for each task */
};
-void task_init(struct task *task, int priority, task_fn_t *func,
- void *context);
-void task_destroy(struct task *task);
struct taskqueue *taskqueue_create(const char *name, int mflags,
taskqueue_enqueue_fn enqueue,
void *context);
@@ -79,14 +73,12 @@ void taskqueue_run(struct taskqueue *queue);
/*
* Initialise a task structure.
*/
-#define TASK_INIT(task, priority, func, context) \
- task_init((task), (priority), (func), (context))
-
-/*
- * Destroy a task structure.
- */
-#define TASK_DESTROY(task) \
- task_destroy((task))
+#define TASK_INIT(task, priority, func, context) do { \
+ (task)->ta_pending = 0; \
+ (task)->ta_priority = (priority); \
+ (task)->ta_func = (func); \
+ (task)->ta_context = (context); \
+} while (0)
/*
* Declare a reference to a taskqueue.