All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/prime: Fix mmap fake offset for drm_gem_object_funcs.mmap
@ 2019-10-23 22:22 Rob Herring
  2019-10-24  9:02 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2019-10-23 22:22 UTC (permalink / raw)
  To: dri-devel, Gerd Hoffmann; +Cc: Daniel Vetter

Commit c40069cb7bd6 ("drm: add mmap() to drm_gem_object_funcs")
introduced a GEM object mmap() hook which is expected to subtract the
fake offset from vm_pgoff. However, for mmap() on dmabufs, there is not
a fake offset. To fix this, we need to add the fake offset just like the
driver->fops->mmap() code path.

Fixes: c40069cb7bd6 ("drm: add mmap() to drm_gem_object_funcs")
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Rob Herring <robh@kernel.org>
---
I ran into this while working on converting vgem to shmem helpers and
the IGT vgem_basic dmabuf-mmap test failed. This fixes shmem, but I
have checked any other users of the new mmap hook.

Rob

 drivers/gpu/drm/drm_prime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 0814211b0f3f..5d06690a2e9d 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -713,6 +713,8 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	struct file *fil;
 	int ret;
 
+	vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
+
 	if (obj->funcs && obj->funcs->mmap) {
 		ret = obj->funcs->mmap(obj, vma);
 		if (ret)
@@ -737,8 +739,6 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	if (ret)
 		goto out;
 
-	vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
-
 	ret = obj->dev->driver->fops->mmap(fil, vma);
 
 	drm_vma_node_revoke(&obj->vma_node, priv);
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-25  5:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-23 22:22 [PATCH] drm/prime: Fix mmap fake offset for drm_gem_object_funcs.mmap Rob Herring
2019-10-24  9:02 ` Gerd Hoffmann
2019-10-24 12:32   ` Daniel Vetter
2019-10-24 14:39     ` Rob Herring
2019-10-24 14:56       ` Daniel Vetter
2019-10-25  5:25     ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.