From: Yijing Wang <wangyijing@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Xinwei Hu <huxinwei@huawei.com>, Wuyun <wuyun.wu@huawei.com>,
linux-arm-kernel@lists.infradead.org,
Russell King <linux@arm.linux.org.uk>,
x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linuxppc-dev@lists.ozlabs.org, Tony Luck <tony.luck@intel.com>,
linux-ia64@vger.kernel.org,
Thierry Reding <thierry.reding@gmail.com>,
Liviu Dudau <liviu@dudau.co.uk>,
Suravee.Suthikulpanit@amd.com,
Yijing Wang <wangyijing@huawei.com>
Subject: [RFC PATCH 15/16] arm/PCI: Use pci_scan_host_bridge() instead of pci_scan_root_bus()
Date: Mon, 17 Nov 2014 09:43:00 +0000 [thread overview]
Message-ID: <1416219710-26088-16-git-send-email-wangyijing@huawei.com> (raw)
In-Reply-To: <1416219710-26088-1-git-send-email-wangyijing@huawei.com>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
---
arch/arm/include/asm/mach/pci.h | 1 +
arch/arm/kernel/bios32.c | 52 +++++++++++++++++++++++---------------
2 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index 370b3bd..a26eb3a 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -46,6 +46,7 @@ struct hw_pci {
struct pci_sys_data {
struct list_head node;
int busnr; /* primary bus number */
+ u8 nr;
u64 mem_offset; /* bus->cpu memory mapping offset */
unsigned long io_offset; /* bus->cpu IO mapping offset */
struct pci_bus *bus; /* PCI bus */
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 3fe56f1..535d7ec 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -426,33 +426,41 @@ static int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
return irq;
}
-static int pcibios_init_resources(int busnr, struct pci_sys_data *sys)
+static int pcibios_init_resources(struct pci_host_bridge *host,
+ struct pci_host_info *info)
{
int ret;
- struct pci_host_bridge_window *window;
+ struct pci_sys_data *sys = info->arg;
+ struct pci_host_bridge_window *window, *n;
if (list_empty(&sys->resources)) {
- pci_add_resource_offset(&sys->resources,
+ pci_add_resource_offset(&host->windows,
&iomem_resource, sys->mem_offset);
+ } else {
+ list_for_each_entry_safe(window, n,
+ &sys->resources, list) {
+ list_move_tail(&window->list,
+ &host->windows);
+ }
}
- list_for_each_entry(window, &sys->resources, list) {
+ list_for_each_entry(window, &host->windows, list) {
if (resource_type(window->res) = IORESOURCE_IO)
return 0;
}
- sys->io_res.start = (busnr * SZ_64K) ? : pcibios_min_io;
- sys->io_res.end = (busnr + 1) * SZ_64K - 1;
+ sys->io_res.start = (sys->nr * SZ_64K) ? : pcibios_min_io;
+ sys->io_res.end = (sys->nr + 1) * SZ_64K - 1;
sys->io_res.flags = IORESOURCE_IO;
sys->io_res.name = sys->io_res_name;
- sprintf(sys->io_res_name, "PCI%d I/O", busnr);
+ sprintf(sys->io_res_name, "PCI%d I/O", sys->nr);
ret = request_resource(&ioport_resource, &sys->io_res);
if (ret) {
pr_err("PCI: unable to allocate I/O port region (%d)\n", ret);
return ret;
}
- pci_add_resource_offset(&sys->resources, &sys->io_res,
+ pci_add_resource_offset(&host->windows, &sys->io_res,
sys->io_offset);
return 0;
@@ -462,8 +470,9 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
struct list_head *head)
{
struct pci_sys_data *sys = NULL;
- int ret;
- int nr, busnr;
+ int ret, nr, busnr, domain;
+ struct pci_host_bridge *host;
+ struct pci_host_info info;
for (nr = busnr = 0; nr < hw->nr_controllers; nr++) {
sys = kzalloc(sizeof(struct pci_sys_data), GFP_KERNEL);
@@ -471,6 +480,7 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
panic("PCI: unable to allocate sys data!");
sys->busnr = busnr;
+ sys->nr = nr;
sys->swizzle = hw->swizzle;
sys->map_irq = hw->map_irq;
sys->align_resource = hw->align_resource;
@@ -482,25 +492,25 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
sys->private_data = hw->private_data[nr];
ret = hw->setup(nr, sys);
-
if (ret > 0) {
- ret = pcibios_init_resources(nr, sys);
- if (ret) {
- kfree(sys);
- break;
- }
-
+ init_pci_host_info(&info);
+ info.arg = sys;
+ info.init_res = pcibios_init_resources;
+ domain = pci_get_domain_nr(parent);
if (hw->scan)
sys->bus = hw->scan(nr, sys);
- else
- sys->bus = pci_scan_root_bus(parent, sys->busnr,
- hw->ops, sys, &sys->resources);
+ else {
+ host = pci_scan_host_bridge(parent,
+ PCI_DOMBUS(domain, sys->busnr),
+ hw->ops, &info);
+ if (host)
+ sys->bus = host->bus;
+ }
if (!sys->bus)
panic("PCI: unable to scan bus!");
busnr = sys->bus->busn_res.end + 1;
-
list_add(&sys->node, head);
} else {
kfree(sys);
--
1.7.1
next prev parent reply other threads:[~2014-11-17 9:43 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 9:43 [RFC PATCH 00/16] Refine PCI host bridge scan interfaces Yijing Wang
2014-11-17 9:40 ` [RFC PATCH 03/16] PCI: Clean up pci_scan_bus() Yijing Wang
2014-11-17 9:40 ` [RFC PATCH 12/16] ia64/PCI: Remove the redundant bus variable Yijing Wang
2014-11-17 9:40 ` [RFC PATCH 05/16] PCI: Use pci_scan_root_bus() instead of pci_scan_bus_parented() Yijing Wang
2014-11-17 9:42 ` [RFC PATCH 16/16] powerpc/PCI: Use pci_scan_host_bridge() to scan PCI bus Yijing Wang
2014-11-17 9:43 ` Yijing Wang [this message]
2014-11-17 9:43 ` [RFC PATCH 14/16] arm/PCI: Introduce pci_get_domain_nr() Yijing Wang
2014-11-17 12:08 ` Lorenzo Pieralisi
2014-11-18 0:55 ` Yijing Wang
2014-11-17 9:43 ` [RFC PATCH 13/16] ia64/PCI: Use pci_scan_host_bridge() to refactor pci_acpi_scan_root() Yijing Wang
2014-11-17 9:43 ` [RFC PATCH 09/16] PCI: Associate .get_msi_ctrl() with pci_host_bridge Yijing Wang
2014-11-17 15:03 ` Lorenzo Pieralisi
2014-11-17 9:43 ` [RFC PATCH 10/16] PCI: Add of_scan_bus() to pci_host_info Yijing Wang
2014-11-17 9:43 ` [RFC PATCH 04/16] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus() Yijing Wang
2014-11-18 14:34 ` Liviu Dudau
2014-11-19 1:21 ` Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 06/16] PCI: Use u32 type to combine PCI domain and bus number Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 02/16] PCI: Use pci_scan_root_bus() instead of pci_scan_bus() Yijing Wang
2014-11-18 14:28 ` Liviu Dudau
2014-11-19 1:19 ` Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 01/16] PCI: Enhance pci_scan_root_bus() to support default IO/MEM resources Yijing Wang
2014-11-17 10:08 ` Arnd Bergmann
2014-11-18 7:44 ` Yijing Wang
2014-11-18 9:36 ` Arnd Bergmann
2014-11-18 11:46 ` Yijing Wang
2014-11-18 14:23 ` Liviu Dudau
2014-11-19 1:15 ` Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 08/16] PCI: Introduce pci_scan_host_bridge() and pci_host_info Yijing Wang
2014-11-18 15:42 ` Liviu Dudau
2014-11-19 2:09 ` Yijing Wang
2014-11-19 16:41 ` Liviu Dudau
2014-11-20 2:54 ` Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 11/16] x86/PCI: Use pci_scan_host_bridge() instead of pci_create_root_bus() Yijing Wang
2014-11-17 9:45 ` [RFC PATCH 07/16] PCI: Separate pci_host_bridge creation out " Yijing Wang
2014-11-17 10:56 ` Arnd Bergmann
2014-11-18 8:32 ` Yijing Wang
2014-11-18 9:30 ` Arnd Bergmann
2014-11-18 11:44 ` Yijing Wang
2014-11-18 12:25 ` Arnd Bergmann
2014-11-18 12:41 ` Yijing Wang
2014-11-18 14:48 ` Liviu Dudau
2014-11-19 2:24 ` Yijing Wang
2014-11-19 16:29 ` Liviu Dudau
2014-11-20 2:00 ` Yijing Wang
2014-11-18 15:30 ` Liviu Dudau
2014-11-19 1:42 ` Yijing Wang
2014-11-19 16:37 ` Liviu Dudau
2014-11-20 2:47 ` Yijing Wang
2014-11-20 9:47 ` Liviu Dudau
2014-11-21 2:53 ` Yijing Wang
2014-11-21 9:53 ` Liviu Dudau
2014-11-17 14:13 ` [RFC PATCH 00/16] Refine PCI host bridge scan interfaces Arnd Bergmann
2014-11-18 11:17 ` Yijing Wang
2014-11-18 11:30 ` Arnd Bergmann
2014-11-18 11:45 ` Lorenzo Pieralisi
2014-11-18 12:14 ` Yijing Wang
2014-11-18 12:17 ` Yijing Wang
2014-11-18 12:27 ` Arnd Bergmann
2014-11-20 12:01 ` Tomasz Nowicki
2014-11-20 13:15 ` Arnd Bergmann
2014-11-20 11:54 ` Tomasz Nowicki
2014-11-20 12:08 ` Liviu Dudau
2014-11-20 12:53 ` Tomasz Nowicki
2014-11-20 16:39 ` Liviu Dudau
2014-11-21 2:58 ` 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=1416219710-26088-16-git-send-email-wangyijing@huawei.com \
--to=wangyijing@huawei.com \
--cc=Suravee.Suthikulpanit@amd.com \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=huxinwei@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=liviu@dudau.co.uk \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
--cc=tony.luck@intel.com \
--cc=wuyun.wu@huawei.com \
--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