From patchwork Thu Jun 25 01:22:14 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: 488252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 463EA1402ED for ; Thu, 25 Jun 2015 11:26:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ubHYA49C; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751055AbbFYB0t (ORCPT ); Wed, 24 Jun 2015 21:26:49 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:33022 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbbFYB0r (ORCPT ); Wed, 24 Jun 2015 21:26:47 -0400 Received: by pdjn11 with SMTP id n11so41908326pdj.0; Wed, 24 Jun 2015 18:26:47 -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=imLsAaark+d/cRU8o+NzU7bPo4brsvkKDusOtZYaXuA=; b=ubHYA49CSIyfRcJEZGt3MrQot88txIZszgryGBTGhXSGUDd9ulEiN6sFzXKA7pnpez 8yyfkCqRH5RSuNLULxw8uZ9y49x7XpWeUGM+PgnfUNJ6k0oXrcrhKji/6+H/+IcXTxcR OMRQuYY3nhya+OwbOzDmmfTaMv3ab7XKFP4QqGJ94E494CGocTSK3DLBQGhVT8EvJ9Q+ 0r/XWPznIjjGc1/n1T40Mz+WxpNof8tHily1SoiLqMc9QkeoeqVSKlwlWUcCYA+9xXoo tC/Lo3UfNyerxQv1dWu3apzuJ49UU452fVOtRUzSsjVRppqrli+ZaiFKfo+zUwBT8WcH AQwQ== X-Received: by 10.68.108.132 with SMTP id hk4mr86608494pbb.6.1435195607302; Wed, 24 Jun 2015 18:26:47 -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 xd9sm28131951pab.6.2015.06.24.18.26.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Jun 2015 18:26:46 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 24 Jun 2015 18:24:36 -0700 From: "Luis R. Rodriguez" To: bp@suse.de Cc: mingo@kernel.org, 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" , Suresh Siddha , Ingo Molnar , Thomas Gleixner , Juergen Gross , Daniel Vetter , Dave Airlie , Antonino Daplas , Jean-Christophe Plagniol-Villard , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Mel Gorman , Vlastimil Babka , Davidlohr Bueso Subject: [PATCH v8 1/9] pci: add pci_ioremap_wc_bar() Date: Wed, 24 Jun 2015 18:22:14 -0700 Message-Id: <1435195342-26879-2-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435195342-26879-1-git-send-email-mcgrof@do-not-panic.com> References: <1435195342-26879-1-git-send-email-mcgrof@do-not-panic.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 Acked-by: Arnd Bergmann 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);