2.5.50: sleeping function called from illegal context
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at include/asm/semaphore.h:119
Call Trace: [<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xb
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
At Tue, 3 Dec 2002 04:07:52 +0100,
Quoted 11 lines · Duncan Sands
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at
include/asm/semaphore.h:119Call Trace: [<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xb
ouch, we are using rwlock in the control ioctls.
mutex is necessary for many controls, so we cannot suppress the use of mutex in control callbacks.
but temporary unlocking looks ad-hoc, too...
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
Quoted 14 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:07:52 +0100,
Quoted 10 lines · Duncan Sands
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at
include/asm/semaphore.h:119Call Trace:[<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xb
Quoted 5 lines
ouch, we are using rwlock in the control ioctls.
mutex is necessary for many controls, so we cannot suppress the use of mutex in control callbacks.
but temporary unlocking looks ad-hoc, too...
If I understand right, the problem is that snd_ctl_elem_write acquires control_rwlock, which is a rw spinlock. It then calls snd_cs46xx_iec958_put which acquires chip->spos_mutex, which is a semaphore. Thus the message. Now I deduce from the fact that you don't use read_lock_irqsave that the data structure is not read from interrupt context. That means you are only protecting against other CPUs. So why not use a semaphore instead of a spinlock?
All the best,
Duncan.
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
At Tue, 3 Dec 2002 04:55:15 +0100,
Quoted 22 lines · Duncan Sands
Quoted 14 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:07:52 +0100,
Quoted 10 lines · Duncan Sands
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at
include/asm/semaphore.h:119Call Trace:[<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xbQuoted 5 lines
ouch, we are using rwlock in the control ioctls.
mutex is necessary for many controls, so we cannot suppress the use of mutex in control callbacks.
but temporary unlocking looks ad-hoc, too...
Quoted 8 lines
If I understand right, the problem is that
snd_ctl_elem_writeacquirescontrol_rwlock, which is a rw spinlock. It then callssnd_cs46xx_iec958_putwhich acquireschip->spos_mutex, which is a semaphore. Thus the message. Now I deduce from the fact that you don't useread_lock_irqsavethat the data structure is not read from interrupt context. That means you are only protecting against other CPUs. So why not use a semaphore instead of a spinlock?
hmm, there are some places calling with irq lock.
for example, snd_ctl_notify() can be called from the interrupt handler for some interrupts like h/w volume change.
however, it seems that a single rwlock is used for the management of two different lists. and snd_ctl_elem_write() uses card->controls only, whereas snd_ctl_notify() uses card->ctl_files only. hence, we can merge two locks, rwsem for card->controls and rwlock for card->ctl_files. i'll give a try.
ciao,
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
Quoted 33 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:55:15 +0100,
Quoted 21 lines · Duncan Sands
Quoted 14 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:07:52 +0100,
Quoted 10 lines · Duncan Sands
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at
include/asm/semaphore.h:119Call Trace:[<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xbQuoted 5 lines
ouch, we are using rwlock in the control ioctls.
mutex is necessary for many controls, so we cannot suppress the use of mutex in control callbacks.
but temporary unlocking looks ad-hoc, too...Quoted 8 lines
If I understand right, the problem is that
snd_ctl_elem_writeacquirescontrol_rwlock, which is a rw spinlock. It then callssnd_cs46xx_iec958_putwhich acquireschip->spos_mutex, which is a semaphore. Thus the message. Now I deduce from the fact that you don't useread_lock_irqsavethat the data structure is not read from interrupt context. That means you are only protecting against other CPUs. So why not use a semaphore instead of a spinlock?
Quoted 3 lines
hmm, there are some places calling with irq lock.
for example,snd_ctl_notify()can be called from the interrupt handler for some interrupts like h/w volume change.
Uh oh!
Quoted 5 lines
however, it seems that a single rwlock is used for the management of two different lists. and
snd_ctl_elem_write()usescard->controlsonly, whereassnd_ctl_notify()usescard->ctl_filesonly. hence, we can merge two locks, rwsem forcard->controlsand rwlock forcard->ctl_files. i'll give a try.
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.
Duncan.
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
At Tue, 3 Dec 2002 06:57:45 +0100,
Quoted 47 lines · Duncan Sands
Quoted 33 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:55:15 +0100,
Quoted 21 lines · Duncan Sands
Quoted 14 lines · Takashi Iwai
At Tue, 3 Dec 2002 04:07:52 +0100,
Quoted 10 lines · Duncan Sands
Got this with today 2.5 BK tree:
Debug: sleeping function called from illegal context at
include/asm/semaphore.h:119Call Trace:[<c0113f1a>] __might_sleep+0x52/0x58 [<c024291a>] snd_cs46xx_iec958_put+0x36/0xf8 [<c0217f28>] snd_ctl_elem_write+0xe0/0x1a4 [<c0218360>] snd_ctl_ioctl+0x184/0x2c8 [<c01462e6>] sys_ioctl+0x1fa/0x244 [<c01088f7>] syscall_call+0x7/0xbQuoted 5 lines
ouch, we are using rwlock in the control ioctls.
mutex is necessary for many controls, so we cannot suppress the use of mutex in control callbacks.
but temporary unlocking looks ad-hoc, too...Quoted 8 lines
If I understand right, the problem is that
snd_ctl_elem_writeacquirescontrol_rwlock, which is a rw spinlock. It then callssnd_cs46xx_iec958_putwhich acquireschip->spos_mutex, which is a semaphore. Thus the message. Now I deduce from the fact that you don't useread_lock_irqsavethat the data structure is not read from interrupt context. That means you are only protecting against other CPUs. So why not use a semaphore instead of a spinlock?Quoted 3 lines
hmm, there are some places calling with irq lock.
for example,snd_ctl_notify()can be called from the interrupt handler for some interrupts like h/w volume change.Uh oh!
Quoted 5 lines
however, it seems that a single rwlock is used for the management of two different lists. and
snd_ctl_elem_write()usescard->controlsonly, whereassnd_ctl_notify()usescard->ctl_filesonly. hence, we can merge two locks, rwsem forcard->controlsand rwlock forcard->ctl_files. i'll give a try.
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_notifyis put on the queue, where it will later be run in process context, and can safely take the semaphore.
yes, basically what snd_ctl_notify() does is the same. it queues an event and wakes up the sleepers. thus, it's ok to separate the stuff from the semaphore.
the attached is a patch to rewrite the locks with rwsem. please check whether it works for you.
thanks,
Takashi
Quoted 6 lines
yes, basically what
snd_ctl_notify()does is the same. it queues an event and wakes up the sleepers. thus, it's ok to separate the stuff from the semaphore.the attached is a patch to rewrite the locks with rwsem. please check whether it works for you.
This is against alsa cvs and not 2.5.50, right? That means it will take me a little longer to test it (but I will test it).
Thanks a lot,
Duncan.
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
Quoted 11 lines
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_notifyis put on the queue, where it will later be run in process context, and can safely take the semaphore.yes, basically what
snd_ctl_notify()does is the same. it queues an event and wakes up the sleepers. thus, it's ok to separate the stuff from the semaphore.the attached is a patch to rewrite the locks with rwsem. please check whether it works for you.
It seems to work fine.
Thanks a lot,
Duncan.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
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_notifyis 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.
--p
-------------------------------------------------------
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