From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org
Cc: bhelgaas@google.com, yinghai@kernel.org,
Gavin Shan <shangw@linux.vnet.ibm.com>
Subject: [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses
Date: Mon, 6 May 2013 21:44:17 +0800 [thread overview]
Message-ID: <1367847858-6506-2-git-send-email-shangw@linux.vnet.ibm.com> (raw)
In-Reply-To: <1367847858-6506-1-git-send-email-shangw@linux.vnet.ibm.com>
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 <shangw@linux.vnet.ibm.com>
---
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 */
--
1.7.5.4
next prev parent reply other threads:[~2013-05-06 13:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 13:44 [PATCH 1/3] PCI: PCI_BUS_FLAGS_NO_IO flag for PCI bus Gavin Shan
2013-05-06 13:44 ` Gavin Shan [this message]
2013-05-06 21:33 ` [PATCH 2/3] powerpc/powernv: Disable IO space for PCI buses Benjamin Herrenschmidt
2013-05-07 5:11 ` Gavin Shan
2013-05-06 13:44 ` [PATCH 3/3] powerpc/powernv: Don't configure IO window on PHB3 Gavin Shan
2013-05-06 21:34 ` Benjamin Herrenschmidt
2013-05-07 5:12 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367847858-6506-2-git-send-email-shangw@linux.vnet.ibm.com \
--to=shangw@linux.vnet.ibm.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).