Bug 20734

Summary: USB mouse detaches and never reataches
Product: Base System Reporter: Joakim Henriksson <murduth>
Component: kernAssignee: Nick Hibma <n_hibma>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
uhub.c none

Description Joakim Henriksson 2000-08-20 18:40:00 UTC
Occasionaly the mouse is detached from the USB bus and as far as i know there 
is no way to reattach it after it is gone. It doesn't seem to matter where on 
the bus the mouse is connected.

Fix: 

Unknown



-- 
regards/ Joakim
How-To-Repeat: 
Use the mouse.
Comment 1 Nick Hibma freebsd_committer freebsd_triage 2000-08-21 17:00:07 UTC
Responsible Changed
From-To: freebsd-bugs->n_hibma

I'll see whether I can figure this one out.
Comment 2 n_hibma 2000-08-21 17:47:16 UTC
> Aug 20 19:09:11 rmstar /kernel: ums0: detached
> Aug 20 19:09:11 rmstar moused: unable to open /dev/ums0: Device not configured
> Aug 20 19:09:12 rmstar /kernel: uhub1: device problem, disabling port 3
> Aug 20 19:09:12 rmstar /kernel: uhub1: port error, giving up port 3

The problem might be that the port reset returns too quickly and the
mouse isn't ready yet. Could you try the following patch (full file,
sys/dev/usb/uhub.c, attached):

Index: uhub.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/usb/uhub.c,v
retrieving revision 1.26
diff -w -u -r1.26 uhub.c
--- uhub.c	2000/07/17 18:41:19	1.26
+++ uhub.c	2000/08/21 16:37:04
@@ -415,8 +415,6 @@
 			printf("%s: strange, connected port %d has no power\n",
 			       USBDEVNAME(sc->sc_dev), port);
 
-		up->restartcnt = 0;
-
 		/* Wait for maximum device power up time. */
 		usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
 
@@ -446,9 +444,10 @@
 			printf("%s: device problem, disabling port %d\n",
 			       USBDEVNAME(sc->sc_dev), port);
 			usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
-			/* Make sure we don't try to restart it infinitely. */
-			up->restartcnt = USBD_RESTART_MAX;
 		} else {
+			/* the port set up succeeded, reset error count */
+			up->restartcnt = 0;
+
 			if (up->device->hub)
 				up->device->hub->explore(up->device);
 		}


The patch modifies the restartcnt in that it retries several times
before giving up on the newly arrived device (the mouse).

If that does not help, or not in all cases, could you increase the value
for USB_PORT_RESET_RECOVERY in sys/dev/usb/usb.h, line 416, to 200:

#define USB_PORT_RESET_RECOVERY 200 /* ms */

This should give the mouse more time to recover from the reset before it
is being spoken to.

Let me know if you need more information on recompiling your kernel.

> >Description:
> 
> Occasionaly the mouse is detached from the USB bus and as far as i know there 
> is no way to reattach it after it is gone. It doesn't seem to matter where on 
> the bus the mouse is connected.

Do you have any indication of why the mouse detaches every so often?
I've had, with an external MacAlly hub had problem with the hub shorting
whenever something was plugged in. All devices connected to the hub
would disconnect and reconnect at that point.

Could you check for bad connector on the mouse or the hub.

At the very moment the mouse disconnects are you touching else, like the
monitor, a metal table, the hub itself, etc?

Is the hub powered by a separate power supply

Hope this helps.

Thanks for the very detailed, excellent bug report!

Nick
--
Qube Software, Ltd.                                             Private:
n_hibma@qubesoft.com                              n_hibma@webweaving.org
                                                     n_hibma@freebsd.org
http://www.qubesoft.com/                   http://www.etla.net/~n_hibma/
Comment 3 Joakim Henriksson 2001-11-29 16:23:32 UTC
> i get the same problems with my mouse disapearing
> it happens about every hour or two
> the only way i have found to fix it is to reboot my system
> 
> the patch submitted wont work for my version of src/sys/dev/usb/uhub.c
> 
> can someone remake the patch for 4.4 release ??

My problem was a very broken cable. I cut of half a meter of it and resoldered 
it inside the mouse. Not a problem since...
-- 
regards/ Joakim
Comment 4 Nick Hibma freebsd_committer freebsd_triage 2001-11-29 16:49:23 UTC
State Changed
From-To: open->closed

Hardware fault it seems. Thanks for confirming.
Comment 5 Peter Brown 2001-12-01 03:10:29 UTC
hi all
i just bought my mouse about 2 months ago so i'm not going th cut it up just yet

its not a hardware fault in my case

if i unplug the mouse and plug it back in it works for a while again

why does the mouse detach in the first place ??

i would like a patch for 4.4 

thanks
Comment 6 n_hibma 2001-12-01 11:28:57 UTC
The reason for disconnection is probably that the mouse is cheap and
electrically unstable, producing a disconnect once in a while.

Or the firmware is shoddy and freezes up once in a while.

Lots of reasons. But it is definitely not the USB stack's fault as the
stack only disconnects the mouse in the case where it disconnects itself
electrically from the hub.
Comment 7 Peter Brown 2001-12-02 01:19:33 UTC
> The reason for disconnection is probably that the mouse is cheap and
>  electrically unstable, producing a disconnect once in a while.

i wish people wouldnt insult hardware they have never met
 
i bought this mouse in particular because it was actually on the list
of usb mice that FreeBSD supports

> Or the firmware is shoddy and freezes up once in a while.

well my mother board is one of the early usb ones
 
> Lots of reasons. But it is definitely not the USB stack's fault as the
> stack only disconnects the mouse in the case where it disconnects itself
> electrically from the hub.

so why does it not reconnect in these instances ????
that other infamous OS does