From dd7968cf8a5ea6af037d6ce3cd8c6aace2815f32 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98rjan=20Eide?= Date: Mon, 5 Sep 2016 13:49:12 +0200 Subject: [PATCH] CHROMIUM: drm/rockchip: Respect page offset in IOMMU mmap When mapping buffers through the PRIME DMA-buf mmap path we might be given an offset which has to be respected. The DRM GEM mmap path already takes care of zeroing out the fake mmap offset, so we can just make the IOMMU mmap implementation always respect the offset. BUG=chrome-os-partner:56615 TEST=graphics_GLBench Change-Id: Iec83e720b24ddd35a92f3df8312015bc5af798f0 Signed-off-by: rjan Eide Signed-off-by: Tomasz Figa Reviewed-on: https://chromium-review.googlesource.com/386477 Reviewed-by: Daniel Kurtz Signed-off-by: Randy Li --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index dc7ec1de3b06..f79238149ff6 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -218,12 +218,16 @@ static int rockchip_drm_gem_object_mmap_iommu(struct drm_gem_object *obj, unsigned int i, count = obj->size >> PAGE_SHIFT; unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; unsigned long uaddr = vma->vm_start; + unsigned long offset = vma->vm_pgoff; + unsigned long end = user_count + offset; int ret; - if (user_count == 0 || user_count > count) + if (user_count == 0) + return -ENXIO; + if (end > count) return -ENXIO; - for (i = 0; i < user_count; i++) { + for (i = offset; i < end; i++) { ret = vm_insert_page(vma, uaddr, rk_obj->pages[i]); if (ret) return ret; -- 2.34.1