[PATCH v2] usb: Wait before re-enabling a port that has been disabled due to EMI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello again.

On lun, 2016-03-21 at 09:36 -0400, Greg KH wrote:
> On Sun, Mar 20, 2016 at 06:57:30PM +0100, Guido Trentalancia wrote:
> > 
> > Hello Greg !
> > 
> > On dom, 2016-03-20 at 10:34 -0700, Greg KH wrote:
> > > 
> > > On Sun, Mar 20, 2016 at 06:09:57PM +0100, Guido Trentalancia
> > > wrote:
> > > > 
> > > >  
> > > > [ 1295.575679] usb 6-2: FTDI USB Serial Device converter now
> > > > attached
> > > > to ttyUSB1
> > > > [ 1302.204285] usb usb6-port2: disabled by hub (EMI?), re-
> > > > enabling...
> > > > 
> > > > *** NOTE: EMI is probably still present here ***
> > > > 
> > > > [ 1303.205202] usb 6-2: USB disconnect, device number 6
> > > > [ 1303.205907] ftdi_sio ttyUSB1: FTDI USB Serial Device
> > > > converter
> > > > now
> > > > disconnected from ttyUSB1
> > > > [ 1303.205950] ftdi_sio 6-2:1.0: device disconnected
> > > > [ 1303.414089] usb 6-2: new full-speed USB device number 7
> > > > using
> > > > uhci_hcd
> > > > [ 1303.526226] usb 6-2: device descriptor read/64, error -71
> > > > [ 1303.894228] usb 6-2: new full-speed USB device number 8
> > > > using
> > > > uhci_hcd
> > > > [ 1304.006185] usb 6-2: device descriptor read/64, error -71
> > > > [ 1304.219089] usb 6-2: device descriptor read/64, error -71
> > > > [ 1304.422107] usb 6-2: new full-speed USB device number 9
> > > > using
> > > > uhci_hcd
> > > > [ 1304.640020] usb 6-2: device not accepting address 9, error
> > > > -71
> > > > [ 1304.752024] usb 6-2: new full-speed USB device number 10
> > > > using
> > > > uhci_hcd
> > > > [ 1305.160020] usb 6-2: device not accepting address 10, error
> > > > -71
> > > > [ 1305.160038] hub 6-0:1.0: unable to enumerate USB device on
> > > > port
> > > > 2
> > > > 
> > > > *** NOTE: Device is permanently disabled at this point ***
> > > > 
> Yes, this needs more work, and again, don't use a module parameter
> please, make it "automatic" if at all possible.

Here is a revised patch. I've tried to keep things very simple.

It's "automatic" and it doesn't make use of a module parameter as
suggested by Greg. Also, it avoids the risk of stalling for seconds
because of a misconfiguration of the module parameter.

Regards, Guido.

Modify the usbcore module to wait for a second before trying to re-enable
a USB port that has been previously disabled by the hub (possibly due to
EMI).

In general, the duration of EMI is random and unpredictable. This patch
tries to ammeliorate several common cases, while at the same time avoiding 
to wait for an unacceptable period of time.

Signed-off-by: Guido Trentalancia <guido@xxxxxxxxxxxxxxxx>
---
 drivers/usb/core/hub.c |    1 +
 1 file changed, 1 insertion(+)

--- linux-4.5-orig/drivers/usb/core/hub.c	2016-03-23 23:00:40.153721641 +0100
+++ linux-4.5/drivers/usb/core/hub.c	2016-03-23 21:41:41.527575138 +0100
@@ -4975,6 +4975,7 @@ static void port_event(struct usb_hub *h
 		if (!(portstatus & USB_PORT_STAT_ENABLE)
 		    && !connect_change && udev) {
 			dev_err(&port_dev->dev, "disabled by hub (EMI?), re-enabling...\n");
+			msleep(1000);	/* Wait for EMI transient to finish or fade */
 			connect_change = 1;
 		}
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux