Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jan 2020 09:57:05 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Shichun.Ma@dell.com, freebsd-usb@freebsd.org
Cc:        Shunchao.Hu@dell.com
Subject:   Re: minor improve for xhci_cmd_stop_ep in xhci_configure_reset_endpoint
Message-ID:  <e91118b0-7efa-bf9d-3463-5dbf18d177d7@selasky.org>
In-Reply-To: <1578623361805.72194@Dell.com>
References:  <1578623361805.72194@Dell.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e91118b0-7efa-bf9d-3463-5dbf18d177d7>