From patchwork Fri Jun 19 22:08:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6649231 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 AA652C05AC for ; Fri, 19 Jun 2015 22:13:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3520A2053D for ; Fri, 19 Jun 2015 22:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C59A0203C4 for ; Fri, 19 Jun 2015 22:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756710AbbFSWNA (ORCPT ); Fri, 19 Jun 2015 18:13:00 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:36509 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756085AbbFSWM6 (ORCPT ); Fri, 19 Jun 2015 18:12:58 -0400 Received: by pdjm12 with SMTP id m12so98674684pdj.3; Fri, 19 Jun 2015 15:12:57 -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 :mime-version:content-type:content-transfer-encoding; bh=Pg4KcDTm8tn3i8WFO5BZqrfFIbOlr5NQfYFTuW/zmX4=; b=T9sJ2/XaWbKcoyKQydUO2OKm61PsZKnzDYIKOZ3mnQDmSQal/A11PH6GAfdcuCelSl ch2o1AWT284uYFPYz/c4wDRGU2kRBkBaz5zzLFQjxMTkEvv3bf/bJ2rjf0/xi3QmeVkF mC66BUKm/6nB69jA7jtHQ3GAYXlm9kg6gevnvFiKxTwa2TFwBXWgw1d0BgC4+O5G+MOM JOQaL4zVCjdOlHNH6Fz64TcPUTLlDerkAm4FeQzppSw38+2GrOB+QiizqrLu02p27Zwo cEIt1ELJyK9Uj3uns0K2x+8Y9rOYubnA0dGgPCKD/nrZIiA/l6G7dJKkiXQzAe9Z5pbP fwsA== X-Received: by 10.67.29.199 with SMTP id jy7mr35911263pad.87.1434751977895; Fri, 19 Jun 2015 15:12:57 -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 or7sm12237950pdb.9.2015.06.19.15.12.54 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 19 Jun 2015 15:12:56 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Fri, 19 Jun 2015 15:10:46 -0700 From: "Luis R. Rodriguez" To: arnd@arndb.de Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, linux-fbdev@vger.kernel.org, "Luis R. Rodriguez" , Toshi Kani , Bjorn Helgaas , Suresh Siddha , Ingo Molnar , Thomas Gleixner , Juergen Gross , Daniel Vetter , Andy Lutomirski , Dave Airlie , Antonino Daplas , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Mel Gorman , Vlastimil Babka , Borislav Petkov , Davidlohr Bueso Subject: [PATCH v7 1/9] pci: add pci_ioremap_wc_bar() Date: Fri, 19 Jun 2015 15:08:24 -0700 Message-Id: <1434751712-24333-2-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434751712-24333-1-git-send-email-mcgrof@do-not-panic.com> References: <1434751712-24333-1-git-send-email-mcgrof@do-not-panic.com> MIME-Version: 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=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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" This lets drivers take advantage of PAT when available. This should help with the transition of converting video drivers over to ioremap_wc() to help with the goal of eventually using _PAGE_CACHE_UC over _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (de33c442e titled "x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()") Cc: Toshi Kani Cc: Bjorn Helgaas 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: Ville Syrjälä Cc: Mel Gorman Cc: Vlastimil Babka Cc: Borislav Petkov Cc: Davidlohr Bueso Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez --- drivers/pci/pci.c | 14 ++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 0008c95..fdae37b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -138,6 +138,20 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) return ioremap_nocache(res->start, resource_size(res)); } EXPORT_SYMBOL_GPL(pci_ioremap_bar); + +void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar) +{ + /* + * Make sure the BAR is actually a memory resource, not an IO resource + */ + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { + WARN_ON(1); + return NULL; + } + return ioremap_wc(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} +EXPORT_SYMBOL_GPL(pci_ioremap_wc_bar); #endif #define PCI_FIND_CAP_TTL 48 diff --git a/include/linux/pci.h b/include/linux/pci.h index c0dd4ab..1193975 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1657,6 +1657,7 @@ static inline void pci_mmcfg_late_init(void) { } int pci_ext_cfg_avail(void); void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); +void __iomem *pci_ioremap_wc_bar(struct pci_dev *pdev, int bar); #ifdef CONFIG_PCI_IOV int pci_iov_virtfn_bus(struct pci_dev *dev, int id);