Date: Tue, 08 Nov 2005 12:18:58 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: thierry@herbelot.com Cc: freebsd-current@freebsd.org Subject: Re: Attempting to sleep in interrupts Message-ID: <20051108.121858.51703736.imp@bsdimp.com> In-Reply-To: <200511081913.15042.thierry@herbelot.com> References: <20051107094655.GA76489@cirb503493.alcatel.com.au> <200511081913.15042.thierry@herbelot.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Does this solve the problem? Warner Index: subr_power.c =================================================================== RCS file: /cache/ncvs/src/sys/kern/subr_power.c,v retrieving revision 1.5 diff -u -r1.5 subr_power.c --- subr_power.c 2 Jan 2004 18:24:13 -0000 1.5 +++ subr_power.c 8 Nov 2005 19:17:54 -0000 @@ -32,10 +32,20 @@ #include <sys/proc.h> #include <sys/power.h> +#include <sys/taskqueue.h> static u_int power_pm_type = POWER_PM_TYPE_NONE; static power_pm_fn_t power_pm_fn = NULL; static void *power_pm_arg = NULL; +static struct task power_pm_task; + +static void +power_pm_deferred_fn(void *arg, int pending) +{ + int state = (int)arg; + + power_pm_fn(POWER_CMD_SUSPEND, power_pm_arg, state); +} int power_pm_register(u_int pm_type, power_pm_fn_t pm_fn, void *pm_arg) @@ -48,6 +58,7 @@ power_pm_fn = pm_fn; power_pm_arg = pm_arg; error = 0; + TASK_INIT(&power_pm_task, 0, power_pm_deferred_fn, NULL); } else { error = ENXIO; } @@ -72,8 +83,8 @@ state != POWER_SLEEP_STATE_SUSPEND && state != POWER_SLEEP_STATE_HIBERNATE) return; - - power_pm_fn(POWER_CMD_SUSPEND, power_pm_arg, state); + power_pm_task.ta_context = (void *)state; + taskqueue_enqueue(taskqueue_swi, &power_pm_task); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051108.121858.51703736.imp>