From patchwork Thu Aug 3 10:17:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Pisati X-Patchwork-Id: 797135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xNQwN6yzjz9s7v; Thu, 3 Aug 2017 20:17:24 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1ddDBv-0007LT-Nd; Thu, 03 Aug 2017 10:17:19 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ddDBr-0007KG-2T for kernel-team@lists.ubuntu.com; Thu, 03 Aug 2017 10:17:15 +0000 Received: from 1.general.ppisati.uk.vpn ([10.172.193.134] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ddDBq-0002Yf-OV for kernel-team@lists.ubuntu.com; Thu, 03 Aug 2017 10:17:14 +0000 From: Paolo Pisati To: kernel-team@lists.ubuntu.com Subject: [PATCH] drm/fb_cma_helper: Implement fb_mmap callback Date: Thu, 3 Aug 2017 12:17:13 +0200 Message-Id: <1501755433-21337-2-git-send-email-paolo.pisati@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501755433-21337-1-git-send-email-paolo.pisati@canonical.com> References: <1501755433-21337-1-git-send-email-paolo.pisati@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Robin Murphy BugLink: https://bugs.launchpad.net/bugs/1708417 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 Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/8fd95ac1440e0f01daad6d4380be3a4c8fa61055.1465301219.git.robin.murphy@arm.com (cherry picked from commit ce0c5757681052eb8965209129f28362c3a4d8a7) Signed-off-by: Paolo Pisati Acked-by: Stefan Bader Acked-by: Kleber Sacilotto de Souza --- drivers/gpu/drm/drm_fb_cma_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 6349d0c..033f846 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -23,6 +23,7 @@ #include #include #include +#include #include struct drm_fb_cma { @@ -220,6 +221,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg) EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show); #endif +static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma) +{ + return dma_mmap_writecombine(info->device, vma, info->screen_base, + info->fix.smem_start, info->fix.smem_len); +} + static struct fb_ops drm_fbdev_cma_ops = { .owner = THIS_MODULE, .fb_fillrect = drm_fb_helper_sys_fillrect, @@ -230,6 +237,7 @@ static struct fb_ops drm_fbdev_cma_ops = { .fb_blank = drm_fb_helper_blank, .fb_pan_display = drm_fb_helper_pan_display, .fb_setcmap = drm_fb_helper_setcmap, + .fb_mmap = drm_fb_cma_mmap, }; static int drm_fbdev_cma_create(struct drm_fb_helper *helper,