From patchwork Fri Aug 26 15:53:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9301749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15E6E601C0 for ; Fri, 26 Aug 2016 15:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 083D32961A for ; Fri, 26 Aug 2016 15:54:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0E4B2963A; Fri, 26 Aug 2016 15:54:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BBEE2961A for ; Fri, 26 Aug 2016 15:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750869AbcHZPyv (ORCPT ); Fri, 26 Aug 2016 11:54:51 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:54455 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbcHZPyu (ORCPT ); Fri, 26 Aug 2016 11:54:50 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3sLQZM3tyVz3hjJy; Fri, 26 Aug 2016 17:53:47 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3sLQZM3F5SzvlJQ; Fri, 26 Aug 2016 17:53:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id 7FozonODt8e5; Fri, 26 Aug 2016 17:53:46 +0200 (CEST) X-Auth-Info: QsA1nbCPkwGha9Ig2NbeLxZtn+cuVwbi7YbwTs/Yc1k= Received: from chi.lan (unknown [195.140.253.167]) by mail.mnet-online.de (Postfix) with ESMTPA; Fri, 26 Aug 2016 17:53:46 +0200 (CEST) From: Marek Vasut To: linux-fbdev@vger.kernel.org Cc: Marek Vasut , Tomi Valkeinen , Fabio Estevam , Lucas Stach , Shawn Guo Subject: [PATCH V2] video: mxsfb: Fix framebuffer corruption on mx6sx Date: Fri, 26 Aug 2016 17:53:35 +0200 Message-Id: <20160826155335.8747-1-marex@denx.de> X-Mailer: git-send-email 2.9.3 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allocate the framebuffer memory as coherent, otherwise the framebuffer will suffer from artifacts when displaying scrolling text or video. This can be replicated on i.MX6SX (armv7), which has more complex memory architecture compared to the i.MX23/28 (armv5). Signed-off-by: Marek Vasut Cc: Tomi Valkeinen Cc: Fabio Estevam Cc: Lucas Stach Cc: Shawn Guo --- V2: Switch to from dma_{alloc,free}_coherent() to dma_{alloc,free}_wc() for performance reasons, as suggested by Lucas Stach --- drivers/video/fbdev/mxsfb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 4e6608c..7846f0e 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -800,6 +800,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, struct fb_videomode *vmode) { int ret; + struct device *dev = &host->pdev->dev; struct fb_info *fb_info = &host->fb_info; struct fb_var_screeninfo *var = &fb_info->var; dma_addr_t fb_phys; @@ -825,12 +826,10 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, /* Memory allocation for framebuffer */ fb_size = SZ_2M; - fb_virt = alloc_pages_exact(fb_size, GFP_DMA); + fb_virt = dma_alloc_wc(dev, PAGE_ALIGN(fb_size), &fb_phys, GFP_KERNEL); if (!fb_virt) return -ENOMEM; - fb_phys = virt_to_phys(fb_virt); - fb_info->fix.smem_start = fb_phys; fb_info->screen_base = fb_virt; fb_info->screen_size = fb_info->fix.smem_len = fb_size; @@ -843,9 +842,11 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host, static void mxsfb_free_videomem(struct mxsfb_info *host) { + struct device *dev = &host->pdev->dev; struct fb_info *fb_info = &host->fb_info; - free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len); + dma_free_wc(dev, fb_info->screen_size, fb_info->screen_base, + fb_info->fix.smem_start); } static const struct platform_device_id mxsfb_devtype[] = {