• Ben Dooks's avatar
    dmaengine: tegra: avoid overflow of byte tracking · 2bece1d3
    Ben Dooks authored
    [ Upstream commit e486df39 ]
    
    The dma_desc->bytes_transferred counter tracks the number of bytes
    moved by the DMA channel. This is then used to calculate the information
    passed back in the in the tegra_dma_tx_status callback, which is usually
    fine.
    
    When the DMA channel is configured as continous, then the bytes_transferred
    counter will increase over time and eventually overflow to become negative
    so the residue count will become invalid and the ALSA sound-dma code will
    report invalid hardware pointer values to the application. This results in
    some users becoming confused about the playout position and putting audio
    data in the wrong place.
    
    To fix this issue, always ensure the bytes_transferred field is modulo the
    size of the request. We only do this for the case of the cyclic transfer
    done ISR as anyone attempting to move 2GiB of DMA data in one transfer
    is unlikely.
    
    Note, we don't fix the issue that we should /never/ transfer a negative
    number of bytes so we could make those fields unsigned.
    Reviewed-by: 's avatarDmitry Osipenko <digetx@gmail.com>
    Signed-off-by: Ben Dooks's avatarBen Dooks <ben.dooks@codethink.co.uk>
    Acked-by: 's avatarJon Hunter <jonathanh@nvidia.com>
    Signed-off-by: Vinod Koul's avatarVinod Koul <vkoul@kernel.org>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    2bece1d3
Name
Last commit
Last update
Documentation Loading commit data...
LICENSES Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.clang-format Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...