• Sarah Sharp's avatar
    USB: xhci: properly set endpoint context fields for periodic eps. · 9238f25d
    Sarah Sharp authored
    For periodic endpoints, we must let the xHCI hardware know the maximum
    payload an endpoint can transfer in one service interval.  The xHCI
    specification refers to this as the Maximum Endpoint Service Interval Time
    Payload (Max ESIT Payload).  This is used by the hardware for bandwidth
    management and scheduling of packets.
    
    For SuperSpeed endpoints, the maximum is calculated by multiplying the max
    packet size by the number of bursts and the number of opportunities to
    transfer within a service interval (the Mult field of the SuperSpeed
    Endpoint companion descriptor).  Devices advertise this in the
    wBytesPerInterval field of their SuperSpeed Endpoint Companion Descriptor.
    
    For high speed devices, this is taken by multiplying the max packet size by the
    "number of additional transaction opportunities per microframe" (the high
    bits of the wMaxPacketSize field in the endpoint descriptor).
    
    For FS/LS devices, this is just the max packet size.
    
    The other thing we must set in the endpoint context is the Average TRB
    Length.  This is supposed to be the average of the total bytes in the
    transfer descriptor (TD), divided by the number of transfer request blocks
    (TRBs) it takes to describe the TD.  This gives the host controller an
    indication of whether the driver will be enqueuing a scatter gather list
    with many entries comprised of small buffers, or one contiguous buffer.
    
    It also takes into account the number of extra TRBs you need for every TD.
    This includes No-op TRBs and Link TRBs used to link ring segments
    together.  Some drivers may choose to chain an Event Data TRB on the end
    of every TD, thus increasing the average number of TRBs per TD.  The Linux
    xHCI driver does not use Event Data TRBs.
    
    In theory, if there was an API to allow drivers to state what their
    bandwidth requirements are, we could set this field accurately.  For now,
    we set it to the same number as the Max ESIT payload.
    
    The Average TRB Length should also be set for bulk and control endpoints,
    but I have no idea how to guess what it should be.
    Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
    Cc: stable <stable@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    
    9238f25d
xhci-mem.c 39.6 KB