Re: [PATCH v2 2/2] drm: share address space for dma bufs

2019-11-26 Thread Christian König

Am 22.11.19 um 19:21 schrieb Alex Deucher:

On Fri, Nov 22, 2019 at 4:17 AM Daniel Vetter  wrote:

On Fri, Nov 22, 2019 at 7:37 AM Gerd Hoffmann  wrote:

Use the shared address space of the drm device (see drm_open() in
drm_file.c) for dma-bufs too.  That removes a difference betweem drm
device mmap vmas and dma-buf mmap vmas and fixes corner cases like
dropping ptes (using madvise(DONTNEED) for example) not working
properly.

Also remove amdgpu driver's private dmabuf update.  It is not needed
any more now that we are doing this for everybody.

Signed-off-by: Gerd Hoffmann 

Reviewed-by: Daniel Vetter 

But I think you want at least an ack from amd guys for double checking here.
-Daniel

Looks correct to me.

Reviewed-by: Alex Deucher 


Reviewed-by: Christian König 





---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +---
  drivers/gpu/drm/drm_prime.c | 4 +++-
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index d5bcdfefbad6..586db4fb46bd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -361,10 +361,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct 
drm_gem_object *gobj,
 return ERR_PTR(-EPERM);

 buf = drm_gem_prime_export(gobj, flags);
-   if (!IS_ERR(buf)) {
-   buf->file->f_mapping = gobj->dev->anon_inode->i_mapping;
+   if (!IS_ERR(buf))
 buf->ops = _dmabuf_ops;
-   }

 return buf;
  }
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index a9633bd241bb..c3fc341453c0 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



--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-de...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v2 2/2] drm: share address space for dma bufs

2019-11-22 Thread Alex Deucher
On Fri, Nov 22, 2019 at 4:17 AM Daniel Vetter  wrote:
>
> On Fri, Nov 22, 2019 at 7:37 AM Gerd Hoffmann  wrote:
> >
> > Use the shared address space of the drm device (see drm_open() in
> > drm_file.c) for dma-bufs too.  That removes a difference betweem drm
> > device mmap vmas and dma-buf mmap vmas and fixes corner cases like
> > dropping ptes (using madvise(DONTNEED) for example) not working
> > properly.
> >
> > Also remove amdgpu driver's private dmabuf update.  It is not needed
> > any more now that we are doing this for everybody.
> >
> > Signed-off-by: Gerd Hoffmann 
>
> Reviewed-by: Daniel Vetter 
>
> But I think you want at least an ack from amd guys for double checking here.
> -Daniel

Looks correct to me.

Reviewed-by: Alex Deucher 


> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +---
> >  drivers/gpu/drm/drm_prime.c | 4 +++-
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > index d5bcdfefbad6..586db4fb46bd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> > @@ -361,10 +361,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct 
> > drm_gem_object *gobj,
> > return ERR_PTR(-EPERM);
> >
> > buf = drm_gem_prime_export(gobj, flags);
> > -   if (!IS_ERR(buf)) {
> > -   buf->file->f_mapping = gobj->dev->anon_inode->i_mapping;
> > +   if (!IS_ERR(buf))
> > buf->ops = _dmabuf_ops;
> > -   }
> >
> > return buf;
> >  }
> > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> > index a9633bd241bb..c3fc341453c0 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
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Re: [PATCH v2 2/2] drm: share address space for dma bufs

2019-11-22 Thread Daniel Vetter
On Fri, Nov 22, 2019 at 7:37 AM Gerd Hoffmann  wrote:
>
> Use the shared address space of the drm device (see drm_open() in
> drm_file.c) for dma-bufs too.  That removes a difference betweem drm
> device mmap vmas and dma-buf mmap vmas and fixes corner cases like
> dropping ptes (using madvise(DONTNEED) for example) not working
> properly.
>
> Also remove amdgpu driver's private dmabuf update.  It is not needed
> any more now that we are doing this for everybody.
>
> Signed-off-by: Gerd Hoffmann 

Reviewed-by: Daniel Vetter 

But I think you want at least an ack from amd guys for double checking here.
-Daniel
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +---
>  drivers/gpu/drm/drm_prime.c | 4 +++-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> index d5bcdfefbad6..586db4fb46bd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> @@ -361,10 +361,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct 
> drm_gem_object *gobj,
> return ERR_PTR(-EPERM);
>
> buf = drm_gem_prime_export(gobj, flags);
> -   if (!IS_ERR(buf)) {
> -   buf->file->f_mapping = gobj->dev->anon_inode->i_mapping;
> +   if (!IS_ERR(buf))
> buf->ops = _dmabuf_ops;
> -   }
>
> return buf;
>  }
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index a9633bd241bb..c3fc341453c0 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
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx