Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1483935 > unrolled thread

[PATCH v1 0/2] Two small dma-coherent bug fixes

Started byMark Craske <Mark_Craske@mentor.com>
First post2016-09-15 11:40 +0200
Last post2016-09-15 11:50 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske <Mark_Craske@mentor.com> - 2016-09-15 11:40 +0200
    [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske <Mark_Craske@mentor.com> - 2016-09-15 11:50 +0200

#1483935 — [PATCH v1 0/2] Two small dma-coherent bug fixes

FromMark Craske <Mark_Craske@mentor.com>
Date2016-09-15 11:40 +0200
Subject[PATCH v1 0/2] Two small dma-coherent bug fixes
Message-ID<shBjb-5el-19@gated-at.bofh.it>
This patchset contains the following commits:

Bastian Hecht (1):
  drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()

George G. Davis (1):
  drivers: dma-coherent: Fix DMA coherent size for less than page

 drivers/base/dma-coherent.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Background information
----------------------
These 2 commits were originally developed and validated on an ARM i.MX6 based
commercial project running a highly modified 3.14 Linux kernel.
The commits were needed to amend dma_mmap_from_coherent() to deal correctly
with mappings of less than one page, and to improve latency on SMP systems
where large DMA buffers are used.

The commits have been forward-ported to driver-core-next master branch HEAD
(c693593 Linux 4.8-rc5)

Commit details
--------------
This patchset fixes a couple of problems with dma-coherent seen
on a commercial i.MX6 based system.

Note: Testing has only been done on an ARM i.MX6 based platform.
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1483941 — [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()

FromMark Craske <Mark_Craske@mentor.com>
Date2016-09-15 11:50 +0200
Subject[PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()
Message-ID<shBsS-5hW-9@gated-at.bofh.it>
In reply to#1483935
From: Bastian Hecht <bhecht@de.adit-jv.com>

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>
---
 drivers/base/dma-coherent.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index abd83b7..d092df4 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;
 
-- 
1.7.9.5

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web