From owner-freebsd-usb@freebsd.org Mon Jul 29 09:45:12 2019 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69192A4950 for ; Mon, 29 Jul 2019 09:45:12 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8A11755C2 for ; Mon, 29 Jul 2019 09:45:11 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 7A2E22602C5; Mon, 29 Jul 2019 11:45:09 +0200 (CEST) Subject: Re: Problem attaching USB Garmin device To: Mariappan N , "freebsd-usb@freebsd.org" References: <20701523-c2e3-e184-b695-ecd6dfed639b@selasky.org> <4aaaaadf-cf6b-8dc6-62a8-d4a577d19691@selasky.org> From: Hans Petter Selasky Message-ID: <2f317631-7e92-6fcc-7061-ae098ce99a68@selasky.org> Date: Mon, 29 Jul 2019 11:44:31 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------ABD72E887FFD97DC44F9B1CD" Content-Language: en-US X-Rspamd-Queue-Id: B8A11755C2 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 88.99.82.50 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-6.36 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[selasky.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[cached: mail.turbocat.net]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; IP_SCORE(-3.19)[ip: (-9.39), ipnet: 88.99.0.0/16(-4.75), asn: 24940(-1.82), country: DE(-0.01)]; FREEMAIL_TO(0.00)[outlook.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; MIME_UNKNOWN(0.10)[text/x-patch] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2019 09:45:12 -0000 This is a multi-part message in MIME format. --------------ABD72E887FFD97DC44F9B1CD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 2019-07-29 10:37, Mariappan N wrote: > Hi HPS, > > Attached the USB analyzer trace for Garmin and other working device connected to XHCI. Please download from the following link. > > > https://www.dropbox.com/sh/jkw2zns9l857e4v/AACp7r3dGjR-r9Vfy9KDmzZ6a?dl=0 > Hi, Basically the Garmin doesn't respond to status stage of the set address message, which is a clear USB specification violation. I wonder if doing a bus-reset right before the set-address, like in the other trace, will cause the device to recover. Can you make a new trace with the attached patch? --HPS --------------ABD72E887FFD97DC44F9B1CD Content-Type: text/x-patch; name="xhci.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xhci.diff" Index: sys/dev/usb/controller/xhci.c =================================================================== --- sys/dev/usb/controller/xhci.c (revision 349802) +++ sys/dev/usb/controller/xhci.c (working copy) @@ -165,6 +165,7 @@ #ifdef USB_DEBUG static uint64_t xhci_ctx_get_le64(struct xhci_softc *sc, volatile uint64_t *ptr); #endif +static usb_error_t xhci_cmd_reset_dev(struct xhci_softc *, uint8_t slot_id); static const struct usb_bus_methods xhci_bus_methods; @@ -1457,7 +1458,14 @@ err = xhci_cmd_set_address(sc, buf_inp.physaddr, (address == 0), index); - if (err != 0) { + /* upon failure, try resetting the device before setting the address */ + if (err != 0 && address != 0) { + err = xhci_cmd_reset_dev(sc, index); + if (err == 0) + err = xhci_cmd_set_address(sc, buf_inp.physaddr, 0, index); + if (err != 0) + break; + } else if (err != 0) { temp = le32toh(sc->sc_cmd_result[0]); if (address == 0 && sc->sc_port_route != NULL && XHCI_TRB_2_ERROR_GET(temp) == --------------ABD72E887FFD97DC44F9B1CD--