summaryrefslogtreecommitdiffstats
path: root/drivers/base/dma-coherent.c
diff options
context:
space:
mode:
authorBastian Hecht <bhecht@de.adit-jv.com>2016-09-28 09:51:57 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-28 17:53:16 +0200
commitdd01c75f1df311793de6ef217c72036552000c9a (patch)
tree0da39cc93ddfb308acd94a627663033a7f421bc2 /drivers/base/dma-coherent.c
parentdrivers: dma-coherent: Fix DMA coherent size for less than page (diff)
downloadlinux-dd01c75f1df311793de6ef217c72036552000c9a.tar.xz
linux-dd01c75f1df311793de6ef217c72036552000c9a.zip
drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()
We don't need to hold the spinlock while zeroing the allocated memory. In case we handle big buffers this is a severe issue as other CPUs might be spinning half a second or longer. Signed-off-by: Bastian Hecht <bhecht@de.adit-jv.com> Signed-off-by: George G. Davis <george_davis@mentor.com> Signed-off-by: Mark Craske <Mark_Craske@mentor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/dma-coherent.c')
-rw-r--r--drivers/base/dma-coherent.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 2789f7a95b93..640a7e63c453 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -165,6 +165,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
int order = get_order(size);
unsigned long flags;
int pageno;
+ int dma_memory_map;
if (!dev)
return 0;
@@ -187,11 +188,12 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size,
*/
*dma_handle = mem->device_base + (pageno << PAGE_SHIFT);
*ret = mem->virt_base + (pageno << PAGE_SHIFT);
- if (mem->flags & DMA_MEMORY_MAP)
+ dma_memory_map = (mem->flags & DMA_MEMORY_MAP);
+ spin_unlock_irqrestore(&mem->spinlock, flags);
+ if (dma_memory_map)
memset(*ret, 0, size);
else
memset_io(*ret, 0, size);
- spin_unlock_irqrestore(&mem->spinlock, flags);
return 1;