From patchwork Fri Jun 29 06:47:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 168005 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 8FA44100966 for ; Fri, 29 Jun 2012 16:56:34 +1000 (EST) Received: by ozlabs.org (Postfix) id 55F9C1007ED; Fri, 29 Jun 2012 16:48:50 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e7.ny.us.ibm.com (e7.ny.us.ibm.com [32.97.182.137]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e7.ny.us.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 78E4710082E for ; Fri, 29 Jun 2012 16:48:49 +1000 (EST) Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Jun 2012 02:48:46 -0400 Received: from d01relay03.pok.ibm.com (9.56.227.235) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 29 Jun 2012 02:48:00 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5T6m091382472 for ; Fri, 29 Jun 2012 02:48:00 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5T6lxUs001746 for ; Fri, 29 Jun 2012 03:48:00 -0300 Received: from shangw ([9.77.178.49]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5T6lwZq001712; Fri, 29 Jun 2012 03:47:58 -0300 Received: by shangw (Postfix, from userid 1000) id B04C63818B1; Fri, 29 Jun 2012 14:47:56 +0800 (CST) From: Gavin Shan To: linux-pci@vger.kernel.org, linuxppc-dev@ozlabs.org Subject: [PATCH 6/7] pci: function to retrieve alignment of p2p bars Date: Fri, 29 Jun 2012 14:47:49 +0800 Message-Id: <9229382f79ce3eeb4645160b5349a51bb51db06b.1340949637.git.shangw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: x-cbid: 12062906-5806-0000-0000-000016C78CE5 Cc: bhelgaas@google.com, yinghai@kernel.org, Gavin Shan , linuxram@us.ibm.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15rc1 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The patch introduces function pci_align_boundary() to retrieve the minimal alignment of p2p bars according to the argument. Signed-off-by: Gavin Shan --- drivers/pci/host-bridge.c | 24 ++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 1854a2d..dc9a95e 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -105,3 +105,27 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, } EXPORT_SYMBOL(pcibios_bus_to_resource); + +resource_size_t pci_align_boundary(struct pci_bus *bus, unsigned long flags) +{ + resource_size_t align = 0; + struct pci_host_bridge *bridge = find_pci_host_bridge(bus); + + flags &= (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH); + switch (flags) { + case IORESOURCE_IO: + align = (1 << bridge->io_align_shift); + break; + case IORESOURCE_MEM: + align = (1 << bridge->mem_align_shift); + break; + case (IORESOURCE_MEM | IORESOURCE_PREFETCH): + align = (1 << bridge->pmem_align_shift); + break; + default: + printk(KERN_WARNING "%s: invalid flags 0x%lx\n", + __func__, flags); + } + + return align; +} diff --git a/include/linux/pci.h b/include/linux/pci.h index 2b2b38d..64523ef 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -673,6 +673,7 @@ void __pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, struct pci_bus_region *region); void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, struct pci_bus_region *region); +resource_size_t pci_align_boundary(struct pci_bus *bus, unsigned long flags); void pcibios_scan_specific_bus(int busn); extern struct pci_bus *pci_find_bus(int domain, int busnr); void pci_bus_add_devices(const struct pci_bus *bus);