Subject: Re: allocmem in interrupt context
To: Iain Hibbert <>
From: Matthew Orgass <>
List: tech-kern
Date: 10/30/2005 17:53:36
On 2005-10-30 wrote:
> relatedly, can one use tsleep from a soft interrupt context?  The time has
> not yet arrived, but I might sometime need to send commands in response to
> events, and sending commands may sleep (because of flow control) so I'm
> thinking I would have to look into replacing the soft interrupt which
> currently services incoming packets with a kthread tsleep/wakeup

  No, that's why normal memory allocation doesn't work :).  I think it
would be great if something like kcont was available whenever tsleep was
used, however current kcont doesn't have a good general means of adding
new deferral types and little if anything uses it yet.

> Is usb_transfer_complete() in dev/usb/usbdi.c (and hence my callback)
> called in a process context?  I'm thinking it would likely be a usb_task
> but I can't quite figger it (ie, it would be ok to use m_copyback() in the
> callback routine?)

  No, it is called from a soft interrupt.  You can check the bus
intr_context member if necessary, which sould always be non-zero in
(soft) interrupt context.

  (I actually tried calling usb_transfer_complete from a usb_task in my
new slhci driver, but this doesn't work since synchronous transfers are
started from usb_tasks.)

Matthew Orgass