How should a driver shutdown a taskqueue on detach?

John-Mark Gurney jmg at funkthat.com
Wed Jul 1 23:25:12 UTC 2015


Ryan Stone wrote this message on Wed, Jul 01, 2015 at 15:44 -0400:
> I'm trying to figure out how a driver is supposed to shut down its
> interrupt-handling taskqueue when it detaches.  taskqueue(9) recommends
> disabling interrupts, draining each task and then freeing the taskqueue.
> The problem that I have is the interrupt-handling tasks will sometimes
> re-enable interrupts on the device.  Is there a better way than using some
> kind of flag internally in the driver to note that a detach is in progress
> that the interrupt handlers will have to check before enabling interrupts?

Why not disabled interrupts, unregister interrupt handler, and then
make sure interrupts are disabled (only needed to prevent an interrupt
storm)?  Once you have unregistered the interrupt handler, it can't run
again...  Then you're free to drain the task queue safely...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-current mailing list