From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH v5 6/7] PCI: Enable pci bridge when it is needed
Date: Fri, 31 May 2013 23:03:11 -0700 [thread overview]
Message-ID: <1370066593-22736-6-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1370066593-22736-1-git-send-email-yinghai@kernel.org>
Current we enable bridges after bus scan and assign resources.
and it is spreaded a lot of places.
We can enable them later when their children pci device is enabled.
Need to go up to root bus and enable bridge one by one down to pci
device.
So that will delay enable bridge as needed bassis,
also kill one inconsistent between boot path and hot-add
path in acpi_pci_root_add().
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/arm/kernel/bios32.c | 5 -----
arch/m68k/platform/coldfire/pci.c | 1 -
arch/mips/pci/pci.c | 1 -
arch/sh/drivers/pci/pci.c | 1 -
drivers/acpi/pci_root.c | 4 ----
drivers/parisc/lba_pci.c | 1 -
drivers/pci/bus.c | 19 -------------------
drivers/pci/hotplug/acpiphp_glue.c | 1 -
drivers/pci/pci.c | 20 ++++++++++++++++++++
drivers/pci/probe.c | 1 -
drivers/pci/setup-bus.c | 10 +++-------
drivers/pcmcia/cardbus.c | 1 -
include/linux/pci.h | 1 -
13 files changed, 23 insertions(+), 43 deletions(-)
Index: linux-2.6/arch/arm/kernel/bios32.c
===================================================================
--- linux-2.6.orig/arch/arm/kernel/bios32.c
+++ linux-2.6/arch/arm/kernel/bios32.c
@@ -524,11 +524,6 @@ void pci_common_init(struct hw_pci *hw)
* Assign resources.
*/
pci_bus_assign_resources(bus);
-
- /*
- * Enable bridges
- */
- pci_enable_bridges(bus);
}
/*
Index: linux-2.6/arch/m68k/platform/coldfire/pci.c
===================================================================
--- linux-2.6.orig/arch/m68k/platform/coldfire/pci.c
+++ linux-2.6/arch/m68k/platform/coldfire/pci.c
@@ -319,7 +319,6 @@ static int __init mcf_pci_init(void)
pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
pci_bus_size_bridges(rootbus);
pci_bus_assign_resources(rootbus);
- pci_enable_bridges(rootbus);
return 0;
}
Index: linux-2.6/arch/mips/pci/pci.c
===================================================================
--- linux-2.6.orig/arch/mips/pci/pci.c
+++ linux-2.6/arch/mips/pci/pci.c
@@ -113,7 +113,6 @@ static void pcibios_scanbus(struct pci_c
if (!pci_has_flag(PCI_PROBE_ONLY)) {
pci_bus_size_bridges(bus);
pci_bus_assign_resources(bus);
- pci_enable_bridges(bus);
}
}
}
Index: linux-2.6/arch/sh/drivers/pci/pci.c
===================================================================
--- linux-2.6.orig/arch/sh/drivers/pci/pci.c
+++ linux-2.6/arch/sh/drivers/pci/pci.c
@@ -69,7 +69,6 @@ static void pcibios_scanbus(struct pci_c
pci_bus_size_bridges(bus);
pci_bus_assign_resources(bus);
- pci_enable_bridges(bus);
} else {
pci_free_resource_list(&resources);
}
Index: linux-2.6/drivers/parisc/lba_pci.c
===================================================================
--- linux-2.6.orig/drivers/parisc/lba_pci.c
+++ linux-2.6/drivers/parisc/lba_pci.c
@@ -1533,7 +1533,6 @@ lba_driver_probe(struct parisc_device *d
lba_dump_res(&lba_dev->hba.lmmio_space, 2);
#endif
}
- pci_enable_bridges(lba_bus);
/*
** Once PCI register ops has walked the bus, access to config
Index: linux-2.6/drivers/pci/bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/bus.c
+++ linux-2.6/drivers/pci/bus.c
@@ -216,24 +216,6 @@ void pci_bus_add_devices(const struct pc
}
}
-void pci_enable_bridges(struct pci_bus *bus)
-{
- struct pci_dev *dev;
- int retval;
-
- list_for_each_entry(dev, &bus->devices, bus_list) {
- if (dev->subordinate) {
- if (!pci_is_enabled(dev)) {
- retval = pci_enable_device(dev);
- if (retval)
- dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n", retval);
- pci_set_master(dev);
- }
- pci_enable_bridges(dev->subordinate);
- }
- }
-}
-
/** pci_walk_bus - walk devices on/under bus, calling callback.
* @top bus whose devices should be walked
* @cb callback to be called for each device found
@@ -301,4 +283,3 @@ EXPORT_SYMBOL(pci_bus_put);
EXPORT_SYMBOL(pci_bus_alloc_resource);
EXPORT_SYMBOL_GPL(pci_bus_add_device);
EXPORT_SYMBOL(pci_bus_add_devices);
-EXPORT_SYMBOL(pci_enable_bridges);
Index: linux-2.6/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux-2.6.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux-2.6/drivers/pci/hotplug/acpiphp_glue.c
@@ -704,7 +704,6 @@ static int __ref enable_device(struct ac
acpiphp_sanitize_bus(bus);
acpiphp_set_hpp_values(bus);
acpiphp_set_acpi_region(slot);
- pci_enable_bridges(bus);
list_for_each_entry(dev, &bus->devices, bus_list) {
/* Assume that newly added devices are powered on already. */
Index: linux-2.6/drivers/pci/pci.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci.c
+++ linux-2.6/drivers/pci/pci.c
@@ -1145,6 +1145,24 @@ int pci_reenable_device(struct pci_dev *
return 0;
}
+static void pci_enable_bridge(struct pci_dev *dev)
+{
+ int retval;
+
+ if (!dev)
+ return;
+
+ pci_enable_bridge(dev->bus->self);
+
+ if (pci_is_enabled(dev))
+ return;
+ retval = pci_enable_device(dev);
+ if (retval)
+ dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n",
+ retval);
+ pci_set_master(dev);
+}
+
static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
{
int err;
@@ -1165,6 +1183,8 @@ static int pci_enable_device_flags(struc
if (atomic_inc_return(&dev->enable_cnt) > 1)
return 0; /* already enabled */
+ pci_enable_bridge(dev->bus->self);
+
/* only skip sriov related */
for (i = 0; i <= PCI_ROM_RESOURCE; i++)
if (dev->resource[i].flags & flags)
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1964,7 +1964,6 @@ unsigned int __ref pci_rescan_bus(struct
max = pci_scan_child_bus(bus);
pci_assign_unassigned_bus_resources(bus);
- pci_enable_bridges(bus);
pci_bus_add_devices(bus);
return max;
Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -1503,7 +1503,7 @@ again:
/* any device complain? */
if (list_empty(&fail_head))
- goto enable_and_dump;
+ goto dump;
if (tried_times >= pci_try_num) {
if (enable_local == undefined)
@@ -1512,7 +1512,7 @@ again:
dev_info(&bus->dev, "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n");
free_list(&fail_head);
- goto enable_and_dump;
+ goto dump;
}
dev_printk(KERN_DEBUG, &bus->dev,
@@ -1545,10 +1545,7 @@ again:
goto again;
-enable_and_dump:
- /* Depth last, update the hardware. */
- pci_enable_bridges(bus);
-
+dump:
/* dump the resource on buses */
pci_bus_dump_resources(bus);
}
@@ -1621,7 +1618,6 @@ enable_all:
if (retval)
dev_err(&bridge->dev, "Error reenabling bridge (%d)\n", retval);
pci_set_master(bridge);
- pci_enable_bridges(parent);
}
EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources);
Index: linux-2.6/drivers/pcmcia/cardbus.c
===================================================================
--- linux-2.6.orig/drivers/pcmcia/cardbus.c
+++ linux-2.6/drivers/pcmcia/cardbus.c
@@ -91,7 +91,6 @@ int __ref cb_alloc(struct pcmcia_socket
if (s->tune_bridge)
s->tune_bridge(s, bus);
- pci_enable_bridges(bus);
pci_bus_add_devices(bus);
return 0;
Index: linux-2.6/include/linux/pci.h
===================================================================
--- linux-2.6.orig/include/linux/pci.h
+++ linux-2.6/include/linux/pci.h
@@ -1043,7 +1043,6 @@ int __must_check pci_bus_alloc_resource(
resource_size_t,
resource_size_t),
void *alignf_data);
-void pci_enable_bridges(struct pci_bus *bus);
/* Proper probing supporting hot-pluggable devices */
int __must_check __pci_register_driver(struct pci_driver *, struct module *,
Index: linux-2.6/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_root.c
+++ linux-2.6/drivers/acpi/pci_root.c
@@ -537,10 +537,6 @@ static int acpi_pci_root_add(struct acpi
pci_assign_unassigned_bus_resources(root->bus);
}
- /* need to after hot-added ioapic is registered */
- if (system_state != SYSTEM_BOOTING)
- pci_enable_bridges(root->bus);
-
pci_bus_add_devices(root->bus);
return 1;
next prev parent reply other threads:[~2013-06-01 6:03 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-05 0:10 Resource assignment oddities Benjamin Herrenschmidt
2013-05-05 0:15 ` Benjamin Herrenschmidt
2013-05-05 5:18 ` Yinghai Lu
2013-05-05 5:34 ` Benjamin Herrenschmidt
2013-05-05 7:09 ` Yinghai Lu
2013-05-05 7:52 ` Benjamin Herrenschmidt
[not found] ` <51871088.4594420a.0ccc.7300SMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-06 3:04 ` Yinghai Lu
[not found] ` <20130506103159.GA16927@shangw.(null)>
2013-05-06 10:48 ` Benjamin Herrenschmidt
2013-05-06 19:56 ` Yinghai Lu
[not found] ` <5188b791.a110420a.0bea.077eSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-07 22:21 ` Yinghai Lu
[not found] ` <5189c22b.45f7440a.0a88.6b75SMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-08 3:42 ` Yinghai Lu
2013-05-17 5:36 ` Benjamin Herrenschmidt
2013-05-21 17:28 ` Bjorn Helgaas
2013-05-21 17:39 ` Yinghai Lu
2013-05-21 22:01 ` Benjamin Herrenschmidt
2013-05-06 23:15 ` [PATCH 1/2] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-06 23:15 ` [PATCH 2/2] PCI: Skip IORESOURCE_IO size and allocation for root bus without ioport range Yinghai Lu
2013-05-07 0:50 ` [PATCH 1/2] PCI: Split pci_assign_unassigned_resources to per root bus Benjamin Herrenschmidt
[not found] ` <51885a04.c181440a.37c9.ffffa88eSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-07 7:34 ` Yinghai Lu
2013-05-21 20:41 ` Bjorn Helgaas
2013-05-07 22:17 ` [PATCH v3 0/5] PCI: Skip resource allocation for root bus without conresponding type resource Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 1/5] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 2/5] PCI: Skip IORESOURCE_IO allocation for root bus without ioport range Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 3/5] PCI: Skip IORESOURCE_MMIO allocation for root bus without MMIO range Yinghai Lu
2013-05-07 22:28 ` Benjamin Herrenschmidt
2013-05-07 22:44 ` Yinghai Lu
2013-05-08 1:16 ` Benjamin Herrenschmidt
2013-05-08 3:57 ` Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 4/5] PCI: Enable pci bridge when it is needed Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 5/5] PCI: Retry assign unassigned resources for hotadd root bus Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 0/8] PCI: Skip resource allocation for root bus without conresponding type resource Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 1/8] PCI: Don't use temp bus for pci_bus_release_bridge_resources Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 2/8] PCI: Use pci_walk_bus to detect unassigned resources Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 3/8] PCI: Introduce enable_local to prepare per root bus handling Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 4/8] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 5/8] PCI: Skip IORESOURCE_IO allocation for root bus without ioport range Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 6/8] PCI: Skip IORESOURCE_MMIO allocation for root bus without MMIO range Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 7/8] PCI: Enable pci bridge when it is needed Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 8/8] PCI: Retry assign unassigned resources for hotadd root bus Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 2/7] PCI: Don't use temp bus for pci_bus_release_bridge_resources Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 3/7] PCI: Use pci_walk_bus to detect unassigned resources Yinghai Lu
2013-06-25 21:15 ` Bjorn Helgaas
2013-06-25 21:38 ` Benjamin Herrenschmidt
2013-06-25 21:46 ` Bjorn Helgaas
2013-06-26 8:07 ` Yinghai Lu
2013-06-26 7:38 ` Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 4/7] PCI: Introduce enable_local to prepare per root bus handling Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 5/7] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-06-01 6:03 ` Yinghai Lu [this message]
2013-06-01 6:03 ` [PATCH v5 7/7] PCI: Retry assign unassigned resources for hotadd " Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 1/7] PCI: Don't let mmio fallback to must-only, if ioport fails with must+optional Yinghai Lu
2013-06-22 3:00 ` [PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis Yinghai Lu
[not found] ` <518786a7.64bbec0a.58a0.1f6bSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-22 14:54 ` Resource assignment oddities Bjorn Helgaas
2013-05-22 16:59 ` Yinghai Lu
2013-05-22 17:21 ` Bjorn Helgaas
2013-05-22 20:44 ` Benjamin Herrenschmidt
2013-05-22 21:01 ` Yinghai Lu
2013-05-22 20:43 ` Benjamin Herrenschmidt
2013-05-22 21:00 ` Yinghai Lu
2013-05-22 21:13 ` Benjamin Herrenschmidt
2013-05-22 20:50 ` Yinghai Lu
[not found] ` <519dcfbe.89e9420a.4934.488bSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-23 17:08 ` Yinghai Lu
2013-05-23 17:12 ` Bjorn Helgaas
2013-05-23 17:17 ` Yinghai Lu
2013-05-23 19:47 ` Bjorn Helgaas
2013-05-23 21:00 ` Yinghai Lu
2013-05-23 21:23 ` Benjamin Herrenschmidt
2013-05-23 22:16 ` Yinghai Lu
2013-05-24 15:59 ` Bjorn Helgaas
2013-05-24 16:33 ` Benjamin Herrenschmidt
2013-05-24 16:34 ` Yinghai Lu
2013-05-23 17:11 ` [PATCH] PCI: Don't let mmio fallback to must-only, if ioport fails with must+optional Yinghai Lu
2013-05-24 17:25 ` Bjorn Helgaas
2013-05-24 23:31 ` [PATCH v3] " Yinghai Lu
2013-05-24 23:34 ` [PATCH] " Yinghai Lu
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=1370066593-22736-6-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=shangw@linux.vnet.ibm.com \
/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).