Thread (64 messages) 64 messages, 7 authors, 2011-06-29
STALE5456d

[PATCH] USB: ehci: use packed, aligned(4) instead of removing the packed attribute

From: arnd@arndb.de (Arnd Bergmann)
Date: 2011-06-25 08:09:04

On Saturday 25 June 2011, Nicolas Pitre wrote:
quoted
which means that the dma_buf variable is dereferenced before the
volatile mmio_reg variable, which opens up a race: An interrupt may have
signalled us that a DMA is in progress, so we read a MMIO register from
the device (this is guaranteed to flush the DMA on PCI and similar buses).
If we read the dma_buf before we read the mmio register, the data we get
back may be stale.

Adding a barrier() between the two turns the assembly into the expected

        ldr     r3, [r1, #0]
        ldr     r0, [r0, #0]
        bx      lr
But isn't the usual dma_unmap_*() API call providing that barrier 
already?
Yes, for the streaming mapping that would be sufficient, but not
for a coherent mapping, which doesn't need dma_unmap_* or dma_sync*
calls before accessing the buffer.

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help