Author: hselasky
Date: Tue Dec 30 09:20:29 2014
New Revision: 276407
URL: https://svnweb.freebsd.org/changeset/base/276407

Log:
  Allow systems having a page size greater than 4K to use fewer
  scatter-gather XHCI TRB entries for its payload data. The XHCI
  controller can handle at least 65536 bytes per scatter-gather list
  entry.
  
  MFC after:    1 week
  Suggested by: Kohji Okuno <[email protected]>

Modified:
  head/sys/dev/usb/controller/xhci.h

Modified: head/sys/dev/usb/controller/xhci.h
==============================================================================
--- head/sys/dev/usb/controller/xhci.h  Tue Dec 30 08:50:50 2014        
(r276406)
+++ head/sys/dev/usb/controller/xhci.h  Tue Dec 30 09:20:29 2014        
(r276407)
@@ -320,11 +320,23 @@ struct xhci_dev_endpoint_trbs {
            XHCI_MAX_TRANSFERS) + XHCI_MAX_STREAMS];
 };
 
-#define        XHCI_TD_PAGE_NBUF       17      /* units, room enough for 
64Kbytes */
-#define        XHCI_TD_PAGE_SIZE       4096    /* bytes */
-#define        XHCI_TD_PAYLOAD_MAX     (XHCI_TD_PAGE_SIZE * (XHCI_TD_PAGE_NBUF 
- 1))
+#if (USB_PAGE_SIZE < 4096)
+#error "The XHCI driver needs a pagesize above 4K"
+#endif
+
+/* Define the maximum payload which we will handle in a single TRB */
+#define        XHCI_TD_PAYLOAD_MAX     65536   /* bytes */
+
+/* Define the maximum payload of a single scatter-gather list element */
+#define        XHCI_TD_PAGE_SIZE \
+  ((USB_PAGE_SIZE < XHCI_TD_PAYLOAD_MAX) ? USB_PAGE_SIZE : XHCI_TD_PAYLOAD_MAX)
+
+/* Define the maximum length of the scatter-gather list */
+#define        XHCI_TD_PAGE_NBUF \
+  (((XHCI_TD_PAYLOAD_MAX + XHCI_TD_PAGE_SIZE - 1) / XHCI_TD_PAGE_SIZE) + 1)
 
 struct xhci_td {
+       /* one LINK TRB has been added to the TRB array */
        struct xhci_trb         td_trb[XHCI_TD_PAGE_NBUF + 1];
 
 /*
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to