Using a sysmon taskqueue to report events; fixes crashes when booting

multi-user while calling sysmon_pswitch_event().

Imported from the khorben-n900 branch
This commit is contained in:
khorben 2013-06-03 01:47:58 +00:00
parent caa514cdf8
commit c31b1e76e3
7 changed files with 77 additions and 40 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_acad.c,v 1.5 2013/04/20 03:37:55 khorben Exp $ */
/* $NetBSD: n900_acad.c,v 1.6 2013/06/03 01:47:58 khorben Exp $ */
/*
* AC adapter driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_acad.c,v 1.5 2013/04/20 03:37:55 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_acad.c,v 1.6 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_acad.c,v 1.5 2013/04/20 03:37:55 khorben Exp $"
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -73,9 +74,9 @@ static int n900acad_detach(device_t, int);
CFATTACH_DECL_NEW(n900acad, sizeof(struct n900acad_softc),
n900acad_match, n900acad_attach, n900acad_detach, NULL);
static void n900acad_refresh(struct n900acad_softc *);
static void n900acad_refresh(void *);
static int n900acad_intr(void *v);
static int n900acad_intr(void *);
static int
@ -143,6 +144,7 @@ n900acad_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_ACADAPTER;
sysmon_pswitch_register(&sc->sc_smpsw);
@ -161,6 +163,7 @@ n900acad_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -170,13 +173,14 @@ n900acad_intr(void *v)
{
struct n900acad_softc *sc = v;
n900acad_refresh(sc);
sysmon_task_queue_sched(0, n900acad_refresh, sc);
return 1;
}
static void
n900acad_refresh(struct n900acad_softc *sc)
n900acad_refresh(void *v)
{
struct n900acad_softc *sc = v;
int i;
int event;

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_audjck.c,v 1.1 2013/05/06 22:56:54 khorben Exp $ */
/* $NetBSD: n900_audjck.c,v 1.2 2013/06/03 01:47:58 khorben Exp $ */
/*
* Audio jack driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_audjck.c,v 1.1 2013/05/06 22:56:54 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_audjck.c,v 1.2 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_audjck.c,v 1.1 2013/05/06 22:56:54 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -74,9 +75,9 @@ static int n900audjck_detach(device_t, int);
CFATTACH_DECL_NEW(n900audjck, sizeof(struct n900audjck_softc),
n900audjck_match, n900audjck_attach, n900audjck_detach, NULL);
static void n900audjck_refresh(struct n900audjck_softc *);
static void n900audjck_refresh(void *);
static int n900audjck_intr(void *v);
static int n900audjck_intr(void *);
static int
@ -144,6 +145,7 @@ n900audjck_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_HOTKEY;
sc->sc_state = PSWITCH_EVENT_RELEASED;
@ -164,6 +166,7 @@ n900audjck_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -173,13 +176,14 @@ n900audjck_intr(void *v)
{
struct n900audjck_softc *sc = v;
n900audjck_refresh(sc);
sysmon_task_queue_sched(0, n900audjck_refresh, sc);
return 1;
}
static void
n900audjck_refresh(struct n900audjck_softc *sc)
n900audjck_refresh(void *v)
{
struct n900audjck_softc *sc = v;
int i;
int event;

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_cambtn.c,v 1.1 2013/04/20 03:37:55 khorben Exp $ */
/* $NetBSD: n900_cambtn.c,v 1.2 2013/06/03 01:47:58 khorben Exp $ */
/*
* Camera button driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_cambtn.c,v 1.1 2013/04/20 03:37:55 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_cambtn.c,v 1.2 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_cambtn.c,v 1.1 2013/04/20 03:37:55 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -76,9 +77,10 @@ static int n900cambtn_detach(device_t, int);
CFATTACH_DECL_NEW(n900cambtn, sizeof(struct n900cambtn_softc),
n900cambtn_match, n900cambtn_attach, n900cambtn_detach, NULL);
static void n900cambtn_refresh(void *);
static void n900cambtn_refresh_pin(struct n900cambtn_softc *, int);
static int n900cambtn_intr(void *v);
static int n900cambtn_intr(void *);
static int
@ -163,6 +165,8 @@ n900cambtn_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
/* focus button */
sc->sc_smpsw[0].smpsw_name = kmem_asprintf("%s%s", device_xname(self),
"focus");
@ -193,6 +197,7 @@ n900cambtn_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -202,9 +207,17 @@ n900cambtn_intr(void *v)
{
struct n900cambtn_softc *sc = v;
sysmon_task_queue_sched(0, n900cambtn_refresh, sc);
return 1;
}
static void
n900cambtn_refresh(void *v)
{
struct n900cambtn_softc *sc = v;
n900cambtn_refresh_pin(sc, N900CAMBTN_PIN_CAPTURE);
n900cambtn_refresh_pin(sc, N900CAMBTN_PIN_FOCUS);
return 1;
}
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_camcvr.c,v 1.1 2013/04/20 03:37:55 khorben Exp $ */
/* $NetBSD: n900_camcvr.c,v 1.2 2013/06/03 01:47:58 khorben Exp $ */
/*
* Camera cover driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_camcvr.c,v 1.1 2013/04/20 03:37:55 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_camcvr.c,v 1.2 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_camcvr.c,v 1.1 2013/04/20 03:37:55 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -73,9 +74,9 @@ static int n900camcvr_detach(device_t, int);
CFATTACH_DECL_NEW(n900camcvr, sizeof(struct n900camcvr_softc),
n900camcvr_match, n900camcvr_attach, n900camcvr_detach, NULL);
static void n900camcvr_refresh(struct n900camcvr_softc *);
static void n900camcvr_refresh(void *);
static int n900camcvr_intr(void *v);
static int n900camcvr_intr(void *);
static int
@ -143,6 +144,7 @@ n900camcvr_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_HOTKEY;
sysmon_pswitch_register(&sc->sc_smpsw);
@ -162,6 +164,7 @@ n900camcvr_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -171,13 +174,14 @@ n900camcvr_intr(void *v)
{
struct n900camcvr_softc *sc = v;
n900camcvr_refresh(sc);
sysmon_task_queue_sched(0, n900camcvr_refresh, sc);
return 1;
}
static void
n900camcvr_refresh(struct n900camcvr_softc *sc)
n900camcvr_refresh(void *v)
{
struct n900camcvr_softc *sc = v;
int i;
int event;

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_kbdsld.c,v 1.1 2013/04/20 03:37:55 khorben Exp $ */
/* $NetBSD: n900_kbdsld.c,v 1.2 2013/06/03 01:47:58 khorben Exp $ */
/*
* Keypad slide driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_kbdsld.c,v 1.1 2013/04/20 03:37:55 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_kbdsld.c,v 1.2 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_kbdsld.c,v 1.1 2013/04/20 03:37:55 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -73,9 +74,9 @@ static int n900kbdsld_detach(device_t, int);
CFATTACH_DECL_NEW(n900kbdsld, sizeof(struct n900kbdsld_softc),
n900kbdsld_match, n900kbdsld_attach, n900kbdsld_detach, NULL);
static void n900kbdsld_refresh(struct n900kbdsld_softc *);
static void n900kbdsld_refresh(void *);
static int n900kbdsld_intr(void *v);
static int n900kbdsld_intr(void *);
static int
@ -143,6 +144,7 @@ n900kbdsld_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_HOTKEY;
sysmon_pswitch_register(&sc->sc_smpsw);
@ -161,6 +163,7 @@ n900kbdsld_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -170,13 +173,14 @@ n900kbdsld_intr(void *v)
{
struct n900kbdsld_softc *sc = v;
n900kbdsld_refresh(sc);
sysmon_task_queue_sched(0, n900kbdsld_refresh, sc);
return 1;
}
static void
n900kbdsld_refresh(struct n900kbdsld_softc *sc)
n900kbdsld_refresh(void *v)
{
struct n900kbdsld_softc *sc = v;
int i;
int event;

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_lckbtn.c,v 1.3 2013/04/20 03:37:55 khorben Exp $ */
/* $NetBSD: n900_lckbtn.c,v 1.4 2013/06/03 01:47:58 khorben Exp $ */
/*
* Lock button driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_lckbtn.c,v 1.3 2013/04/20 03:37:55 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_lckbtn.c,v 1.4 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_lckbtn.c,v 1.3 2013/04/20 03:37:55 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -74,9 +75,9 @@ static int n900lckbtn_detach(device_t, int);
CFATTACH_DECL_NEW(n900lckbtn, sizeof(struct n900lckbtn_softc),
n900lckbtn_match, n900lckbtn_attach, n900lckbtn_detach, NULL);
static void n900lckbtn_refresh(struct n900lckbtn_softc *);
static void n900lckbtn_refresh(void *);
static int n900lckbtn_intr(void *v);
static int n900lckbtn_intr(void *);
static int
@ -144,6 +145,7 @@ n900lckbtn_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_HOTKEY;
sc->sc_state = PSWITCH_EVENT_RELEASED;
@ -161,6 +163,7 @@ n900lckbtn_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -170,13 +173,14 @@ n900lckbtn_intr(void *v)
{
struct n900lckbtn_softc *sc = v;
n900lckbtn_refresh(sc);
sysmon_task_queue_sched(0, n900lckbtn_refresh, sc);
return 1;
}
static void
n900lckbtn_refresh(struct n900lckbtn_softc *sc)
n900lckbtn_refresh(void *v)
{
struct n900lckbtn_softc *sc = v;
int i;
int event;

View File

@ -1,4 +1,4 @@
/* $NetBSD: n900_prxmty.c,v 1.1 2013/05/06 22:56:54 khorben Exp $ */
/* $NetBSD: n900_prxmty.c,v 1.2 2013/06/03 01:47:58 khorben Exp $ */
/*
* Proximity sensor driver for the Nokia N900.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: n900_prxmty.c,v 1.1 2013/05/06 22:56:54 khorben Exp $");
__KERNEL_RCSID(0, "$NetBSD: n900_prxmty.c,v 1.2 2013/06/03 01:47:58 khorben Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: n900_prxmty.c,v 1.1 2013/05/06 22:56:54 khorben Exp
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
#include <arm/omap/omap2_gpio.h>
@ -73,9 +74,9 @@ static int n900prxmty_detach(device_t, int);
CFATTACH_DECL_NEW(n900prxmty, sizeof(struct n900prxmty_softc),
n900prxmty_match, n900prxmty_attach, n900prxmty_detach, NULL);
static void n900prxmty_refresh(struct n900prxmty_softc *);
static void n900prxmty_refresh(void *);
static int n900prxmty_intr(void *v);
static int n900prxmty_intr(void *);
static int
@ -143,6 +144,7 @@ n900prxmty_attach(device_t parent, device_t self, void *aux)
"couldn't establish power handler\n");
}
sysmon_task_queue_init();
sc->sc_smpsw.smpsw_name = device_xname(self);
sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_HOTKEY;
sysmon_pswitch_register(&sc->sc_smpsw);
@ -161,6 +163,7 @@ n900prxmty_detach(device_t self, int flags)
gpio_pin_unmap(sc->sc_gpio, &sc->sc_map);
pmf_device_deregister(self);
sysmon_task_queue_fini();
return 0;
}
@ -170,13 +173,14 @@ n900prxmty_intr(void *v)
{
struct n900prxmty_softc *sc = v;
n900prxmty_refresh(sc);
sysmon_task_queue_sched(0, n900prxmty_refresh, sc);
return 1;
}
static void
n900prxmty_refresh(struct n900prxmty_softc *sc)
n900prxmty_refresh(void *v)
{
struct n900prxmty_softc *sc = v;
int i;
int event;