From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Gu Zheng <guz.fnst@cn.fujitsu.com>,
Guo Chao <yan@linux.vnet.ibm.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH v3 11/12] PCI: Sort pci root bus resources list
Date: Sat, 30 Nov 2013 14:40:37 -0800 [thread overview]
Message-ID: <1385851238-21085-12-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1385851238-21085-1-git-send-email-yinghai@kernel.org>
Some x86 systems expose above 4G 64bit mmio in _CRS as non-pref mmio range.
[ 49.415281] PCI host bridge to bus 0000:00
[ 49.419921] pci_bus 0000:00: root bus resource [bus 00-1e]
[ 49.426107] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7]
[ 49.433041] pci_bus 0000:00: root bus resource [io 0x1000-0x5fff]
[ 49.440010] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[ 49.447768] pci_bus 0000:00: root bus resource [mem 0xfed8c000-0xfedfffff]
[ 49.455532] pci_bus 0000:00: root bus resource [mem 0x90000000-0x9fffbfff]
[ 49.463259] pci_bus 0000:00: root bus resource [mem 0x380000000000-0x381fffffffff]
During assign unassigned 64bit mmio resource, it will go through
every non-pref mmio for root bus in pci_bus_alloc_resource().
As the loop is with pci_bus_for_each_resource(), and could have chance
to use under 4G mmio range instead of above 4G mmio range if the requested
range is not big enough, even it could handle above 4G 64bit pref mmio.
For root bus, we can order list from high to low in pci_add_resource_offset(),
during creating root bus, it will still keep the same order in final bus
resource list.
pci_acpi_scan_root
==> add_resources
==> pci_add_resource_offset: # Add to temp resources
==> pci_create_root_bus
==> pci_bus_add_resource # add to final bus resources.
After that, we can make sure 64bit pref mmio for pci bridges will be allocated
higest of mmio non-pref, and in this case it is above 4G instead of under 4G.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/bus.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 82eb234..30993ab 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -21,7 +21,8 @@
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
resource_size_t offset)
{
- struct pci_host_bridge_window *window;
+ struct pci_host_bridge_window *window, *tmp;
+ struct list_head *n;
window = kzalloc(sizeof(struct pci_host_bridge_window), GFP_KERNEL);
if (!window) {
@@ -31,7 +32,17 @@ void pci_add_resource_offset(struct list_head *resources, struct resource *res,
window->res = res;
window->offset = offset;
- list_add_tail(&window->list, resources);
+
+ /* sorted it according to res end */
+ n = resources;
+ list_for_each_entry(tmp, resources, list)
+ if (window->res->end > tmp->res->end) {
+ n = &tmp->list;
+ break;
+ }
+
+ /* Insert it just before n */
+ list_add_tail(&window->list, n);
}
EXPORT_SYMBOL(pci_add_resource_offset);
--
1.8.1.4
next prev parent reply other threads:[~2013-11-30 22:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 22:40 [PATCH v3 00/12] PCI: Double removing fix and allocate 64bit mmio pref Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 01/12] PCI: Use device_release_driver in pci_stop_root_bus Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 02/12] PCI: Move back pci_proc_attach_devices calling Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 03/12] PCI: Move resources and bus_list releasing to pci_release_dev Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 04/12] PCI: Destroy pci dev only once Yinghai Lu
2013-12-01 1:05 ` Rafael J. Wysocki
2013-12-04 2:19 ` Yinghai Lu
2013-12-04 20:03 ` Rafael J. Wysocki
2013-11-30 22:40 ` [PATCH v3 05/12] PCI: pcibus address to resource converting take bus instead of dev Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 06/12] PCI: Only enable realloc auto when root bus has 64bit mmio Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 07/12] PCI: Don't use 4G bus address directly in resource allocation Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 08/12] PCI: Try to allocate mem64 above 4G at first Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 09/12] PCI: Kill PCIBIOS_MAX_MEM_32 Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 10/12] PCI: Try best to allocate pref mmio 64bit above 4g Yinghai Lu
2013-11-30 22:40 ` Yinghai Lu [this message]
2013-12-02 23:11 ` [PATCH v3 11/12] PCI: Sort pci root bus resources list Bjorn Helgaas
2013-12-04 2:12 ` Yinghai Lu
2013-11-30 22:40 ` [PATCH v3 12/12] intel-gtt: Read 64bit for gmar_bus_addr Yinghai Lu
2013-12-01 17:05 ` [PATCH v3 00/12] PCI: Double removing fix and allocate 64bit mmio pref Myron Stowe
2013-12-04 2:03 ` 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=1385851238-21085-12-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=bhelgaas@google.com \
--cc=guz.fnst@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=yan@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).