From owner-freebsd-current Fri Aug 30 12: 9:21 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3FE137B43A for ; Fri, 30 Aug 2002 12:09:03 -0700 (PDT) Received: from scl8owa02.int.exodus.net (scl8out02.exodus.net [66.35.230.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0565D43E6E for ; Fri, 30 Aug 2002 12:09:03 -0700 (PDT) (envelope-from Maksim.Yevmenkin@exodus.net) Received: from scl8owa01.int.exodus.net ([66.35.230.241]) by scl8owa02.int.exodus.net with Microsoft SMTPSVC(5.0.2195.4905); Fri, 30 Aug 2002 12:10:43 -0700 Received: from exodus.net ([206.220.227.147]) by scl8owa01.int.exodus.net over TLS secured channel with Microsoft SMTPSVC(5.0.2195.4905); Fri, 30 Aug 2002 12:10:42 -0700 Message-ID: <3D6FC2C6.37DCEAF6@exodus.net> Date: Fri, 30 Aug 2002 12:08:54 -0700 From: Maksim Yevmenkin X-Mailer: Mozilla 4.78 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: Josef Karthauser Cc: Julian Elischer , current@freebsd.org, Peter Wemm Subject: Re: USB slowdown on recent -current [PATCH] References: <3D6BCEFB.4B40833A@exodus.net> <3D6BE521.937373AE@exodus.net> <20020828105535.GA4404@genius.tao.org.uk> Content-Type: multipart/mixed; boundary="------------BF359346C0AD3AC7BFD25A22" X-OriginalArrivalTime: 30 Aug 2002 19:10:42.0654 (UTC) FILETIME=[EF932FE0:01C25058] Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------BF359346C0AD3AC7BFD25A22 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hackers, please find attached patch for UHCI that fixes bus hanging after a device has been unplugged. i can not provide a patch for OHCI because i do not have hardware to test. after looking into this in more detail i found a somewhat similar patch in PR "kern/37928". also if someone can comment on http://mail-index.netbsd.org/current-users/2001/04/13/0022.html regarding to FreeBSD. another problems i'm having with USB are 1) when i put my laptop into docking station it somewhat hard to attach USB device. i'm getting "device problem" errors (see attached usb.errors file). however if i try to plug/ unplug device several times then it works. perhaps something is wrong with USB hub in docking station? there is no such problem when i connect device directly to the laptop, i.e. no docking station. 2) there is bug somewhere which i can reproduce at will with my hardware. it seems that USB stack missing one interrupt transfer from the device. in only happens when driver re-opens USB pipes, i.e. 1) Device plugged 2) Driver open USB pipe 3) Driver sends control request 4) Device sends interrupt transfer 1 5) Device sends interrupt transfer 2 6) Driver closes USB pipe 7) Driver opens USB pipe 8) Driver sends control request 9) ??? no interrupt transfer 1 ??? 10) Device sends interrupt transfer 2 if i re-plug device than everything works again. i can reproduce it with both my driver and "ugen" driver. any clues? thanks, max Josef Karthauser wrote: > > On Tue, Aug 27, 2002 at 01:46:25PM -0700, Maksim Yevmenkin wrote: > > Hackers, > > > > Replying to myself and -current. Strange, but commenting out > > > > #define USB_USE_SOFTINTR > > > > in /sys/dev/usb_ports.h fixed my problem. USB device back to > > full speed and now i'm getting solid ~60 KBytes/sec. > > > > Note: this is _the_only_ change i made. the rest of the > > code has not been changed. > > > > Hmmm.... Anyone care to comment? > > That's interesting and was going to be my suggestion. > Unfortunately there's a nasty bug in there without that defined, which > I've not managed to track down yet. If you come across it please let > me know privately and we'll try and nail it. It manifests itself as the > bus hanging after a device has been unplugged. > > Joe > -- > "As far as the laws of mathematics refer to reality, they are not certain; > and as far as they are certain, they do not refer to reality." - Albert > Einstein, 1921 --------------BF359346C0AD3AC7BFD25A22 Content-Type: text/plain; charset=us-ascii; name="usb.errors" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb.errors" Aug 30 11:34:22 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:23 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:23 beetle kernel: uhub1: device problem, disabling port 1 Aug 30 11:34:27 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:27 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:27 beetle kernel: uhub1: device problem, disabling port 2 Aug 30 11:34:30 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:30 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:30 beetle kernel: uhub1: device problem, disabling port 2 Aug 30 11:34:33 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:33 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:33 beetle kernel: uhub1: device problem, disabling port 1 Aug 30 11:34:36 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:36 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:36 beetle kernel: uhub1: device problem, disabling port 2 Aug 30 11:34:38 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:38 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:38 beetle kernel: uhub1: device problem, disabling port 1 Aug 30 11:34:41 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:41 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:41 beetle kernel: uhub1: device problem, disabling port 2 Aug 30 11:34:44 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:44 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:44 beetle kernel: uhub1: device problem, disabling port 1 Aug 30 11:34:46 beetle kernel: usbd_new_device: addr=3, getting first desc failed Aug 30 11:34:46 beetle kernel: uhub_explore: usb_new_device failed, error=IOERROR Aug 30 11:34:46 beetle kernel: uhub1: device problem, disabling port 1 Aug 30 11:34:49 beetle kernel: ubt0: 3Com product 0x00a0, rev 1.10/1.15, addr 3 Aug 30 11:34:49 beetle kernel: ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2 Aug 30 11:34:49 beetle kernel: ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3; wMaxPacketSize=49; nframes=6, buffer size=294 --------------BF359346C0AD3AC7BFD25A22 Content-Type: text/plain; charset=us-ascii; name="usb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb.patch" --- uhci.c.orig Thu Aug 29 09:30:08 2002 +++ uhci.c Fri Aug 30 10:24:57 2002 @@ -1264,18 +1264,20 @@ * output on a slow console). * We scan all interrupt descriptors to see if any have * completed. */ LIST_FOREACH(ii, &sc->sc_intrhead, list) uhci_check_intr(sc, ii); +#ifdef USB_USE_SOFTINTR if (sc->sc_softwake) { sc->sc_softwake = 0; wakeup(&sc->sc_softwake); } +#endif /* USB_USE_SOFTINTR */ sc->sc_bus.intr_context--; } /* Check for an interrupt. */ void uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii) @@ -1923,18 +1925,22 @@ /* * Step 2: Wait until we know hardware has finished any possible * use of the xfer. Also make sure the soft interrupt routine * has run. */ usb_delay_ms(upipe->pipe.device->bus, 2); /* Hardware finishes in 1ms */ s = splusb(); +#ifdef USB_USE_SOFTINTR sc->sc_softwake = 1; +#endif /* USB_USE_SOFTINTR */ usb_schedsoftintr(&sc->sc_bus); +#ifdef USB_USE_SOFTINTR DPRINTFN(1,("uhci_abort_xfer: tsleep\n")); tsleep(&sc->sc_softwake, PZERO, "uhciab", 0); +#endif /* USB_USE_SOFTINTR */ splx(s); /* * Step 3: Execute callback. */ xfer->hcpriv = ii; --- uhcivar.h.orig Thu Aug 29 09:29:58 2002 +++ uhcivar.h Thu Aug 29 09:31:08 2002 @@ -163,15 +163,18 @@ u_int8_t sc_addr; /* device address */ u_int8_t sc_conf; /* device configuration */ u_int8_t sc_saved_sof; u_int16_t sc_saved_frnum; +#ifdef USB_USE_SOFTINTR char sc_softwake; +#endif /* USB_USE_SOFTINTR */ + char sc_isreset; char sc_suspend; char sc_dying; LIST_HEAD(, uhci_intr_info) sc_intrhead; /* Info for the root hub interrupt channel. */ --- usb_port.h.orig Tue Aug 27 13:06:39 2002 +++ usb_port.h Fri Aug 30 11:08:42 2002 @@ -335,15 +335,15 @@ MALLOC_DECLARE(M_USBDEV); MALLOC_DECLARE(M_USBHC); #endif #define USBVERBOSE -#define USB_USE_SOFTINTR +/* #define USB_USE_SOFTINTR */ #define Static static #define device_ptr_t device_t #define USBBASEDEVICE device_t #define USBDEV(bdev) (bdev) #define USBDEVNAME(bdev) device_get_nameunit(bdev) --------------BF359346C0AD3AC7BFD25A22-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message