From patchwork Thu May 28 19:39:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6501431 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A80AD9F38C for ; Thu, 28 May 2015 19:41:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5847C20765 for ; Thu, 28 May 2015 19:41:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0A262075F for ; Thu, 28 May 2015 19:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754455AbbE1TlY (ORCPT ); Thu, 28 May 2015 15:41:24 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:34202 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752909AbbE1TlX (ORCPT ); Thu, 28 May 2015 15:41:23 -0400 Received: by pdbki1 with SMTP id ki1so48754546pdb.1; Thu, 28 May 2015 12:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=Nbz5J0jCqi6QEQm/RJ0jlgrjK8rxL4CFk+3gGUv+nmM=; b=kAmbs8IApe9Go7Od58gwz4sNi2d0wBVWTCRJCD9SG0RQ1iADISyPJJeFUvb6EqCcor 7V4thjJLueuFHwfD0z2CZ5j5Ka1/VJyzMIHEFuRhqJDM+vvTm+tU/vOG5ugtKuEnST4r 4joRs51GDTeWhlNWRLGquuXzj8xK5NSguihv2qKA4YjJbT7cBorG457zewNx9MBbBRlP sYaJ8bYhM+QMBPBCFr55rWw0aa7TmzBV98VshNoM3wCq7DqZXBG1ILzRGJWCb/abdYvJ xW1Mx69pbfM9dqXEkxM0WmLAKKAHn93j9Tybjq7LgRGx0WpMOCB9dmc5nIsxbMgRKZQH BFEw== X-Received: by 10.69.10.196 with SMTP id ec4mr8485195pbd.69.1432842083047; Thu, 28 May 2015 12:41:23 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id fb3sm3186863pbd.91.2015.05.28.12.41.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 12:41:21 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Thu, 28 May 2015 12:39:12 -0700 From: "Luis R. Rodriguez" To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" , Arnaud Patard , Aaro Koskinen , Brian Vandre , Thomas Gummerer , Aya Mahfouz , Lubomir Rintel , Vitor Braga , Sudip Mukherjee , Suresh Siddha , Ingo Molnar , Thomas Gleixner , Juergen Gross , Daniel Vetter , Andy Lutomirski , Dave Airlie , Antonino Daplas , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org Subject: [PATCH REPOST] staging: xgifb: use arch_phys_wc_add() and ioremap_wc() Date: Thu, 28 May 2015 12:39:07 -0700 Message-Id: <1432841947-11249-1-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 From: "Luis R. Rodriguez" The same area used for ioremap() is used for the MTRR area. Convert the driver from using the x86 specific MTRR code to the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add() will avoid MTRR if write-combining is available, in order to take advantage of that also ensure the ioremap'd area is requested as write-combining. There are a few motivations for this: a) Take advantage of PAT when available b) Help bury MTRR code away, MTRR is architecture specific and on x86 its replaced by PAT c) Help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()") The conversion done is expressed by the following Coccinelle SmPL patch, it additionally required manual intervention to address all the #ifdery and removal of redundant things which arch_phys_wc_add() already addresses such as verbose message about when MTRR fails and doing nothing when we didn't get an MTRR. @ mtrr_found @ expression index, base, size; @@ -index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1); +index = arch_phys_wc_add(base, size); @ mtrr_rm depends on mtrr_found @ expression mtrr_found.index, mtrr_found.base, mtrr_found.size; @@ -mtrr_del(index, base, size); +arch_phys_wc_del(index); @ mtrr_rm_zero_arg depends on mtrr_found @ expression mtrr_found.index; @@ -mtrr_del(index, 0, 0); +arch_phys_wc_del(index); @ mtrr_rm_fb_info depends on mtrr_found @ struct fb_info *info; expression mtrr_found.index; @@ -mtrr_del(index, info->fix.smem_start, info->fix.smem_len); +arch_phys_wc_del(index); @ ioremap_replace_nocache depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap_nocache(base, size); +info->screen_base = ioremap_wc(base, size); @ ioremap_replace_default depends on mtrr_found @ struct fb_info *info; expression base, size; @@ -info->screen_base = ioremap(base, size); +info->screen_base = ioremap_wc(base, size); Generated-by: Coccinelle SmPL Cc: Arnaud Patard Cc: Greg Kroah-Hartman Cc: Aaro Koskinen Cc: Brian Vandre Cc: Thomas Gummerer Cc: Aya Mahfouz Cc: Lubomir Rintel Cc: Vitor Braga Cc: Sudip Mukherjee Cc: Suresh Siddha Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Juergen Gross Cc: Daniel Vetter Cc: Andy Lutomirski Cc: Dave Airlie Cc: Antonino Daplas Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: devel@driverdev.osuosl.org Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez --- Greg, this is a respost from my March 20th submission which seems to have fallen through the cracks likely due to me not directing it to you. Apologies for that. This repost goes unchanged and is rebased on top of linux-next next-20150528. drivers/staging/xgifb/XGI_main_26.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 74e8820..943d463 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -8,10 +8,7 @@ #include #include - -#ifdef CONFIG_MTRR -#include -#endif +#include #include "XGI_main.h" #include "vb_init.h" @@ -1770,7 +1767,7 @@ static int xgifb_probe(struct pci_dev *pdev, } xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress = - ioremap(xgifb_info->video_base, xgifb_info->video_size); + ioremap_wc(xgifb_info->video_base, xgifb_info->video_size); xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, xgifb_info->mmio_size); @@ -2014,12 +2011,8 @@ static int xgifb_probe(struct pci_dev *pdev, fb_alloc_cmap(&fb_info->cmap, 256, 0); -#ifdef CONFIG_MTRR - xgifb_info->mtrr = mtrr_add(xgifb_info->video_base, - xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1); - if (xgifb_info->mtrr >= 0) - dev_info(&pdev->dev, "Added MTRR\n"); -#endif + xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base, + xgifb_info->video_size); if (register_framebuffer(fb_info) < 0) { ret = -EINVAL; @@ -2031,11 +2024,7 @@ static int xgifb_probe(struct pci_dev *pdev, return 0; error_mtrr: -#ifdef CONFIG_MTRR - if (xgifb_info->mtrr >= 0) - mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, - xgifb_info->video_size); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(xgifb_info->mtrr); error_1: iounmap(xgifb_info->mmio_vbase); iounmap(xgifb_info->video_vbase); @@ -2059,11 +2048,7 @@ static void xgifb_remove(struct pci_dev *pdev) struct fb_info *fb_info = xgifb_info->fb_info; unregister_framebuffer(fb_info); -#ifdef CONFIG_MTRR - if (xgifb_info->mtrr >= 0) - mtrr_del(xgifb_info->mtrr, xgifb_info->video_base, - xgifb_info->video_size); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(xgifb_info->mtrr); iounmap(xgifb_info->mmio_vbase); iounmap(xgifb_info->video_vbase); release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);