From patchwork Mon May 6 13:44:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 241669 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 2CC042C0259 for ; Mon, 6 May 2013 23:49:38 +1000 (EST) Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e34.co.us.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2B70A2C00EC for ; Mon, 6 May 2013 23:49:14 +1000 (EST) Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 May 2013 07:49:10 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 May 2013 07:45:04 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 2AB4019D8041 for ; Mon, 6 May 2013 07:44:35 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r46DiUqa339384 for ; Mon, 6 May 2013 07:44:30 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r46DiOCu011365 for ; Mon, 6 May 2013 07:44:26 -0600 Received: from shangw ([9.125.31.68]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r46DiLOF010987; Mon, 6 May 2013 07:44:22 -0600 Received: by shangw (Postfix, from userid 1000) id 477C53019B5; Mon, 6 May 2013 21:44:21 +0800 (CST) From: Gavin Shan To: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org Subject: [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses Date: Mon, 6 May 2013 21:44:17 +0800 Message-Id: <1367847858-6506-2-git-send-email-shangw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1367847858-6506-1-git-send-email-shangw@linux.vnet.ibm.com> References: <1367847858-6506-1-git-send-email-shangw@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050613-2876-0000-0000-00000855AD0A Cc: bhelgaas@google.com, yinghai@kernel.org, Gavin Shan X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 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 intends to set the special flag (PCI_BUS_FLAGS_NO_IO) for root buses so PCI core will skip assignment for IO stuff. Besides, we also clear the IO resources on all PCI devices for PHB3. Signed-off-by: Gavin Shan --- arch/powerpc/include/asm/machdep.h | 3 ++ arch/powerpc/kernel/pci-common.c | 7 +++++ arch/powerpc/platforms/powernv/pci-ioda.c | 38 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index 3f3f691..ebc2ffd 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -220,6 +220,9 @@ struct machdep_calls { /* Called during PCI resource reassignment */ resource_size_t (*pcibios_window_alignment)(struct pci_bus *, unsigned long type); + /* Called when adding PCI bus */ + void (*pcibios_add_bus)(struct pci_bus *); + /* Called to shutdown machine specific hardware not already controlled * by other drivers. */ diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index f325dc9..7b8a6f1 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -120,6 +120,13 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus, return 1; } +/* The function will be called while adding PCI bus to system */ +void pcibios_add_bus(struct pci_bus *bus) +{ + if (ppc_md.pcibios_add_bus) + ppc_md.pcibios_add_bus(bus); +} + static resource_size_t pcibios_io_size(const struct pci_controller *hose) { #ifdef CONFIG_PPC64 diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 8c6c9cf..0c3fa29 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1015,6 +1015,40 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus, return phb->ioda.io_segsize; } +/* + * The function will be called while adding PCI bus to the + * system. In turn, we should set flag to indicate that the + * root bus doesn't have IO resources. + */ +static void pnv_pci_add_bus(struct pci_bus *bus) +{ + struct pci_controller *hose = pci_bus_to_host(bus); + struct pnv_phb *phb = hose->private_data; + + /* + * We only need set the flag for root bus since the + * bus flags are copied over from parent to children + */ + if (pci_is_root_bus(bus) && + phb->model == PNV_PHB_MODEL_PHB3) + bus->bus_flags |= PCI_BUS_FLAGS_NO_IO; +} + +static void pnv_pci_fixup_resources(struct pci_dev *dev) +{ + int i; + struct resource *res; + + if (!(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_IO)) + return; + + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + res = dev->resource + i; + if (res->flags & IORESOURCE_IO) + res->flags = 0; + } +} + /* Prevent enabling devices for which we couldn't properly * assign a PE */ @@ -1189,6 +1223,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type) ppc_md.pcibios_fixup = pnv_pci_ioda_fixup; ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; ppc_md.pcibios_window_alignment = pnv_pci_window_alignment; + if (ioda_type == PNV_PHB_IODA2) { + ppc_md.pcibios_add_bus = pnv_pci_add_bus; + ppc_md.pcibios_fixup_resources = pnv_pci_fixup_resources; + } pci_add_flags(PCI_REASSIGN_ALL_RSRC); /* Reset IODA tables to a clean state */