• Sergei Shtylyov's avatar
    USB: musb: bugfixes for multi-packet TXDMA support · c7bbc056
    Sergei Shtylyov authored
    We really want to use DMA mode 1 for all multi-packet transfers;
    that's one IRQ on DMA completion, instead of one per packet.
    
    There is an important issue with such transfers, especially on
    the host side:  when such transfers end with a full-size packet,
    we must defer musb_dma_completion() calls until the FIFO empties.
    Else we report URB completions too soon, and may clobber data in
    the FIFO fifo when writing the next packet (losing data).
    
    The Inventra DMA support uses DMA mode 1, but it ignores that
    issue.  The CPPI DMA support uses mode 0, but doesn't handle
    its TXPKTRDY interrupts quite right either; it can get stale
    "packet ready" interrupts, and report transfer completion too
    early using slightly different code paths, also losing data.
    
    So I'm solving it in a generic way -- by adding a sort of the
    "interrupt filter" into musb_host_tx(), catching these cases
    where a DMA completion IRQ doesn't suffice and removing some
    needlessly controller-specific logic.  When a TXDMA interrupt
    happens and DMA request mode 1 is active, that filter resets
    to mode 0 and defers URB completion processing until TXPKTRDY,
    unless the FIFO is already empty.  Related filtering logic in
    Inventra and CPPI code gets removed.
    
    Since it should be competely safe now to use the DMA request
    mode 1 for host side transfers with the CPPI DMA controller,
    set it in musb_h_tx_dma_start() ... now renamed (and shared).
    
    [ dbrownell@users.sourceforge.net: don't introduce more
    CamElCase; use more concise explanations ]
    Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
    Cc: Felipe Balbi <felipe.balbi@nokia.com>
    Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    c7bbc056
musb_host.c 62.7 KB