alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Re: Ooops when working with USB MIDI (2.6.33.1)
       [not found]     ` <201004090751.35398.tvrtko@ursulin.net>
@ 2010-04-09  7:29       ` Takashi Iwai
  2010-04-09 17:36         ` Tvrtko Ursulin
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2010-04-09  7:29 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: alsa-devel, Clemens Ladisch, linux-kernel

At Fri, 9 Apr 2010 07:51:35 +0100,
Tvrtko Ursulin wrote:
> 
> On Thursday 08 Apr 2010 13:22:36 Takashi Iwai wrote:
> > > Takashi, do you remember what the original problem was?
> > 
> > Well, I have only a vague memory -- it's a similar scenario that some app
> > still accessing after disconnection.  The URB can't be handled after
> > the disconnection is finished.
> > 
> > I think the patch below might fix in this case.  You can try it
> > instead of reverting the commit above.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> > ---
> > diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
> > index 2c59afd..81c8d85 100644
> > --- a/sound/usb/usbmidi.c
> > +++ b/sound/usb/usbmidi.c
> > @@ -986,6 +986,8 @@ static void snd_usbmidi_output_drain(struct
> >  snd_rawmidi_substream *substream) DEFINE_WAIT(wait);
> >  	long timeout = msecs_to_jiffies(50);
> > 
> > +	if (ep->umidi->disconnected)
> > +		return;
> >  	/*
> >  	 * The substream buffer is empty, but some data might still be in the
> >  	 * currently active URBs, so we have to wait for those to complete.
> > @@ -1275,6 +1277,11 @@ void snd_usbmidi_disconnect(struct list_head* p)
> >  			snd_usbmidi_in_endpoint_delete(ep->in);
> >  			ep->in = NULL;
> >  		}
> > +		ep->active_urbs = 0;
> > +		if (ep->drain_urbs) {
> > +			ep->drain_urbs = 0;
> > +			wake_up(&ep->drain_wait);
> > +		}
> >  	}
> >  	del_timer_sync(&umidi->error_timer);
> >  }
> 
> For the second hunk, do you think ep->out->... and so on? That would be more 
> in-line with code present in 2.6.33.

Ah, crap.  Sorry, that's just messing up.
The revised (compiled but untested) patch is below.


thanks,

Takashi

---
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 2c59afd..9e28b20 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -986,6 +986,8 @@ static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream)
 	DEFINE_WAIT(wait);
 	long timeout = msecs_to_jiffies(50);
 
+	if (ep->umidi->disconnected)
+		return;
 	/*
 	 * The substream buffer is empty, but some data might still be in the
 	 * currently active URBs, so we have to wait for those to complete.
@@ -1123,14 +1125,21 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi,
  * Frees an output endpoint.
  * May be called when ep hasn't been initialized completely.
  */
-static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint* ep)
+static void snd_usbmidi_out_endpoint_clear(struct snd_usb_midi_out_endpoint *ep)
 {
 	unsigned int i;
 
 	for (i = 0; i < OUTPUT_URBS; ++i)
-		if (ep->urbs[i].urb)
+		if (ep->urbs[i].urb) {
 			free_urb_and_buffer(ep->umidi, ep->urbs[i].urb,
 					    ep->max_transfer);
+			ep->urbs[i].urb = NULL;
+		}
+}
+
+static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep)
+{
+	snd_usbmidi_out_endpoint_clear(ep);
 	kfree(ep);
 }
 
@@ -1262,15 +1271,18 @@ void snd_usbmidi_disconnect(struct list_head* p)
 				usb_kill_urb(ep->out->urbs[j].urb);
 			if (umidi->usb_protocol_ops->finish_out_endpoint)
 				umidi->usb_protocol_ops->finish_out_endpoint(ep->out);
+			ep->out->active_urbs = 0;
+			if (ep->out->drain_urbs) {
+				ep->out->drain_urbs = 0;
+				wake_up(&ep->out->drain_wait);
+			}
 		}
 		if (ep->in)
 			for (j = 0; j < INPUT_URBS; ++j)
 				usb_kill_urb(ep->in->urbs[j]);
 		/* free endpoints here; later call can result in Oops */
-		if (ep->out) {
-			snd_usbmidi_out_endpoint_delete(ep->out);
-			ep->out = NULL;
-		}
+		if (ep->out)
+			snd_usbmidi_out_endpoint_clear(ep->out);
 		if (ep->in) {
 			snd_usbmidi_in_endpoint_delete(ep->in);
 			ep->in = NULL;

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

* Re: Ooops when working with USB MIDI (2.6.33.1)
  2010-04-09  7:29       ` Ooops when working with USB MIDI (2.6.33.1) Takashi Iwai
@ 2010-04-09 17:36         ` Tvrtko Ursulin
  2010-04-11  7:04           ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Tvrtko Ursulin @ 2010-04-09 17:36 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Clemens Ladisch, alsa-devel, linux-kernel

On Friday 09 Apr 2010 08:29:33 Takashi Iwai wrote:
> At Fri, 9 Apr 2010 07:51:35 +0100,
> 
> Tvrtko Ursulin wrote:
> > On Thursday 08 Apr 2010 13:22:36 Takashi Iwai wrote:
> > > > Takashi, do you remember what the original problem was?
> > >
> > > Well, I have only a vague memory -- it's a similar scenario that some
> > > app still accessing after disconnection.  The URB can't be handled
> > > after the disconnection is finished.
> > >
> > > I think the patch below might fix in this case.  You can try it
> > > instead of reverting the commit above.

A very quick test and it looks good  - did not crash in the disconnect and 
then exit TuxGuitar scenario. Thank you!

Tvrtko

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

* Re: Ooops when working with USB MIDI (2.6.33.1)
  2010-04-09 17:36         ` Tvrtko Ursulin
@ 2010-04-11  7:04           ` Takashi Iwai
  2010-05-03 12:48             ` Tvrtko Ursulin
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2010-04-11  7:04 UTC (permalink / raw)
  To: Tvrtko Ursulin; +Cc: alsa-devel, Clemens Ladisch, linux-kernel

At Fri, 9 Apr 2010 18:36:50 +0100,
Tvrtko Ursulin wrote:
> 
> On Friday 09 Apr 2010 08:29:33 Takashi Iwai wrote:
> > At Fri, 9 Apr 2010 07:51:35 +0100,
> > 
> > Tvrtko Ursulin wrote:
> > > On Thursday 08 Apr 2010 13:22:36 Takashi Iwai wrote:
> > > > > Takashi, do you remember what the original problem was?
> > > >
> > > > Well, I have only a vague memory -- it's a similar scenario that some
> > > > app still accessing after disconnection.  The URB can't be handled
> > > > after the disconnection is finished.
> > > >
> > > > I think the patch below might fix in this case.  You can try it
> > > > instead of reverting the commit above.
> 
> A very quick test and it looks good  - did not crash in the disconnect and 
> then exit TuxGuitar scenario. Thank you!

OK, now I merged thte patch.  Let me know if you see any regressions.


thanks,

Takashi

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

* Re: Ooops when working with USB MIDI (2.6.33.1)
  2010-04-11  7:04           ` Takashi Iwai
@ 2010-05-03 12:48             ` Tvrtko Ursulin
  0 siblings, 0 replies; 4+ messages in thread
From: Tvrtko Ursulin @ 2010-05-03 12:48 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Clemens Ladisch, alsa-devel, linux-kernel

On Sunday 11 Apr 2010 08:04:48 Takashi Iwai wrote:
> At Fri, 9 Apr 2010 18:36:50 +0100,
> 
> Tvrtko Ursulin wrote:
> > On Friday 09 Apr 2010 08:29:33 Takashi Iwai wrote:
> > > At Fri, 9 Apr 2010 07:51:35 +0100,
> > >
> > > Tvrtko Ursulin wrote:
> > > > On Thursday 08 Apr 2010 13:22:36 Takashi Iwai wrote:
> > > > > > Takashi, do you remember what the original problem was?
> > > > >
> > > > > Well, I have only a vague memory -- it's a similar scenario that
> > > > > some app still accessing after disconnection.  The URB can't be
> > > > > handled after the disconnection is finished.
> > > > >
> > > > > I think the patch below might fix in this case.  You can try it
> > > > > instead of reverting the commit above.
> >
> > A very quick test and it looks good  - did not crash in the disconnect
> > and then exit TuxGuitar scenario. Thank you!
> 
> OK, now I merged thte patch.  Let me know if you see any regressions.

Just saw possibly the same oops on 2.6.34-rc6, which seems to have this patch applied:

[185589.243713] BUG: unable to handle kernel paging request at 000000000040c840
[185589.243732] IP: [<ffffffff810685c8>] module_put+0x18/0x60
[185589.243752] PGD c4616067 PUD b741a067 PMD c47c0067 PTE 0
[185589.243768] Oops: 0000 [#1] PREEMPT SMP
[185589.243779] last sysfs file: /sys/devices/platform/it87.656/temp1_input
[185589.243790] CPU 0
[185589.243795] Modules linked in: nls_iso8859_1 nls_cp437 vfat fat it87 hwmon_vid snd_pcm_oss snd_mixer_oss snd_seq ppp_deflate 
zlib_deflate bsd_comp ppp_async crc_ccitt ppp_generic slhc radeon i2c_algo_bit nls_utf8 cifs cpufreq_conservative cpufreq_userspace 
cpufreq_powersave powernow_k8 fuse sha256_generic ansi_cprng krng eseqiv rng cryptd crypto_wq aes_x86_64 aes_generic cbc cryptomgr 
crypto_hash aead pcompress edd dm_crypt crypto_blkcipher crypto_algapi xfs exportfs loop raid0 dm_mod snd_hda_codec_atihdmi 
snd_hda_codec_via snd_usb_audio snd_hda_intel snd_hda_codec snd_usb_lib snd_hwdep snd_pcm snd_rawmidi kvm_amd snd_timer 
snd_seq_device kvm ipaq i2c_piix4 uvcvideo sr_mod snd psmouse snd_page_alloc usbserial pcspkr r8169 joydev videodev v4l1_compat 
v4l2_compat_ioctl32 wmi k10temp serio_raw button sg firewire_ohci cdrom firewire_core crc_itu_t ext4 jbd2 crc16 drm_kms_helper ttm drm fan 
processor ata_generic pata_atiixp thermal thermal_sys
[185589.244003]
[185589.244007] Pid: 21953, comm: java Not tainted 2.6.34-rc6 #2 M4A785TD-M EVO/System Product Name
[185589.244007] RIP: 0010:[<ffffffff810685c8>]  [<ffffffff810685c8>] module_put+0x18/0x60
[185589.244007] RSP: 0018:ffff8800cec7fec8  EFLAGS: 00010202
[185589.244007] RAX: ffff8800cec7ffd8 RBX: ffff88011e0d4000 RCX: 1000000000000081
[185589.244007] RDX: 000000000000003e RSI: ffffea00016e0248 RDI: 000000000040c668
[185589.244007] RBP: ffff88011d99cc20 R08: dead000000100100 R09: dead000000200200
[185589.244007] R10: dead000000100100 R11: dead000000200200 R12: 0000000000000008
[185589.244007] R13: ffff8800c1255678 R14: ffff88011d549700 R15: 00000000023cb800
[185589.244007] FS:  00007f1c265fa910(0000) GS:ffff880001800000(0000) knlGS:00000000f6959a80
[185589.244007] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[185589.244007] CR2: 000000000040c840 CR3: 0000000093488000 CR4: 00000000000006f0
[185589.244007] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[185589.244007] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[185589.244007] Process java (pid: 21953, threadinfo ffff8800cec7e000, task ffff8800cedd3480)
[185589.244007] Stack:
[185589.244007]  ffff88011d549700 ffffffffa02017da ffff880058621600 ffff8800c1006f00
[185589.244007] <0> ffff8800c1006f00 ffff8800c1006f00 ffff880058621600 ffffffff810d2071
[185589.244007] <0> ffff8800c1006f00 ffff8800b76c6100 0000000000000000 ffff8800b76c6180
[185589.244007] Call Trace:
[185589.244007]  [<ffffffffa02017da>] ? snd_rawmidi_release+0x4a/0x60 [snd_rawmidi]
[185589.244007]  [<ffffffff810d2071>] ? __fput+0xd1/0x1f0
[185589.244007]  [<ffffffff810ce8bb>] ? filp_close+0x4b/0x80
[185589.244007]  [<ffffffff810ce9a4>] ? sys_close+0xb4/0x110
[185589.244007]  [<ffffffff8100256b>] ? system_call_fastpath+0x16/0x1b
[185589.244007] Code: 89 44 24 08 e8 7a b6 31 00 48 8b 44 24 08 eb a6 0f 1f 00 48 83 ec 08 48 85 ff 74 37 65 48 8b 04 25 48 b5 00 00 ff 80 
44 e0 ff ff <48> 8b 87 d8 01 00 00 65 ff 40 04 83 3f 02 74 1d 65 48 8b 04 25
[185589.244007] RIP  [<ffffffff810685c8>] module_put+0x18/0x60
[185589.244007]  RSP <ffff8800cec7fec8>
[185589.244007] CR2: 000000000040c840
[185589.244432] ---[ end trace 9fdd48a93090f3c0 ]---
[185589.244442] note: java[21953] exited with preempt_count 1
[185590.711963] hda-intel: IRQ timing workaround is activated for card #1. Suggest a bigger bdl_pos_adj.

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

end of thread, other threads:[~2010-05-03 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <201004051433.47171.tvrtko@ursulin.net>
     [not found] ` <4BBDA92B.8010505@ladisch.de>
     [not found]   ` <s5haateyvzn.wl%tiwai@suse.de>
     [not found]     ` <201004090751.35398.tvrtko@ursulin.net>
2010-04-09  7:29       ` Ooops when working with USB MIDI (2.6.33.1) Takashi Iwai
2010-04-09 17:36         ` Tvrtko Ursulin
2010-04-11  7:04           ` Takashi Iwai
2010-05-03 12:48             ` Tvrtko Ursulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).