• Vardan Mikayelyan's avatar
    usb: dwc2: host: fix logical omissions in dwc2_process_non_isoc_desc · 3142a16b
    Vardan Mikayelyan authored
    Fixes memory manipulation issues and makes Host DDMA bulk transfers
    work.
    
    dwc2_process_non_isoc_desc() must return non zero value ONLY when
    failure happens in one of the queued descriptors. After receiving
    non zero value the caller must stop processing of remaining
    QTDs and their descriptors from chain.
    
    Commit 26a19ea6 ("usb: dwc2: host: fix use of qtd after
    free in desc dma mode") breaks non_isoc transaction completion logic
    in Host DDMA mode. There were bugs before that, but after this patch
    dwc2_process_non_isoc_desc() returns fail status even if descriptor
    was processed normally. This causes break from loop which is processing
    remaining descriptors assigned to QTD, which is not correct for QTDs
    containing more than one descriptor.
    
    Current dwc2 driver gathers queued BULK URBs until receiving URB
    without URB_NO_INTERRUPT flag. Once getting it, SW creates
    descriptor chain, stores it in qh structure and passes start
    address to HW. Multiple URB data is contained in that chain.
    Hence on getting error on descriptor after its processing by HW,
    SW should go out of both loops(qh->qtd, qtd->descs) and report
    the failure.
    
    Fixes: 26a19ea6 ("usb: dwc2: host: fix use of qtd after free in desc dma mode")
    Cc: Gregory Herrero <gregory.herrero@intel.com>
    Signed-off-by: default avatarVardan Mikayelyan <mvardan@synopsys.com>
    Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
    Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
    3142a16b
hcd_ddma.c 37.6 KB