[ARM] tegra: dma: Fix critical data corruption bugs
authorColin Cross <ccross@google.com>
Wed, 18 Aug 2010 07:19:12 +0000 (00:19 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:26:31 +0000 (16:26 -0700)
commit771f2628641969b7fb71f7aa04495943016742bc
treebfec4d3322fcd5485757c70ce7d2106210489ab6
parent087c9f50bff0e22d675b7308b7c27c8b3dc0d490
[ARM] tegra: dma: Fix critical data corruption bugs

Sometimes, due to high interrupt latency in the continuous mode
of DMA transfer, the half buffer complete interrupt is handled
after DMA has transferred the full buffer.  When this is detected,
stop DMA immediately and restart with the next buffer if the next
buffer is ready.

originally fixed by Victor(Weiguo) Pan <wpan@nvidia.com>

In place of using the simple spin_lock()/spi_unlock() in the
interrupt thread, using the spin_lock_irqsave() and
spin_unlock_irqrestore(). The lock is shared between the normal
process context and interrupt context.

originally fixed by Laxman Dewangan (ldewangan@nvidia.com)

The use of shadow registers caused memory corruption at physical
address 0 because the enable bit was not shadowed, and assuming it
needed to be set would enable an unconfigured dma block.  Most of the
register accesses don't need to know the previous state of the
registers, and the few places that do need to modify only a few bits
in the registers are the same ones that were sometimes incorrectly
setting the enable bit.  This patch convert tegra_dma_update_hardware
to set the entire register, and the other users to read-modify-write,
and drops the shadow registers completely.

Also fixes missing locking in tegra_dma_allocate_channel

Signed-off-by: Colin Cross <ccross@android.com>
arch/arm/mach-tegra/dma.c