Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1237019
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v6 33/53] PCI: Add support for more than two alt_size entries under same bridge |
| Date | 2015-10-01 08:10 +0200 |
| Message-ID | <qeFe3-3CQ-37@gated-at.bofh.it> (permalink) |
| References | <qeF4l-3bG-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
When we have two bridges under parent bridge, and each child
bridge has alt_size, we need to increase parent alt_size to make
sure it could fit all alt entries.
In the patch, we first select one big size, and then keep reducing
the size and retrying to get the minimum value for alt_size.
For example, two bridges:
one have 8M/8M, and 1M/1M children res.
one have 4M/4M, and 1M/1M children res.
Then we have child pridges alt_align/alt_size: 8M/9M, 4M/5M.
Before this patch, parent bridge alt_align/alt_size is 8M/14M
that is wrong, as it can not fit two alt entries at all.
With this patch parent bridge alt_align/alt_size: 8M/17M.
8M 16M 20M 24M
|------------|-------------|-----|-----|
8M 25M
|---------------------------|
17M
|---9M----------| |-5M----|
At same time, child bridges required align/size: 4M/12M, 2M/6M.
and prarent bridge required align/size: 4M/20M.
So at last, we use 8M/17M as parent bridge alt_align/alt_size.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=100451
Reported-by: Yijing Wang <wangyijing@huawei.com>
Tested-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index f19b098..ba5635a 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1335,6 +1335,47 @@ out:
return good_align;
}
+static resource_size_t calculate_mem_alt_size(struct list_head *head,
+ resource_size_t max_align, resource_size_t size,
+ resource_size_t align_low)
+{
+ struct align_test_res *p;
+ resource_size_t tmp;
+ resource_size_t good_size, bad_size;
+ int count = 0, order;
+
+ good_size = ALIGN(size, align_low);
+
+ list_for_each_entry(p, head, list)
+ count++;
+
+ if (count <= 1)
+ goto out;
+
+ sort_align_test(head);
+
+ tmp = max(size, max_align);
+ order = __fls(count);
+ if ((1ULL << order) < count)
+ order++;
+ good_size = ALIGN((tmp << order), align_low);
+ bad_size = ALIGN(size, align_low) - align_low;
+ size = good_size;
+ while (size > bad_size) {
+ /* check if align/size fit all entries */
+ if (is_align_size_good(head, max_align, size, 0))
+ good_size = size;
+ else
+ bad_size = size;
+
+ size = bad_size + ((good_size - bad_size) >> 1);
+ size = round_down(size, align_low);
+ }
+
+out:
+ return good_size;
+}
+
static inline bool is_optional(int i)
{
@@ -1381,6 +1422,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
mask | IORESOURCE_PREFETCH, type);
LIST_HEAD(align_test_list);
LIST_HEAD(align_test_add_list);
+ LIST_HEAD(align_test_alt_list);
resource_size_t alt_size = 0, alt_align = 0;
resource_size_t window_align;
@@ -1454,10 +1496,17 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
dev_res = res_to_dev_res(realloc_head, r);
if (dev_res && dev_res->alt_size) {
+ add_to_align_test_list(
+ &align_test_alt_list,
+ dev_res->alt_align,
+ dev_res->alt_size);
alt_size += dev_res->alt_size;
if (alt_align < dev_res->alt_align)
alt_align = dev_res->alt_align;
} else if (r_size > 1) {
+ add_to_align_test_list(
+ &align_test_alt_list,
+ align, r_size);
alt_size += r_size;
if (alt_align < align)
alt_align = align;
@@ -1477,14 +1526,17 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
if (size0 && realloc_head) {
alt_align = max(alt_align, window_align);
- alt_size = calculate_memsize(alt_size, min_size,
- 0, window_align);
+ /* need to increase size to fit more alt */
+ alt_size = calculate_mem_alt_size(&align_test_alt_list,
+ alt_align, alt_size,
+ window_align);
/* required is better ? */
if (alt_size >= size0) {
alt_align = 0;
alt_size = 0;
}
}
+ free_align_test_list(&align_test_alt_list);
if (sum_add_size < min_sum_size)
sum_add_size = min_sum_size;
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v6 00/53] PCI: Resource allocation cleanup for v4.4 Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 27/53] PCI: Separate out save_resources()/restore_resources() Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 41/53] PCI: Kill macro checking for bus io port sizing Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 38/53] PCI: Unify calculate_size() for io port and MMIO Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 46/53] PCI: Check pref compatible bit for mem64 resource of PCIe device Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 35/53] PCI: Don't add too much optional size for hotplug bridge io Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 50/53] PCI: Restore pref MMIO allocation logic for host bridge without mmio64 Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 16/53] PCI: Optimize bus align/size calculation for optional during sizing Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 21/53] PCI: Treat ROM resource as optional during realloc Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 30/53] PCI: Skip required+optional if there is no optional Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 39/53] PCI: Allow bridge optional only io port resource required size to be 0 Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 25/53] PCI: Cache window alignment value during bus sizing Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 53/53] PCI: Don't set flags to 0 when assign resource fail Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 17/53] PCI: Don't add too much optional size for hotplug bridge MMIO Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 42/53] resources: Split out __allocate_resource() Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 48/53] PCI: Add has_mem64 for struct host_bridge Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 33/53] PCI: Add support for more than two alt_size entries under same bridge Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 45/53] PCI: Add debug print out for min_align and alt_size Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:10 +0200 [PATCH v6 24/53] PCI: Add __add_to_list() Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:20 +0200 [PATCH v6 44/53] PCI, x86: Allocate from high in available window for MMIO Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:20 +0200 [PATCH v6 12/53] PCI: Cleanup res_to_dev_res() printout Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:20 +0200 [PATCH v6 52/53] PCI: Introduce resource_disabled() Yinghai Lu <yinghai@kernel.org> - 2015-10-01 08:20 +0200 [PATCH v6 51/53] PCI, x86: Add pci=assign_pref_bars to reallocate pref BARs Yinghai Lu <yinghai@kernel.org> - 2015-10-01 09:00 +0200 [PATCH v6 26/53] PCI: Check if resource is allocated before trying to assign one Yinghai Lu <yinghai@kernel.org> - 2015-10-01 09:00 +0200 [PATCH v6 20/53] PCI: Rename pdev_sort_resources() to pdev_assign_resources_prepare() Yinghai Lu <yinghai@kernel.org> - 2015-10-01 09:00 +0200 [PATCH v6 49/53] PCI: Only treat non-pref mmio64 as pref if host bridge has mmio64 Yinghai Lu <yinghai@kernel.org> - 2015-10-01 09:00 +0200 [PATCH v6 34/53] PCI: Fix size calculation with old_size on rescan path Yinghai Lu <yinghai@kernel.org> - 2015-10-01 09:00 +0200
csiph-web