Skip to contentSkip to conversation

2.5.50: sleeping function called from illegal context

DISCUSSION Duncan Sands 2 participants 2 messages Dec 3, 2002 – Dec 4, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Paul Davis
Quoted 4 lines

I guess another way of dealing with this kind of problem is to use a semaphore rather than a spinlock, and a workqueue: when the interrupt comes in, the call to snd_ctl_notify is put on the queue, where it will later be run in process context, and can safely take the semaphore.

can i get a pointer to some code that does this? we need to do this for handling MIDI I/O in the hammerfall dsp driver. doing it from the interrupt handler causes audio dropouts because the midi i/o is so much slower.

For the use of workqueues (introduced in 2.5), see
http://lwn.net/Articles/11360/
and
http://lwn.net/Articles/10963/

For the use of task queues (now gone) and tasklets, see for example "Linux device drivers" by Rubini and Corbet.

If you need to go to sleep, you need to use a workqueue. If you are happy running in interrupt context, a tasklet may be enough.

I hope this helps,

Duncan.

-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en

#2 lore raw

At Tue, 3 Dec 2002 13:21:41 +0100,

Quoted 12 lines · Duncan Sands
Quoted 9 lines · Paul Davis
Quoted 4 lines

I guess another way of dealing with this kind of problem is to use a semaphore rather than a spinlock, and a workqueue: when the interrupt comes in, the call to snd_ctl_notify is put on the queue, where it will later be run in process context, and can safely take the semaphore.

can i get a pointer to some code that does this? we need to do this for handling MIDI I/O in the hammerfall dsp driver. doing it from the interrupt handler causes audio dropouts because the midi i/o is so much slower.

Quoted 4 lines

For the use of workqueues (introduced in 2.5), see
http://lwn.net/Articles/11360/
and
http://lwn.net/Articles/10963/

thanks for pointers!

i believe the tasklet would be enough for a task like the midi handler, too.

regarding to the workqueue, it can be used for a new stuff to shutdown the module asynchronously for hotplug, which Jaroslav added recently. the current implementation is invoking a kernel thread directly. with the workqueue, the code would be much simpler (although there is another issue for compatibility with older kernels :)

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en