PERFORCE change 122980 for review
Rui Paulo
rpaulo at FreeBSD.org
Fri Jul 6 00:29:19 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122980
Change 122980 by rpaulo at rpaulo_epsilon on 2007/07/06 00:28:30
Bring back support for INTR_FILTER. This time I hope I used it
correctly.
Now we only need to create a taskqueue if INTR_FILTER kernel
option is not used.
Explained by: jhb
Affected files ...
.. //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#20 edit
Differences ...
==== //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#20 (text+ko) ====
@@ -23,7 +23,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#19 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#20 $
*
*/
@@ -81,8 +81,10 @@
static int asmc_temp_getvalue(device_t dev, const char *key);
static int asmc_sms_read(device_t, const char *key, int16_t *val);
static void asmc_sms_calibrate(device_t dev);
-static int asmc_sms_intr(void *arg);
-static void asmc_sms_fastintr(void *arg);
+static int asmc_sms_intrfast(void *arg);
+#ifdef INTR_FILTER
+static void asmc_sms_handler(void *arg);
+#endif
static void asmc_sms_printintr(device_t dev, uint8_t);
static void asmc_sms_task(void *arg, int pending);
@@ -359,14 +361,18 @@
* PI_REALTIME is used due to the sensitivity of the
* interrupt. An interrupt from the SMS means that the
* disk heads should be turned off as quickly as possible.
+ *
+ * We only need to do this for the non INTR_FILTER case.
*/
+ sc->sc_sms_tq = NULL;
+#ifndef INTR_FILTER
TASK_INIT(&sc->sc_sms_task, 0, asmc_sms_task, sc);
sc->sc_sms_tq = taskqueue_create_fast("asmc_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->sc_sms_tq);
taskqueue_start_threads(&sc->sc_sms_tq, 1, PI_REALTIME, "%s sms taskq",
device_get_nameunit(dev));
+#endif
-
/*
* Allocate an IRQ for the SMS.
*/
@@ -375,29 +381,30 @@
ASMC_IRQ, ASMC_IRQ, 1, RF_ACTIVE);
if (sc->sc_res == NULL) {
device_printf(dev, "unable to allocate IRQ resource\n");
- taskqueue_free(sc->sc_sms_tq);
- goto out;
+ if (sc->sc_sms_tq)
+ taskqueue_free(sc->sc_sms_tq);
+ return (ENXIO);
}
ret = bus_setup_intr(dev, sc->sc_res,
INTR_TYPE_MISC | INTR_MPSAFE,
- asmc_sms_intr, NULL, dev, &sc->sc_cookie);
+#ifdef INTR_FILTER
+ asmc_sms_intrfast, asmc_sms_handler,
+#else
+ asmc_sms_intrfast, NULL,
+#endif
+ dev, &sc->sc_cookie);
- if (ret) {
- ret = bus_setup_intr(dev, sc->sc_res,
- INTR_TYPE_MISC | INTR_MPSAFE,
- NULL, asmc_sms_fastintr, dev,
- &sc->sc_cookie);
- if (ret == 0)
- device_printf(dev, "unable to setup fast interrupt. "
- "Using normal mode.\n");
- }
if (ret) {
device_printf(dev, "unable to setup SMS IRQ\n");
bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid, sc->sc_res);
+ if (sc->sc_sms_tq)
+ taskqueue_free(sc->sc_sms_tq);
+ return (ret);
}
+
out:
return (0);
}
@@ -769,7 +776,7 @@
}
static int
-asmc_sms_intr(void *arg)
+asmc_sms_intrfast(void *arg)
{
uint8_t type;
device_t dev = (device_t) arg;
@@ -781,26 +788,24 @@
sc->sc_sms_intrtype = type;
asmc_sms_printintr(dev, type);
+
+#ifdef INTR_FILTER
+ return (FILTER_SCHEDULE_THREAD | FILTER_HANDLED);
+#else
taskqueue_enqueue(sc->sc_sms_tq, &sc->sc_sms_task);
-
+#endif
return (FILTER_HANDLED);
}
+#ifdef INTR_FILTER
static void
-asmc_sms_fastintr(void *arg)
+asmc_sms_handler(void *arg)
{
- uint8_t type;
- device_t dev = (device_t) arg;
- struct asmc_softc *sc = device_get_softc(dev);
-
- mtx_lock_spin(&sc->sc_mtx);
- type = inb(ASMC_INTPORT);
- mtx_unlock_spin(&sc->sc_mtx);
-
- sc->sc_sms_intrtype = type;
- asmc_sms_printintr(dev, type);
- taskqueue_enqueue_fast(sc->sc_sms_tq, &sc->sc_sms_task);
+ struct asmc_softc *sc = device_get_softc(arg);
+
+ asmc_sms_task(sc, 0);
}
+#endif
static void
More information about the p4-projects
mailing list