Print this page
MFV: illumos-gate@2aba3acda67326648fd60aaf2bfb4e18ee8c04ed
9816 Multi-TRB xhci transfers should use event data
9817 xhci needs to always set slot context
8550 increase xhci bulk transfer sgl count
9818 xhci_transfer_get_tdsize can return values that are too large
Reviewed by: Alex Wilson <alex.wilson@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
Author: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/usb/hcd/xhci/xhci_ring.c
          +++ new/usr/src/uts/common/io/usb/hcd/xhci/xhci_ring.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright 2016 Joyent, Inc.
       13 + * Copyright (c) 2018, Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * -----------------------------
  18   18   * xHCI Ring Management Routines
  19   19   * -----------------------------
  20   20   *
  21   21   * There are three major different types of rings for xHCI, these are:
  22   22   *
  23   23   * 1) Command Rings
↓ open down ↓ 257 lines elided ↑ open up ↑
 281  281  }
 282  282  
 283  283  /*
 284  284   * Fill in a TRB in the ring at offset trboff. If cycle is currently set to
 285  285   * B_TRUE, then we fill in the appropriate cycle bit to tell the system to
 286  286   * advance, otherwise we leave the existing cycle bit untouched so the system
 287  287   * doesn't accidentally advance until we have everything filled in.
 288  288   */
 289  289  void
 290  290  xhci_ring_trb_fill(xhci_ring_t *xrp, uint_t trboff, xhci_trb_t *host_trb,
 291      -    boolean_t put_cycle)
      291 +    uint64_t *trb_pap, boolean_t put_cycle)
 292  292  {
 293  293          uint_t i;
 294  294          uint32_t flags;
 295  295          uint_t ent = xrp->xr_head;
 296  296          uint8_t cycle = xrp->xr_cycle;
 297  297          xhci_trb_t *trb;
 298  298  
 299  299          for (i = 0; i < trboff; i++) {
 300  300                  ent++;
 301  301                  if (ent == xrp->xr_ntrb - 1) {
↓ open down ↓ 15 lines elided ↑ open up ↑
 317  317          trb->trb_addr = host_trb->trb_addr;
 318  318          trb->trb_status = host_trb->trb_status;
 319  319          flags = host_trb->trb_flags;
 320  320          if (cycle == 0) {
 321  321                  flags &= ~LE_32(XHCI_TRB_CYCLE);
 322  322          } else {
 323  323                  flags |= LE_32(XHCI_TRB_CYCLE);
 324  324          }
 325  325  
 326  326          trb->trb_flags = flags;
      327 +
      328 +        if (trb_pap != NULL) {
      329 +                uint64_t pa;
      330 +
      331 +                /*
      332 +                 * This logic only works if we have a single cookie address.
      333 +                 * However, this is prettty tightly assumed for rings through
      334 +                 * the xhci driver at this time.
      335 +                 */
      336 +                ASSERT3U(xrp->xr_dma.xdb_ncookies, ==, 1);
      337 +                pa = xrp->xr_dma.xdb_cookies[0].dmac_laddress;
      338 +                pa += ((uintptr_t)trb - (uintptr_t)&xrp->xr_trb[0]);
      339 +                *trb_pap = pa;
      340 +        }
 327  341  }
 328  342  
 329  343  /*
 330  344   * Update our metadata for the ring and verify the cycle bit is correctly set
 331  345   * for the first trb. It is expected that it is incorrectly set.
 332  346   */
 333  347  void
 334  348  xhci_ring_trb_produce(xhci_ring_t *xrp, uint_t ntrb)
 335  349  {
 336  350          uint_t i, ohead;
↓ open down ↓ 36 lines elided ↑ open up ↑
 373  387          trb->trb_flags ^= LE_32(XHCI_TRB_CYCLE);
 374  388  }
 375  389  
 376  390  /*
 377  391   * This is a convenience wrapper for the single TRB case to make callers less
 378  392   * likely to mess up some of the required semantics.
 379  393   */
 380  394  void
 381  395  xhci_ring_trb_put(xhci_ring_t *xrp, xhci_trb_t *trb)
 382  396  {
 383      -        xhci_ring_trb_fill(xrp, 0U, trb, B_FALSE);
      397 +        xhci_ring_trb_fill(xrp, 0U, trb, NULL, B_FALSE);
 384  398          xhci_ring_trb_produce(xrp, 1U);
 385  399  }
 386  400  
 387  401  /*
 388  402   * Update the tail pointer for a ring based on the DMA address of a consumed
 389  403   * entry. Note, this entry indicates what we just processed, therefore we should
 390  404   * bump the tail entry to the next one.
 391  405   */
 392  406  boolean_t
 393  407  xhci_ring_trb_consumed(xhci_ring_t *xrp, uint64_t dma)
↓ open down ↓ 51 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX