From: Yijing Wang <wangyijing@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
Liviu Dudau <liviu@dudau.co.uk>, <x86@kernel.org>,
<linux-ia64@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
<linuxppc-dev@lists.ozlabs.org>, <linux-pci@vger.kernel.org>,
<dja@axtens.net>, Arnd Bergmann <arnd@arndb.de>,
Yijing Wang <wangyijing@huawei.com>
Subject: [PATCH Part3 v11 7/9] PCI: Create pci host bridge prior to root bus
Date: Fri, 8 May 2015 15:22:57 +0800 [thread overview]
Message-ID: <1431069779-29346-8-git-send-email-wangyijing@huawei.com> (raw)
In-Reply-To: <1431069779-29346-1-git-send-email-wangyijing@huawei.com>
Pci_host_bridge hold the domain number, we need
to assign domain number prior to root bus creation,
because root bus need to know the domain number
to check whether it's alreay exist.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
drivers/pci/probe.c | 60 ++++++++++++++++++++++++++------------------------
1 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9ed8ab7..e4ef791 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -515,7 +515,7 @@ static void pci_release_host_bridge_dev(struct device *dev)
kfree(bridge);
}
-static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
+static struct pci_host_bridge *pci_alloc_host_bridge(void)
{
struct pci_host_bridge *bridge;
@@ -524,7 +524,6 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
return NULL;
INIT_LIST_HEAD(&bridge->windows);
- bridge->bus = b;
return bridge;
}
@@ -1902,48 +1901,51 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int domain,
{
int error;
struct pci_host_bridge *bridge;
- struct pci_bus *b, *b2;
+ struct pci_bus *b;
struct resource_entry *window, *n;
struct resource *res;
resource_size_t offset;
char bus_addr[64];
char *fmt;
- b = pci_alloc_bus(NULL);
- if (!b)
- return NULL;
-
- b->sysdata = sysdata;
- b->ops = ops;
- b->number = b->busn_res.start = bus;
- pci_bus_assign_domain_nr(b, parent);
- b2 = pci_find_bus(pci_domain_nr(b), bus);
- if (b2) {
- /* If we already got to this bus through a different bridge, ignore it */
- dev_dbg(&b2->dev, "bus already known\n");
- goto err_out;
- }
-
- bridge = pci_alloc_host_bridge(b);
+ bridge = pci_alloc_host_bridge();
if (!bridge)
- goto err_out;
+ return NULL;
- bridge->domain = domain;
bridge->dev.parent = parent;
+ pci_host_assign_domain_nr(bridge, domain);
bridge->dev.release = pci_release_host_bridge_dev;
dev_set_drvdata(&bridge->dev, sysdata);
- dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
+ dev_set_name(&bridge->dev, "pci%04x:%02x", bridge->domain, bus);
error = pcibios_root_bridge_prepare(bridge);
if (error) {
kfree(bridge);
- goto err_out;
+ return NULL;
}
error = device_register(&bridge->dev);
if (error) {
put_device(&bridge->dev);
- goto err_out;
+ return NULL;
}
+
+ b = pci_find_bus(bridge->domain, bus);
+ if (b) {
+ /* If we already got to this bus through a different bridge, ignore it */
+ dev_dbg(&b->dev, "bus already known\n");
+ goto unregister_host;
+ }
+
+ b = pci_alloc_bus(NULL);
+ if (!b)
+ goto unregister_host;
+
+ bridge->bus = b;
+ b->sysdata = sysdata;
+ b->ops = ops;
+ b->number = b->busn_res.start = bus;
+ pci_bus_assign_domain_nr(b, parent);
+
b->bridge = get_device(&bridge->dev);
device_enable_async_suspend(b->bridge);
pci_set_bus_of_node(b);
@@ -1956,11 +1958,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int domain,
dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
error = pcibios_root_bus_prepare(bridge);
if (error)
- goto class_dev_reg_err;
+ goto free_bus;
error = device_register(&b->dev);
if (error)
- goto class_dev_reg_err;
+ goto free_bus;
pcibios_add_bus(b);
@@ -2000,11 +2002,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int domain,
return b;
-class_dev_reg_err:
+free_bus:
+ kfree(b);
put_device(&bridge->dev);
+unregister_host:
device_unregister(&bridge->dev);
-err_out:
- kfree(b);
return NULL;
}
EXPORT_SYMBOL_GPL(pci_create_root_bus);
--
1.7.1
next prev parent reply other threads:[~2015-05-08 7:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 7:22 [PATCH Part3 v11 0/9] Remove platform pci_domain_nr() Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 1/9] PCI: Save domain in pci_host_bridge Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 2/9] PCI: Move pci_bus_assign_domain_nr() declaration into drivers/pci/pci.h Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 3/9] PCI: Remove declaration for pci_get_new_domain_nr() Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 4/9] PCI: Introduce pci_host_assign_domain_nr() to assign domain Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 5/9] powerpc/PCI: Rename pcibios_root_bridge_prepare() to pcibios_root_bus_prepare() Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 6/9] PCI: Make pci_host_bridge hold sysdata in drvdata Yijing Wang
2015-05-08 7:22 ` Yijing Wang [this message]
2015-05-08 7:22 ` [PATCH Part3 v11 8/9] PCI: Remove platform specific pci_domain_nr() Yijing Wang
2015-05-08 7:22 ` [PATCH Part3 v11 9/9] PCI: Remove pci_bus_assign_domain_nr() Yijing Wang
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=1431069779-29346-8-git-send-email-wangyijing@huawei.com \
--to=wangyijing@huawei.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=dja@axtens.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=liviu@dudau.co.uk \
--cc=x86@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).