Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Use sysmon_taskq.
details: https://anonhg.NetBSD.org/src/rev/6bbd4b5eb3ff
branches: trunk
changeset: 546118:6bbd4b5eb3ff
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Apr 20 20:21:29 2003 +0000
description:
Use sysmon_taskq.
diffstat:
sys/dev/acpi/acpica/Osd/OsdSchedule.c | 172 +++------------------------------
sys/dev/acpi/files.acpi | 4 +-
2 files changed, 22 insertions(+), 154 deletions(-)
diffs (267 lines):
diff -r 41d2d13be04e -r 6bbd4b5eb3ff sys/dev/acpi/acpica/Osd/OsdSchedule.c
--- a/sys/dev/acpi/acpica/Osd/OsdSchedule.c Sun Apr 20 20:20:35 2003 +0000
+++ b/sys/dev/acpi/acpica/Osd/OsdSchedule.c Sun Apr 20 20:21:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: OsdSchedule.c,v 1.5 2003/01/19 16:50:16 thorpej Exp $ */
+/* $NetBSD: OsdSchedule.c,v 1.6 2003/04/20 20:21:30 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -42,14 +42,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: OsdSchedule.c,v 1.5 2003/01/19 16:50:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: OsdSchedule.c,v 1.6 2003/04/20 20:21:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
-#include <sys/lock.h>
-#include <sys/queue.h>
#include <sys/proc.h>
-#include <sys/kthread.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -57,46 +54,12 @@
#include <dev/acpi/acpi_osd.h>
+#include <dev/sysmon/sysmon_taskq.h>
+
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME("SCHEDULE")
/*
- * ACPICA uses callbacks that are priority scheduled. We run a kernel
- * thread to execute the callbacks. The callbacks may be scheduled
- * in interrupt context.
- */
-
-struct acpi_task {
- TAILQ_ENTRY(acpi_task) at_list;
- OSD_EXECUTION_CALLBACK at_func;
- void *at_arg;
- int at_pri;
-};
-
-TAILQ_HEAD(, acpi_task) acpi_task_queue =
- TAILQ_HEAD_INITIALIZER(acpi_task_queue);
-struct simplelock acpi_task_queue_slock = SIMPLELOCK_INITIALIZER;
-
-#define ACPI_TASK_QUEUE_LOCK(s) \
-do { \
- s = splhigh(); \
- simple_lock(&acpi_task_queue_slock); \
-} while (/*CONSTCOND*/0)
-
-#define ACPI_TASK_QUEUE_UNLOCK(s) \
-do { \
- simple_unlock(&acpi_task_queue_slock); \
- splx((s)); \
-} while (/*CONSTCOND*/0)
-
-__volatile int acpi_osd_sched_sem;
-
-struct proc *acpi_osd_sched_proc;
-
-void acpi_osd_sched_create_thread(void *);
-void acpi_osd_sched(void *);
-
-/*
* acpi_osd_sched_init:
*
* Initialize the APCICA Osd scheduler. Called from AcpiOsInitialize().
@@ -107,7 +70,7 @@
ACPI_FUNCTION_TRACE(__FUNCTION__);
- kthread_create(acpi_osd_sched_create_thread, NULL);
+ sysmon_task_queue_init();
return_VOID;
}
@@ -120,91 +83,15 @@
void
acpi_osd_sched_fini(void)
{
- int s;
ACPI_FUNCTION_TRACE(__FUNCTION__);
- ACPI_TASK_QUEUE_LOCK(s);
-
- acpi_osd_sched_sem = 1;
- wakeup(&acpi_task_queue);
-
- while (acpi_osd_sched_sem != 0)
- (void) ltsleep((void *) &acpi_osd_sched_sem, PVM, "asfini", 0,
- &acpi_task_queue_slock);
-
- ACPI_TASK_QUEUE_UNLOCK(s);
+ sysmon_task_queue_fini();
return_VOID;
}
/*
- * acpi_osd_sched_create_thread:
- *
- * Create the ACPICA Osd scheduler thread.
- */
-void
-acpi_osd_sched_create_thread(void *arg)
-{
- int error;
-
- error = kthread_create1(acpi_osd_sched, NULL, &acpi_osd_sched_proc,
- "acpi sched");
- if (error) {
- printf("ACPI: Unable to create scheduler thread, error = %d\n",
- error);
- panic("ACPI Osd Scheduler init failed");
- }
-}
-
-/*
- * acpi_osd_sched:
- *
- * The Osd Scheduler thread. We execute the callbacks that
- * have been queued for us.
- */
-void
-acpi_osd_sched(void *arg)
-{
- struct acpi_task *at;
- int s;
-
- /*
- * Run through all the tasks before we check
- * for the exit condition; it's probably more
- * imporatant that ACPICA get all of the work
- * it has expected to get done actually done.
- */
- for (;;) {
- ACPI_TASK_QUEUE_LOCK(s);
- at = TAILQ_FIRST(&acpi_task_queue);
- if (at == NULL) {
- /*
- * Check for the exit condition.
- */
- if (acpi_osd_sched_sem != 0) {
- /* Time to die. */
- acpi_osd_sched_sem = 0;
- wakeup((void *) &acpi_osd_sched_sem);
- ACPI_TASK_QUEUE_UNLOCK(s);
- kthread_exit(0);
- }
- (void) ltsleep(&acpi_task_queue, PVM, "acpisched",
- 0, &acpi_task_queue_slock);
- ACPI_TASK_QUEUE_UNLOCK(s);
- continue;
- }
- TAILQ_REMOVE(&acpi_task_queue, at, at_list);
- ACPI_TASK_QUEUE_UNLOCK(s);
-
- (*at->at_func)(at->at_arg);
- free(at, M_TEMP);
- }
-
- panic("acpi_osd_sched: impossible");
-}
-
-/*
* AcpiOsGetThreadId:
*
* Obtain the ID of the currently executing thread.
@@ -228,60 +115,41 @@
AcpiOsQueueForExecution(UINT32 Priority, OSD_EXECUTION_CALLBACK Function,
void *Context)
{
- struct acpi_task *at, *lat;
- int s;
+ int pri;
ACPI_FUNCTION_TRACE(__FUNCTION__);
- if (acpi_osd_sched_proc == NULL)
- printf("ACPI: WARNING: Callback scheduled before "
- "thread present.\n");
-
- if (Function == NULL)
- return_ACPI_STATUS(AE_BAD_PARAMETER);
-
- at = malloc(sizeof(*at), M_TEMP, M_NOWAIT);
- if (at == NULL)
- return_ACPI_STATUS(AE_NO_MEMORY);
-
- at->at_func = Function;
- at->at_arg = Context;
-
switch (Priority) {
case OSD_PRIORITY_GPE:
- at->at_pri = 3;
+ pri = 3;
break;
case OSD_PRIORITY_HIGH:
- at->at_pri = 2;
+ pri = 2;
break;
case OSD_PRIORITY_MED:
- at->at_pri = 1;
+ pri = 1;
break;
case OSD_PRIORITY_LO:
- at->at_pri = 0;
+ pri = 0;
break;
default:
- free(at, M_TEMP);
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
- ACPI_TASK_QUEUE_LOCK(s);
- TAILQ_FOREACH(lat, &acpi_task_queue, at_list) {
- if (at->at_pri > lat->at_pri) {
- TAILQ_INSERT_BEFORE(lat, at, at_list);
- break;
- }
+ switch (sysmon_task_queue_sched(pri, Function, Context)) {
+ case 0:
+ return_ACPI_STATUS(AE_OK);
+
+ case ENOMEM:
+ return_ACPI_STATUS(AE_NO_MEMORY);
+
+ default:
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
}
- if (lat == NULL)
- TAILQ_INSERT_TAIL(&acpi_task_queue, at, at_list);
- wakeup(&acpi_task_queue);
- ACPI_TASK_QUEUE_UNLOCK(s);
-
- return_ACPI_STATUS(AE_OK);
}
/*
diff -r 41d2d13be04e -r 6bbd4b5eb3ff sys/dev/acpi/files.acpi
--- a/sys/dev/acpi/files.acpi Sun Apr 20 20:20:35 2003 +0000
+++ b/sys/dev/acpi/files.acpi Sun Apr 20 20:21:29 2003 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: files.acpi,v 1.18 2003/04/17 20:56:29 matt Exp $
+# $NetBSD: files.acpi,v 1.19 2003/04/20 20:21:29 thorpej Exp $
include "dev/acpi/acpica/files.acpica"
defflag opt_acpi.h ACPIVERBOSE ACPI_DEBUG ACPI_PCI_FIXUP ACPI_ACTIVATE_DEV
-device acpi { }: sysmon_power
+device acpi { }: sysmon_power, sysmon_taskq
attach acpi at acpibus
file dev/acpi/acpi.c acpi needs-flag
file dev/acpi/acpi_resource.c acpi
Home |
Main Index |
Thread Index |
Old Index