From owner-freebsd-usb@freebsd.org Fri Jan 10 08:57:19 2020 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 024CA1E09C5 for ; Fri, 10 Jan 2020 08:57:19 +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 47vH1B0dJSz4MZY for ; Fri, 10 Jan 2020 08:57:17 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.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 DC3FD26013D; Fri, 10 Jan 2020 09:57:15 +0100 (CET) Subject: Re: minor improve for xhci_cmd_stop_ep in xhci_configure_reset_endpoint To: Shichun.Ma@dell.com, freebsd-usb@freebsd.org Cc: Shunchao.Hu@dell.com References: <1578623361805.72194@Dell.com> From: Hans Petter Selasky Message-ID: Date: Fri, 10 Jan 2020 09:57:05 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <1578623361805.72194@Dell.com> Content-Type: multipart/mixed; boundary="------------31F2CCFE12350A658CB943A8" Content-Language: en-US X-Rspamd-Queue-Id: 47vH1B0dJSz4MZY X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; 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 [-5.41 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[selasky.org]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; TO_MATCH_ENVRCPT_SOME(0.00)[]; IP_SCORE(-3.11)[ip: (-9.34), ipnet: 88.99.0.0/16(-4.71), asn: 24940(-1.50), country: DE(-0.02)]; 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)[]; RCVD_COUNT_TWO(0.00)[2] 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: Fri, 10 Jan 2020 08:57:19 -0000 This is a multi-part message in MIME format. --------------31F2CCFE12350A658CB943A8 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Hi, Can you test the attached patch? --HPS --------------31F2CCFE12350A658CB943A8 Content-Type: text/x-patch; charset=UTF-8; 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 356545) +++ sys/dev/usb/controller/xhci.c (working copy) @@ -1598,11 +1598,27 @@ xhci_cmd_stop_ep(struct xhci_softc *sc, uint8_t suspend, uint8_t ep_id, uint8_t slot_id) { + struct usb_page_search buf_dev; + struct xhci_dev_ctx *pdev; struct xhci_trb trb; uint32_t temp; DPRINTF("\n"); + usbd_get_page(&sc->sc_hw.devs[slot_id].device_pc, 0, &buf_dev); + pdev = buf_dev.buffer; + usb_pc_cpu_invalidate(&sc->sc_hw.devs[slot_id].device_pc); + + switch (XHCI_EPCTX_0_EPSTATE_GET(pdev->ctx_ep[ep_id - 1].dwEpCtx0)) { + case XHCI_EPCTX_0_EPSTATE_DISABLED: + case XHCI_EPCTX_0_EPSTATE_STOPPED: + DPRINTF("Endpoint %u on slot %u is already stopped\n", + ep_id, slot_id); + return (USB_ERR_NORMAL_COMPLETION); + default: + break; + } + trb.qwTrb0 = 0; trb.dwTrb2 = 0; temp = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_STOP_EP) | Index: sys/dev/usb/controller/xhci.h =================================================================== --- sys/dev/usb/controller/xhci.h (revision 356545) +++ sys/dev/usb/controller/xhci.h (working copy) @@ -115,6 +115,14 @@ volatile uint32_t dwEpCtx0; #define XHCI_EPCTX_0_EPSTATE_SET(x) ((x) & 0x7) #define XHCI_EPCTX_0_EPSTATE_GET(x) ((x) & 0x7) +#define XHCI_EPCTX_0_EPSTATE_DISABLED 0 +#define XHCI_EPCTX_0_EPSTATE_RUNNING 1 +#define XHCI_EPCTX_0_EPSTATE_HALTED 2 +#define XHCI_EPCTX_0_EPSTATE_STOPPED 3 +#define XHCI_EPCTX_0_EPSTATE_ERROR 4 +#define XHCI_EPCTX_0_EPSTATE_RESERVED_5 5 +#define XHCI_EPCTX_0_EPSTATE_RESERVED_6 6 +#define XHCI_EPCTX_0_EPSTATE_RESERVED_7 7 #define XHCI_EPCTX_0_MULT_SET(x) (((x) & 0x3) << 8) #define XHCI_EPCTX_0_MULT_GET(x) (((x) >> 8) & 0x3) #define XHCI_EPCTX_0_MAXP_STREAMS_SET(x) (((x) & 0x1F) << 10) --------------31F2CCFE12350A658CB943A8--