• Lukas Wunner's avatar
    xhci: Set DESI bits in ERDP register correctly · 044818a6
    Lukas Wunner authored
    When using more than one Event Ring segment (ERSTSZ > 1), software shall
    set the DESI bits in the ERDP register to the number of the segment to
    which the upper ERDP bits are pointing.  The xHC may use the DESI bits
    as a shortcut to determine whether it needs to check for an Event Ring
    Full condition:  If it's enqueueing events in a different segment, it
    need not compare its internal Enqueue Pointer with the Dequeue Pointer
    in the upper bits of the ERDP register (sec 5.5.2.3.3).
    
    Not setting the DESI bits correctly can result in the xHC enqueueing
    events past the Dequeue Pointer.  On Renesas uPD720201 host controllers,
    incorrect DESI bits cause an interrupt storm.  For comparison, VIA VL805
    host controllers do not exhibit such problems.  Perhaps they do not take
    advantage of the optimization afforded by the DESI bits.
    
    To fix the issue, assign the segment number to each struct xhci_segment
    in xhci_segment_alloc().  When advancing the Dequeue Pointer in
    xhci_update_erst_dequeue(), write the segment number to the DESI bits.
    
    On driver probe, set the DESI bits to zero in xhci_set_hc_event_deq() as
    processing starts in segment 0.  Likewise on driver teardown, clear the
    DESI bits to zero in xhci_free_interrupter() when clearing the upper
    bits of the ERDP register.  Previously those functions (incorrectly)
    treated the DESI bits as if they're declared RsvdP.
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20231019102924.2797346-5-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    044818a6
xhci-ring.c 131 KB