[PATCH v2] drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap

Daniel Vetter daniel at ffwll.ch
Thu Nov 21 08:49:53 UTC 2019


On Thu, Nov 21, 2019 at 09:02:59AM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> > > update-object-after-move works fine.
> > > 
> > > try zap mappings with madvise(dontneed) has no bad effects (after vram
> > > move, trying to force re-creating the ptes).
> > 
> > Well if it's broken the zapping wouldn't work :-)
> > 
> > > didn't try the memory pressure thing yet.
> > 
> > I'm surprised ... and I have no idea how/why it keeps working.
> > 
> > For my paranoia, can you instrument the ttm page fault handler, and double
> > check that we get new faults after the move, and set up new ptes for the
> > same old mapping, but now pointing at the new place in vram?
> 
> Hmm, only the drm device mapping is faulted in after moving it,
> the dma-buf mapping is not.  Fixed by:

Ah yes, that's more what I'd expect to happen, and the below is what I'd
expect to fix things up. I think we should move it up ahead of the device
callback (so that drivers can overwrite) and then push as a fix. Separate
from a possible patch to undo the fake offset removal.
-Daniel

> 
> -------------------------- cut here ------------------------
> From 3a7f6c6dbf3b1e4b412c2b283b2ea4edff9f33b5 Mon Sep 17 00:00:00 2001
> From: Gerd Hoffmann <kraxel at redhat.com>
> Date: Thu, 21 Nov 2019 08:39:17 +0100
> Subject: [PATCH] drm: share address space for dma bufs
> 
> ---
>  drivers/gpu/drm/drm_prime.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 0814211b0f3f..07c88d2aedee 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)
>  struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
>  				      struct dma_buf_export_info *exp_info)
>  {
> +	struct drm_gem_object *obj = exp_info->priv;
>  	struct dma_buf *dma_buf;
>  
>  	dma_buf = dma_buf_export(exp_info);
> @@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,
>  		return dma_buf;
>  
>  	drm_dev_get(dev);
> -	drm_gem_object_get(exp_info->priv);
> +	drm_gem_object_get(obj);
> +	dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;
>  
>  	return dma_buf;
>  }
> -- 
> 2.18.1
> 
> -------------------------- cut here ------------------------
> 
> git branch: https://git.kraxel.org/cgit/linux/log/?h=drm-mmap-debug
> 
> cheers,
>   Gerd
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list