From: John Einar Reitan <john.reitan@foss.arm.com>
To: gregkh@linuxfoundation.org
Cc: arve@android.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org,
John Einar Reitan <john.reitan@foss.arm.com>
Subject: [PATCH] ion: scatterlist offset not used for buffer map
Date: Thu, 7 Apr 2016 13:29:59 +0200 [thread overview]
Message-ID: <1460028599-22356-1-git-send-email-john.reitan@foss.arm.com> (raw)
ion's default user/kernel page mapping code don't honor the offset
option for scatterlists. It uses sg_page and expect the whole page to be
mapped, while the offset could dictate an offset within a large page.
sg_phys correctly accounts for the offset, so should be used instead.
Signed-off-by: John Einar Reitan <john.reitan@foss.arm.com>
---
drivers/staging/android/ion/ion_heap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index ca15a87..e83002dc 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -47,7 +47,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
for_each_sg(table->sgl, sg, table->nents, i) {
int npages_this_entry = PAGE_ALIGN(sg->length) / PAGE_SIZE;
- struct page *page = sg_page(sg);
+ struct page *page = pfn_to_page(PFN_DOWN(sg_phys(sg)));
BUG_ON(i >= npages);
for (j = 0; j < npages_this_entry; j++)
@@ -79,7 +79,6 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
int ret;
for_each_sg(table->sgl, sg, table->nents, i) {
- struct page *page = sg_page(sg);
unsigned long remainder = vma->vm_end - addr;
unsigned long len = sg->length;
@@ -87,18 +86,18 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer,
offset -= sg->length;
continue;
} else if (offset) {
- page += offset / PAGE_SIZE;
len = sg->length - offset;
- offset = 0;
}
len = min(len, remainder);
- ret = remap_pfn_range(vma, addr, page_to_pfn(page), len,
- vma->vm_page_prot);
+ ret = remap_pfn_range(vma, addr, PFN_DOWN(sg_phys(sg) + offset),
+ len, vma->vm_page_prot);
if (ret)
return ret;
addr += len;
if (addr >= vma->vm_end)
return 0;
+
+ offset = 0;
}
return 0;
}
--
2.7.3
next reply other threads:[~2016-04-07 11:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 11:29 John Einar Reitan [this message]
2016-04-07 19:37 ` [PATCH] ion: scatterlist offset not used for buffer map Laura Abbott
2016-04-08 6:56 ` John Einar Reitan
2016-04-08 22:43 ` Laura Abbott
2016-04-08 23:11 ` Colin Cross
2016-04-11 7:10 ` John Einar Reitan
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=1460028599-22356-1-git-send-email-john.reitan@foss.arm.com \
--to=john.reitan@foss.arm.com \
--cc=arve@android.com \
--cc=devel@driverdev.osuosl.org \
--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;
as well as URLs for NNTP newsgroup(s).