From 2823fb7428f42722ea57f545a04e08828ab5d4b5 Mon Sep 17 00:00:00 2001 From: ad Date: Tue, 9 Oct 2007 12:45:27 +0000 Subject: [PATCH] Defer wakeup() to a soft interrupt, since lptintr() can be called above IPL_SCHED. --- sys/dev/ic/lpt.c | 18 ++++++++++++++---- sys/dev/ic/lptvar.h | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/lpt.c b/sys/dev/ic/lpt.c index e75575863746..06c6c8d37c85 100644 --- a/sys/dev/ic/lpt.c +++ b/sys/dev/ic/lpt.c @@ -1,4 +1,4 @@ -/* $NetBSD: lpt.c,v 1.70 2007/07/09 21:00:37 ad Exp $ */ +/* $NetBSD: lpt.c,v 1.71 2007/10/09 12:45:27 ad Exp $ */ /* * Copyright (c) 1993, 1994 Charles M. Hannum. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.70 2007/07/09 21:00:37 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.71 2007/10/09 12:45:27 ad Exp $"); #include #include @@ -67,9 +67,9 @@ __KERNEL_RCSID(0, "$NetBSD: lpt.c,v 1.70 2007/07/09 21:00:37 ad Exp $"); #include #include #include +#include #include -#include #include #include @@ -104,6 +104,8 @@ const struct cdevsw lpt_cdevsw = { #define LPTUNIT(s) (minor(s) & 0x1f) #define LPTFLAGS(s) (minor(s) & 0xe0) +static void lptsoftintr(void *); + void lpt_attach_subr(sc) struct lpt_softc *sc; @@ -119,6 +121,7 @@ lpt_attach_subr(sc) bus_space_write_1(iot, ioh, lpt_control, LPC_NINIT); callout_init(&sc->sc_wakeup_ch, 0); + sc->sc_sih = softint_establish(SOFTINT_SERIAL, lptsoftintr, sc); sc->sc_dev_ok = 1; } @@ -402,12 +405,19 @@ lptintr(arg) if (sc->sc_count == 0) { /* none, wake up the top half to get more */ - wakeup((void *)sc); + softint_schedule(sc->sc_sih); } return 1; } +static void +lptsoftintr(void *cookie) +{ + + wakeup(cookie); +} + int lptioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) diff --git a/sys/dev/ic/lptvar.h b/sys/dev/ic/lptvar.h index acfd977e5f57..95c2d9f3fc3b 100644 --- a/sys/dev/ic/lptvar.h +++ b/sys/dev/ic/lptvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: lptvar.h,v 1.53 2005/12/11 12:21:27 christos Exp $ */ +/* $NetBSD: lptvar.h,v 1.54 2007/10/09 12:45:27 ad Exp $ */ /* * Copyright (c) 1993, 1994 Charles M. Hannum. @@ -61,8 +61,9 @@ struct lpt_softc { struct device sc_dev; void *sc_ih; - struct callout sc_wakeup_ch; + callout_t sc_wakeup_ch; size_t sc_count; + void *sc_sih; void *sc_inbuf; u_char *sc_cp; int sc_spinmax;