Applied.<br><br>Thanks,<br>Inki Dae<br><br><br><div class="gmail_quote">2012/11/6 Rahul Sharma <span dir="ltr"><<a href="mailto:rahul.sharma@samsung.com" target="_blank">rahul.sharma@samsung.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This patch fixes the problem of mapping contigous and non contigous dma buffers.<br>
<br>
Currently page struct is calculated from the buf->dma_addr which is not the<br>
physical address. It is replaced by buf->pages which points to the page struct<br>
of the first page of contigous memory chunk. This gives the correct page frame<br>
number for mapping.<br>
<br>
Non-contigous dma buffers are described using SG table and SG lists. Each<br>
valid SG List is pointing to a single page or group of pages which are<br>
physically contigous. Current implementation just maps the first page of each<br>
SG List and leave the other pages unmapped, leading to a crash. Given solution<br>
finds the page struct for the faulting page through parsing SG table and map it.<br>
<br>
Signed-off-by: Rahul Sharma <<a href="mailto:rahul.sharma@samsung.com">rahul.sharma@samsung.com</a>><br>
---<br>
drivers/gpu/drm/exynos/exynos_drm_gem.c | 28 +++++++++++++++++++++++++---<br>
1 files changed, 25 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c<br>
index 8cb6824..50d73f1 100644<br>
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c<br>
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c<br>
@@ -95,15 +95,37 @@ static int exynos_drm_gem_map_buf(struct drm_gem_object *obj,<br>
{<br>
struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj);<br>
struct exynos_drm_gem_buf *buf = exynos_gem_obj->buffer;<br>
+ struct scatterlist *sgl;<br>
unsigned long pfn;<br>
+ int i;<br>
<br>
if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {<br>
+ if (!buf->sgt)<br>
+ return -EINTR;<br>
+<br>
+ sgl = buf->sgt->sgl;<br>
+ for_each_sg(buf->sgt->sgl, sgl, buf->sgt->nents, i) {<br>
+ if (!sgl) {<br>
+ DRM_ERROR("invalid SG table\n");<br>
+ return -EINTR;<br>
+ }<br>
+ if (page_offset < (sgl->length >> PAGE_SHIFT))<br>
+ break;<br>
+ page_offset -= (sgl->length >> PAGE_SHIFT);<br>
+ }<br>
+<br>
+ if (i >= buf->sgt->nents) {<br>
+ DRM_ERROR("invalid page offset\n");<br>
+ return -EINVAL;<br>
+ }<br>
+<br>
+ pfn = __phys_to_pfn(sg_phys(sgl)) + page_offset;<br>
+ } else {<br>
if (!buf->pages)<br>
return -EINTR;<br>
<br>
- pfn = page_to_pfn(buf->pages[page_offset++]);<br>
- } else<br>
- pfn = (buf->dma_addr >> PAGE_SHIFT) + page_offset;<br>
+ pfn = page_to_pfn(buf->pages[0]) + page_offset;<br>
+ }<br>
<br>
return vm_insert_mixed(vma, f_vaddr, pfn);<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.0.4<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</font></span></blockquote></div><br>