From patchwork Wed Mar 7 01:00:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 145131 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 23715B7121 for ; Wed, 7 Mar 2012 12:01:52 +1100 (EST) Received: from mail-gx0-f201.google.com (mail-gx0-f201.google.com [209.85.161.201]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 118ACB6FCA for ; Wed, 7 Mar 2012 12:00:21 +1100 (EST) Received: by ggki24 with SMTP id i24so698196ggk.2 for ; Tue, 06 Mar 2012 17:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=1VXupxeWgDVfWWaXOs0aOVY21sILBOFcD03mvMkb8QU=; b=WXgoL/KjnAugMpa+W9MPzkUrGbuea5i99hKcdLLATEl2zWZqVkz9kIVHX+tX1XxwYY yFPmkoiLu1f0bP0TvxWgygQ2WVMkdGdOp0ehk01UctyxyOw9e06LPbp4QJCO0n7GPlvu J54DIOnTv75t5d2/M8+aLoPo44QxVXh4XszxSLTTPqhMaZe3OUGsCD9JDX83c1DQPBbT aD7/HannF5p2G+p6iCBEujuN4M7pDnivPywDsLll4hEtQb335XKS26DQOaYenPLvboVY UwRBICMZENxwzBdroM95aCqZGYgqUmDpIVIGjIBPrHv5ZQ3y++JY7ihHYdC6yfFbOfaT Esag== Received: by 10.236.119.242 with SMTP id n78mr144226yhh.4.1331082018098; Tue, 06 Mar 2012 17:00:18 -0800 (PST) Received: by 10.236.119.242 with SMTP id n78mr144208yhh.4.1331082018027; Tue, 06 Mar 2012 17:00:18 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id k13si892444yhi.1.2012.03.06.17.00.17 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 06 Mar 2012 17:00:18 -0800 (PST) Received: from bhelgaas.mtv.corp.google.com (bhelgaas.mtv.corp.google.com [172.18.96.155]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id C57C91E005A; Tue, 6 Mar 2012 17:00:17 -0800 (PST) Received: from bhelgaas.mtv.corp.google.com (unknown [IPv6:::1]) by bhelgaas.mtv.corp.google.com (Postfix) with ESMTP id 7CF48180146; Tue, 6 Mar 2012 17:00:17 -0800 (PST) Subject: [PATCH v1 2/9] powerpc/PCI: compute I/O space bus-to-resource offset consistently To: Jesse Barnes From: Bjorn Helgaas Date: Tue, 06 Mar 2012 18:00:17 -0700 Message-ID: <20120307010017.27465.29519.stgit@bhelgaas.mtv.corp.google.com> In-Reply-To: <20120307005905.27465.71131.stgit@bhelgaas.mtv.corp.google.com> References: <20120307005905.27465.71131.stgit@bhelgaas.mtv.corp.google.com> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlBaJbAsYlDPLDdE3xBxrtNLm7Wm0OxT12nLAac3K8CCwM4TN4+AzKFjUCdgFSySCjNFlPXwksBAeanhLeoAqRR/kSVmfhL3bMun1JRNv6RDqfQOZ1ftC0zJu7YUfmgWFfG/ojYY4N5r5wN56PQ6H5OAXArJBXl2KGjV7Rts3dqdVyNCifR1jLn3ga0uiB5cq3vSb38 Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Make sure we compute CPU addresses (resource start/end) the same way both when we set up the I/O aperture (hose->io_resource) and when we use pcibios_bus_to_resource() to convert BAR values into resources. CC: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org Signed-off-by: Bjorn Helgaas --- arch/powerpc/include/asm/pci.h | 1 + arch/powerpc/kernel/pci-common.c | 8 ++++++-- arch/powerpc/kernel/pci_32.c | 6 +++--- arch/powerpc/kernel/pci_64.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 201e352..6653f27 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -182,6 +182,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar, const struct resource *rsrc, resource_size_t *start, resource_size_t *end); +extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); extern void pcibios_setup_bus_devices(struct pci_bus *bus); extern void pcibios_setup_bus_self(struct pci_bus *bus); extern void pcibios_setup_phb_io_space(struct pci_controller *hose); diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 910b9de..2efd52d 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1492,6 +1492,11 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) return pci_enable_resources(dev, mask); } +resource_size_t pcibios_io_space_offset(struct pci_controller *hose) +{ + return (unsigned long) hose->io_base_virt - _IO_BASE; +} + static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) { struct resource *res; @@ -1516,8 +1521,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s (unsigned long long)res->start, (unsigned long long)res->end, (unsigned long)res->flags); - pci_add_resource_offset(resources, res, - (resource_size_t) hose->io_base_virt - _IO_BASE); + pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose)); /* Hookup PHB Memory resources */ for (i = 0; i < 3; ++i) { diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index fdd1a3d..4b06ec5 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c @@ -219,9 +219,9 @@ void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose) struct resource *res = &hose->io_resource; /* Fixup IO space offset */ - io_offset = (unsigned long)hose->io_base_virt - isa_io_base; - res->start = (res->start + io_offset) & 0xffffffffu; - res->end = (res->end + io_offset) & 0xffffffffu; + io_offset = pcibios_io_space_offset(hose); + res->start += io_offset; + res->end += io_offset; } static int __init pcibios_init(void) diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 75417fd..94a54f6 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -168,7 +168,7 @@ static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose) return -ENOMEM; /* Fixup hose IO resource */ - io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE; + io_virt_offset = pcibios_io_space_offset(hose); hose->io_resource.start += io_virt_offset; hose->io_resource.end += io_virt_offset;