From 3d6b20bdedc331561dd04a1ac48f4eea61ddda4c Mon Sep 17 00:00:00 2001 Message-Id: <3d6b20bdedc331561dd04a1ac48f4eea61ddda4c.1531317141.git.marcel.ziswiler@toradex.com> In-Reply-To: <6654e1bd342708a683daf47e7558455f709a3e7e.1531317141.git.marcel.ziswiler@toradex.com> References: <6654e1bd342708a683daf47e7558455f709a3e7e.1531317141.git.marcel.ziswiler@toradex.com> From: Thierry Reding Date: Wed, 7 Feb 2018 18:45:56 +0100 Subject: [PATCH 11/33] drm/tegra: fb: Implement ->fb_mmap() callback 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. Reported-by: Marcel Ziswiler Signed-off-by: Thierry Reding Tested-by: Stefan Agner Tested-by: Marcel Ziswiler Reported-by: Marcel Ziswiler Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/fb.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 80540c1c66dc..4681e184f125 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -201,12 +201,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, -- 2.14.4