Skip to contentSkip to conversation

Linux 2.6.14: Total lockup using aplaymidi

DISCUSSION Chris Rankin 4 participants 38 messages Oct 28, 2005 – Nov 9, 2005 1 message not in the archive Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hi,

I've just installed Linux 2.6.14-SMP with ALSA 1.0.10rc1 on my UP PIII machine, and I've found that:

$ aplaymidi -p 65:0 <midifile>

immediately locks my machine up hard. This machine has a "SB-Live! 5.1 Gamer" sound card, and the PCM driver seems to be OK. I don't get an Oops on the serial console, and so I'm suspecting a dead-lock somewhere. 30 seconds later, the watchdog driver forces a reboot.

I have also tried this kernel with ALSA 1.0.10rc2 CVS, with exactly the same results.

Cheers,
Chris

___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#1 lore raw
Quoted 5 lines · Chris Rankin

Hi,

I've just installed Linux 2.6.14-SMP with ALSA 1.0.10rc1 on my UP PIII machine, and I've found that:

Quoted 7 lines
$ aplaymidi -p 65:0 <midifile>

immediately locks my machine up hard. This machine has a "SB-Live! 5.1 Gamer" sound card, and the PCM driver seems to be OK. I don't get an Oops on the serial console, and so I'm suspecting a dead-lock somewhere. 30 seconds later, the watchdog driver forces a reboot.

I have also tried this kernel with ALSA 1.0.10rc2 CVS, with exactly the same results.

What was the last version where this worked?

Which soundfont do you have loaded? Are any other apps using the audio device at the time? What does /proc/asound/card0/voices look like?

Try creating a MIDI file with only 8 notes, does that also cause the lockup? If this works then try 16, 32 etc until it locks up.

Can the problem be reproduced on a UP kernel?

Lee

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#2 lore raw
Quoted 8 lines · --- Lee Revell
Quoted 6 lines

I've just installed Linux 2.6.14-SMP with ALSA 1.0.10rc1 on my UP PIII machine, and I've found that:

$ aplaymidi -p 65:0 <midifile>

immediately locks my machine up hard.

What was the last version where this worked?

At least 1.0.9b, I think.

Quoted 1 line

Which soundfont do you have loaded?

It's the 8mbgmsfx.sf2 sound-font that came with the card.

Quoted 1 line

Are any other apps using the audio device at the time?

None.

Quoted 1 line

What does /proc/asound/card0/voices look like?

$ cat /proc/asound/card0/voices 
ch      use     pcm     efx     synth   midi
0       0       0       0       0       0
1       0       0       0       0       0
2       0       0       0       0       0
3       0       0       0       0       0
4       0       0       0       0       0
5       0       0       0       0       0
6       0       0       0       0       0
7       0       0       0       0       0
8       0       0       0       0       0
9       0       0       0       0       0
10      0       0       0       0       0
11      0       0       0       0       0
12      0       0       0       0       0
13      0       0       0       0       0
14      0       0       0       0       0
15      0       0       0       0       0
16      0       0       0       0       0
17      0       0       0       0       0
18      0       0       0       0       0
19      0       0       0       0       0
20      0       0       0       0       0
21      0       0       0       0       0
22      0       0       0       0       0
23      0       0       0       0       0
24      0       0       0       0       0
25      0       0       0       0       0
26      0       0       0       0       0
27      0       0       0       0       0
28      0       0       0       0       0
29      0       0       0       0       0
30      0       0       0       0       0
31      0       0       0       0       0
32      0       0       0       0       0
33      0       0       0       0       0
34      0       0       0       0       0
35      0       0       0       0       0
36      0       0       0       0       0
37      0       0       0       0       0
38      0       0       0       0       0
39      0       0       0       0       0
40      0       0       0       0       0
41      0       0       0       0       0
42      0       0       0       0       0
43      0       0       0       0       0
44      0       0       0       0       0
45      0       0       0       0       0
46      0       0       0       0       0
47      0       0       0       0       0
48      0       0       0       0       0
49      0       0       0       0       0
50      0       0       0       0       0
51      0       0       0       0       0
52      0       0       0       0       0
53      0       0       0       0       0
54      0       0       0       0       0
55      0       0       0       0       0
56      0       0       0       0       0
57      0       0       0       0       0
58      0       0       0       0       0
59      0       0       0       0       0
60      0       0       0       0       0
61      0       0       0       0       0
62      0       0       0       0       0
63      0       0       0       0       0
Quoted 2 lines

Try creating a MIDI file with only 8 notes, does that also cause the lockup? If this works then try 16, 32 etc until it locks up.

I have no idea how to create a MIDI file; Again, I've been using MIDI files that came with the card. And in fact, it doesn't play a single note before it locks up.

Quoted 1 line

Can the problem be reproduced on a UP kernel?

I'll bear that test in mind; my next test will be seeing if my Audigy2 behaves the same in my SMP box.

Update: I've just rebooted this machine back into 2.6.13.1 to check which version of the ALSA drivers I was using before. Apparently, it was 1.0.10rc1 as of 30th September, and yes, the MIDI lockup was present. However, this time the NMI watchdog was able to give me an oops report:

NMI Watchdog detected LOCKUP on CPU0, eip c029a65a, registers:

Modules linked in: snd_usb_audio snd_usb_lib snd_seq_oss snd_seq_midi snd_emu10k1_synth

snd_emux_synth snd_seq_virmidi snd_seq_midi_event snd_seq_midi_emul mga
drm ipv6 floppy snd_pcm_oss snd_mixer_oss snd_seq snd_rtctimer binfmt_misc matroxfb_maven i2c_matroxfb i2c_algo_bit loop w83781d eeprom i2c_sensor tsdev ide_cd
cdrom psmouse pcspkr button processor nfs nfsd exportfs lockd parport_pc parport ehci_hcd eth1394 ohci_hcd ohci1394 ieee1394 8139too mii emu10k1_gp gameport snd_emu10k1 snd_rawmidi snd_seq_device snd_ac97_codec snd_pcm snd_timer snd_ac97_bus snd_page_alloc snd_util_mem snd_hwdep snd soundcore i2c_i801 i2c_core uhci_hcd usbcore i8xx_tco intel_agp agpgart evdev sunrpc ext3 jbd

CPU:    0
EIP:    0060:[<c029a65a>]    Not tainted VLI
EFLAGS: 00000086   (2.6.13.1)

EIP is at _spin_lock+0xa/0x10
eax: dafe64e4 ebx: dfd49220 ecx: d808ed0c edx: 00000001
esi: 00000000 edi: dafe6400 ebp: 00000008 esp: c0389f8c
ds: 007b es: 007b ss: 0068
Process aplaymidi (pid: 3932, threadinfo=c0389000 task=dfadfa60)

Stack: e2900e13 00000001 d9b41a2c 00000292 0000284c dafe64e4 d9b41800 80020024
       dfd49220 00000000 d808ed84 00000008 c02029d5 d808efbc c0139be2 00000000
       c034c2c0 00000008 dfd49220 c034c2dc c0139cf9 d808efbc dfd49220 d808ed84
Call Trace:
 [<e2900e13>] snd_timer_interrupt+0x23/0x310 [snd_timer]
 [<c02029d5>] rtc_interrupt+0xe5/0xf0
 [<c0139be2>] handle_IRQ_event+0x32/0x70
 [<c0139cf9>] __do_IRQ+0xd9/0x140
 [<c0105306>] do_IRQ+0x46/0x70
 =======================
 [<c0103836>] common_interrupt+0x1a/0x20
 [<c02031e8>] rtc_do_ioctl+0x6c8/0x8a0
 [<c0142a9c>] make_ahead_window+0x7c/0xc0
 [<c0120a4f>] current_fs_time+0x5f/0x70
 [<c013f7d0>] prep_new_page+0x40/0x70
 [<c013fd17>] buffered_rmqueue+0xe7/0x1d0
 [<c0140139>] __alloc_pages+0x269/0x400
 [<c0203710>] rtc_control+0x30/0x70
 [<e2b72067>] rtctimer_start+0x27/0x30 [snd_rtctimer]
 [<e290093e>] snd_timer_start1+0x7e/0xa0 [snd_timer]
 [<e2900a25>] snd_timer_start+0x65/0xa0 [snd_timer]
 [<e2c3ee86>] snd_seq_timer_start+0x36/0x50 [snd_seq]
 [<e2c3da60>] snd_seq_queue_process_event+0xb0/0x100 [snd_seq]
 [<e2c3d41f>] queue_access_lock+0x3f/0x60 [snd_seq]
 [<e2c3dafd>] snd_seq_control_queue+0x4d/0x90 [snd_seq]
 [<e2c39bdf>] snd_seq_deliver_single_event+0x16f/0x180 [snd_seq]
 [<e2c39de4>] snd_seq_deliver_event+0x34/0x50 [snd_seq]
 [<e2c3a036>] snd_seq_client_enqueue_event+0xe6/0x130 [snd_seq]
 [<c01afb8a>] copy_from_user+0x3a/0x80
 [<e2c3a225>] snd_seq_write+0x125/0x1a0 [snd_seq]
 [<c0159390>] vfs_write+0x170/0x180
 [<c0159451>] sys_write+0x41/0x70
 [<c0102e1f>] sysenter_past_esp+0x54/0x75
Code: c3 ba 00 f0 ff ff 21 e2 81 42 14 00 01 00 00 f0 81 28 00 00 00 01 74 05 e8 7c e8 ff ff c3 8d

76 00 f0 fe 08 79 09 f3 90 80 38 00 <7e> f9 eb f2 c3 90 f0 81 28 00 00 00 01 74 05 e8 5a e8 ff ff c3
console shuts up ...

Much more useful :-).

Cheers,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#3 lore raw
Quoted 51 lines · Chris Rankin

NMI Watchdog detected LOCKUP on CPU0, eip c029a65a, registers:

Modules linked in: snd_usb_audio snd_usb_lib snd_seq_oss snd_seq_midi snd_emu10k1_synth

snd_emux_synth snd_seq_virmidi snd_seq_midi_event snd_seq_midi_emul mga
drm ipv6 floppy snd_pcm_oss snd_mixer_oss snd_seq snd_rtctimer binfmt_misc matroxfb_maven i2c_matroxfb i2c_algo_bit loop w83781d eeprom i2c_sensor tsdev ide_cd
cdrom psmouse pcspkr button processor nfs nfsd exportfs lockd parport_pc parport ehci_hcd eth1394 ohci_hcd ohci1394 ieee1394 8139too mii emu10k1_gp gameport snd_emu10k1 snd_rawmidi snd_seq_device snd_ac97_codec snd_pcm snd_timer snd_ac97_bus snd_page_alloc snd_util_mem snd_hwdep snd soundcore i2c_i801 i2c_core uhci_hcd usbcore i8xx_tco intel_agp agpgart evdev sunrpc ext3 jbd

CPU:    0
EIP:    0060:[<c029a65a>]    Not tainted VLI
EFLAGS: 00000086   (2.6.13.1)

EIP is at _spin_lock+0xa/0x10
eax: dafe64e4 ebx: dfd49220 ecx: d808ed0c edx: 00000001
esi: 00000000 edi: dafe6400 ebp: 00000008 esp: c0389f8c
ds: 007b es: 007b ss: 0068
Process aplaymidi (pid: 3932, threadinfo=c0389000 task=dfadfa60)

Stack: e2900e13 00000001 d9b41a2c 00000292 0000284c dafe64e4 d9b41800 80020024
       dfd49220 00000000 d808ed84 00000008 c02029d5 d808efbc c0139be2 00000000
       c034c2c0 00000008 dfd49220 c034c2dc c0139cf9 d808efbc dfd49220 d808ed84
Call Trace:
 [<e2900e13>] snd_timer_interrupt+0x23/0x310 [snd_timer]
 [<c02029d5>] rtc_interrupt+0xe5/0xf0
 [<c0139be2>] handle_IRQ_event+0x32/0x70
 [<c0139cf9>] __do_IRQ+0xd9/0x140
 [<c0105306>] do_IRQ+0x46/0x70
 =======================
 [<c0103836>] common_interrupt+0x1a/0x20
 [<c02031e8>] rtc_do_ioctl+0x6c8/0x8a0
 [<c0142a9c>] make_ahead_window+0x7c/0xc0
 [<c0120a4f>] current_fs_time+0x5f/0x70
 [<c013f7d0>] prep_new_page+0x40/0x70
 [<c013fd17>] buffered_rmqueue+0xe7/0x1d0
 [<c0140139>] __alloc_pages+0x269/0x400
 [<c0203710>] rtc_control+0x30/0x70
 [<e2b72067>] rtctimer_start+0x27/0x30 [snd_rtctimer]
 [<e290093e>] snd_timer_start1+0x7e/0xa0 [snd_timer]
 [<e2900a25>] snd_timer_start+0x65/0xa0 [snd_timer]
 [<e2c3ee86>] snd_seq_timer_start+0x36/0x50 [snd_seq]
 [<e2c3da60>] snd_seq_queue_process_event+0xb0/0x100 [snd_seq]
 [<e2c3d41f>] queue_access_lock+0x3f/0x60 [snd_seq]
 [<e2c3dafd>] snd_seq_control_queue+0x4d/0x90 [snd_seq]
 [<e2c39bdf>] snd_seq_deliver_single_event+0x16f/0x180 [snd_seq]
 [<e2c39de4>] snd_seq_deliver_event+0x34/0x50 [snd_seq]
 [<e2c3a036>] snd_seq_client_enqueue_event+0xe6/0x130 [snd_seq]
 [<c01afb8a>] copy_from_user+0x3a/0x80
 [<e2c3a225>] snd_seq_write+0x125/0x1a0 [snd_seq]
 [<c0159390>] vfs_write+0x170/0x180
 [<c0159451>] sys_write+0x41/0x70
 [<c0102e1f>] sysenter_past_esp+0x54/0x75
Code: c3 ba 00 f0 ff ff 21 e2 81 42 14 00 01 00 00 f0 81 28 00 00 00 01 74 05 e8 7c e8 ff ff c3 8d
Quoted 3 lines

76 00 f0 fe 08 79 09 f3 90 80 38 00 <7e> f9 eb f2 c3 90 f0 81 28 00 00 00 01 74 05 e8 5a e8 ff ff c3
console shuts up ...

OK, great. This is related to the recent change to make the RTC the default timer for the ALSA sequencer, it's not an emu10k1 driver bug.

Lee

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#4 lore raw
Quoted 2 lines · --- Lee Revell

OK, great. This is related to the recent change to make the RTC the default timer for the ALSA sequencer, it's not an emu10k1 driver bug.

Which means it affects *every* ALSA user, and not just SB-Live! and Audigy owners ... ;-). I guess people just aren't using aplaymidi on SMP machines much.

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#5 lore raw
Quoted 6 lines · Chris Rankin
Quoted 2 lines · --- Lee Revell

OK, great. This is related to the recent change to make the RTC the default timer for the ALSA sequencer, it's not an emu10k1 driver bug.

Which means it affects *every* ALSA user, and not just SB-Live! and Audigy owners ... ;-). I guess people just aren't using aplaymidi on SMP machines much.

You can blame Linus for this. By insisting that default system timer frequency be lowered from 1000HZ to 250HZ, he forced the ALSA developers to use a different timer source for the sequencer. There was not a lot of time to test this before the 2.6.14 release.

Lee

-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information

#6 lore raw
In reply to Chris Rankin

At Sat, 29 Oct 2005 21:08:42 +0100 (BST),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Lee Revell

OK, great. This is related to the recent change to make the RTC the default timer for the ALSA sequencer, it's not an emu10k1 driver bug.

Which means it affects *every* ALSA user, and not just SB-Live! and Audigy owners ... ;-). I guess
people just aren't using aplaymidi on SMP machines much.

It's also not easily reproducible with SHT/SMP, at least it's working on my machine with a pure luck.

Anyway, try the patch below. We need a better clean up later.

Takashi

Index: alsa-kernel/core/timer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/timer.c,v retrieving revision 1.67

core/timer.c +33 -11
diff -u -r1.67 timer.c
@@ -424,6 +424,9 @@
 static int snd_timer_start1(snd_timer_t *timer, snd_timer_instance_t *timeri,
 			    unsigned long sticks)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&timer->lock, flags);
 	list_del(&timeri->active_list);
 	list_add_tail(&timeri->active_list, &timer->active_list_head);
 	if (timer->running) {
@@ -431,13 +434,19 @@
 			goto __start_now;
 		timer->flags |= SNDRV_TIMER_FLG_RESCHED;
 		timeri->flags |= SNDRV_TIMER_IFLG_START;
+		spin_unlock_irqrestore(&timer->lock, flags);
 		return 1;	/* delayed start */
 	} else {
 		timer->sticks = sticks;
+		if (!(timer->hw.flags & SNDRV_TIMER_HW_ATOMIC))
+			spin_unlock_irqrestore(&timer->lock, flags);
 		timer->hw.start(timer);
+		if (!(timer->hw.flags & SNDRV_TIMER_HW_ATOMIC))
+			spin_lock_irqsave(&timer->lock, flags);
 	      __start_now:
 		timer->running++;
 		timeri->flags |= SNDRV_TIMER_IFLG_RUNNING;
+		spin_unlock_irqrestore(&timer->lock, flags);
 		return 0;
 	}
 }
@@ -477,8 +486,8 @@
 	spin_lock_irqsave(&timer->lock, flags);
 	timeri->ticks = timeri->cticks = ticks;
 	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, ticks);
 	spin_unlock_irqrestore(&timer->lock, flags);
+	result = snd_timer_start1(timer, timeri, ticks);
 	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START);
 	return result;
 }
@@ -488,6 +497,7 @@
 {
 	snd_timer_t *timer;
 	unsigned long flags;
+	int running = 1;
 
 	snd_assert(timeri != NULL, return -ENXIO);
 
@@ -505,22 +515,32 @@
 	spin_lock_irqsave(&timer->lock, flags);
 	list_del_init(&timeri->ack_list);
 	list_del_init(&timeri->active_list);
-	if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&
-	    !(--timer->running)) {
+	if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING)
+		running = --timer->running;
+	spin_unlock_irqrestore(&timer->lock, flags);
+	if (! running) {
 		timer->hw.stop(timer);
+		spin_lock_irqsave(&timer->lock, flags);
 		if (timer->flags & SNDRV_TIMER_FLG_RESCHED) {
 			timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
 			snd_timer_reschedule(timer, 0);
 			if (timer->flags & SNDRV_TIMER_FLG_CHANGE) {
 				timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
+				if (! (timer->hw.flags & SNDRV_TIMER_HW_ATOMIC))
+					spin_unlock_irqrestore(&timer->lock, flags);
 				timer->hw.start(timer);
+				if (! (timer->hw.flags & SNDRV_TIMER_HW_ATOMIC))
+					spin_lock_irqsave(&timer->lock, flags);
 			}
 		}
+		spin_unlock_irqrestore(&timer->lock, flags);
 	}
-	if (!keep_flag)
+	if (!keep_flag) {
+		spin_lock_irqsave(&slave_active_lock, flags);
 		timeri->flags &=
 			~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
-	spin_unlock_irqrestore(&timer->lock, flags);
+		spin_unlock_irqrestore(&slave_active_lock, flags);
+	}
       __end:
 	if (event != SNDRV_TIMER_EVENT_RESOLUTION)
 		snd_timer_notify1(timeri, event);
@@ -569,8 +589,8 @@
 	if (!timeri->cticks)
 		timeri->cticks = 1;
 	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, timer->sticks);
 	spin_unlock_irqrestore(&timer->lock, flags);
+	result = snd_timer_start1(timer, timeri, timer->sticks);
 	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_CONTINUE);
 	return result;
 }
@@ -718,17 +738,19 @@
 	if (timer->flags & SNDRV_TIMER_FLG_RESCHED)
 		snd_timer_reschedule(timer, ticks_left);
 	if (timer->running) {
-		if (timer->hw.flags & SNDRV_TIMER_HW_STOP) {
+		if ((timer->hw.flags & SNDRV_TIMER_HW_STOP) &&
+		    (timer->hw.flags & SNDRV_TIMER_HW_ATOMIC)) {
 			timer->hw.stop(timer);
 			timer->flags |= SNDRV_TIMER_FLG_CHANGE;
 		}
-		if (!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||
-		    (timer->flags & SNDRV_TIMER_FLG_CHANGE)) {
+		if ((!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||
+		     (timer->flags & SNDRV_TIMER_FLG_CHANGE)) &&
+		    (timer->hw.flags & SNDRV_TIMER_HW_ATOMIC)){
 			/* restart timer */
 			timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
 			timer->hw.start(timer);
 		}
-	} else {
+	} else if (timer->hw.flags & SNDRV_TIMER_HW_ATOMIC) {
 		timer->hw.stop(timer);
 	}
 
@@ -1015,7 +1037,7 @@
 
 static struct _snd_timer_hardware snd_timer_system =
 {
-	.flags =	SNDRV_TIMER_HW_FIRST | SNDRV_TIMER_HW_TASKLET,
+	.flags =	SNDRV_TIMER_HW_FIRST | SNDRV_TIMER_HW_TASKLET | SNDRV_TIMER_HW_ATOMIC,
 	.resolution =	1000000000L / HZ,
 	.ticks =	10000000L,
 	.start =	snd_timer_s_start,

Index: alsa-kernel/include/timer.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/include/timer.h,v retrieving revision 1.14

include/timer.h +1 -0
diff -u -r1.14 timer.h
@@ -51,6 +51,7 @@
 #define SNDRV_TIMER_HW_SLAVE	0x00000004	/* only slave timer (variable resolution) */
 #define SNDRV_TIMER_HW_FIRST	0x00000008	/* first tick can be incomplete */
 #define SNDRV_TIMER_HW_TASKLET	0x00000010	/* timer is called from tasklet */
+#define SNDRV_TIMER_HW_ATOMIC	0x00000020	/* start/stop are atomoic */
 
 #define SNDRV_TIMER_IFLG_SLAVE	  0x00000001
 #define SNDRV_TIMER_IFLG_RUNNING  0x00000002
#7 lore raw
Quoted 1 line · --- Takashi Iwai

Anyway, try the patch below. We need a better clean up later.

The MIDI files play now, but this happened when I tried to unload the modules using the following command:

# awk '{print \$1}' < /proc/modules | grep ^snd | xargs /sbin/rmmod
BUG: soft lockup detected on CPU#0!

Pid: 4057, comm: asfxload
EIP: 0060:[<c029e7ee>] CPU: 0
EIP is at _spin_lock_irqsave+0x1e/0x30
EFLAGS: 00000286 Not tainted (2.6.14)
EAX: ddcd30ec EBX: ddcd30e4 ECX: 00000000 EDX: 00000286
ESI: ddcd30ec EDI: d96adf4c EBP: ddac8a70 DS: 007b ES: 007b
CR0: 8005003b CR2: 080df5d4 CR3: 1963d000 CR4: 000006d0

 [<c029e57c>] __down+0x3c/0xe0
 [<c0117ab0>] default_wake_function+0x0/0x10
 [<c014e3de>] unmap_region+0xfe/0x150
 [<c029cedf>] __down_failed+0x7/0xc
 [<e28e32f0>] snd_hwdep_release+0x0/0xd0 [snd_hwdep]
 [<e28e3be6>] .text.lock.hwdep+0x4b/0xf5 [snd_hwdep]
 [<c015aab6>] __fput+0x136/0x170
 [<c015906c>] filp_close+0x3c/0x80
 [<c0102e0f>] sysenter_past_esp+0x54/0x75

Cheers,
Chris

___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#8 lore raw
Quoted 11 lines · Chris Rankin
Quoted 1 line · --- Takashi Iwai

Anyway, try the patch below. We need a better clean up later.

The MIDI files play now, but this happened when I tried to unload the modules using the following command:

# awk '{print \$1}' < /proc/modules | grep ^snd | xargs /sbin/rmmod
BUG: soft lockup detected on CPU#0!

Pid: 4057, comm: asfxload

You unloaded the modules while asfxload was loading a soundfont?

Lee

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#9 lore raw
Quoted 1 line

You unloaded the modules while asfxload was loading a soundfont?

a) Not intentionally. (It must have been udev.)
b) It *still* shouldn't have caused an oops.

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#10 lore raw

At Wed, 2 Nov 2005 00:00:23 +0000 (GMT),

Quoted 5 lines · Chris Rankin
Quoted 2 lines

You unloaded the modules while asfxload was loading a soundfont?

a) Not intentionally. (It must have been udev.)
b) It *still* shouldn't have caused an oops.

a) It doesn't matter whether it's intentional or not.
b) Yes, the oops must be killed always.

We need to know in which condition the oops occurs. The stack trace doesn't show the right path.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#11 lore raw
Quoted 3 lines · --- Takashi Iwai

We need to know in which condition the oops occurs. The stack trace doesn't show the right path.

Like I said, I was unloading every module listed in /proc/modules that started with "snd".

Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#12 lore raw

At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),

Quoted 7 lines · Chris Rankin
Quoted 3 lines · --- Takashi Iwai

We need to know in which condition the oops occurs. The stack trace doesn't show the right path.

Like I said, I was unloading every module listed in /proc/modules that started with "snd".

Which rmmod triggers the oops?
Apparently, the udev is who starts asfxload during rmmod. Please show up the configuration, too, in order to check the condition.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#13 lore raw
Quoted 3 lines · --- Takashi Iwai

Which rmmod triggers the oops?
Apparently, the udev is who starts asfxload during rmmod. Please show up the configuration, too, in order to check the condition.

I'm not in front of that PC right now, but from memory, the oops happened when I ran my "unalsa" alias. This alias is basically parsing /proc/modules into awk, picking those modules beginning with ^snd and rmmoding them. Hence it was trying to remove them *all*, in the order that they appear in /proc/modules, and I think the oops showed that it was the snd_hwdep module that deadlocked while unmapping something.

I'll dig out udev's alsa.dev file when I get home.

Cheers,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#14 lore raw
In reply to Takashi Iwai
Quoted 11 lines · Takashi Iwai

At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),

Quoted 7 lines · Chris Rankin
Quoted 3 lines · --- Takashi Iwai

We need to know in which condition the oops occurs. The stack trace doesn't show the right path.

Like I said, I was unloading every module listed in /proc/modules that started with "snd".

Which rmmod triggers the oops?

It was not an Oops, the kernel detected a "soft lockup" which IIRC means some process ran in the kernel for an abnormally long time. This usually indicates a bug.

Lee

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#15 lore raw

At Wed, 02 Nov 2005 11:57:04 -0500,

Quoted 7 lines · Lee Revell
Quoted 5 lines · Takashi Iwai

At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),

Quoted 3 lines · Chris Rankin
Quoted 1 line · --- Takashi Iwai
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

We need to know in which condition the oops occurs. The stack trace doesn't show the right path.

Like I said, I was unloading every module listed in /proc/modules that started with "snd".

Which rmmod triggers the oops?

It was not an Oops, the kernel detected a "soft lockup"

Oh yes, it's a thinko.

Quoted 3 lines

which IIRC means
some process ran in the kernel for an abnormally long time. This usually indicates a bug.

Yes, for example, when irq is released wrongly.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#16 lore raw
In reply to Takashi Iwai
Quoted 3 lines · --- Takashi Iwai

Which rmmod triggers the oops?
Apparently, the udev is who starts asfxload during rmmod. Please show up the configuration, too, in order to check the condition.

$ cat /etc/dev.d/snd/controlC0/alsa.dev 
#!/bin/sh -e
exec /usr/sbin/alsactl restore 0
$ cat /etc/dev.d/snd/midiC0D1/alsa.dev 
#!/bin/sh -e
exec /usr/bin/asfxload /usr/lib/sfbank/8mbgmsfx.sf2

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#17 lore raw

At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),

Quoted 6 lines · Chris Rankin
Quoted 3 lines · --- Takashi Iwai

Which rmmod triggers the oops?
Apparently, the udev is who starts asfxload during rmmod. Please show up the configuration, too, in order to check the condition.

Quoted 7 lines
$ cat /etc/dev.d/snd/controlC0/alsa.dev 
#!/bin/sh -e
exec /usr/sbin/alsactl restore 0
$ cat /etc/dev.d/snd/midiC0D1/alsa.dev 
#!/bin/sh -e
exec /usr/bin/asfxload /usr/lib/sfbank/8mbgmsfx.sf2

Hmm, it means that the device is recreated again at unloading? IOW, the module is re-inserted during or shortly after unloading.

I remember such behavior is triggered when alsa-lib is built without --disable-aload configure option once on my system.

Anyway, could you run rmmod manually just like your script and check the soft lockup at each rmmod?

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#18 lore raw

At Wed, 02 Nov 2005 19:41:48 +0100,

Quoted 17 lines · 私 wrote:

At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),

Quoted 6 lines · Chris Rankin
Quoted 3 lines · --- Takashi Iwai

Which rmmod triggers the oops?
Apparently, the udev is who starts asfxload during rmmod. Please show up the configuration, too, in order to check the condition.

Quoted 7 lines
$ cat /etc/dev.d/snd/controlC0/alsa.dev 
#!/bin/sh -e
exec /usr/sbin/alsactl restore 0
$ cat /etc/dev.d/snd/midiC0D1/alsa.dev 
#!/bin/sh -e
exec /usr/bin/asfxload /usr/lib/sfbank/8mbgmsfx.sf2
Quoted 8 lines

Hmm, it means that the device is recreated again at unloading? IOW, the module is re-inserted during or shortly after unloading.

I remember such behavior is triggered when alsa-lib is built without --disable-aload configure option once on my system.

Anyway, could you run rmmod manually just like your script and check the soft lockup at each rmmod?

Above all, please check whether the problem at unloading happens, too, if the system timer is used instead of rtctimer. I guess it's related to rtctimer, though.

Also, the below is an improved patch for the timer deadlock. Please give a shot.

Takashi

Index: alsa-kernel/core/timer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/timer.c,v retrieving revision 1.67

core/timer.c +42 -11
diff -u -r1.67 timer.c
@@ -421,9 +421,20 @@
 	spin_unlock_irqrestore(&timer->lock, flags);
 }
 
+#define call_timer_hw(action,timer,flags) do {			\
+	if ((timer)->hw.flags & SNDRV_TIMER_HW_NONATOMIC)	\
+		spin_unlock_irqrestore(&(timer)->lock, flags);	\
+	(timer)->hw.action(timer);				\
+	if ((timer)->hw.flags & SNDRV_TIMER_HW_NONATOMIC)	\
+		spin_lock_irqsave(&(timer)->lock, flags);	\
+} while (0)
+
 static int snd_timer_start1(snd_timer_t *timer, snd_timer_instance_t *timeri,
 			    unsigned long sticks)
 {
+	unsigned long flags;
+
+	spin_lock_irqsave(&timer->lock, flags);
 	list_del(&timeri->active_list);
 	list_add_tail(&timeri->active_list, &timer->active_list_head);
 	if (timer->running) {
@@ -431,13 +442,18 @@
 			goto __start_now;
 		timer->flags |= SNDRV_TIMER_FLG_RESCHED;
 		timeri->flags |= SNDRV_TIMER_IFLG_START;
+		spin_unlock_irqrestore(&timer->lock, flags);
 		return 1;	/* delayed start */
 	} else {
 		timer->sticks = sticks;
-		timer->hw.start(timer);
+		if (timer->state == SNDRV_TIMER_STATE_RUNNING)
+			call_timer_hw(stop, timer, flags);
+		call_timer_hw(start, timer, flags);
+		timer->state = SNDRV_TIMER_STATE_RUNNING;
 	      __start_now:
 		timer->running++;
 		timeri->flags |= SNDRV_TIMER_IFLG_RUNNING;
+		spin_unlock_irqrestore(&timer->lock, flags);
 		return 0;
 	}
 }
@@ -477,8 +493,8 @@
 	spin_lock_irqsave(&timer->lock, flags);
 	timeri->ticks = timeri->cticks = ticks;
 	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, ticks);
 	spin_unlock_irqrestore(&timer->lock, flags);
+	result = snd_timer_start1(timer, timeri, ticks);
 	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_START);
 	return result;
 }
@@ -488,6 +504,7 @@
 {
 	snd_timer_t *timer;
 	unsigned long flags;
+	int state;
 
 	snd_assert(timeri != NULL, return -ENXIO);
 
@@ -505,21 +522,28 @@
 	spin_lock_irqsave(&timer->lock, flags);
 	list_del_init(&timeri->ack_list);
 	list_del_init(&timeri->active_list);
-	if ((timeri->flags & SNDRV_TIMER_IFLG_RUNNING) &&
-	    !(--timer->running)) {
-		timer->hw.stop(timer);
-		if (timer->flags & SNDRV_TIMER_FLG_RESCHED) {
+	state = timer->state;
+	if (timeri->flags & SNDRV_TIMER_IFLG_RUNNING)
+		timer->running--;
+	if (! timer->running) {
+		state = SNDRV_TIMER_STATE_STOP;
+		if (timer->state != state &&
+		    (timer->flags & SNDRV_TIMER_FLG_RESCHED)) {
 			timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
 			snd_timer_reschedule(timer, 0);
 			if (timer->flags & SNDRV_TIMER_FLG_CHANGE) {
 				timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
-				timer->hw.start(timer);
+				state = SNDRV_TIMER_STATE_RUNNING;
 			}
 		}
 	}
 	if (!keep_flag)
 		timeri->flags &=
 			~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
+	if (state != timer->state) {
+		call_timer_hw(stop, timer, flags);
+		timer->state = SNDRV_TIMER_STATE_STOP;
+	}
 	spin_unlock_irqrestore(&timer->lock, flags);
       __end:
 	if (event != SNDRV_TIMER_EVENT_RESOLUTION)
@@ -569,8 +593,8 @@
 	if (!timeri->cticks)
 		timeri->cticks = 1;
 	timeri->pticks = 0;
-	result = snd_timer_start1(timer, timeri, timer->sticks);
 	spin_unlock_irqrestore(&timer->lock, flags);
+	result = snd_timer_start1(timer, timeri, timer->sticks);
 	snd_timer_notify1(timeri, SNDRV_TIMER_EVENT_CONTINUE);
 	return result;
 }
@@ -719,17 +743,24 @@
 		snd_timer_reschedule(timer, ticks_left);
 	if (timer->running) {
 		if (timer->hw.flags & SNDRV_TIMER_HW_STOP) {
-			timer->hw.stop(timer);
+			if (! (timer->hw.flags & SNDRV_TIMER_HW_NONATOMIC)) {
+				timer->hw.stop(timer);
+				timer->state = SNDRV_TIMER_STATE_STOP;
+			}
 			timer->flags |= SNDRV_TIMER_FLG_CHANGE;
 		}
 		if (!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||
 		    (timer->flags & SNDRV_TIMER_FLG_CHANGE)) {
 			/* restart timer */
 			timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
-			timer->hw.start(timer);
+			if (! (timer->hw.flags & SNDRV_TIMER_HW_NONATOMIC)) {
+				timer->hw.start(timer);
+				timer->state = SNDRV_TIMER_STATE_RUNNING;
+			}
 		}
-	} else {
+	} else if (! (timer->hw.flags & SNDRV_TIMER_HW_NONATOMIC)) {
 		timer->hw.stop(timer);
+		timer->state = SNDRV_TIMER_STATE_STOP;
 	}
 
 	/* now process all fast callbacks */

Index: alsa-kernel/include/timer.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/include/timer.h,v retrieving revision 1.14

include/timer.h +5 -0
diff -u -r1.14 timer.h
@@ -51,6 +51,10 @@
 #define SNDRV_TIMER_HW_SLAVE	0x00000004	/* only slave timer (variable resolution) */
 #define SNDRV_TIMER_HW_FIRST	0x00000008	/* first tick can be incomplete */
 #define SNDRV_TIMER_HW_TASKLET	0x00000010	/* timer is called from tasklet */
+#define SNDRV_TIMER_HW_NONATOMIC 0x00000020	/* start/stop are non-atomic */
+
+#define SNDRV_TIMER_STATE_STOP		0
+#define SNDRV_TIMER_STATE_RUNNING	1
 
 #define SNDRV_TIMER_IFLG_SLAVE	  0x00000001
 #define SNDRV_TIMER_IFLG_RUNNING  0x00000002
@@ -95,6 +99,7 @@
 	char name[80];
 	unsigned int flags;
 	int running;			/* running instances */
+	int state;			/* running state */
 	unsigned long sticks;		/* schedule ticks */
 	void *private_data;
 	void (*private_free) (snd_timer_t *timer);
#19 lore raw
Quoted 2 lines · --- Takashi Iwai
Quoted 2 lines

Anyway, could you run rmmod manually just like your script and check the soft lockup at each rmmod?

I have just unloaded every snd* module one by one, by hand, without triggering the soft lockup watchdog.

Quoted 3 lines

Above all, please check whether the problem at unloading happens, too, if the system timer is used instead of rtctimer. I guess it's related to rtctimer, though.

Is it enough just to have the snd-rtctimer module loaded to do that? Because as I rule I *do* have the snd-rtctimer module loaded.

Cheers,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#20 lore raw

At Wed, 2 Nov 2005 23:00:35 +0000 (GMT),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai
Quoted 2 lines

Anyway, could you run rmmod manually just like your script and check the soft lockup at each rmmod?

I have just unloaded every snd* module one by one, by hand, without triggering the soft lockup watchdog.

Quoted 6 lines
Quoted 3 lines

Above all, please check whether the problem at unloading happens, too, if the system timer is used instead of rtctimer. I guess it's related to rtctimer, though.

Is it enough just to have the snd-rtctimer module loaded to do that? Because as I rule I *do* have the snd-rtctimer module loaded.

No, you missed the point.
I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

Set snd_default_timer_device=0 option to snd module to enable the system timer over sequencer.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#21 lore raw
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#22 lore raw

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.
BTW, in the latest cvs, rtctimer is disabled because of this bug.

Takashi
---

drivers/char/rtc.c +38 -27
@@ -149,8 +149,22 @@ static void get_rtc_alm_time (struct rtc
 #ifdef RTC_IRQ
 static void rtc_dropped_irq(unsigned long data);
 
-static void set_rtc_irq_bit(unsigned char bit);
-static void mask_rtc_irq_bit(unsigned char bit);
+static void set_rtc_irq_bit_locked(unsigned char bit);
+static void mask_rtc_irq_bit_locked(unsigned char bit);
+
+static inline void set_rtc_irq_bit(unsigned char bit)
+{
+	spin_lock_irq(&rtc_lock);
+	set_rtc_irq_bit_locked(bit);
+	spin_unlock_irq(&rtc_lock);
+}
+
+static void mask_rtc_irq_bit(unsigned char bit)
+{
+	spin_lock_irq(&rtc_lock);
+	mask_rtc_irq_bit_locked(bit);
+	spin_unlock_irq(&rtc_lock);
+}
 #endif
 
 static int rtc_proc_open(struct inode *inode, struct file *file);
@@ -401,18 +415,19 @@ static int rtc_do_ioctl(unsigned int cmd
 	}
 	case RTC_PIE_OFF:	/* Mask periodic int. enab. bit	*/
 	{
-		mask_rtc_irq_bit(RTC_PIE);
+		unsigned long flags; /* can be called from isr via rtc_control() */
+		spin_lock_irqsave (&rtc_lock, flags);
+		mask_rtc_irq_bit_locked(RTC_PIE);
 		if (rtc_status & RTC_TIMER_ON) {
-			spin_lock_irq (&rtc_lock);
 			rtc_status &= ~RTC_TIMER_ON;
 			del_timer(&rtc_irq_timer);
-			spin_unlock_irq (&rtc_lock);
 		}
+		spin_unlock_irqrestore (&rtc_lock, flags);
 		return 0;
 	}
 	case RTC_PIE_ON:	/* Allow periodic ints		*/
 	{
-
+		unsigned long flags; /* can be called from isr via rtc_control() */
 		/*
 		 * We don't really want Joe User enabling more
 		 * than 64Hz of interrupts on a multi-user machine.
@@ -421,14 +436,14 @@ static int rtc_do_ioctl(unsigned int cmd
 			(!capable(CAP_SYS_RESOURCE)))
 			return -EACCES;
 
+		spin_lock_irqsave (&rtc_lock, flags);
 		if (!(rtc_status & RTC_TIMER_ON)) {
-			spin_lock_irq (&rtc_lock);
 			rtc_irq_timer.expires = jiffies + HZ/rtc_freq + 2*HZ/100;
 			add_timer(&rtc_irq_timer);
 			rtc_status |= RTC_TIMER_ON;
-			spin_unlock_irq (&rtc_lock);
 		}
-		set_rtc_irq_bit(RTC_PIE);
+		set_rtc_irq_bit_locked(RTC_PIE);
+		spin_unlock_irqrestore (&rtc_lock, flags);
 		return 0;
 	}
 	case RTC_UIE_OFF:	/* Mask ints from RTC updates.	*/
@@ -609,6 +624,7 @@ static int rtc_do_ioctl(unsigned int cmd
 	{
 		int tmp = 0;
 		unsigned char val;
+		unsigned long flags; /* can be called from isr via rtc_control() */
 
 		/* 
 		 * The max we can do is 8192Hz.
@@ -631,9 +647,9 @@ static int rtc_do_ioctl(unsigned int cmd
 		if (arg != (1<<tmp))
 			return -EINVAL;
 
-		spin_lock_irq(&rtc_lock);
+		spin_lock_irqsave(&rtc_lock, flags);
 		if (hpet_set_periodic_freq(arg)) {
-			spin_unlock_irq(&rtc_lock);
+			spin_unlock_irqrestore(&rtc_lock, flags);
 			return 0;
 		}
 		rtc_freq = arg;
@@ -641,7 +657,7 @@ static int rtc_do_ioctl(unsigned int cmd
 		val = CMOS_READ(RTC_FREQ_SELECT) & 0xf0;
 		val |= (16 - tmp);
 		CMOS_WRITE(val, RTC_FREQ_SELECT);
-		spin_unlock_irq(&rtc_lock);
+		spin_unlock_irqrestore(&rtc_lock, flags);
 		return 0;
 	}
 #endif
@@ -844,12 +860,15 @@ int rtc_control(rtc_task_t *task, unsign
 #ifndef RTC_IRQ
 	return -EIO;
 #else
-	spin_lock_irq(&rtc_task_lock);
+	unsigned long flags;
+	if (cmd != RTC_PIE_ON && cmd != RTC_PIE_OFF && cmd != RTC_IRQP_SET)
+		return -EINVAL;
+	spin_lock_irqsave(&rtc_task_lock, flags);
 	if (rtc_callback != task) {
-		spin_unlock_irq(&rtc_task_lock);
+		spin_unlock_irqrestore(&rtc_task_lock, flags);
 		return -ENXIO;
 	}
-	spin_unlock_irq(&rtc_task_lock);
+	spin_unlock_irqrestore(&rtc_task_lock, flags);
 	return rtc_do_ioctl(cmd, arg, 1);
 #endif
 }
@@ -1306,40 +1325,32 @@ static void get_rtc_alm_time(struct rtc_
  * meddles with the interrupt enable/disable bits.
  */
 
-static void mask_rtc_irq_bit(unsigned char bit)
+static void mask_rtc_irq_bit_locked(unsigned char bit)
 {
 	unsigned char val;
 
-	spin_lock_irq(&rtc_lock);
-	if (hpet_mask_rtc_irq_bit(bit)) {
-		spin_unlock_irq(&rtc_lock);
+	if (hpet_mask_rtc_irq_bit(bit))
 		return;
-	}
 	val = CMOS_READ(RTC_CONTROL);
 	val &=  ~bit;
 	CMOS_WRITE(val, RTC_CONTROL);
 	CMOS_READ(RTC_INTR_FLAGS);
 
 	rtc_irq_data = 0;
-	spin_unlock_irq(&rtc_lock);
 }
 
-static void set_rtc_irq_bit(unsigned char bit)
+static void set_rtc_irq_bit_locked(unsigned char bit)
 {
 	unsigned char val;
 
-	spin_lock_irq(&rtc_lock);
-	if (hpet_set_rtc_irq_bit(bit)) {
-		spin_unlock_irq(&rtc_lock);
+	if (hpet_set_rtc_irq_bit(bit))
 		return;
-	}
 	val = CMOS_READ(RTC_CONTROL);
 	val |= bit;
 	CMOS_WRITE(val, RTC_CONTROL);
 	CMOS_READ(RTC_INTR_FLAGS);
 
 	rtc_irq_data = 0;
-	spin_unlock_irq(&rtc_lock);
 }
 #endif
 

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#23 lore raw
Quoted 2 lines · --- Takashi Iwai

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.

And we have a winner! The snd-rtctimer module is in use, and the unalsa alias can still remove everything without locking the box up.

I'm still using your latest ALSA patch, too. Do I need that now?

Cheers,
Chris

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#24 lore raw
In reply to Takashi Iwai
Quoted 7 lines · Takashi Iwai

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),

Quoted 5 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

Quoted 7 lines
Quoted 3 lines

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.
BTW, in the latest cvs, rtctimer is disabled because of this bug.

This may not be accepted by the -stable maintainers, it's too big complex. I've sent them much simpler patches for emu10k1 regressions that got rejected.

Lee

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#25 lore raw
Quoted 3 lines · --- Lee Revell

This may not be accepted by the -stable maintainers, it's too big complex. I've sent them much simpler patches for emu10k1 regressions that got rejected.

Heh, I can live with it until someone comes up without something that *is* acceptable. But it does seem to highlight the existence of an RTC bug.

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#26 lore raw
In reply to Lee Revell

At Mon, 07 Nov 2005 15:22:34 -0500,

Quoted 13 lines · Lee Revell
Quoted 11 lines · Takashi Iwai

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Quoted 7 lines
Quoted 3 lines

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.
BTW, in the latest cvs, rtctimer is disabled because of this bug.

This may not be accepted by the -stable maintainers, it's too big complex. I've sent them much simpler patches for emu10k1 regressions that got rejected.

Right. But this bug is more serious, so let's hope it'll get merged.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#27 lore raw
Quoted 19 lines · Takashi Iwai

At Mon, 07 Nov 2005 15:22:34 -0500,

Quoted 17 lines · Lee Revell
Quoted 14 lines · Takashi Iwai

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.
BTW, in the latest cvs, rtctimer is disabled because of this bug.

Quoted 5 lines
Quoted 3 lines

This may not be accepted by the -stable maintainers, it's too big complex. I've sent them much simpler patches for emu10k1 regressions that got rejected.

Right. But this bug is more serious, so let's hope it'll get merged.

I think that it's already merged in Linus's git tree:

commit c3348760aaffd268f7e91b2185999025fdc5607f
tree dc4fd97943a8547189bb025c71321fb67c5fc3c6
parent 1d4ae4a119e5ba711f12b05cdf27f794460add4b
author Takashi Iwai <[email protected]> Mon, 07 Nov 2005 11:14:57 +0100 committer Jaroslav Kysela <[email protected]> Mon, 07 Nov 2005 11:14:57 +0100

[PATCH] Fix wrong irq enable via rtc_control()

rtc_control() may be called in the interrupt context in ALSA rtc-timer driver. The patch fixes the wrong irq enable in rtc.c, and also fixes the possible race of bit flags.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#28 lore raw

At Tue, 8 Nov 2005 11:34:27 +0100 (CET),

Quoted 22 lines · Jaroslav
Quoted 19 lines · Takashi Iwai

At Mon, 07 Nov 2005 15:22:34 -0500,

Quoted 17 lines · Lee Revell
Quoted 14 lines · Takashi Iwai

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),

Quoted 8 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

I want to know whether this happens _without_ snd-rtctimer, but with the very same system.

My "unalsa" alias works fine if seq_default_timer_device = 0. My machine has also locked up once with the new patch and aplaymidi when aplaymidi forced the snd-rtctimer module to autoload. However, this time, the machine actually played the MIDI file before locking up.

Then, we have to fix rtc.c itself. The patch is below. I'll submit it to stable tree, too, if it works.
BTW, in the latest cvs, rtctimer is disabled because of this bug.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

This may not be accepted by the -stable maintainers, it's too big complex. I've sent them much simpler patches for emu10k1 regressions that got rejected.

Right. But this bug is more serious, so let's hope it'll get merged.

I think that it's already merged in Linus's git tree:

That's good to hear, but we talked about the 2.6.14.x stable tree :)

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#29 lore raw
Quoted 3 lines · Takashi Iwai
Quoted 1 line

I think that it's already merged in Linus's git tree:

That's good to hear, but we talked about the 2.6.14.x stable tree :)

I see. Sorry.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#30 lore raw
In reply to Chris Rankin

At Wed, 2 Nov 2005 23:00:35 +0000 (GMT),

Quoted 7 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai
Quoted 2 lines

Anyway, could you run rmmod manually just like your script and check the soft lockup at each rmmod?

I have just unloaded every snd* module one by one, by hand, without triggering the soft lockup watchdog.

So, you can't reproduce it when you do manually. Does the script do anything else than what you did manually?

Anyway, check /proc/asound directories after you did rmmod all snd* modules whether they are reall all removed.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#31 lore raw
In reply to Takashi Iwai
Quoted 2 lines · --- Takashi Iwai

Also, the below is an improved patch for the timer deadlock. Please give a shot.

The first patch worked, but this second one didn't.

Cheers,
Chris

___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#32 lore raw

At Wed, 2 Nov 2005 23:24:51 +0000 (GMT),

Quoted 6 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

Also, the below is an improved patch for the timer deadlock. Please give a shot.

The first patch worked, but this second one didn't.

Sorry, a patch was incomplete. Apply the below additionally.

Takashi

Index: alsa-kernel/core/rtctimer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/rtctimer.c,v retrieving revision 1.19

core/rtctimer.c +1 -1
diff -u -r1.19 rtctimer.c
@@ -50,7 +50,7 @@
  * The hardware dependent description for this timer.
  */
 static struct _snd_timer_hardware rtc_hw = {
-	.flags =	SNDRV_TIMER_HW_FIRST|SNDRV_TIMER_HW_AUTO,
+	.flags =	SNDRV_TIMER_HW_FIRST|SNDRV_TIMER_HW_AUTO|SNDRV_TIMER_HW_NONATOMIC,
 	.ticks =	100000000L,		/* FIXME: XXX */
 	.open =		rtctimer_open,
 	.close =	rtctimer_close,

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

#34 lore raw

At Thu, 3 Nov 2005 23:01:02 +0000 (GMT),

Quoted 6 lines · Chris Rankin
Quoted 2 lines

Sorry, a patch was incomplete. Apply the below additionally.

The second patch works with this new addition. However, my "unalsa" alias still triggers the soft lockup. Here's a screenshot of my desktop, showing the effect of running "unalsa" in the remote xterm.

I see lots of modules are _not_ unloaded since they are in use. But some seem to be unloaded indeed, e.g. sequencer and synth stuff.

Could you do the following?
- First, show your unalsa script
- Then add the code to print which module is being removed and show the exit status of rmmod. This will make it clearer what is really going on.
- If the bug is 100% reproducible in the same way, put delays (some seconds) between each rmmod call, in order to see which one triggers this bug. If the bug doesn't trigger with delayed calls, it must be a race, most likely among sequencer, synth and hwdep creation/deletion.

Quoted 1 line

Note that the snd-rtctimer module was not loaded when this happened.

Did you set the module option to snd-seq as I requested to disable rtc timer?

thanks,

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#35 lore raw
Quoted 2 lines · --- Takashi Iwai

Could you do the following?
- First, show your unalsa script

I thought I had already? And it's an alias, not a script. Basically, it parses /proc/modules through awk and extracts the module name, which it then passes to rmmod via xargs.

Quoted 2 lines

Did you set the module option to snd-seq as I requested to disable rtc timer?

No, but then the snd-rtctimer module wasn't loaded here in the first place.

Cheers,
Chris

___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#36 lore raw

At Fri, 4 Nov 2005 14:01:45 +0000 (GMT),

Quoted 6 lines · Chris Rankin
Quoted 2 lines · --- Takashi Iwai

Could you do the following?
- First, show your unalsa script

I thought I had already?

No, IIRC, only udev configurations.

Quoted 2 lines

And it's an alias, not a script. Basically, it parses /proc/modules
through awk and extracts the module name, which it then passes to rmmod via xargs.

Then please show the alias. And let's make it a script, so that my requirements (echo the name, status, add sleep) can be filled in.

Quoted 4 lines
Quoted 2 lines

Did you set the module option to snd-seq as I requested to disable rtc timer?

No, but then the snd-rtctimer module wasn't loaded here in the first place.

Even after you use the sequencer stuff?

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#37 lore raw
Quoted 1 line · --- Takashi Iwai

Then please show the alias.

awk '{print \$1}' < /proc/modules | grep ^snd | xargs /sbin/rmmod

___________________________________________________________
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php

#38 lore raw
In reply to Chris Rankin

At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),

Quoted 4 lines · Chris Rankin
$ cat /etc/dev.d/snd/midiC0D1/alsa.dev 
#!/bin/sh -e
exec /usr/bin/asfxload /usr/lib/sfbank/8mbgmsfx.sf2

BTW, this is wrong. You should check hwC0D2, instead.

Takashi

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php