tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: patch: xhci: return error if configure ep fails



Hello,

On 08/16/14 10:30, Takahiro HAYASHI wrote:
This patch makes xhci_open return error code
if xhci_configure_endpoint fails, then, makes umass
comfortable if CONFIGURE_EP fails with TRB_ERROR_PARAMETER
when 3.0 usb drive is connected and umass tries to open
bulk-in/out endpoints.
I have no idea why configure endpoint fails on only my
uPD720200, even though it works on Etron and BayTrail.

The patch below makes xhci use the MaxPacketSize extracted from
endpoint descriptor instead of using fixed value when
configuring endpoints.
This fixes PARAMETER error while CONFIGURE_EP on uPD720200,
and fixes STALL or BABBLE error while transfer.
(BABBLE error occurs when target device sends larger packet
than xHCI expects.)

My USB 3.0 thumb drive uses 1024 as MaxPacketSize and maybe
assumes xHCI uses this value, so xHCI detects BABBLE error
if mps=512 when receiving large size packets.


--- xhci.c.orig	2014-08-12 23:29:37.000000000 +0900
+++ xhci.c	2014-09-20 09:17:19.000000000 +0900
@@ -925,6 +1201,7 @@ xhci_configure_endpoint(usbd_pipe_handle
 	struct xhci_trb trb;
 	usbd_status err;
 	uint32_t *cp;
+	uint32_t mps = UGETW(ed->wMaxPacketSize);
device_printf(sc->sc_dev, "%s dci %u (0x%x)\n", __func__, dci,
 	    pipe->endpoint->edesc->bEndpointAddress);
@@ -953,7 +1236,7 @@ xhci_configure_endpoint(usbd_pipe_handle
 	    XHCI_EPCTX_1_CERR_SET(3) |
 	    XHCI_EPCTX_1_EPTYPE_SET(xhci_ep_get_type(pipe->endpoint->edesc)) |
 	    XHCI_EPCTX_1_MAXB_SET(0) |
-	    XHCI_EPCTX_1_MAXP_SIZE_SET(8) /* XXX */
+	    XHCI_EPCTX_1_MAXP_SIZE_SET(mps ? mps : 8)
 	    );
 	cp[4] = htole32(
 		XHCI_EPCTX_4_AVG_TRB_LEN_SET(8)
@@ -964,7 +1247,7 @@ xhci_configure_endpoint(usbd_pipe_handle
 	    XHCI_EPCTX_1_CERR_SET(3) |
 	    XHCI_EPCTX_1_EPTYPE_SET(xhci_ep_get_type(pipe->endpoint->edesc)) |
 	    XHCI_EPCTX_1_MAXB_SET(0) |
-	    XHCI_EPCTX_1_MAXP_SIZE_SET(512) /* XXX */
+	    XHCI_EPCTX_1_MAXP_SIZE_SET(mps ? mps : 512)
 	    );
 	}
 	*(uint64_t *)(&cp[2]) = htole64(

--
t-hash



Home | Main Index | Thread Index | Old Index