• Weitao Wang's avatar
    USB: HCD: Fix URB giveback issue in tasklet function · 26c6c2f8
    Weitao Wang authored
    Usb core introduce the mechanism of giveback of URB in tasklet context to
    reduce hardware interrupt handling time. On some test situation(such as
    FIO with 4KB block size), when tasklet callback function called to
    giveback URB, interrupt handler add URB node to the bh->head list also.
    If check bh->head list again after finish all URB giveback of local_list,
    then it may introduce a "dynamic balance" between giveback URB and add URB
    to bh->head list. This tasklet callback function may not exit for a long
    time, which will cause other tasklet function calls to be delayed. Some
    real-time applications(such as KB and Mouse) will see noticeable lag.
    
    In order to prevent the tasklet function from occupying the cpu for a long
    time at a time, new URBS will not be added to the local_list even though
    the bh->head list is not empty. But also need to ensure the left URB
    giveback to be processed in time, so add a member high_prio for structure
    giveback_urb_bh to prioritize tasklet and schelule this tasklet again if
    bh->head list is not empty.
    
    At the same time, we are able to prioritize tasklet through structure
    member high_prio. So, replace the local high_prio_bh variable with this
    structure member in usb_hcd_giveback_urb.
    
    Fixes: 94dfd7ed ("USB: HCD: support giveback of URB in tasklet context")
    Cc: stable <stable@kernel.org>
    Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Signed-off-by: default avatarWeitao Wang <WeitaoWang-oc@zhaoxin.com>
    Link: https://lore.kernel.org/r/20220726074918.5114-1-WeitaoWang-oc@zhaoxin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    26c6c2f8
hcd.c 90 KB