linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/cma: Fix recent regression of mmap() in the MMU case.
@ 2017-04-17 23:31 Eric Anholt
  2017-04-18  6:52 ` Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Anholt @ 2017-04-17 23:31 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-kernel, Eric Anholt, Yannick Fertre

The stub get_unmapped_area() function was actually getting called, so
all of our mmap()s failed.

Cc: Yannick Fertre <yannick.fertre@st.com>
Fixes: 97bf3a9aa60f ("drm/cma: Update DEFINE_DRM_GEM_CMA_FOPS to add get_unmapped_area")
Signed-off-by: Eric Anholt <eric@anholt.net>
---
 include/drm/drm_gem_cma_helper.h | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
index 7320b140545a..b42529e0fae0 100644
--- a/include/drm/drm_gem_cma_helper.h
+++ b/include/drm/drm_gem_cma_helper.h
@@ -26,6 +26,13 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
 	return container_of(gem_obj, struct drm_gem_cma_object, base);
 }
 
+#ifndef CONFIG_MMU
+#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
+	.get_unmapped_area	= drm_gem_cma_get_unmapped_area,
+#else
+#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS
+#endif
+
 /**
  * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
  * @name: name for the generated structure
@@ -50,7 +57,7 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
 		.read		= drm_read,\
 		.llseek		= noop_llseek,\
 		.mmap		= drm_gem_cma_mmap,\
-		.get_unmapped_area	= drm_gem_cma_get_unmapped_area,\
+		DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
 	}
 
 /* free GEM object */
@@ -86,15 +93,6 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
 					    unsigned long len,
 					    unsigned long pgoff,
 					    unsigned long flags);
-#else
-static inline unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
-							  unsigned long addr,
-							  unsigned long len,
-							  unsigned long pgoff,
-							  unsigned long flags)
-{
-	return -EINVAL;
-}
 #endif
 
 #ifdef CONFIG_DEBUG_FS
-- 
2.11.0

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

* Re: [PATCH] drm/cma: Fix recent regression of mmap() in the MMU case.
  2017-04-17 23:31 [PATCH] drm/cma: Fix recent regression of mmap() in the MMU case Eric Anholt
@ 2017-04-18  6:52 ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2017-04-18  6:52 UTC (permalink / raw)
  To: Eric Anholt; +Cc: dri-devel, Yannick Fertre, linux-kernel

On Mon, Apr 17, 2017 at 04:31:24PM -0700, Eric Anholt wrote:
> The stub get_unmapped_area() function was actually getting called, so
> all of our mmap()s failed.
> 
> Cc: Yannick Fertre <yannick.fertre@st.com>
> Fixes: 97bf3a9aa60f ("drm/cma: Update DEFINE_DRM_GEM_CMA_FOPS to add get_unmapped_area")
> Signed-off-by: Eric Anholt <eric@anholt.net>

Oh drat, I assumed the core would only call this when needed, but things
don't work like that.

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

The strange thing is that in some cases ->mm->get_unmapped_area overwrites
fops->get_unmapped_area, but not for do_mmap in the mmu case. Seems not
entirely thought out to me ...
-Daniel

> ---
>  include/drm/drm_gem_cma_helper.h | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
> index 7320b140545a..b42529e0fae0 100644
> --- a/include/drm/drm_gem_cma_helper.h
> +++ b/include/drm/drm_gem_cma_helper.h
> @@ -26,6 +26,13 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
>  	return container_of(gem_obj, struct drm_gem_cma_object, base);
>  }
>  
> +#ifndef CONFIG_MMU
> +#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
> +	.get_unmapped_area	= drm_gem_cma_get_unmapped_area,
> +#else
> +#define DRM_GEM_CMA_UNMAPPED_AREA_FOPS
> +#endif
> +
>  /**
>   * DEFINE_DRM_GEM_CMA_FOPS() - macro to generate file operations for CMA drivers
>   * @name: name for the generated structure
> @@ -50,7 +57,7 @@ to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
>  		.read		= drm_read,\
>  		.llseek		= noop_llseek,\
>  		.mmap		= drm_gem_cma_mmap,\
> -		.get_unmapped_area	= drm_gem_cma_get_unmapped_area,\
> +		DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
>  	}
>  
>  /* free GEM object */
> @@ -86,15 +93,6 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
>  					    unsigned long len,
>  					    unsigned long pgoff,
>  					    unsigned long flags);
> -#else
> -static inline unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
> -							  unsigned long addr,
> -							  unsigned long len,
> -							  unsigned long pgoff,
> -							  unsigned long flags)
> -{
> -	return -EINVAL;
> -}
>  #endif
>  
>  #ifdef CONFIG_DEBUG_FS
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

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

end of thread, other threads:[~2017-04-18  6:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 23:31 [PATCH] drm/cma: Fix recent regression of mmap() in the MMU case Eric Anholt
2017-04-18  6:52 ` Daniel Vetter

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).