• Amit Virdi's avatar
    usb: dwc3: gadget: Stop TRB preparation after limit is reached · e82160b7
    Amit Virdi authored
    commit 39e60635 upstream.
    
    DWC3 gadget sets up a pool of 32 TRBs for each EP during initialization. This
    means, the max TRBs that can be submitted for an EP is fixed to 32. Since the
    request queue for an EP is a linked list, any number of requests can be queued
    to it by the gadget layer.  However, the dwc3 driver must not submit TRBs more
    than the pool it has created for. This limit wasn't respected when SG was used
    resulting in submitting more than the max TRBs, eventually leading to
    non-transfer of the TRBs submitted over the max limit.
    
    Root cause:
    When SG is used, there are two loops iterating to prepare TRBs:
     - Outer loop over the request_list
     - Inner loop over the SG list
    The code was missing break to get out of the outer loop.
    
    Fixes: eeb720fb (usb: dwc3: gadget: add support for SG lists)
    Signed-off-by: default avatarAmit Virdi <amit.virdi@st.com>
    Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
    Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
    e82160b7
gadget.c 58.8 KB