Skip to content

Commit ce0c575

Browse files
rmurphy-armdanvet
authored andcommitted
drm/fb_cma_helper: Implement fb_mmap callback
In the absence of an fb_mmap callback, the fbdev code falls back to a naive implementation which relies upon the DMA address being the same as the physical address, and the buffer being physically contiguous from there. Whilst this often holds for standard CMA allocations via the platform's regular DMA ops, if the allocation is provided by an IOMMU then such assumptions can fall apart spectacularly. To resolve this, reroute the fb_mmap call to the appropriate DMA API implementation, as per the other cma_helper calls. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/8fd95ac1440e0f01daad6d4380be3a4c8fa61055.1465301219.git.robin.murphy@arm.com
1 parent cb76e35 commit ce0c575

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/gpu/drm/drm_fb_cma_helper.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <drm/drm_crtc_helper.h>
2424
#include <drm/drm_gem_cma_helper.h>
2525
#include <drm/drm_fb_cma_helper.h>
26+
#include <linux/dma-mapping.h>
2627
#include <linux/module.h>
2728

2829
#define DEFAULT_FBDEFIO_DELAY_MS 50
@@ -302,6 +303,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
302303
EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
303304
#endif
304305

306+
static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
307+
{
308+
return dma_mmap_writecombine(info->device, vma, info->screen_base,
309+
info->fix.smem_start, info->fix.smem_len);
310+
}
311+
305312
static struct fb_ops drm_fbdev_cma_ops = {
306313
.owner = THIS_MODULE,
307314
.fb_fillrect = drm_fb_helper_sys_fillrect,
@@ -312,6 +319,7 @@ static struct fb_ops drm_fbdev_cma_ops = {
312319
.fb_blank = drm_fb_helper_blank,
313320
.fb_pan_display = drm_fb_helper_pan_display,
314321
.fb_setcmap = drm_fb_helper_setcmap,
322+
.fb_mmap = drm_fb_cma_mmap,
315323
};
316324

317325
static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info,

0 commit comments

Comments
 (0)