From patchwork Fri Mar 20 23:18:13 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: 6062271 Return-Path: X-Original-To: patchwork-linux-fbdev@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 16883BF90F for ; Sat, 21 Mar 2015 00:11:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01DCB20421 for ; Sat, 21 Mar 2015 00:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E91CF2041D for ; Sat, 21 Mar 2015 00:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbbCUALf (ORCPT ); Fri, 20 Mar 2015 20:11:35 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:35554 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbbCUALe (ORCPT ); Fri, 20 Mar 2015 20:11:34 -0400 Received: by pdbop1 with SMTP id op1so122824348pdb.2; Fri, 20 Mar 2015 17:11:34 -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:in-reply-to:references; bh=fk2ExUoApHxcphkZJZhLAP1ciI4YDmE9Q6XR6sNGBt8=; b=hliuQphXUDk8KIgODW65uz7GV2UgSfmNIwo1ld5pnJQ6MxxXOz6na1AZ48CrZFCVqP IRzWg2+BYLuDv80R1tnXH2a0lK2bDxpUTPMOGzfb8CJ3tnXxAqgqxjgeHoUorlv5H/bi 5gIojtzXZCvoIFcdageCRmqESHe2p7vMrC4CvWTH5XcKOlWBHeTk5Rs7LqxclLWHfCuc +VPyTpnJFJH7ObrLU+QiYNqnF+ZREs2bu52oLundsc7jEs3mYxxI9XNDHwkzPYK5DLUf gQ/6zdC79Ua7glW8kTbDO2eDzcIEe2Bvqc14AnT3OCNulP4xkwDoiyyo/KzgSYDvLZRT 0TqA== X-Received: by 10.66.166.39 with SMTP id zd7mr175298764pab.117.1426896694261; Fri, 20 Mar 2015 17:11:34 -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 7sm9876252pdj.16.2015.03.20.17.11.30 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 20 Mar 2015 17:11:32 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Fri, 20 Mar 2015 17:09:22 -0700 From: "Luis R. Rodriguez" To: luto@amacapital.net, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, jgross@suse.com, JBeulich@suse.com, bp@suse.de, suresh.b.siddha@intel.com, venkatesh.pallipadi@intel.com, airlied@redhat.com Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org, "Luis R. Rodriguez" , Ingo Molnar , Daniel Vetter , Antonino Daplas , Jean-Christophe Plagniol-Villard , Tomi Valkeinen Subject: [PATCH v1 23/47] staging: xgifb: use arch_phys_wc_add() and ioremap_wc() Date: Fri, 20 Mar 2015 16:18:13 -0700 Message-Id: <1426893517-2511-24-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426893517-2511-1-git-send-email-mcgrof@do-not-panic.com> References: <1426893517-2511-1-git-send-email-mcgrof@do-not-panic.com> 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=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 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() (de33c442e) 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: Suresh Siddha Cc: Venkatesh Pallipadi 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: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez --- 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);