diff mbox series

drm/bochs: fix bochs_gem_prime_mmap

Message ID 20190204183858.8976-1-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/bochs: fix bochs_gem_prime_mmap | expand

Commit Message

Gerd Hoffmann Feb. 4, 2019, 6:38 p.m. UTC
ttm_fbdev_mmap() just doesn't work.  It appears to work fine, mmap()
returns success, but any attempt to actually access the mapping causes a
SIGBUS.

We can just use drm_gem_prime_mmap() instead.  Almost.  We have to copy
over the start offset from the ttm_buffer_object vm_node to the
drm_gem_object vm_node so the offset math in drm_gem_prime_mmap() works
correctly for us even though we use ttm to manage our objects.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/bochs/bochs_mm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Feb. 5, 2019, 9:01 a.m. UTC | #1
On Mon, Feb 04, 2019 at 07:38:58PM +0100, Gerd Hoffmann wrote:
> ttm_fbdev_mmap() just doesn't work.  It appears to work fine, mmap()
> returns success, but any attempt to actually access the mapping causes a
> SIGBUS.
> 
> We can just use drm_gem_prime_mmap() instead.  Almost.  We have to copy
> over the start offset from the ttm_buffer_object vm_node to the
> drm_gem_object vm_node so the offset math in drm_gem_prime_mmap() works
> correctly for us even though we use ttm to manage our objects.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Would be kinda neat if we could teach ttm to not have it's own vma node
...

Anyway, lgtm.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/bochs/bochs_mm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
> index 641a33f134..49463348a0 100644
> --- a/drivers/gpu/drm/bochs/bochs_mm.c
> +++ b/drivers/gpu/drm/bochs/bochs_mm.c
> @@ -442,5 +442,6 @@ int bochs_gem_prime_mmap(struct drm_gem_object *obj,
>  {
>  	struct bochs_bo *bo = gem_to_bochs_bo(obj);
>  
> -	return ttm_fbdev_mmap(vma, &bo->bo);
> +	bo->gem.vma_node.vm_node.start = bo->bo.vma_node.vm_node.start;
> +	return drm_gem_prime_mmap(obj, vma);
>  }
> -- 
> 2.9.3
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index 641a33f134..49463348a0 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -442,5 +442,6 @@  int bochs_gem_prime_mmap(struct drm_gem_object *obj,
 {
 	struct bochs_bo *bo = gem_to_bochs_bo(obj);
 
-	return ttm_fbdev_mmap(vma, &bo->bo);
+	bo->gem.vma_node.vm_node.start = bo->bo.vma_node.vm_node.start;
+	return drm_gem_prime_mmap(obj, vma);
 }