From owner-freebsd-usb@FreeBSD.ORG Sat Nov 6 09:30:34 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6CEB2106564A for ; Sat, 6 Nov 2010 09:30:34 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe01.swip.net [212.247.154.1]) by mx1.freebsd.org (Postfix) with ESMTP id C67CA8FC12 for ; Sat, 6 Nov 2010 09:30:33 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=omSrwDgyMf70S47Fr5SNr0rQzcmIOo0IafWlB/wSLLo= c=1 sm=1 a=teY7EFdY6K0A:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=KPbmjg5OAAAA:8 a=XRaiuko2lMxwtP8Pe4QA:9 a=Z0xn6qAo_vVzdTbD-0zZhZzAn7oA:4 a=PUjeQqilurYA:10 a=QBVAwF9mRAkA:10 a=_-F24eGl5bsik_pZgkkA:9 a=KkmSBDNzQ_MqV3ngSOYA:7 a=HfB1V3pjwhSIJjL_-SBJJaOGREAA:4 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe01.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 46089929; Sat, 06 Nov 2010 10:30:26 +0100 From: Hans Petter Selasky To: Michael Martin Date: Sat, 6 Nov 2010 10:31:33 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.1-STABLE; KDE/4.4.5; amd64; ; ) References: <4CBFEBF5.30203@comcast.net> <201011042037.20274.hselasky@c2i.net> <4CD4ACC9.8040405@comcast.net> In-Reply-To: <4CD4ACC9.8040405@comcast.net> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_1BS1MPIyq+BfUSV" Message-Id: <201011061031.33986.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: USB 3.0 Fails To Attach Western Digital My Book 3.0 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 09:30:34 -0000 --Boundary-00=_1BS1MPIyq+BfUSV Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Hi, Can you revert the last patch I sent an apply the attached one? Then repeat the testing like last time. --HPS > > I captured several debug outputs here: > http://appliedtechnicalknowledge.com/freebsd/usb3-patch-214808/ . Maybe > something in these can help. --Boundary-00=_1BS1MPIyq+BfUSV Content-Type: text/plain; charset="iso-8859-15"; name="usb_30_hub_patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb_30_hub_patch.txt" === usb_hub.c ================================================================== --- usb_hub.c (revision 214808) +++ usb_hub.c (local) @@ -126,9 +126,10 @@ static usb_callback_t uhub_intr_callback; -static void usb_dev_resume_peer(struct usb_device *udev); -static void usb_dev_suspend_peer(struct usb_device *udev); -static uint8_t usb_peer_should_wakeup(struct usb_device *udev); +static void usb_dev_resume_peer(struct usb_device *); +static void usb_dev_suspend_peer(struct usb_device *); +static uint8_t usb_peer_should_wakeup(struct usb_device *); +static uint8_t usb_device_20_compatible(struct usb_device *); static const struct usb_config uhub_config[UHUB_N_TRANSFER] = { @@ -394,13 +395,29 @@ usb_pause_mtx(NULL, USB_MS_TO_TICKS(USB_PORT_POWERUP_DELAY)); - /* reset port, which implies enabling it */ + if (usb_device_20_compatible(udev)) { + /* reset port, which implies enabling it */ + err = usbd_req_reset_port(udev, NULL, portno); + } else { + switch (UPS_PORT_LINK_STATE_GET(sc->sc_st.port_status)) { + case UPS_PORT_LS_U0: + case UPS_PORT_LS_U1: + case UPS_PORT_LS_U2: + case UPS_PORT_LS_U3: + /* no reset needed, link is already UP */ + break; + case UPS_PORT_LS_SS_INA: + /* try to recover link using a warm reset */ + goto error; + default: + /* reset port, which implies enabling it */ + err = usbd_req_reset_port(udev, NULL, portno); + break; + } + } - err = usbd_req_reset_port(udev, NULL, portno); - if (err) { - DPRINTFN(0, "port %d reset " - "failed, error=%s\n", + DPRINTFN(0, "port %d reset failed, error=%s\n", portno, usbd_errstr(err)); goto error; } @@ -517,17 +534,43 @@ usb_free_device(child, 0); child = NULL; } - if (err == 0) { + if (err) { + DPRINTFN(0, "device problem (%s), " + "port %u\n", usbd_errstr(err), portno); + goto error_ret; + } + if (usb_device_20_compatible(udev)) { + /* disable the port, if enabled */ if (sc->sc_st.port_status & UPS_PORT_ENABLED) { err = usbd_req_clear_port_feature( - sc->sc_udev, NULL, - portno, UHF_PORT_ENABLE); + udev, NULL, portno, UHF_PORT_ENABLE); } + } else { + /* get fresh status again */ + err = uhub_read_port_status(sc, portno); + if (err) + goto error_ret; + + switch (UPS_PORT_LINK_STATE_GET(sc->sc_st.port_status)) { + case UPS_PORT_LS_SS_INA: + /* Try a warm port reset to recover the port. */ + err = usbd_req_warm_reset_port(udev, NULL, portno); + if (err) { + DPRINTF("warm port reset failed.\n"); + goto error_ret; + } + break; + default: + /* disable the port, if enabled */ + if (sc->sc_st.port_status & UPS_PORT_ENABLED) { + err = usbd_req_clear_port_feature( + udev, NULL, portno, UHF_PORT_ENABLE); + } + break; + } } - if (err) { - DPRINTFN(0, "device problem (%s), " - "disabling port %d\n", usbd_errstr(err), portno); - } + +error_ret: return (err); } --Boundary-00=_1BS1MPIyq+BfUSV--