summaryrefslogtreecommitdiff
path: root/dma-helpers.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-06-27 14:50:47 +1000
committerAnthony Liguori <aliguori@us.ibm.com>2012-06-27 16:33:26 -0500
commit7a0bac4da9c6a2e36d388412f3b4074b10429e8e (patch)
tree314c04cb25abc8f6144f2f9036f5efbd758c2864 /dma-helpers.c
parentedded454067bd9bda8a4a2a3ef54ae19474407da (diff)
downloadqemu-7a0bac4da9c6a2e36d388412f3b4074b10429e8e.tar.gz
qemu-7a0bac4da9c6a2e36d388412f3b4074b10429e8e.tar.bz2
qemu-7a0bac4da9c6a2e36d388412f3b4074b10429e8e.zip
Add a memory barrier to DMA functions
The emulated devices can run simultaneously with the guest, so we need to be careful with ordering of load and stores done by them to the guest system memory, which need to be observed in the right order by the guest operating system. This adds a barrier call to the basic DMA read/write ops which is currently implemented as a smp_mb(), but could be later improved for more fine grained control of barriers. Additionally, a _relaxed() variant of the accessors is provided to easily convert devices who would be performance sensitive and negatively impacted by the change. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'dma-helpers.c')
-rw-r--r--dma-helpers.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/dma-helpers.c b/dma-helpers.c
index 2e09ceb912..35cb500581 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -31,6 +31,8 @@ static void do_dma_memory_set(dma_addr_t addr, uint8_t c, dma_addr_t len)
int dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c, dma_addr_t len)
{
+ dma_barrier(dma, DMA_DIRECTION_FROM_DEVICE);
+
if (dma_has_iommu(dma)) {
return iommu_dma_memory_set(dma, addr, c, len);
}