linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset
       [not found] <20191121103807.18424-1-kraxel@redhat.com>
@ 2019-11-21 10:38 ` Gerd Hoffmann
  2019-11-21 13:52   ` Daniel Vetter
  2019-11-21 10:38 ` [PATCH 2/2] drm: share address space for dma bufs Gerd Hoffmann
  1 sibling, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2019-11-21 10:38 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Gerd Hoffmann, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, Christian Koenig,
	Huang Rui, open list

The fake offset is going to stay, so change the calling convention for
drm_gem_object_funcs.mmap to include the fake offset.  Update all users
accordingly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/drm/drm_gem.h                  | 4 +---
 drivers/gpu/drm/drm_gem.c              | 3 ---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++
 drivers/gpu/drm/drm_prime.c            | 3 +++
 drivers/gpu/drm/ttm/ttm_bo_vm.c        | 7 -------
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 97a48165642c..0b375069cd48 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -159,9 +159,7 @@ struct drm_gem_object_funcs {
 	 *
 	 * The callback is used by by both drm_gem_mmap_obj() and
 	 * drm_gem_prime_mmap().  When @mmap is present @vm_ops is not
-	 * used, the @mmap callback must set vma->vm_ops instead. The @mmap
-	 * callback is always called with a 0 offset. The caller will remove
-	 * the fake offset as necessary.
+	 * used, the @mmap callback must set vma->vm_ops instead.
 	 */
 	int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 2f2b889096b0..56f42e0f2584 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
 		return -EINVAL;
 
 	if (obj->funcs && obj->funcs->mmap) {
-		/* Remove the fake offset */
-		vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
-
 		ret = obj->funcs->mmap(obj, vma);
 		if (ret)
 			return ret;
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 0810d3ef6961..a421a2eed48a 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	struct drm_gem_shmem_object *shmem;
 	int ret;
 
+	/* Remove the fake offset */
+	vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
+
 	shmem = to_drm_gem_shmem_obj(obj);
 
 	ret = drm_gem_shmem_get_pages(shmem);
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 0814211b0f3f..a9633bd241bb 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 	int ret;
 
 	if (obj->funcs && obj->funcs->mmap) {
+		/* Add the fake offset */
+		vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
+
 		ret = obj->funcs->mmap(obj, vma);
 		if (ret)
 			return ret;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index e6495ca2630b..3e8c3de91ae4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);
 int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
 {
 	ttm_bo_get(bo);
-
-	/*
-	 * FIXME: &drm_gem_object_funcs.mmap is called with the fake offset
-	 * removed. Add it back here until the rest of TTM works without it.
-	 */
-	vma->vm_pgoff += drm_vma_node_start(&bo->base.vma_node);
-
 	ttm_bo_mmap_vma_setup(bo, vma);
 	return 0;
 }
-- 
2.18.1


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

* [PATCH 2/2] drm: share address space for dma bufs
       [not found] <20191121103807.18424-1-kraxel@redhat.com>
  2019-11-21 10:38 ` [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset Gerd Hoffmann
@ 2019-11-21 10:38 ` Gerd Hoffmann
  2019-11-21 13:55   ` Daniel Vetter
  2019-11-21 16:42   ` [Intel-gfx] " Ruhl, Michael J
  1 sibling, 2 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-11-21 10:38 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Gerd Hoffmann, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, open list

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
unmaps not working properly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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 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


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

* Re: [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset
  2019-11-21 10:38 ` [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset Gerd Hoffmann
@ 2019-11-21 13:52   ` Daniel Vetter
  2019-11-21 13:56     ` Daniel Vetter
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2019-11-21 13:52 UTC (permalink / raw)
  To: Gerd Hoffmann, Rob Herring
  Cc: dri-devel, intel-gfx, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, Christian Koenig,
	Huang Rui, open list

On Thu, Nov 21, 2019 at 11:38:06AM +0100, Gerd Hoffmann wrote:
> The fake offset is going to stay, so change the calling convention for
> drm_gem_object_funcs.mmap to include the fake offset.  Update all users
> accordingly.

Please add to the commit message:

Note that this reverts 83b8a6f242ea ("drm/gem: Fix mmap fake offset
handling for drm_gem_object_funcs.mmap") and on top then adds the fake
offset to  drm_gem_prime_mmap to make sure all paths leading to
obj->funcs->mmap are consistent.

Fixes: 83b8a6f242ea ("drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap")
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rob Herring <robh@kernel.org>

With that also Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-Daniel
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/drm/drm_gem.h                  | 4 +---
>  drivers/gpu/drm/drm_gem.c              | 3 ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++
>  drivers/gpu/drm/drm_prime.c            | 3 +++
>  drivers/gpu/drm/ttm/ttm_bo_vm.c        | 7 -------
>  5 files changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 97a48165642c..0b375069cd48 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -159,9 +159,7 @@ struct drm_gem_object_funcs {
>  	 *
>  	 * The callback is used by by both drm_gem_mmap_obj() and
>  	 * drm_gem_prime_mmap().  When @mmap is present @vm_ops is not
> -	 * used, the @mmap callback must set vma->vm_ops instead. The @mmap
> -	 * callback is always called with a 0 offset. The caller will remove
> -	 * the fake offset as necessary.
> +	 * used, the @mmap callback must set vma->vm_ops instead.
>  	 */
>  	int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
>  
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 2f2b889096b0..56f42e0f2584 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
>  		return -EINVAL;
>  
>  	if (obj->funcs && obj->funcs->mmap) {
> -		/* Remove the fake offset */
> -		vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
> -
>  		ret = obj->funcs->mmap(obj, vma);
>  		if (ret)
>  			return ret;
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 0810d3ef6961..a421a2eed48a 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
>  	struct drm_gem_shmem_object *shmem;
>  	int ret;
>  
> +	/* Remove the fake offset */
> +	vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
> +
>  	shmem = to_drm_gem_shmem_obj(obj);
>  
>  	ret = drm_gem_shmem_get_pages(shmem);
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 0814211b0f3f..a9633bd241bb 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
>  	int ret;
>  
>  	if (obj->funcs && obj->funcs->mmap) {
> +		/* Add the fake offset */
> +		vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
> +
>  		ret = obj->funcs->mmap(obj, vma);
>  		if (ret)
>  			return ret;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index e6495ca2630b..3e8c3de91ae4 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);
>  int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
>  {
>  	ttm_bo_get(bo);
> -
> -	/*
> -	 * FIXME: &drm_gem_object_funcs.mmap is called with the fake offset
> -	 * removed. Add it back here until the rest of TTM works without it.
> -	 */
> -	vma->vm_pgoff += drm_vma_node_start(&bo->base.vma_node);
> -
>  	ttm_bo_mmap_vma_setup(bo, vma);
>  	return 0;
>  }
> -- 
> 2.18.1
> 

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

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

* Re: [PATCH 2/2] drm: share address space for dma bufs
  2019-11-21 10:38 ` [PATCH 2/2] drm: share address space for dma bufs Gerd Hoffmann
@ 2019-11-21 13:55   ` Daniel Vetter
  2019-11-21 16:42   ` [Intel-gfx] " Ruhl, Michael J
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-11-21 13:55 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, intel-gfx, Maarten Lankhorst, Maxime Ripard,
	Sean Paul, David Airlie, Daniel Vetter, open list

On Thu, Nov 21, 2019 at 11:38:07AM +0100, 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
> unmaps not working properly.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  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 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;

Can you pls also throw the change to amdgpu_gem_prime_export on top here?
Imo makes a lot more sense that way. With that added I'm happy to r-b.
-Daniel

>  
>  	return dma_buf;
>  }
> -- 
> 2.18.1
> 

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

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

* Re: [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset
  2019-11-21 13:52   ` Daniel Vetter
@ 2019-11-21 13:56     ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-11-21 13:56 UTC (permalink / raw)
  To: Gerd Hoffmann, Rob Herring, dri-devel, intel-gfx,
	Maarten Lankhorst, Maxime Ripard, Sean Paul, David Airlie,
	Christian Koenig, Huang Rui, open list

On Thu, Nov 21, 2019 at 02:52:59PM +0100, Daniel Vetter wrote:
> On Thu, Nov 21, 2019 at 11:38:06AM +0100, Gerd Hoffmann wrote:
> > The fake offset is going to stay, so change the calling convention for
> > drm_gem_object_funcs.mmap to include the fake offset.  Update all users
> > accordingly.
> 
> Please add to the commit message:
> 
> Note that this reverts 83b8a6f242ea ("drm/gem: Fix mmap fake offset
> handling for drm_gem_object_funcs.mmap") and on top then adds the fake
> offset to  drm_gem_prime_mmap to make sure all paths leading to
> obj->funcs->mmap are consistent.
> 
> Fixes: 83b8a6f242ea ("drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap")
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Rob Herring <robh@kernel.org>
> 
> With that also Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Also added Rob to cc here.

Rob, can you pls take a look an ack? The sage took another turn :-)
-Daniel

> -Daniel
> > 
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  include/drm/drm_gem.h                  | 4 +---
> >  drivers/gpu/drm/drm_gem.c              | 3 ---
> >  drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++
> >  drivers/gpu/drm/drm_prime.c            | 3 +++
> >  drivers/gpu/drm/ttm/ttm_bo_vm.c        | 7 -------
> >  5 files changed, 7 insertions(+), 13 deletions(-)
> > 
> > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> > index 97a48165642c..0b375069cd48 100644
> > --- a/include/drm/drm_gem.h
> > +++ b/include/drm/drm_gem.h
> > @@ -159,9 +159,7 @@ struct drm_gem_object_funcs {
> >  	 *
> >  	 * The callback is used by by both drm_gem_mmap_obj() and
> >  	 * drm_gem_prime_mmap().  When @mmap is present @vm_ops is not
> > -	 * used, the @mmap callback must set vma->vm_ops instead. The @mmap
> > -	 * callback is always called with a 0 offset. The caller will remove
> > -	 * the fake offset as necessary.
> > +	 * used, the @mmap callback must set vma->vm_ops instead.
> >  	 */
> >  	int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
> >  
> > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> > index 2f2b889096b0..56f42e0f2584 100644
> > --- a/drivers/gpu/drm/drm_gem.c
> > +++ b/drivers/gpu/drm/drm_gem.c
> > @@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
> >  		return -EINVAL;
> >  
> >  	if (obj->funcs && obj->funcs->mmap) {
> > -		/* Remove the fake offset */
> > -		vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
> > -
> >  		ret = obj->funcs->mmap(obj, vma);
> >  		if (ret)
> >  			return ret;
> > diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> > index 0810d3ef6961..a421a2eed48a 100644
> > --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> > +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> > @@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
> >  	struct drm_gem_shmem_object *shmem;
> >  	int ret;
> >  
> > +	/* Remove the fake offset */
> > +	vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
> > +
> >  	shmem = to_drm_gem_shmem_obj(obj);
> >  
> >  	ret = drm_gem_shmem_get_pages(shmem);
> > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> > index 0814211b0f3f..a9633bd241bb 100644
> > --- a/drivers/gpu/drm/drm_prime.c
> > +++ b/drivers/gpu/drm/drm_prime.c
> > @@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
> >  	int ret;
> >  
> >  	if (obj->funcs && obj->funcs->mmap) {
> > +		/* Add the fake offset */
> > +		vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
> > +
> >  		ret = obj->funcs->mmap(obj, vma);
> >  		if (ret)
> >  			return ret;
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index e6495ca2630b..3e8c3de91ae4 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);
> >  int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
> >  {
> >  	ttm_bo_get(bo);
> > -
> > -	/*
> > -	 * FIXME: &drm_gem_object_funcs.mmap is called with the fake offset
> > -	 * removed. Add it back here until the rest of TTM works without it.
> > -	 */
> > -	vma->vm_pgoff += drm_vma_node_start(&bo->base.vma_node);
> > -
> >  	ttm_bo_mmap_vma_setup(bo, vma);
> >  	return 0;
> >  }
> > -- 
> > 2.18.1
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

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

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

* RE: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
  2019-11-21 10:38 ` [PATCH 2/2] drm: share address space for dma bufs Gerd Hoffmann
  2019-11-21 13:55   ` Daniel Vetter
@ 2019-11-21 16:42   ` Ruhl, Michael J
  2019-11-22  6:32     ` Gerd Hoffmann
  1 sibling, 1 reply; 7+ messages in thread
From: Ruhl, Michael J @ 2019-11-21 16:42 UTC (permalink / raw)
  To: Gerd Hoffmann, dri-devel
  Cc: David Airlie, intel-gfx, open list, Maxime Ripard

>-----Original Message-----
>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Gerd
>Hoffmann
>Sent: Thursday, November 21, 2019 5:38 AM
>To: dri-devel@lists.freedesktop.org
>Cc: David Airlie <airlied@linux.ie>; intel-gfx@lists.freedesktop.org; open list
><linux-kernel@vger.kernel.org>; Maxime Ripard <mripard@kernel.org>; Gerd
>Hoffmann <kraxel@redhat.com>
>Subject: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
>
>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
>unmaps not working properly.

Hi Gerd,

Just want to make sure I understand this...

So unmaps will not work correctly for mappings when a driver does a
drm_vma_node_unamp()?

I.e. the dmabuf mappings will not get cleaned up correctly?

This is a day one bug?

Thanks,

Mike


>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>---
> 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 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
>
>_______________________________________________
>Intel-gfx mailing list
>Intel-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
  2019-11-21 16:42   ` [Intel-gfx] " Ruhl, Michael J
@ 2019-11-22  6:32     ` Gerd Hoffmann
  0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-11-22  6:32 UTC (permalink / raw)
  To: Ruhl, Michael J
  Cc: dri-devel, David Airlie, intel-gfx, open list, Maxime Ripard

On Thu, Nov 21, 2019 at 04:42:10PM +0000, Ruhl, Michael J wrote:
> >-----Original Message-----
> >From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Gerd
> >Hoffmann
> >Sent: Thursday, November 21, 2019 5:38 AM
> >To: dri-devel@lists.freedesktop.org
> >Cc: David Airlie <airlied@linux.ie>; intel-gfx@lists.freedesktop.org; open list
> ><linux-kernel@vger.kernel.org>; Maxime Ripard <mripard@kernel.org>; Gerd
> >Hoffmann <kraxel@redhat.com>
> >Subject: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
> >
> >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
> >unmaps not working properly.
> 
> Hi Gerd,
> 
> Just want to make sure I understand this...
> 
> So unmaps will not work correctly for mappings when a driver does a
> drm_vma_node_unamp()?

Completely removing the mapping (aka munmap syscall) works fine.
Zapping the pte's (using madvise(dontneed) for example) doesn't.

> This is a day one bug?

I guess so, but I'll leave that to others being active longer than me in
drm hacking to answer ...

cheers,
  Gerd


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

end of thread, other threads:[~2019-11-22  6:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191121103807.18424-1-kraxel@redhat.com>
2019-11-21 10:38 ` [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset Gerd Hoffmann
2019-11-21 13:52   ` Daniel Vetter
2019-11-21 13:56     ` Daniel Vetter
2019-11-21 10:38 ` [PATCH 2/2] drm: share address space for dma bufs Gerd Hoffmann
2019-11-21 13:55   ` Daniel Vetter
2019-11-21 16:42   ` [Intel-gfx] " Ruhl, Michael J
2019-11-22  6:32     ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).