From: Mark Craske <Mark_Craske@mentor.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>,
"George G. Davis" <George_Davis@mentor.com>,
Jiada Wang <Jiada_Wang@mentor.com>
Subject: [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page
Date: Thu, 15 Sep 2016 10:39:58 +0100 [thread overview]
Message-ID: <1473932399-23224-2-git-send-email-Mark_Craske@mentor.com> (raw)
In-Reply-To: <1473932399-23224-1-git-send-email-Mark_Craske@mentor.com>
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
next prev parent reply other threads:[~2016-09-15 9:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` Mark Craske [this message]
2016-09-27 10:53 ` [PATCH v1 1/2] drivers: dma-coherent: Fix DMA coherent size for less than page 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473932399-23224-2-git-send-email-Mark_Craske@mentor.com \
--to=mark_craske@mentor.com \
--cc=George_Davis@mentor.com \
--cc=Jiada_Wang@mentor.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®