From patchwork Thu Jul 9 01:54:12 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: 6752231 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 3DF639F319 for ; Thu, 9 Jul 2015 01:55:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D25BF20644 for ; Thu, 9 Jul 2015 01:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAC8320576 for ; Thu, 9 Jul 2015 01:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753067AbbGIByp (ORCPT ); Wed, 8 Jul 2015 21:54:45 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:34353 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752655AbbGIByg (ORCPT ); Wed, 8 Jul 2015 21:54:36 -0400 Received: by pdbep18 with SMTP id ep18so155325677pdb.1; Wed, 08 Jul 2015 18:54:35 -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=4BRT28NPjlLM2to0qN+q/lugPmRIQZJTyYPPAImKO1c=; b=TlcW5XROzCvFHXsObTvmAa5qCipTSIJxBVVVqe/IFKBk1bkkvuz1CwGUORYj3B+VHo N17+TsbjWahHWUkeTqCqXXicQXPtkTpMn0xcwJg3WMoGdvTD+Xj5iOjUf767K8T0ZH3Y PhRCbYlpQf1RBquC02AohOXhzRou0fdNo/RgM8zW1ZnwRHvEwcQGCIxtend/gWlyIH83 NJJpPJ/iugm9fVqBZtrCpl3lZUJbljPE4NuCaPOP7ddhQMsizUX4pRx97vWHvx2GjGzi mrF5VJJqnzgnKcuuFS42s5y2r5IAGmMG1OeU+h8PcVq6aWhwWMeh4OsqdiiJKecD8cR6 p61A== X-Received: by 10.70.0.202 with SMTP id 10mr25772233pdg.41.1436406875772; Wed, 08 Jul 2015 18:54:35 -0700 (PDT) Received: from mcgrof@gmail.com ([2601:646:200:bc5b:ca60:ff:feda:57a7]) by smtp.gmail.com with ESMTPSA id sn7sm3912684pac.5.2015.07.08.18.54.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 18:54:34 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 08 Jul 2015 18:54:31 -0700 From: "Luis R. Rodriguez" To: mingo@kernel.org Cc: bp@suse.de, arnd@arndb.de, bhelgaas@google.com, luto@amacapital.net, akpm@linux-foundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, tomi.valkeinen@ti.com, mst@redhat.com, toshi.kani@hp.com, linux-fbdev@vger.kernel.org, xen-devel@lists.xensource.com, benh@kernel.crashing.org, "Luis R. Rodriguez" , Antonino Daplas , Daniel Vetter , Dave Airlie , Davidlohr Bueso , "H. Peter Anvin" , Jean-Christophe Plagniol-Villard , Juergen Gross , Mel Gorman , Suresh Siddha , Thomas Gleixner , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Vlastimil Babka Subject: [PATCH v9 1/8] PCI: Add pci_ioremap_wc_bar() Date: Wed, 8 Jul 2015 18:54:12 -0700 Message-Id: <1436406859-1280-2-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436406859-1280-1-git-send-email-mcgrof@do-not-panic.com> References: <1436406859-1280-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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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. It 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(), see: de33c442ed2a ("x86 PAT: fix performance drop for glx, use UC minus for ioremap(), ioremap_nocache() and pci_mmap_page_range()") Signed-off-by: Luis R. Rodriguez Acked-by: Arnd Bergmann Cc: Andrew Morton Cc: Andy Lutomirski Cc: Antonino Daplas Cc: benh@kernel.crashing.org Cc: Bjorn Helgaas Cc: Daniel Vetter Cc: Dave Airlie Cc: Davidlohr Bueso Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Jean-Christophe Plagniol-Villard Cc: Juergen Gross Cc: linux-fbdev@vger.kernel.org Cc: linux-pci@vger.kernel.org Cc: Mel Gorman Cc: mst@redhat.com Cc: Suresh Siddha Cc: Thomas Gleixner Cc: Tomi Valkeinen Cc: Toshi Kani Cc: Ville Syrjälä Cc: Vlastimil Babka Link: http://lkml.kernel.org/r/1435195342-26879-2-git-send-email-mcgrof@do-not-panic.com Signed-off-by: Borislav Petkov --- 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 0008c950452c..fdae37b473f8 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 c0dd4ab5c2f5..1193975d20c3 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);