All of lore.kernel.org
 help / color / mirror / Atom feed
* snd-usb-audio hang when rmmoding after unplugging midisport1x1
@ 2004-03-11 14:16 Mathieu Geli
  2004-03-11 15:46 ` Clemens Ladisch
  0 siblings, 1 reply; 13+ messages in thread
From: Mathieu Geli @ 2004-03-11 14:16 UTC (permalink / raw)
  To: alsa-devel

Hello, I've got this 'big' problem for the hotplug feature:

I'm trying to plug/unplug the midisport1x1 from M-Audio. The plug works like a charm, hotplug does its job, load the firmware (fxload) and snd-usb-audio, if not inserted, is auto-loaded. But <hen I unplug the device, and I want to plug it again, the usb just hang, trying to rmmoding snd-usb-audio or anything else usb related will just hang.
 
I've disabled alsa in the kernel, installed instead alsa-driver-1.0.3rc2, and confiured it with intel8x0 (I'm on a dell inspiron 8200 laptop)
, usb-audio and sequencer.

My kernel is a 2.6.3rc4, I'm using debian unstable.

the hid and uhci-hcd are modules, and autoloaded at boot via the "uhci-hcd" line in /etc/modules
I've cleaned anything snd- related in the modules.conf and so far that works.

### dmesg gives ###

usb 2-1: USB disconnect, address 2
usb 2-1: new full speed USB device using address 3
usb 2-1: USB disconnect, address 3
usb 2-1: new full speed USB device using address 4
drivers/usb/core/usb.c: registered new driver snd-usb-audio

* ok the device has been plugged and works fine, led blinking *
* now let's unplug it *

drivers/usb/core/usb.c: deregistering driver snd-usb-audio
ALSA /home/mathieu/alsa-driver-1.0.3rc2/alsa-kernel/usb/usbmidi.c:148: urb status -104
ALSA /home/mathieu/alsa-driver-1.0.3rc2/alsa-kernel/usb/usbmidi.c:134: usb_submit_urb: -32

I've tryed to comment out, and do some silly modifications in this file, but doesn't have any effect.
So I'm wondering if I'll see one day the hotpug for my new midi device wworking ... :/

If you guys  have a solution, well... that'll be a good relief :)

Cheers,

Mathieu


PS: maybe an lsusb -v could as well help...


Bus 002 Device 004: ID 0763:1011 Midiman 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0763 Midiman
  idProduct          0x1011 
  bcdDevice            1.21
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  bytes 32 once
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  bytes 32 once
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  bytes 32 once
        bInterval               0

Bus 002 Device 001: ID 0000:0000  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0000 
  idProduct          0x0000 
  bcdDevice            2.06
  iManufacturer           3 
  iProduct                2 
  iSerial                 1 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x40
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0002  bytes 2 twice
        bInterval             255

Bus 001 Device 002: ID 046d:c012 Logitech, Inc. Optical Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc012 Optical Mouse
  bcdDevice           13.20
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Devices
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  bytes 4 three times
        bInterval              10
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52

Bus 001 Device 001: ID 0000:0000  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            9 Hub
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0000 
  idProduct          0x0000 
  bcdDevice            2.06
  iManufacturer           3 
  iProduct                2 
  iSerial                 1 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x40
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0002  bytes 2 twice
        bInterval             255


Something strange I just notice is, even if the device is inplugged (after rmmoding and bugging all usb) I can do:

$> sudo umount /proc/bus/usb
$> lsusb

$> sudo mount /proc/bus/usb
$> lsusb
Bus 002 Device 004: ID 0763:1011 Midiman 
Bus 002 Device 001: ID 0000:0000  
Bus 001 Device 002: ID 046d:c012 Logitech, Inc. Optical Mouse
Bus 001 Device 001: ID 0000:0000
$>

ok the usbfs is probably totally dead and shows the last working state... hey but my mouse is still working fine (in condition I don't unplug and replug it ^^ )



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio hang when rmmoding after unplugging midisport1x1
  2004-03-11 14:16 snd-usb-audio hang when rmmoding after unplugging midisport1x1 Mathieu Geli
@ 2004-03-11 15:46 ` Clemens Ladisch
  2004-03-11 19:46   ` Mathieu Geli
  0 siblings, 1 reply; 13+ messages in thread
From: Clemens Ladisch @ 2004-03-11 15:46 UTC (permalink / raw)
  To: Mathieu Geli; +Cc: alsa-devel

Mathieu Geli wrote:
> I'm trying to plug/unplug the midisport1x1 from M-Audio. The plug
> works like a charm, hotplug does its job, load the firmware
> (fxload) and snd-usb-audio, if not inserted, is auto-loaded. But
> <hen I unplug the device, and I want to plug it again, the usb
> just hang, trying to rmmoding snd-usb-audio or anything else usb
> related will just hang.

There was a bug which has been fixed three days ago (after 1.0.3 came
out).  Either get the latest version from the CVS, or apply the patch
below.


HTH
Clemens

-- 

--- alsa-kernel/usb/usbmidi.c	3 Mar 2004 11:35:15 -0000	1.24
+++ alsa-kernel/usb/usbmidi.c	8 Mar 2004 09:34:05 -0000	1.25
@@ -453,8 +453,16 @@
 	usbmidi_out_port_t* port = (usbmidi_out_port_t*)substream->runtime->private_data;

 	port->active = up;
-	if (up)
+	if (up) {
+		if (port->ep->umidi->chip->shutdown) {
+			/* gobble up remaining bytes to prevent wait in
+			 * snd_rawmidi_drain_output */
+			while (!snd_rawmidi_transmit_empty(substream))
+				snd_rawmidi_transmit_ack(substream, 1);
+			return;
+		}
 		tasklet_hi_schedule(&port->ep->tasklet);
+	}
 }

 static int snd_usbmidi_input_open(snd_rawmidi_substream_t* substream)




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio hang when rmmoding after unplugging midisport1x1
  2004-03-11 15:46 ` Clemens Ladisch
@ 2004-03-11 19:46   ` Mathieu Geli
  2004-03-11 20:31     ` Mathieu Geli
  2004-03-12 12:17     ` Clemens Ladisch
  0 siblings, 2 replies; 13+ messages in thread
From: Mathieu Geli @ 2004-03-11 19:46 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

Thanks for your reply,

ok, what I did, is first to apply your patch to my source tree (1.0.3rc2), clean, compile, install, and even reboot.
That doesn't output anymore the two lines "urb status -104", and "usb_submit_urb: -32" but still hang after printing:
"drivers/usb/core/usb.c: deregistering driver snd-usb-audio"

So I have dl the CVS and reinstalled alsa-driver. That just have the same effect :/

Mathieu


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio hang when rmmoding after unplugging midisport1x1
  2004-03-11 19:46   ` Mathieu Geli
@ 2004-03-11 20:31     ` Mathieu Geli
  2004-03-12  0:17       ` Hartmut Geissbauer
  2004-03-12 12:17     ` Clemens Ladisch
  1 sibling, 1 reply; 13+ messages in thread
From: Mathieu Geli @ 2004-03-11 20:31 UTC (permalink / raw)
  To: alsa-devel

sorry about my fuzzy observations, my bad, even with the last CVS I got those errors line when rmmoding snd-usb-audio, while the device is on. (I didn't redo the same actions than before)
Is there any way to maybe unplug the device safely (usbfs point of view) ? I was guessing smtgh like a fxUNload programm.
There is obviously something from the midisport1x1 who bugs snd-usb-audio. Indepandently they works both fine :)

Maybe I've a easy view 'bout how the things are working, but I would expect from snd-usb-audio a timeout, after which he gives up, trying to communicate with the device if nothnig happens.

Cheers,

Mathieu


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio hang when rmmoding after unplugging midisport1x1
  2004-03-11 20:31     ` Mathieu Geli
@ 2004-03-12  0:17       ` Hartmut Geissbauer
  0 siblings, 0 replies; 13+ messages in thread
From: Hartmut Geissbauer @ 2004-03-12  0:17 UTC (permalink / raw)
  To: alsa-devel

I've the same symptom. Even with kernel 2.6.4 and the patch provided by Clemens. 
I own a Midisport 4x4. So it seems not to be model specific.
Initialzing is fine. But unplugin/replugin will request a reboot with sysrq intervention. 
First I've had enabled the USB 2.0 features on my motherboard with the same effect. 
But with the disadvantage not _receiving_ any MIDI messages. Sending was quite fine.
So I switched to USB 1.1 in the BIOS and receiving was been although possible.

Regards, Hartmut




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio hang when rmmoding after unplugging midisport1x1
  2004-03-11 19:46   ` Mathieu Geli
  2004-03-11 20:31     ` Mathieu Geli
@ 2004-03-12 12:17     ` Clemens Ladisch
  2004-03-13  3:32       ` snd-usb-audio and midisport1x1 little hack fixes hotplug pb Mathieu Geli
  1 sibling, 1 reply; 13+ messages in thread
From: Clemens Ladisch @ 2004-03-12 12:17 UTC (permalink / raw)
  To: Mathieu Geli; +Cc: alsa-devel

Mathieu Geli wrote:
> ok, what I did, is first to apply your patch to my source tree
> (1.0.3rc2), clean, compile, install, and even reboot. That doesn't
> output anymore the two lines "urb status -104", and
> "usb_submit_urb: -32" but still hang after printing:
> "drivers/usb/core/usb.c: deregistering driver snd-usb-audio"

It seems to work fine on my 2.4.25 kernel.

Can you unload the snd-usb-audio module?  If not, please apply the
patch below to see whether the driver or the USB core is the culprit.


Regards,
Clemens

-- 
--- alsa-kernel/usb/usbaudio.c	8 Mar 2004 09:29:51 -0000	1.87
+++ alsa-kernel/usb/usbaudio.c	12 Mar 2004 12:05:22 -0000
@@ -2928,6 +2928,7 @@
 		return;

 	chip = snd_magic_cast(snd_usb_audio_t, ptr, return);
+	snd_printk(KERN_INFO "snd_usb_audio_disconnect called, refcount = %d\n", chip->num_interfaces);
 	card = chip->card;
 	down(&register_mutex);
 	chip->shutdown = 1;
@@ -2947,6 +2948,7 @@
 	} else {
 		up(&register_mutex);
 	}
+	snd_printk(KERN_INFO "snd_usb_audio_disconnect finished!\n");
 }

 /*




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-12 12:17     ` Clemens Ladisch
@ 2004-03-13  3:32       ` Mathieu Geli
  2004-03-15 18:43         ` Hartmut Geissbauer
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mathieu Geli @ 2004-03-13  3:32 UTC (permalink / raw)
  To: clemens, nwgbh; +Cc: alsa-devel

Ok, I applied your second patch, and get this dmesg output:

drivers/usb/core/usb.c: deregistering driver snd-usb-audio
ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 1
ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 0
ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:148: urb status -104
ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:134: usb_submit_urb: -32

At this point the usb was down not responding anymore, like in the past.

what I did next, is put double each interesting lines printk, what I get is, that the rmmod of the driver was hanging on the midi ressources cleaning stuff.
Hum, first reflex: I just comment out those 3 lines =) and guess what.. that works fine now. I tried to plug/unplug several times my mouse, the midisport, and everything
works fine, so... I don't really know what was the bug's reason, but as long as that works I'm happy ;-)
Probably Takashi Iwai who seems to has coded it should once have a look to understand the 'why' question.

Cheers,

Mathieu 
--


Here is finally the modifications I applied:

--- alsa-kernel/usb/usbmidi.c	3 Mar 2004 11:35:15 -0000	1.24
+++ alsa-kernel/usb/usbmidi.c	8 Mar 2004 09:34:05 -0000	1.25
@@ -453,8 +453,16 @@
 	usbmidi_out_port_t* port = (usbmidi_out_port_t*)substream->runtime->private_data;

 	port->active = up;
-	if (up)
+	if (up) {
+		if (port->ep->umidi->chip->shutdown) {
+			/* gobble up remaining bytes to prevent wait in
+			 * snd_rawmidi_drain_output */
+			while (!snd_rawmidi_transmit_empty(substream))
+				snd_rawmidi_transmit_ack(substream, 1);
+			return;
+		}
 		tasklet_hi_schedule(&port->ep->tasklet);
+	}
 }

 static int snd_usbmidi_input_open(snd_rawmidi_substream_t* substream)


--- alsa-kernel/usb/usbaudio.c	2004-03-11 21:00:25.000000000 +0100
+++ alsa-kernel/usb/usbaudio.c	2004-03-13 04:01:06.000000000 +0100
@@ -2939,9 +2939,9 @@
                        snd_usb_stream_disconnect(p, &usb_audio_driver);
                }
                /* release the midi resources */
-               list_for_each(p, &chip->midi_list) {
-                       snd_usbmidi_disconnect(p, &usb_audio_driver);
-               }
+               /* list_for_each(p, &chip->midi_list) { */
+               /* snd_usbmidi_disconnect(p, &usb_audio_driver); */
+               /* } */
                up(&register_mutex);
                snd_card_free_in_thread(card);
        } else {


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-13  3:32       ` snd-usb-audio and midisport1x1 little hack fixes hotplug pb Mathieu Geli
@ 2004-03-15 18:43         ` Hartmut Geissbauer
  2004-03-16 15:59         ` Takashi Iwai
  2004-03-16 17:03         ` Clemens Ladisch
  2 siblings, 0 replies; 13+ messages in thread
From: Hartmut Geissbauer @ 2004-03-15 18:43 UTC (permalink / raw)
  To: Mathieu Geli; +Cc: clemens, alsa-devel

Salut Mathieu,

that fixes the issue with the 4x4 as well.

Let's see what Takashi is thinking about to comment his code. ;-)

Regards, Hartmut




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-13  3:32       ` snd-usb-audio and midisport1x1 little hack fixes hotplug pb Mathieu Geli
  2004-03-15 18:43         ` Hartmut Geissbauer
@ 2004-03-16 15:59         ` Takashi Iwai
  2004-03-16 17:03         ` Clemens Ladisch
  2 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2004-03-16 15:59 UTC (permalink / raw)
  To: Mathieu Geli; +Cc: clemens, nwgbh, alsa-devel

At Sat, 13 Mar 2004 04:32:34 +0100,
Mathieu Geli wrote:
> 
> Ok, I applied your second patch, and get this dmesg output:
> 
> drivers/usb/core/usb.c: deregistering driver snd-usb-audio
> ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 1
> ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 0
> ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:148: urb status -104
> ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:134: usb_submit_urb: -32

this means that the urbs are still active.  i'm not sure whether these
messages appear after or before calling snd_usbmidi_disconnect(),
though.

> At this point the usb was down not responding anymore, like in the past.
> 
> what I did next, is put double each interesting lines printk, what I
> get is, that the rmmod of the driver was hanging on the midi
> ressources cleaning stuff. 
> Hum, first reflex: I just comment out those 3 lines =) and guess
> what.. that works fine now. I tried to plug/unplug several times my
> mouse, the midisport, and everything 
> works fine, so... I don't really know what was the bug's reason, but
> as long as that works I'm happy ;-) 

i also don't know yet why disconnect() call hangs up.
could you check at which point it happens by adding printk()'s in
snd_usbmidi_disconnect()?

the resource release can work even without disconnect() call, since
the clean up will be done later also by the workqueue when all devices
are closed properly.  the disconnect function should shut up possible
hardware features immediately.


Takashi


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-13  3:32       ` snd-usb-audio and midisport1x1 little hack fixes hotplug pb Mathieu Geli
  2004-03-15 18:43         ` Hartmut Geissbauer
  2004-03-16 15:59         ` Takashi Iwai
@ 2004-03-16 17:03         ` Clemens Ladisch
  2004-03-16 17:51           ` Hartmut Geissbauer
  2 siblings, 1 reply; 13+ messages in thread
From: Clemens Ladisch @ 2004-03-16 17:03 UTC (permalink / raw)
  To: Mathieu Geli; +Cc: nwgbh, Takashi Iwai, alsa-devel

Mathieu Geli wrote:
> Ok, I applied your second patch, and get this dmesg output:
>
> drivers/usb/core/usb.c: deregistering driver snd-usb-audio
> ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 1
> ALSA /home/mathieu/alsa-driver/usb/usbaudio.c:2944: snd_usb_audio_disconnect called, refcount = 0

Two calls to disconnect?  Strange.

> ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:148: urb status -104
> ALSA /home/mathieu/alsa-driver/alsa-kernel/usb/usbmidi.c:134: usb_submit_urb: -32

The driver tries to resubmit the URB although the device is being shut
down.  I don't think this causes the hang, but the patch below
(already in CVS) fixes this.  (-104 is -ECONNRESET which shouldn't
occur when unlinking synchronously.)

Apparently, snd_usb_audio_disconnect hangs before returning.  Please
try to insert printk's in snd_usbmidi_disconnect as Takashi suggestes.


Regards,
Clemens

-- 
diff -u -r1.25 -r1.26
--- alsa-kernel/usb/usbmidi.c	8 Mar 2004 09:34:05 -0000	1.25
+++ alsa-kernel/usb/usbmidi.c	16 Mar 2004 16:36:05 -0000	1.26
@@ -143,8 +143,9 @@
 	if (status == -ENOENT)
 		return status; /* killed */
 	if (status == -EILSEQ ||
+	    status == -ECONNRESET ||
 	    status == -ETIMEDOUT)
-		return -ENODEV; /* device removed */
+		return -ENODEV; /* device removed/shutdown */
 	snd_printk(KERN_ERR "urb status %d\n", status);
 	return 0; /* continue */
 }
@@ -706,7 +707,6 @@
 	int i;

 	umidi = list_entry(p, snd_usb_midi_t, list);
-	usb_driver_release_interface(driver, umidi->iface);
 	for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
 		snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i];
 		if (ep->out && ep->out->urb)
@@ -714,6 +714,7 @@
 		if (ep->in && ep->in->urb)
 			usb_unlink_urb(ep->in->urb);
 	}
+	usb_driver_release_interface(driver, umidi->iface);
 }

 static void snd_usbmidi_rawmidi_free(snd_rawmidi_t* rmidi)




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-16 17:03         ` Clemens Ladisch
@ 2004-03-16 17:51           ` Hartmut Geissbauer
  2004-03-17  8:03             ` Clemens Ladisch
  0 siblings, 1 reply; 13+ messages in thread
From: Hartmut Geissbauer @ 2004-03-16 17:51 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Mathieu Geli, Takashi Iwai, alsa-devel

Clemens Ladisch wrote:
> Apparently, snd_usb_audio_disconnect hangs before returning.  Please
> try to insert printk's in snd_usbmidi_disconnect as Takashi suggestes.
> 

I removed the quick hack from Mathieu and inserted snd_printk's in snd_usbmidi_disconnect.

The new function:

void snd_usbmidi_disconnect(struct list_head* p, struct usb_driver *driver)
{
        snd_usb_midi_t* umidi;
        int i;

        umidi = list_entry(p, snd_usb_midi_t, list);
        snd_printk(KERN_INFO "after list_entry\n");

//      usb_driver_release_interface(driver, umidi->iface);
        for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
        snd_printk(KERN_INFO "in for with i=%d\n",i);

                snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i];
                if (ep->out && ep->out->urb)
                        usb_unlink_urb(ep->out->urb);
                        snd_printk(KERN_INFO "usb_unlink_urb out\n");

                if (ep->in && ep->in->urb)
                        usb_unlink_urb(ep->in->urb);
                        snd_printk(KERN_INFO "usb_unlink_urb in\n");

        }
        usb_driver_release_interface(driver, umidi->iface);
        snd_printk(KERN_INFO "after usb_driver_release_interface\n");
}

The output from dmesg I got:

ohci_hcd 0000:00:02.0: urb e2e2b4c0 path 2.4 ep1in 5e160000 cc 5 --> status -110
hub 1-2:1.0: port 4, status 100, change 1, 12 Mb/s
usb 1-2.4: USB disconnect, address 5
usb 1-2.4: usb_disable_device nuking all URBs
usb 1-2.4: unregistering interface 1-2.4:1.0
ALSA sound/usb/usbaudio.c:2924: snd_usb_audio_disconnect called, refcount = 1
ALSA sound/usb/usbmidi.c:710: after list_entry
ALSA sound/usb/usbmidi.c:714: in for with i=0
usb 1-2.4: hcd_unlink_urb e2e2b640 fail -22
ALSA sound/usb/usbmidi.c:719: usb_unlink_urb out
usb 1-2.4: hcd_unlink_urb e2e2b4c0 fail -22
ALSA sound/usb/usbmidi.c:723: usb_unlink_urb in
ALSA sound/usb/usbmidi.c:714: in for with i=1
usb 1-2.4: hcd_unlink_urb e2e2b3c0 fail -22
ALSA sound/usb/usbmidi.c:719: usb_unlink_urb out
ALSA sound/usb/usbmidi.c:723: usb_unlink_urb in
ALSA sound/usb/usbaudio.c:2924: snd_usb_audio_disconnect called, refcount = 0


Remember this is the output for a 4x4. (If this matters)

Kindly regards, Hartmut




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-16 17:51           ` Hartmut Geissbauer
@ 2004-03-17  8:03             ` Clemens Ladisch
  2004-03-23 18:24               ` [fixed] " Hartmut Geissbauer
  0 siblings, 1 reply; 13+ messages in thread
From: Clemens Ladisch @ 2004-03-17  8:03 UTC (permalink / raw)
  To: Hartmut Geissbauer; +Cc: Mathieu Geli, Takashi Iwai, alsa-devel

Hartmut Geissbauer wrote:
> I removed the quick hack from Mathieu and inserted snd_printk's in
> snd_usbmidi_disconnect.
>
> The new function:
> ...
>                 if (ep->out && ep->out->urb)
>                         usb_unlink_urb(ep->out->urb);
>                         snd_printk(KERN_INFO "usb_unlink_urb out\n");

Please note that this is C, not Python.  :-)

> The output from dmesg I got:
>
> ohci_hcd 0000:00:02.0: urb e2e2b4c0 path 2.4 ep1in 5e160000 cc 5 --> status -110
> hub 1-2:1.0: port 4, status 100, change 1, 12 Mb/s
> usb 1-2.4: USB disconnect, address 5
> usb 1-2.4: usb_disable_device nuking all URBs

It seems we don't need to unlink the URBs as the kernel does this for
us, but it doesn't hurt.

> ...
> ALSA sound/usb/usbmidi.c:723: usb_unlink_urb in
> ALSA sound/usb/usbaudio.c:2924: snd_usb_audio_disconnect called, refcount = 0

Apparently, snd_usb_audio_disconnect is called recursively, caused by
the call to usb_driver_release_interface, and then deadlocks.

The USB core will release all interfaces automatically, so we don't
need this call.  Please remove the usb_driver_release_interface line.


HTH
Clemens




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

* Re: [fixed] snd-usb-audio and midisport1x1 little hack fixes hotplug pb
  2004-03-17  8:03             ` Clemens Ladisch
@ 2004-03-23 18:24               ` Hartmut Geissbauer
  0 siblings, 0 replies; 13+ messages in thread
From: Hartmut Geissbauer @ 2004-03-23 18:24 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

> Apparently, snd_usb_audio_disconnect is called recursively, caused by
> the call to usb_driver_release_interface, and then deadlocks.
> 
> The USB core will release all interfaces automatically, so we don't
> need this call.  Please remove the usb_driver_release_interface line.

Sorry, in case of your're awaiting any response. It works.

Regards, Hartmut



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

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

end of thread, other threads:[~2004-03-23 18:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-11 14:16 snd-usb-audio hang when rmmoding after unplugging midisport1x1 Mathieu Geli
2004-03-11 15:46 ` Clemens Ladisch
2004-03-11 19:46   ` Mathieu Geli
2004-03-11 20:31     ` Mathieu Geli
2004-03-12  0:17       ` Hartmut Geissbauer
2004-03-12 12:17     ` Clemens Ladisch
2004-03-13  3:32       ` snd-usb-audio and midisport1x1 little hack fixes hotplug pb Mathieu Geli
2004-03-15 18:43         ` Hartmut Geissbauer
2004-03-16 15:59         ` Takashi Iwai
2004-03-16 17:03         ` Clemens Ladisch
2004-03-16 17:51           ` Hartmut Geissbauer
2004-03-17  8:03             ` Clemens Ladisch
2004-03-23 18:24               ` [fixed] " Hartmut Geissbauer

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.