From cbd0150530f3f91a83f3aff3899d5dc046a58cda Mon Sep 17 00:00:00 2001 From: Andrew Gallatin Date: Thu, 10 Apr 2003 20:32:29 +0000 Subject: [PATCH] Enable loadable modules to be unloaded on alphas with shared isa interrupts by only disabling the interrupt in hardware if the handler being removed is the only handler. --- sys/alpha/isa/isa.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/sys/alpha/isa/isa.c b/sys/alpha/isa/isa.c index d6ddebcd8a1e..ec1de88c6f80 100644 --- a/sys/alpha/isa/isa.c +++ b/sys/alpha/isa/isa.c @@ -389,17 +389,29 @@ isa_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { struct isa_intr *ii = cookie; + struct intrhand *ih, *handler = (struct intrhand *)ii->ih; + struct ithd *ithread = handler->ih_ithread; + int num_handlers = 0; - mtx_lock_spin(&icu_lock); - isa_intr_disable(irq->r_start); - mtx_unlock_spin(&icu_lock); + mtx_lock(&ithread->it_lock); + TAILQ_FOREACH(ih, &ithread->it_handlers, ih_next) + num_handlers++; + mtx_unlock(&ithread->it_lock); + + /* only disable the interrupt in hardware if there are no + other handlers sharing it */ + + if (num_handlers == 1) { + mtx_lock_spin(&icu_lock); + isa_intr_disable(irq->r_start); + mtx_unlock_spin(&icu_lock); + if (platform.isa_teardown_intr) { + platform.isa_teardown_intr(dev, child, irq, + cookie); + return 0; + } - if (platform.isa_teardown_intr) { - platform.isa_teardown_intr(dev, child, irq, cookie); - return 0; } - alpha_teardown_intr(ii->ih); - return 0; }