Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1237016
| From | Yinghai Lu <yinghai@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v6 17/53] PCI: Don't add too much optional size for hotplug bridge MMIO |
| Date | 2015-10-01 08:10 +0200 |
| Message-ID | <qeFe3-3CQ-33@gated-at.bofh.it> (permalink) |
| References | <qeF4l-3bG-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Current code will always add 2M for hotplug bridge MMIO even
there is child device under it already.
For example:
40:03.0 --- 43:00.0 --- 44:02.0 -+- 45:00.0
\- 45:00.1
44:02.0 will need 1M as must for 45:00.0 and 45:00.1
When we calculate add_size for 44:02.0, we pass 2M as additional
size for hotplug bridge, total will be 3M.
That is different from code before changes for optional support,
or even current code that treat optional as required directly by
not passing realloc list. We only need 2M as total.
The optional size should be 1M, and total size should be 2M.
This patch change to comparing required+optional with min_sum_size to
get smaller optional size.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 3797b71..6fda7ad 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1161,7 +1161,6 @@ out:
* @type2: second match type
* @type3: third match type
* @min_size : the minimum memory window that must to be allocated
- * @add_size : additional optional memory window
* @realloc_head : track the additional memory window on this list
*
* Calculate the size of the bus and minimal alignment which
@@ -1174,10 +1173,11 @@ out:
static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
unsigned long type, unsigned long type2,
unsigned long type3,
- resource_size_t min_size, resource_size_t add_size,
+ resource_size_t min_size,
struct list_head *realloc_head)
{
struct pci_dev *dev;
+ resource_size_t min_sum_size = 0;
resource_size_t min_align = 0, min_add_align = 0;
resource_size_t max_align = 0, max_add_align = 0;
resource_size_t size = 0, size0 = 0, size1 = 0, sum_add_size = 0;
@@ -1189,6 +1189,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
if (!b_res)
return -ENOSPC;
+ if (realloc_head) {
+ min_sum_size = min_size;
+ min_size = 0;
+ }
+
list_for_each_entry(dev, &bus->devices, bus_list) {
int i;
@@ -1259,8 +1264,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
}
free_align_test_list(&align_test_list);
- if ((sum_add_size - size) < add_size)
- sum_add_size = size + add_size;
+ if (sum_add_size < min_sum_size)
+ sum_add_size = min_sum_size;
if (sum_add_size > size && realloc_head) {
min_add_align = calculate_mem_align(&align_test_add_list,
max_add_align, sum_add_size,
@@ -1397,7 +1402,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
{
struct pci_dev *dev;
unsigned long mask, prefmask, type2 = 0, type3 = 0;
- resource_size_t additional_mem_size = 0, additional_io_size = 0;
+ resource_size_t min_mem_size = 0, additional_io_size = 0;
struct resource *b_res;
int ret;
@@ -1431,7 +1436,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
pci_bridge_check_ranges(bus);
if (bus->self->is_hotplug_bridge) {
additional_io_size = pci_hotplug_io_size;
- additional_mem_size = pci_hotplug_mem_size;
+ min_mem_size = pci_hotplug_mem_size;
}
/* Fall through */
default:
@@ -1450,8 +1455,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
prefmask |= IORESOURCE_MEM_64;
ret = pbus_size_mem(bus, prefmask, prefmask,
prefmask, prefmask,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
/*
* If successful, all non-prefetchable resources
@@ -1474,8 +1478,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
prefmask &= ~IORESOURCE_MEM_64;
ret = pbus_size_mem(bus, prefmask, prefmask,
prefmask, prefmask,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
/*
* If successful, only non-prefetchable resources
@@ -1484,7 +1487,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
if (ret == 0)
mask = prefmask;
else
- additional_mem_size += additional_mem_size;
+ min_mem_size += min_mem_size;
type2 = type3 = IORESOURCE_MEM;
}
@@ -1505,8 +1508,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
* window.
*/
pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
- realloc_head ? 0 : additional_mem_size,
- additional_mem_size, realloc_head);
+ min_mem_size, realloc_head);
break;
}
}
--
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