From: Takashi Iwai <tiwai@suse.de>
To: Pieter Palmers <pieter.palmers@student.kuleuven.ac.be>
Cc: Paul Davis <paul@linuxaudiosystems.com>,
Arthur Peters <amp@singingwizard.org>,
Alsa dev list <alsa-devel@lists.sourceforge.net>
Subject: Re: ALSA + jack + xrun = kernel crash
Date: Wed, 21 May 2003 12:33:50 +0200 [thread overview]
Message-ID: <s5hk7ckvbap.wl@alsa2.suse.de> (raw)
In-Reply-To: <3ECAC902.4050903@student.kuleuven.ac.be>
[-- Attachment #1: Type: text/plain, Size: 638 bytes --]
At Wed, 21 May 2003 02:32:02 +0200,
Pieter Palmers wrote:
>
> Ok, second try:
>
> alsa 0.9.3c fresh from CVS
> ---------------------------------------
> /proc/asound/version:
> Advanced Linux Sound Architecture Driver Version 0.9.3c.
> Compiled on May 21 2003 for kernel 2.4.20-LL with versioned symbols.
>
> /proc/asound/cards:
> 0 [AudioPCI ]: ENS1371 - Ensoniq AudioPCI
> Ensoniq AudioPCI ENS1371 at 0xb000, irq 5
>
> ---------------------------------------
how about this one? this should fix another deadlock
(including the simplified expression of stream lock)
Takashi
[-- Attachment #2: pcm-lock-fix.dif --]
[-- Type: application/octet-stream, Size: 6696 bytes --]
Index: alsa-kernel/include/pcm.h
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/include/pcm.h,v
retrieving revision 1.35
diff -u -r1.35 pcm.h
--- alsa-kernel/include/pcm.h 15 May 2003 09:46:39 -0000 1.35
+++ alsa-kernel/include/pcm.h 21 May 2003 09:54:41 -0000
@@ -388,7 +388,7 @@
snd_pcm_substream_t *next;
/* -- linked substreams -- */
struct list_head link_list; /* linked list member */
- snd_pcm_group_t self_group; /* fake group for non linked substream (with substream lock inside) */
+ spinlock_t lock; /* lock per stream */
snd_pcm_group_t *group; /* pointer to current group */
/* -- assigned files -- */
snd_pcm_file_t *file;
@@ -578,42 +578,42 @@
static inline int snd_pcm_stream_linked(snd_pcm_substream_t *substream)
{
- return substream->group != &substream->self_group;
+ return substream->group != NULL;
}
static inline void snd_pcm_stream_lock(snd_pcm_substream_t *substream)
{
read_lock(&snd_pcm_link_rwlock);
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
}
static inline void snd_pcm_stream_unlock(snd_pcm_substream_t *substream)
{
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
read_unlock(&snd_pcm_link_rwlock);
}
static inline void snd_pcm_stream_lock_irq(snd_pcm_substream_t *substream)
{
read_lock_irq(&snd_pcm_link_rwlock);
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
}
static inline void snd_pcm_stream_unlock_irq(snd_pcm_substream_t *substream)
{
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
read_unlock_irq(&snd_pcm_link_rwlock);
}
#define snd_pcm_stream_lock_irqsave(substream, flags) \
do { \
read_lock_irqsave(&snd_pcm_link_rwlock, (flags)); \
- spin_lock(&substream->self_group.lock); \
+ spin_lock(&substream->lock); \
} while (0)
#define snd_pcm_stream_unlock_irqrestore(substream, flags) \
do { \
- spin_unlock(&substream->self_group.lock); \
+ spin_unlock(&substream->lock); \
read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
} while (0)
Index: alsa-kernel/core/pcm.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/core/pcm.c,v
retrieving revision 1.28
diff -u -r1.28 pcm.c
--- alsa-kernel/core/pcm.c 5 May 2003 10:09:09 -0000 1.28
+++ alsa-kernel/core/pcm.c 21 May 2003 10:06:04 -0000
@@ -593,10 +593,8 @@
snd_magic_kfree(substream);
return err;
}
- substream->group = &substream->self_group;
- spin_lock_init(&substream->self_group.lock);
- INIT_LIST_HEAD(&substream->self_group.substreams);
- list_add_tail(&substream->link_list, &substream->self_group.substreams);
+ substream->group = NULL;
+ INIT_LIST_HEAD(&substream->link_list);
spin_lock_init(&substream->timer_lock);
prev = substream;
}
Index: alsa-kernel/core/pcm_native.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/core/pcm_native.c,v
retrieving revision 1.52
diff -u -r1.52 pcm_native.c
--- alsa-kernel/core/pcm_native.c 20 May 2003 08:43:44 -0000 1.52
+++ alsa-kernel/core/pcm_native.c 21 May 2003 10:27:21 -0000
@@ -624,7 +624,7 @@
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
if (s != substream)
- spin_lock(&s->self_group.lock);
+ spin_lock(&s->lock);
res = ops->pre_action(s, state);
if (res < 0)
break;
@@ -640,7 +640,7 @@
ops->post_action(s, state);
}
if (s != substream)
- spin_unlock(&s->self_group.lock);
+ spin_unlock(&s->lock);
}
} else {
snd_pcm_substream_t *s1;
@@ -648,7 +648,7 @@
snd_pcm_group_for_each(pos, substream) {
s1 = snd_pcm_group_substream_entry(pos);
if (s1 != substream)
- spin_unlock(&s1->self_group.lock);
+ spin_unlock(&s1->lock);
if (s1 == s) /* end */
break;
}
@@ -686,9 +686,9 @@
if (snd_pcm_stream_linked(substream)) {
if (!spin_trylock(&substream->group->lock)) {
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
spin_lock(&substream->group->lock);
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
}
res = snd_pcm_action_group(ops, substream, state);
spin_unlock(&substream->group->lock);
@@ -710,14 +710,14 @@
read_lock_irq(&snd_pcm_link_rwlock);
if (snd_pcm_stream_linked(substream)) {
spin_lock(&substream->group->lock);
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
res = snd_pcm_action_group(ops, substream, state);
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
spin_unlock(&substream->group->lock);
} else {
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
res = snd_pcm_action_single(ops, substream, state);
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
}
read_unlock_irq(&snd_pcm_link_rwlock);
return res;
@@ -1136,23 +1136,17 @@
if (snd_pcm_stream_linked(substream)) {
if (!spin_trylock(&substream->group->lock)) {
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&substream->lock);
spin_lock(&substream->group->lock);
- spin_lock(&substream->self_group.lock);
+ spin_lock(&substream->lock);
}
snd_pcm_group_for_each(pos, substream) {
s = snd_pcm_group_substream_entry(pos);
if (s != substream)
- spin_lock(&substream->self_group.lock);
- }
- snd_pcm_group_for_each(pos, substream) {
- s = snd_pcm_group_substream_entry(pos);
+ spin_lock(&s->lock);
s->runtime->status->state = state;
- }
- snd_pcm_group_for_each(pos, substream) {
- s = snd_pcm_group_substream_entry(pos);
if (s != substream)
- spin_unlock(&substream->self_group.lock);
+ spin_unlock(&s->lock);
}
spin_unlock(&substream->group->lock);
} else {
@@ -1485,13 +1479,6 @@
return res;
}
-static void relink_to_local(snd_pcm_substream_t *substream)
-{
- substream->group = &substream->self_group;
- INIT_LIST_HEAD(&substream->self_group.substreams);
- list_add_tail(&substream->link_list, &substream->self_group.substreams);
-}
-
static int snd_pcm_unlink(snd_pcm_substream_t *substream)
{
struct list_head *pos;
@@ -1509,12 +1496,13 @@
}
if (count == 1) { /* detach the last stream, too */
snd_pcm_group_for_each(pos, substream) {
- relink_to_local(snd_pcm_group_substream_entry(pos));
+ snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos);
+ s->group = NULL;
break;
}
kfree(substream->group);
}
- relink_to_local(substream);
+ substream->group = NULL;
_end:
write_unlock_irq(&snd_pcm_link_rwlock);
return 0;
next prev parent reply other threads:[~2003-05-21 10:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-17 1:54 ALSA + jack + xrun = kernel crash Arthur Peters
2003-05-17 12:27 ` Paul Davis
2003-05-17 12:47 ` Jaroslav Kysela
2003-05-17 20:48 ` Arthur Peters
2003-05-19 16:10 ` Takashi Iwai
2003-05-19 16:38 ` Paul Davis
2003-05-19 19:16 ` Benny Sjostrand
2003-05-20 8:46 ` Takashi Iwai
2003-05-21 0:32 ` Pieter Palmers
2003-05-21 10:33 ` Takashi Iwai [this message]
2003-05-21 11:35 ` Jaroslav Kysela
2003-05-21 11:49 ` Takashi Iwai
2003-05-21 12:54 ` Jaroslav Kysela
[not found] ` <3ECBCF5B.2020807@esat.kuleuven.ac.be>
2003-05-21 23:08 ` Pieter Palmers
2003-05-21 23:50 ` Tarragon Allen
2003-05-22 1:20 ` Paul Davis
2003-05-17 20:57 ` Benny Sjostrand
2003-05-17 21:38 ` Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hk7ckvbap.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=amp@singingwizard.org \
--cc=paul@linuxaudiosystems.com \
--cc=pieter.palmers@student.kuleuven.ac.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.