* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
[not found] ` <1359265003-16166-1-git-send-email-yinghai@kernel.org>
@ 2013-01-27 5:36 ` Yinghai Lu
2013-01-27 17:38 ` Russell King - ARM Linux
0 siblings, 1 reply; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 5:36 UTC (permalink / raw)
To: linux-arm-kernel
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
---
arch/arm/kernel/bios32.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
void pcibios_report_status(u_int status_mask, int warn)
{
- struct list_head *l;
+ struct pci_host_bridge *host_bridge = NULL;
- list_for_each(l, &pci_root_buses) {
- struct pci_bus *bus = pci_bus_b(l);
-
- pcibios_bus_report_status(bus, status_mask, warn);
- }
+ for_each_pci_host_bridge(host_bridge)
+ pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
}
/*
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
2013-01-27 5:36 ` [PATCH v2 16/22] PCI, arm: Kill pci_root_buses Yinghai Lu
@ 2013-01-27 17:38 ` Russell King - ARM Linux
2013-01-27 18:22 ` Yinghai Lu
0 siblings, 1 reply; 10+ messages in thread
From: Russell King - ARM Linux @ 2013-01-27 17:38 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: linux-arm-kernel at lists.infradead.org
So... what's this about. This email is all I've recieved, and the only
thing that I have to go on is one single subject line and not description
about what's going on. I guess there's some other patch introducing this
for_each_pci_host_bridge() macro somewhere? I guess that's part of this
patch set?
Yet... I guess you want an ack for this or something... which would be
irresponsible to give without knowing the purpose behind this, the
reasoning, or even being able to tell whether the replacement code is
functionally equivalent.
So, no ack (or nack) at the moment.
> ---
> arch/arm/kernel/bios32.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index 9b72261..d0befe4 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>
> void pcibios_report_status(u_int status_mask, int warn)
> {
> - struct list_head *l;
> + struct pci_host_bridge *host_bridge = NULL;
>
> - list_for_each(l, &pci_root_buses) {
> - struct pci_bus *bus = pci_bus_b(l);
> -
> - pcibios_bus_report_status(bus, status_mask, warn);
> - }
> + for_each_pci_host_bridge(host_bridge)
> + pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
> }
>
> /*
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
2013-01-27 17:38 ` Russell King - ARM Linux
@ 2013-01-27 18:22 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
0 siblings, 1 reply; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 18:22 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jan 27, 2013 at 9:38 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: linux-arm-kernel at lists.infradead.org
>
> So... what's this about. This email is all I've recieved, and the only
> thing that I have to go on is one single subject line and not description
> about what's going on. I guess there's some other patch introducing this
> for_each_pci_host_bridge() macro somewhere? I guess that's part of this
> patch set?
yes.
sorry for not put you in the cc list of the whole patchset. will do
that next reversion.
>
> Yet... I guess you want an ack for this or something... which would be
> irresponsible to give without knowing the purpose behind this, the
> reasoning, or even being able to tell whether the replacement code is
> functionally equivalent.
the purpose is to make iteration for root bus to be root-bus
hotplug safe.
will update change log.
>
> So, no ack (or nack) at the moment.
>
>> ---
>> arch/arm/kernel/bios32.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
>> index 9b72261..d0befe4 100644
>> --- a/arch/arm/kernel/bios32.c
>> +++ b/arch/arm/kernel/bios32.c
>> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>>
>> void pcibios_report_status(u_int status_mask, int warn)
>> {
>> - struct list_head *l;
>> + struct pci_host_bridge *host_bridge = NULL;
>>
>> - list_for_each(l, &pci_root_buses) {
>> - struct pci_bus *bus = pci_bus_b(l);
>> -
>> - pcibios_bus_report_status(bus, status_mask, warn);
>> - }
>> + for_each_pci_host_bridge(host_bridge)
>> + pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
>> }
>>
>> /*
>> --
>> 1.7.10.4
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
2013-01-27 18:22 ` Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.
Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.
We replace searching root bus with searching host_bridge,
as host_bridge->bus is the root bus.
After those replacing, we even could kill pci_root_buses list.
based on pci/next
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge
-v2: updated after pci_root_bus_hotplug get into pci/next
-v3: update changelog and add cc for pci core change for arch guys.
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
Yinghai Lu (22):
PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
PCI: Add dummy bus_type for pci_host_bridge
PCI, libata: remove find_bridge in acpi_bus_type
PCI, ACPI: Update comments for find_bridge in acpi_bus_type
PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
PCI: Kill pci_find_next_bus in pci_sysfs
PCI, edac: Kill pci_find_next_bus in edac
PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
PCI, x86: Kill pci_root_buses in resources reservations
PCI, drm: Kill pci_root_buses in alpha hose setting
PCI: Kill pci_root_buses in setup-bus
PCI, sparc: Kill pci_find_next_bus
PCI, ia64: Kill pci_find_next_bus
PCI, alpha: Kill pci_root_buses
PCI, arm: Kill pci_root_buses
PCI, frv: Kill pci_root_buses in resources reservations
PCI, microblaze: Kill pci_root_buses in resources reservations
PCI, mn10300: Kill pci_root_buses in resources reservations
PCI, powerpc: Kill pci_root_buses in resources reservations
PCI: Kill pci_find_next_bus
PCI: Kill pci_root_buses
arch/alpha/kernel/pci.c | 6 +--
arch/arm/kernel/bios32.c | 9 ++---
arch/frv/mb93090-mb00/pci-frv.c | 37 +++++++++---------
arch/ia64/hp/common/sba_iommu.c | 7 ++--
arch/ia64/sn/kernel/io_common.c | 5 ++-
arch/microblaze/pci/pci-common.c | 10 ++---
arch/mn10300/unit-asb2305/pci-asb2305.c | 62 ++++++++++++++++---------------
arch/powerpc/kernel/pci-common.c | 13 +++----
arch/powerpc/kernel/pci_64.c | 8 ++--
arch/sparc/kernel/pci.c | 6 ++-
arch/x86/pci/common.c | 9 +++--
arch/x86/pci/i386.c | 20 +++++-----
drivers/ata/libata-acpi.c | 6 ---
drivers/edac/i7core_edac.c | 6 +--
drivers/gpu/drm/drm_fops.c | 10 +++--
drivers/pci/hotplug/sgi_hotplug.c | 6 ++-
drivers/pci/pci-driver.c | 11 +++++-
drivers/pci/pci-sysfs.c | 6 +--
drivers/pci/probe.c | 13 ++-----
drivers/pci/search.c | 61 +++++++++++++++---------------
drivers/pci/setup-bus.c | 24 ++++++------
include/acpi/acpi_bus.h | 2 +-
include/linux/pci.h | 18 +++++----
23 files changed, 187 insertions(+), 168 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
Need to use it for looping registered host_bridge, and kill
pci_root_buses list.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
drivers/pci/pci-driver.c | 11 ++++++++++-
drivers/pci/probe.c | 1 +
include/linux/pci.h | 2 ++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
.pm = PCI_PM_OPS_PTR,
};
+struct bus_type pci_host_bridge_bus_type = {
+ .name = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+ return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
static int __init pci_driver_init(void)
{
return bus_register(&pci_bus_type);
}
-
postcore_initcall(pci_driver_init);
EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
goto err_out;
bridge->dev.parent = parent;
+ bridge->dev.bus = &pci_host_bridge_bus_type;
bridge->dev.release = pci_release_host_bridge_dev;
dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
extern enum pcie_bus_config_types pcie_bus_config;
+extern struct bus_type pci_host_bridge_bus_type;
extern struct bus_type pci_bus_type;
/* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
void pci_remove_root_bus(struct pci_bus *bus);
void pci_setup_cardbus(struct pci_bus *bus);
extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
#define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
#define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 16/22] PCI, arm: Kill pci_root_buses Yinghai Lu
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.
Also pci_find_next_bus is pretty misleading name, and it is only finding
next root bus instead of regular pci bus.
Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.
In folllowing patches will replace searching root bus with searching host_bridge.
after using with that host-bridge, will need to call put device to release
reference if break early from the loop.
After those replacing, we even could kill pci_root_buses list.
-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
drivers/pci/search.c | 24 ++++++++++++++++++++++++
include/linux/pci.h | 9 +++++++++
2 files changed, 33 insertions(+)
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
}
EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+ return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+ struct device *dev;
+ struct device *dev_start = NULL;
+ struct pci_host_bridge *bridge = NULL;
+
+ WARN_ON(in_interrupt());
+ if (from)
+ dev_start = &from->dev;
+ dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+ match_pci_host_bridge);
+ if (dev)
+ bridge = to_pci_host_bridge(dev);
+ if (from)
+ put_device(&from->dev);
+ return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
static int match_pci_dev_by_id(struct device *dev, void *data)
{
struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
};
#define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
void (*release_fn)(struct pci_host_bridge *),
void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
struct pci_dev *from);
struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
{ return NULL; }
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+ struct pci_host_bridge *host_bridge)
+{
+ return NULL;
+}
+
#define dev_is_pci(d) (false)
#define dev_is_pf(d) (false)
#define dev_num_vf(d) (0)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 16/22] PCI, arm: Kill pci_root_buses
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
Replace that with hotplug-safe version iteration.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
---
arch/arm/kernel/bios32.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
void pcibios_report_status(u_int status_mask, int warn)
{
- struct list_head *l;
+ struct pci_host_bridge *host_bridge = NULL;
- list_for_each(l, &pci_root_buses) {
- struct pci_bus *bus = pci_bus_b(l);
-
- pcibios_bus_report_status(bus, status_mask, warn);
- }
+ for_each_pci_host_bridge(host_bridge)
+ pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
}
/*
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 21/22] PCI: Kill pci_find_next_bus
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
` (2 preceding siblings ...)
2013-01-27 19:23 ` [PATCH v3 16/22] PCI, arm: Kill pci_root_buses Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
2013-02-02 21:50 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Bjorn Helgaas
5 siblings, 0 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
No user now, remove it.
That name is misleading as it only for root buses.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
drivers/pci/search.c | 37 +++++++------------------------------
include/linux/pci.h | 4 ----
2 files changed, 7 insertions(+), 34 deletions(-)
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
*/
struct pci_bus * pci_find_bus(int domain, int busnr)
{
- struct pci_bus *bus = NULL;
+ struct pci_host_bridge *host_bridge = NULL;
struct pci_bus *tmp_bus;
- while ((bus = pci_find_next_bus(bus)) != NULL) {
- if (pci_domain_nr(bus) != domain)
+ for_each_pci_host_bridge(host_bridge) {
+ if (pci_domain_nr(host_bridge->bus) != domain)
continue;
- tmp_bus = pci_do_find_bus(bus, busnr);
- if (tmp_bus)
+ tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+ if (tmp_bus) {
+ put_device(&host_bridge->dev);
return tmp_bus;
+ }
}
return NULL;
}
/**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses. A new search is
- * initiated by passing %NULL as the @from argument. Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus *
-pci_find_next_bus(const struct pci_bus *from)
-{
- struct list_head *n;
- struct pci_bus *b = NULL;
-
- WARN_ON(in_interrupt());
- down_read(&pci_bus_sem);
- n = from ? from->node.next : pci_root_buses.next;
- if (n != &pci_root_buses)
- b = pci_bus_b(n);
- up_read(&pci_bus_sem);
- return b;
-}
-
-/**
* pci_get_slot - locate PCI device for a given PCI slot
* @bus: PCI bus on which desired PCI device resides
* @devfn: encodes number of PCI slot in which the desired PCI
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
/* For boot time work */
EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
/* For everyone */
EXPORT_SYMBOL(pci_get_device);
EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
static inline void pci_unblock_cfg_access(struct pci_dev *dev)
{ }
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
unsigned int devfn)
{ return NULL; }
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 22/22] PCI: Kill pci_root_buses
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
` (3 preceding siblings ...)
2013-01-27 19:23 ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
@ 2013-01-27 19:23 ` Yinghai Lu
2013-02-02 21:50 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Bjorn Helgaas
5 siblings, 0 replies; 10+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
To: linux-arm-kernel
No user now, remove it.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
drivers/pci/probe.c | 8 --------
include/linux/pci.h | 3 ---
2 files changed, 11 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
.flags = IORESOURCE_BUS,
};
-/* Ugh. Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
static LIST_HEAD(pci_domain_busn_res_list);
struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
}
- down_write(&pci_bus_sem);
- list_add_tail(&b->node, &pci_root_buses);
- up_write(&pci_bus_sem);
-
return b;
class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
extern struct bus_type pci_host_bridge_bus_type;
extern struct bus_type pci_bus_type;
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses; /* list of all known PCI buses */
/* Some device drivers need know if pci is initiated */
extern int no_pci_devices(void);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
` (4 preceding siblings ...)
2013-01-27 19:23 ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
@ 2013-02-02 21:50 ` Bjorn Helgaas
5 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2013-02-02 21:50 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jan 27, 2013 at 12:23 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> Now we have pci_root_buses list, and there is lots of iteration with
> list_of_each of it, that is not safe after we add pci root bus hotplug
> support after booting stage.
>
> Add pci_get_next_host_bridge and use bus_find_device in driver core to
> iterate host bridge and the same time get root bus.
>
> We replace searching root bus with searching host_bridge,
> as host_bridge->bus is the root bus.
> After those replacing, we even could kill pci_root_buses list.
These are the problems I think you're fixing:
1) pci_find_next_bus() is not safe because even though it holds
pci_bus_sem while walking the pci_root_buses list, it doesn't hold a
reference on the bus it returns. The bus could be removed while the
caller is using it.
2) "list_for_each_entry(bus, &pci_root_buses, node)" is not safe
because hotplug might modify the pci_root_buses list. Replacing that
with for_each_pci_host_bridge() solves that problem by using
bus_find_device(), which is built on klists, which are designed for
that problem.
3) pci_find_next_bus() claims to iterate through all known PCI buses,
but in fact only iterates through root buses.
So far, so good. Those are problems we need to fix.
Your solution is to introduce for_each_pci_host_bridge() as an
iterator through the known host bridges. There are two scenarios
where we use something like this:
1) We want to perform an operation on every known host bridge.
2) We want to initialize something for every host bridge.
In my opinion, the only instance of scenario 1) is bus_rescan_store(),
where we want to rescan all PCI host bridges.
In every other case, we're doing some kind of initialization of all
the host bridges. For these cases, for_each_pci_host_bridge() is the
wrong solution because it doesn't work for hot-added bridges. I think
these cases should be changed to use pcibios_root_bridge_prepare() or
something something else called in the host bridge add path.
Bjorn
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-02-02 21:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAE9FiQUhrVPNKcdWbiqHLa5PzH7Dg-uduVc9BP-OjM-eCqSXdw@mail.gmail.com>
[not found] ` <1359265003-16166-1-git-send-email-yinghai@kernel.org>
2013-01-27 5:36 ` [PATCH v2 16/22] PCI, arm: Kill pci_root_buses Yinghai Lu
2013-01-27 17:38 ` Russell King - ARM Linux
2013-01-27 18:22 ` Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 16/22] PCI, arm: Kill pci_root_buses Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
2013-01-27 19:23 ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
2013-02-02 21:50 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Bjorn Helgaas
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).