Skip to contentSkip to conversation

drm/tegra: gem: Reshuffle declarations

PATCH New Thierry Reding 4 participants 5 messages Feb 7, 2018 – Feb 8, 2018 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/tegra: gem: Reshuffle declarations

From: Thierry Reding <[email protected]>

Move declarations in the gem.h header file into the same order as the corresponding definitions in gem.c.

---
 drivers/gpu/drm/tegra/gem.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/gem.h +2 -2
index 8eaf5e3f6630..7e1635a01c81 100644
@@ -73,10 +73,10 @@ void tegra_bo_free_object(struct drm_gem_object *gem);
 int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
 			 struct drm_mode_create_dumb *args);
 
-int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
-
 extern const struct vm_operations_struct tegra_bo_vm_ops;
 
+int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
+
 struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
 				       struct drm_gem_object *gem,
 				       int flags);
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180207174556.25401-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/3 drm/tegra: gem: Make __tegra_gem_mmap() available more widely

From: Thierry Reding <[email protected]>

This function allows mapping a GEM object into a virtual memory address space, which makes it useful outside of the GEM code.

While at it, rename the function so it doesn't clash with the function that implements the DRM_TEGRA_GEM_MMAP IOCTL.

---
 drivers/gpu/drm/tegra/gem.c | 7 +++----
 drivers/gpu/drm/tegra/gem.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/gem.c +3 -4
index 0e390ae73559..4b80fe58d4f7 100644
@@ -464,8 +464,7 @@ const struct vm_operations_struct tegra_bo_vm_ops = {
 	.close = drm_gem_vm_close,
 };
 
-static int tegra_gem_mmap(struct drm_gem_object *gem,
-			  struct vm_area_struct *vma)
+int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma)
 {
 	struct tegra_bo *bo = to_tegra_bo(gem);
 
@@ -512,7 +511,7 @@ int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma)
 
 	gem = vma->vm_private_data;
 
-	return tegra_gem_mmap(gem, vma);
+	return __tegra_gem_mmap(gem, vma);
 }
 
 static struct sg_table *
@@ -633,7 +632,7 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma)
 	if (err < 0)
 		return err;
 
-	return tegra_gem_mmap(gem, vma);
+	return __tegra_gem_mmap(gem, vma);
 }
 
 static void *tegra_gem_prime_vmap(struct dma_buf *buf)
drivers/gpu/drm/tegra/gem.h +1 -0
index 7e1635a01c81..bb369c129fdd 100644
@@ -75,6 +75,7 @@ int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
 
 extern const struct vm_operations_struct tegra_bo_vm_ops;
 
+int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
 int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
 
 struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 drm/tegra: fb: Implement ->fb_mmap() callback

In reply to a message not in the archive

From: Thierry Reding <[email protected]>

This fixes hangs with legacy applications that use the mmap() syscall on the fbdev device to map framebuffer memory. The fbdev implementation for mmap() creates a mapping that conflicts with DRM usage and causes a hang when the memory is accessed through the mapping.

---
 drivers/gpu/drm/tegra/fb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/tegra/fb.c +16 -0
index 001cb77e2f59..0786159edef3 100644
@@ -224,12 +224,28 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
 }
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
+static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+	struct drm_fb_helper *helper = info->par;
+	struct tegra_bo *bo;
+	int err;
+
+	bo = tegra_fb_get_plane(helper->fb, 0);
+
+	err = drm_gem_mmap_obj(&bo->gem, bo->gem.size, vma);
+	if (err < 0)
+		return err;
+
+	return __tegra_gem_mmap(&bo->gem, vma);
+}
+
 static struct fb_ops tegra_fb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_fillrect = drm_fb_helper_sys_fillrect,
 	.fb_copyarea = drm_fb_helper_sys_copyarea,
 	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_mmap = tegra_fb_mmap,
 };
 
 static int tegra_fbdev_probe(struct drm_fb_helper *helper,
Signature · 1 line
2.15.1
Tested-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] drm/tegra: fb: Implement ->fb_mmap() callback

Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This fixes hangs with legacy applications that use the mmap() syscall on the fbdev device to map framebuffer memory. The fbdev implementation for mmap() creates a mapping that conflicts with DRM usage and causes a hang when the memory is accessed through the mapping.

That helps using applications making use of mmap & fbdev on an Apalis TK1!

--
Stefan

Quoted 40 lines
---
 drivers/gpu/drm/tegra/fb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/tegra/fb.c +16 -0
index 001cb77e2f59..0786159edef3 100644
@@ -224,12 +224,28 @@ struct drm_framebuffer *tegra_fb_create(struct
 drm_device *drm,
 }
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
+static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+	struct drm_fb_helper *helper = info->par;
+	struct tegra_bo *bo;
+	int err;
+
+	bo = tegra_fb_get_plane(helper->fb, 0);
+
+	err = drm_gem_mmap_obj(&bo->gem, bo->gem.size, vma);
+	if (err < 0)
+		return err;
+
+	return __tegra_gem_mmap(&bo->gem, vma);
+}
+
 static struct fb_ops tegra_fb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_fillrect = drm_fb_helper_sys_fillrect,
 	.fb_copyarea = drm_fb_helper_sys_copyarea,
 	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_mmap = tegra_fb_mmap,
 };
 
Quoted 1 line

static int tegra_fbdev_probe(struct drm_fb_helper *helper,

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180207174556.25401-3-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Tested-by
#6 lore raw

Re: [PATCH 3/3] drm/tegra: fb: Implement ->fb_mmap() callback

Quoted 9 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This fixes hangs with legacy applications that use the mmap() syscall on
the fbdev device to map framebuffer memory. The fbdev implementation for
mmap() creates a mapping that conflicts with DRM usage and causes a hang
when the memory is accessed through the mapping.

With that legacy Qt4e applications run just fine now on Apalis TK1 running Linux kernel 4.14.18.

Thanks, Thierry!

Quoted 40 lines
---
 drivers/gpu/drm/tegra/fb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/tegra/fb.c +16 -0
index 001cb77e2f59..0786159edef3 100644
@@ -224,12 +224,28 @@ struct drm_framebuffer *tegra_fb_create(struct
 drm_device *drm,
 }
 
 #ifdef CONFIG_DRM_FBDEV_EMULATION
+static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct
 *vma)
+{
+	struct drm_fb_helper *helper = info->par;
+	struct tegra_bo *bo;
+	int err;
+
+	bo = tegra_fb_get_plane(helper->fb, 0);
+
+	err = drm_gem_mmap_obj(&bo->gem, bo->gem.size, vma);
+	if (err < 0)
+		return err;
+
+	return __tegra_gem_mmap(&bo->gem, vma);
+}
+
 static struct fb_ops tegra_fb_ops = {
 	.owner = THIS_MODULE,
 	DRM_FB_HELPER_DEFAULT_OPS,
 	.fb_fillrect = drm_fb_helper_sys_fillrect,
 	.fb_copyarea = drm_fb_helper_sys_copyarea,
 	.fb_imageblit = drm_fb_helper_sys_imageblit,
+	.fb_mmap = tegra_fb_mmap,
 };

static int tegra_fbdev_probe(struct drm_fb_helper *helper,