From patchwork Wed Mar 16 14:57:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 8601701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CFF19C0553 for ; Wed, 16 Mar 2016 15:09:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2E0020304 for ; Wed, 16 Mar 2016 15:09:45 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E5C7201E4 for ; Wed, 16 Mar 2016 15:09:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1agCvT-0001n9-6o; Wed, 16 Mar 2016 14:59:55 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1agCvP-00013e-RI for linux-arm-kernel@lists.infradead.org; Wed, 16 Mar 2016 14:59:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7EF1249; Wed, 16 Mar 2016 07:56:53 -0700 (PDT) Received: from e104324-lin.cambridge.arm.com (e104324-lin.cambridge.arm.com [10.1.205.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 128183F25E; Wed, 16 Mar 2016 07:57:53 -0700 (PDT) From: Robin Murphy To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH] drm/fb_cma_helper: Implement fb_mmap callback Date: Wed, 16 Mar 2016 14:57:49 +0000 Message-Id: <11eb10d95109abc104beb94c0409d49644ea8517.1458140105.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.7.3.dirty X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160316_075952_066181_24533E27 X-CRM114-Status: GOOD ( 11.10 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liviu.dudau@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RDNS_NONE,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Daniel Vetter --- Hi dri-devel, This is an empirical fix for something I tickled via the newly-added ARM HDLCD driver on a Juno platform - I have no idea whatsoever about how "proper" it is in terms of the DRM infrastructure, so feel free to treat this as a bug report rather than an actual patch if appropriate ;) 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 bb88e3d..117d7ea 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 { @@ -221,6 +222,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, @@ -231,6 +238,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,