* [PATCH v1 0/2] Two small dma-coherent bug fixes
[not found] <Mark Craske <Mark_Craske@mentor.com>
@ 2016-09-15 9:39 ` Mark Craske
2016-09-15 9:39 ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-15 9:39 ` [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
2016-09-28 7:51 ` [PATCH v2 0/2] Two small dma-coherent bug fixes Mark Craske
1 sibling, 2 replies; 7+ messages in thread
From: Mark Craske @ 2016-09-15 9:39 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page
2016-09-15 9:39 ` [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske
@ 2016-09-15 9:39 ` Mark Craske
2016-09-27 10:53 ` Greg Kroah-Hartman
2016-09-15 9:39 ` [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
1 sibling, 1 reply; 7+ messages in thread
From: Mark Craske @ 2016-09-15 9:39 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
From: "George G. Davis" <george_davis@mentor.com>
We fix a bug in dma_mmap_from_coherent() that appears when we map non page
aligned DMA memory. It cuts off the non aligned part (this is different to
dma_alloc_coherent() that always rounds up to full pages). So for mappings
of less than a page we get -ENXIO as dma_mmap_from_coherent() assumes we
want to map zero pages.
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Mark Craske <Mark_Craske@mentor.com>
---
drivers/base/dma-coherent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index bdf28f7..abd83b7 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -262,7 +262,7 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
unsigned long off = vma->vm_pgoff;
int start = (vaddr - mem->virt_base) >> PAGE_SHIFT;
int user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
- int count = size >> PAGE_SHIFT;
+ int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
*ret = -ENXIO;
if (off < count && user_count <= count - off) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()
2016-09-15 9:39 ` [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-15 9:39 ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
@ 2016-09-15 9:39 ` Mark Craske
1 sibling, 0 replies; 7+ messages in thread
From: Mark Craske @ 2016-09-15 9:39 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page
2016-09-15 9:39 ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
@ 2016-09-27 10:53 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2016-09-27 10:53 UTC (permalink / raw)
To: Mark Craske; +Cc: linux-kernel, George G. Davis, Jiada Wang
On Thu, Sep 15, 2016 at 10:39:58AM +0100, Mark Craske wrote:
> From: "George G. Davis" <george_davis@mentor.com>
>
> We fix a bug in dma_mmap_from_coherent() that appears when we map non page
> aligned DMA memory. It cuts off the non aligned part (this is different to
> dma_alloc_coherent() that always rounds up to full pages). So for mappings
> of less than a page we get -ENXIO as dma_mmap_from_coherent() assumes we
> want to map zero pages.
>
> Signed-off-by: George G. Davis <george_davis@mentor.com>
> Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
> Signed-off-by: Mark Craske <Mark_Craske@mentor.com>
> ---
> drivers/base/dma-coherent.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
> index bdf28f7..abd83b7 100644
> --- a/drivers/base/dma-coherent.c
> +++ b/drivers/base/dma-coherent.c
> @@ -262,7 +262,7 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
> unsigned long off = vma->vm_pgoff;
> int start = (vaddr - mem->virt_base) >> PAGE_SHIFT;
> int user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
> - int count = size >> PAGE_SHIFT;
> + int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
>
> *ret = -ENXIO;
> if (off < count && user_count <= count - off) {
> --
> 1.7.9.5
>
Doesn't apply to my tree (or linux-next) :(
Can you refresh this series and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 0/2] Two small dma-coherent bug fixes
[not found] <Mark Craske <Mark_Craske@mentor.com>
2016-09-15 9:39 ` [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske
@ 2016-09-28 7:51 ` Mark Craske
2016-09-28 7:51 ` [PATCH v2 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-28 7:51 ` [PATCH v2 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
1 sibling, 2 replies; 7+ messages in thread
From: Mark Craske @ 2016-09-28 7:51 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
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 repo driver-core-next
branch HEAD (6ee6d1c carl9170: fix debugfs crashes)
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page
2016-09-28 7:51 ` [PATCH v2 0/2] Two small dma-coherent bug fixes Mark Craske
@ 2016-09-28 7:51 ` Mark Craske
2016-09-28 7:51 ` [PATCH v2 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
1 sibling, 0 replies; 7+ messages in thread
From: Mark Craske @ 2016-09-28 7:51 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
From: "George G. Davis" <george_davis@mentor.com>
We fix a bug in dma_mmap_from_coherent() that appears when we map non page
aligned DMA memory. It cuts off the non aligned part (this is different to
dma_alloc_coherent() that always rounds up to full pages). So for mappings
of less than a page we get -ENXIO as dma_mmap_from_coherent() assumes we
want to map zero pages.
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Mark Craske <Mark_Craske@mentor.com>
---
drivers/base/dma-coherent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index db122a0..2789f7a 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -262,7 +262,7 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
unsigned long off = vma->vm_pgoff;
int start = (vaddr - mem->virt_base) >> PAGE_SHIFT;
int user_count = vma_pages(vma);
- int count = size >> PAGE_SHIFT;
+ int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
*ret = -ENXIO;
if (off < count && user_count <= count - off) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent()
2016-09-28 7:51 ` [PATCH v2 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-28 7:51 ` [PATCH v2 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
@ 2016-09-28 7:51 ` Mark Craske
1 sibling, 0 replies; 7+ messages in thread
From: Mark Craske @ 2016-09-28 7:51 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, George G. Davis, Jiada Wang
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 2789f7a..640a7e6 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-09-28 7:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Mark Craske <Mark_Craske@mentor.com>
2016-09-15 9:39 ` [PATCH v1 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-15 9:39 ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-27 10:53 ` Greg Kroah-Hartman
2016-09-15 9:39 ` [PATCH v1 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
2016-09-28 7:51 ` [PATCH v2 0/2] Two small dma-coherent bug fixes Mark Craske
2016-09-28 7:51 ` [PATCH v2 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page Mark Craske
2016-09-28 7:51 ` [PATCH v2 2/2] drivers: dma-coherent: Move spinlock in dma_alloc_from_coherent() Mark Craske
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox