All of lore.kernel.org
 help / color / mirror / Atom feed
* Linux 2.6.14: Total lockup using aplaymidi
@ 2005-10-28 23:33 Chris Rankin
  2005-10-29  1:26 ` Lee Revell
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-10-28 23:33 UTC (permalink / raw)
  To: alsa-devel

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-28 23:33 Linux 2.6.14: Total lockup using aplaymidi Chris Rankin
@ 2005-10-29  1:26 ` Lee Revell
  2005-10-29 10:23   ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Lee Revell @ 2005-10-29  1:26 UTC (permalink / raw)
  To: Chris Rankin; +Cc: alsa-devel

On Sat, 2005-10-29 at 00:33 +0100, Chris Rankin wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-29  1:26 ` Lee Revell
@ 2005-10-29 10:23   ` Chris Rankin
  2005-10-29 17:30     ` Lee Revell
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-10-29 10:23 UTC (permalink / raw)
  To: Lee Revell; +Cc: alsa-devel

--- Lee Revell <rlrevell@joe-job.com> wrote:
> > 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.

> Which soundfont do you have loaded?

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

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

None.

>  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
 
> 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.

> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-29 10:23   ` Chris Rankin
@ 2005-10-29 17:30     ` Lee Revell
  2005-10-29 20:08       ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Lee Revell @ 2005-10-29 17:30 UTC (permalink / raw)
  To: Chris Rankin; +Cc: alsa-devel

On Sat, 2005-10-29 at 11:23 +0100, Chris Rankin wrote:
> 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 ...

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-29 17:30     ` Lee Revell
@ 2005-10-29 20:08       ` Chris Rankin
  2005-10-29 22:32         ` Lee Revell
  2005-10-31 17:22         ` Takashi Iwai
  0 siblings, 2 replies; 38+ messages in thread
From: Chris Rankin @ 2005-10-29 20:08 UTC (permalink / raw)
  To: Lee Revell; +Cc: alsa-devel

--- Lee Revell <rlrevell@joe-job.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-29 20:08       ` Chris Rankin
@ 2005-10-29 22:32         ` Lee Revell
  2005-10-31 17:22         ` Takashi Iwai
  1 sibling, 0 replies; 38+ messages in thread
From: Lee Revell @ 2005-10-29 22:32 UTC (permalink / raw)
  To: Chris Rankin; +Cc: alsa-devel

On Sat, 2005-10-29 at 21:08 +0100, Chris Rankin wrote:
> --- Lee Revell <rlrevell@joe-job.com> wrote:
> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-29 20:08       ` Chris Rankin
  2005-10-29 22:32         ` Lee Revell
@ 2005-10-31 17:22         ` Takashi Iwai
  2005-11-01 22:23           ` Chris Rankin
  1 sibling, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-10-31 17:22 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

At Sat, 29 Oct 2005 21:08:42 +0100 (BST),
Chris Rankin wrote:
> 
> --- Lee Revell <rlrevell@joe-job.com> wrote:
> > 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

[-- Attachment #2: timer-deadlock-fix.diff --]
[-- Type: application/octet-stream, Size: 5293 bytes --]

Index: alsa-kernel/core/timer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/timer.c,v
retrieving revision 1.67
diff -u -r1.67 timer.c
--- alsa-kernel/core/timer.c	12 Oct 2005 16:36:55 -0000	1.67
+++ alsa-kernel/core/timer.c	31 Oct 2005 17:22:04 -0000
@@ -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
diff -u -r1.14 timer.h
--- alsa-kernel/include/timer.h	12 Oct 2005 16:36:55 -0000	1.14
+++ alsa-kernel/include/timer.h	31 Oct 2005 17:22:04 -0000
@@ -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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-10-31 17:22         ` Takashi Iwai
@ 2005-11-01 22:23           ` Chris Rankin
  2005-11-01 23:22             ` Lee Revell
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-01 22:23 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-01 22:23           ` Chris Rankin
@ 2005-11-01 23:22             ` Lee Revell
  2005-11-02  0:00               ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Lee Revell @ 2005-11-01 23:22 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Takashi Iwai, alsa-devel

On Tue, 2005-11-01 at 22:23 +0000, Chris Rankin wrote:
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-01 23:22             ` Lee Revell
@ 2005-11-02  0:00               ` Chris Rankin
  2005-11-02 10:44                 ` Takashi Iwai
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-02  0:00 UTC (permalink / raw)
  To: Lee Revell; +Cc: Takashi Iwai, alsa-devel

> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02  0:00               ` Chris Rankin
@ 2005-11-02 10:44                 ` Takashi Iwai
  2005-11-02 11:00                   ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-02 10:44 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 00:00:23 +0000 (GMT),
Chris Rankin wrote:
> 
> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 10:44                 ` Takashi Iwai
@ 2005-11-02 11:00                   ` Chris Rankin
  2005-11-02 11:25                     ` Takashi Iwai
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-02 11:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 11:00                   ` Chris Rankin
@ 2005-11-02 11:25                     ` Takashi Iwai
  2005-11-02 12:42                       ` Chris Rankin
                                         ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-02 11:25 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > 
> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 11:25                     ` Takashi Iwai
@ 2005-11-02 12:42                       ` Chris Rankin
  2005-11-02 16:57                       ` Lee Revell
  2005-11-02 18:29                       ` Chris Rankin
  2 siblings, 0 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-02 12:42 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
 
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 11:25                     ` Takashi Iwai
  2005-11-02 12:42                       ` Chris Rankin
@ 2005-11-02 16:57                       ` Lee Revell
  2005-11-02 18:39                         ` Takashi Iwai
  2005-11-02 18:29                       ` Chris Rankin
  2 siblings, 1 reply; 38+ messages in thread
From: Lee Revell @ 2005-11-02 16:57 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Chris Rankin, alsa-devel

On Wed, 2005-11-02 at 12:25 +0100, Takashi Iwai wrote:
> At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),
> Chris Rankin wrote:
> > 
> > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > 
> > > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 11:25                     ` Takashi Iwai
  2005-11-02 12:42                       ` Chris Rankin
  2005-11-02 16:57                       ` Lee Revell
@ 2005-11-02 18:29                       ` Chris Rankin
  2005-11-02 18:41                         ` Takashi Iwai
  2005-11-04 11:16                         ` Takashi Iwai
  2 siblings, 2 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-02 18:29 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 16:57                       ` Lee Revell
@ 2005-11-02 18:39                         ` Takashi Iwai
  0 siblings, 0 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-02 18:39 UTC (permalink / raw)
  To: Lee Revell; +Cc: Chris Rankin, alsa-devel

At Wed, 02 Nov 2005 11:57:04 -0500,
Lee Revell wrote:
> 
> On Wed, 2005-11-02 at 12:25 +0100, Takashi Iwai wrote:
> > At Wed, 2 Nov 2005 11:00:45 +0000 (GMT),
> > Chris Rankin wrote:
> > > 
> > > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > > 
> > > > 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.

>  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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 18:29                       ` Chris Rankin
@ 2005-11-02 18:41                         ` Takashi Iwai
  2005-11-02 20:06                           ` Takashi Iwai
  2005-11-04 11:16                         ` Takashi Iwai
  1 sibling, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-02 18:41 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > 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

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 18:41                         ` Takashi Iwai
@ 2005-11-02 20:06                           ` Takashi Iwai
  2005-11-02 23:00                             ` Chris Rankin
  2005-11-02 23:24                             ` Chris Rankin
  0 siblings, 2 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-02 20:06 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]

At Wed, 02 Nov 2005 19:41:48 +0100,
私 wrote:
> 
> At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),
> Chris Rankin wrote:
> > 
> > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > 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
> 
> 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

[-- Attachment #2: timer-deadlock-fix2.diff --]
[-- Type: application/octet-stream, Size: 5492 bytes --]

Index: alsa-kernel/core/timer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/timer.c,v
retrieving revision 1.67
diff -u -r1.67 timer.c
--- alsa-kernel/core/timer.c	12 Oct 2005 16:36:55 -0000	1.67
+++ alsa-kernel/core/timer.c	2 Nov 2005 20:04:48 -0000
@@ -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
diff -u -r1.14 timer.h
--- alsa-kernel/include/timer.h	12 Oct 2005 16:36:55 -0000	1.14
+++ alsa-kernel/include/timer.h	2 Nov 2005 20:04:48 -0000
@@ -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);

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 20:06                           ` Takashi Iwai
@ 2005-11-02 23:00                             ` Chris Rankin
  2005-11-03  9:36                               ` Takashi Iwai
  2005-11-03  9:40                               ` Takashi Iwai
  2005-11-02 23:24                             ` Chris Rankin
  1 sibling, 2 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-02 23:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> > 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.
 
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 20:06                           ` Takashi Iwai
  2005-11-02 23:00                             ` Chris Rankin
@ 2005-11-02 23:24                             ` Chris Rankin
  2005-11-03 10:12                               ` Takashi Iwai
  1 sibling, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-02 23:24 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 23:00                             ` Chris Rankin
@ 2005-11-03  9:36                               ` Takashi Iwai
  2005-11-05 20:44                                 ` Chris Rankin
  2005-11-03  9:40                               ` Takashi Iwai
  1 sibling, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-03  9:36 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 23:00:35 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > > 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.
>  
> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 23:00                             ` Chris Rankin
  2005-11-03  9:36                               ` Takashi Iwai
@ 2005-11-03  9:40                               ` Takashi Iwai
  1 sibling, 0 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-03  9:40 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 23:00:35 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 23:24                             ` Chris Rankin
@ 2005-11-03 10:12                               ` Takashi Iwai
       [not found]                                 ` <20051103230102.88018.qmail@web52901.mail.yahoo.com>
  0 siblings, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-03 10:12 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

At Wed, 2 Nov 2005 23:24:51 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > 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

[-- Attachment #2: rtctimer-fix.diff --]
[-- Type: application/octet-stream, Size: 685 bytes --]

Index: alsa-kernel/core/rtctimer.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/rtctimer.c,v
retrieving revision 1.19
diff -u -r1.19 rtctimer.c
--- alsa-kernel/core/rtctimer.c	12 Oct 2005 16:36:55 -0000	1.19
+++ alsa-kernel/core/rtctimer.c	3 Nov 2005 10:11:34 -0000
@@ -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,

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-02 18:29                       ` Chris Rankin
  2005-11-02 18:41                         ` Takashi Iwai
@ 2005-11-04 11:16                         ` Takashi Iwai
  1 sibling, 0 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-04 11:16 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Wed, 2 Nov 2005 18:29:51 +0000 (GMT),
Chris Rankin wrote:
> 
> $ 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
       [not found]                                 ` <20051103230102.88018.qmail@web52901.mail.yahoo.com>
@ 2005-11-04 11:26                                   ` Takashi Iwai
  2005-11-04 14:01                                     ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-04 11:26 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Thu, 3 Nov 2005 23:01:02 +0000 (GMT),
Chris Rankin wrote:
> 
> > 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.

>  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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-04 11:26                                   ` Takashi Iwai
@ 2005-11-04 14:01                                     ` Chris Rankin
  2005-11-04 14:05                                       ` Takashi Iwai
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-04 14:01 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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. 

> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-04 14:01                                     ` Chris Rankin
@ 2005-11-04 14:05                                       ` Takashi Iwai
  2005-11-04 16:39                                         ` Chris Rankin
  0 siblings, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-04 14:05 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Fri, 4 Nov 2005 14:01:45 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > Could you do the following?
> > - First, show your unalsa script
> 
> I thought I had already?

No, IIRC, only udev configurations.

>  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.

> > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-04 14:05                                       ` Takashi Iwai
@ 2005-11-04 16:39                                         ` Chris Rankin
  0 siblings, 0 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-04 16:39 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-03  9:36                               ` Takashi Iwai
@ 2005-11-05 20:44                                 ` Chris Rankin
  2005-11-07 10:39                                   ` Takashi Iwai
  0 siblings, 1 reply; 38+ messages in thread
From: Chris Rankin @ 2005-11-05 20:44 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-05 20:44                                 ` Chris Rankin
@ 2005-11-07 10:39                                   ` Takashi Iwai
  2005-11-07 20:18                                     ` Chris Rankin
  2005-11-07 20:22                                     ` Lee Revell
  0 siblings, 2 replies; 38+ messages in thread
From: Takashi Iwai @ 2005-11-07 10:39 UTC (permalink / raw)
  To: Chris Rankin; +Cc: Lee Revell, alsa-devel

At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),
Chris Rankin wrote:
> 
> --- Takashi Iwai <tiwai@suse.de> wrote:
> > 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
---
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-07 10:39                                   ` Takashi Iwai
@ 2005-11-07 20:18                                     ` Chris Rankin
  2005-11-07 20:22                                     ` Lee Revell
  1 sibling, 0 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-07 20:18 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, alsa-devel

--- Takashi Iwai <tiwai@suse.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-07 10:39                                   ` Takashi Iwai
  2005-11-07 20:18                                     ` Chris Rankin
@ 2005-11-07 20:22                                     ` Lee Revell
  2005-11-07 22:08                                       ` Chris Rankin
  2005-11-08 10:18                                       ` Takashi Iwai
  1 sibling, 2 replies; 38+ messages in thread
From: Lee Revell @ 2005-11-07 20:22 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Chris Rankin, alsa-devel

On Mon, 2005-11-07 at 11:39 +0100, Takashi Iwai wrote:
> At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),
> Chris Rankin wrote:
> > 
> > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > 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.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-07 20:22                                     ` Lee Revell
@ 2005-11-07 22:08                                       ` Chris Rankin
  2005-11-08 10:18                                       ` Takashi Iwai
  1 sibling, 0 replies; 38+ messages in thread
From: Chris Rankin @ 2005-11-07 22:08 UTC (permalink / raw)
  To: Lee Revell, Takashi Iwai; +Cc: alsa-devel

--- Lee Revell <rlrevell@joe-job.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-07 20:22                                     ` Lee Revell
  2005-11-07 22:08                                       ` Chris Rankin
@ 2005-11-08 10:18                                       ` Takashi Iwai
  2005-11-08 10:34                                         ` Jaroslav Kysela
  1 sibling, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-08 10:18 UTC (permalink / raw)
  To: Lee Revell; +Cc: Chris Rankin, alsa-devel

At Mon, 07 Nov 2005 15:22:34 -0500,
Lee Revell wrote:
> 
> On Mon, 2005-11-07 at 11:39 +0100, Takashi Iwai wrote:
> > At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),
> > Chris Rankin wrote:
> > > 
> > > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > > 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.
> 
> 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-08 10:18                                       ` Takashi Iwai
@ 2005-11-08 10:34                                         ` Jaroslav Kysela
  2005-11-08 10:55                                           ` Takashi Iwai
  0 siblings, 1 reply; 38+ messages in thread
From: Jaroslav Kysela @ 2005-11-08 10:34 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, Chris Rankin, alsa-devel

On Tue, 8 Nov 2005, Takashi Iwai wrote:

> At Mon, 07 Nov 2005 15:22:34 -0500,
> Lee Revell wrote:
> > 
> > On Mon, 2005-11-07 at 11:39 +0100, Takashi Iwai wrote:
> > > At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),
> > > Chris Rankin wrote:
> > > > 
> > > > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > > > 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.
> > 
> > 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 <tiwai@suse.de> Mon, 07 Nov 2005 11:14:57 +0100
committer Jaroslav Kysela <perex@suse.cz> 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.

    Signed-off-by: Takashi Iwai <tiwai@suse.de>


						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-08 10:34                                         ` Jaroslav Kysela
@ 2005-11-08 10:55                                           ` Takashi Iwai
  2005-11-09  9:34                                             ` Jaroslav Kysela
  0 siblings, 1 reply; 38+ messages in thread
From: Takashi Iwai @ 2005-11-08 10:55 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Lee Revell, Chris Rankin, alsa-devel

At Tue, 8 Nov 2005 11:34:27 +0100 (CET),
Jaroslav wrote:
> 
> On Tue, 8 Nov 2005, Takashi Iwai wrote:
> 
> > At Mon, 07 Nov 2005 15:22:34 -0500,
> > Lee Revell wrote:
> > > 
> > > On Mon, 2005-11-07 at 11:39 +0100, Takashi Iwai wrote:
> > > > At Sat, 5 Nov 2005 20:44:39 +0000 (GMT),
> > > > Chris Rankin wrote:
> > > > > 
> > > > > --- Takashi Iwai <tiwai@suse.de> wrote:
> > > > > > 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.
> > > 
> > > 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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: Linux 2.6.14: Total lockup using aplaymidi
  2005-11-08 10:55                                           ` Takashi Iwai
@ 2005-11-09  9:34                                             ` Jaroslav Kysela
  0 siblings, 0 replies; 38+ messages in thread
From: Jaroslav Kysela @ 2005-11-09  9:34 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Lee Revell, Chris Rankin, alsa-devel

On Tue, 8 Nov 2005, Takashi Iwai wrote:

> > 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 <perex@suse.cz>
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

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2005-11-09  9:34 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-28 23:33 Linux 2.6.14: Total lockup using aplaymidi Chris Rankin
2005-10-29  1:26 ` Lee Revell
2005-10-29 10:23   ` Chris Rankin
2005-10-29 17:30     ` Lee Revell
2005-10-29 20:08       ` Chris Rankin
2005-10-29 22:32         ` Lee Revell
2005-10-31 17:22         ` Takashi Iwai
2005-11-01 22:23           ` Chris Rankin
2005-11-01 23:22             ` Lee Revell
2005-11-02  0:00               ` Chris Rankin
2005-11-02 10:44                 ` Takashi Iwai
2005-11-02 11:00                   ` Chris Rankin
2005-11-02 11:25                     ` Takashi Iwai
2005-11-02 12:42                       ` Chris Rankin
2005-11-02 16:57                       ` Lee Revell
2005-11-02 18:39                         ` Takashi Iwai
2005-11-02 18:29                       ` Chris Rankin
2005-11-02 18:41                         ` Takashi Iwai
2005-11-02 20:06                           ` Takashi Iwai
2005-11-02 23:00                             ` Chris Rankin
2005-11-03  9:36                               ` Takashi Iwai
2005-11-05 20:44                                 ` Chris Rankin
2005-11-07 10:39                                   ` Takashi Iwai
2005-11-07 20:18                                     ` Chris Rankin
2005-11-07 20:22                                     ` Lee Revell
2005-11-07 22:08                                       ` Chris Rankin
2005-11-08 10:18                                       ` Takashi Iwai
2005-11-08 10:34                                         ` Jaroslav Kysela
2005-11-08 10:55                                           ` Takashi Iwai
2005-11-09  9:34                                             ` Jaroslav Kysela
2005-11-03  9:40                               ` Takashi Iwai
2005-11-02 23:24                             ` Chris Rankin
2005-11-03 10:12                               ` Takashi Iwai
     [not found]                                 ` <20051103230102.88018.qmail@web52901.mail.yahoo.com>
2005-11-04 11:26                                   ` Takashi Iwai
2005-11-04 14:01                                     ` Chris Rankin
2005-11-04 14:05                                       ` Takashi Iwai
2005-11-04 16:39                                         ` Chris Rankin
2005-11-04 11:16                         ` Takashi Iwai

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.