Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Preserve resource size during alignment reordering

In d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing
and assigning"), we store additional alignment in realloc_head and take
this into consideration for assignment.

In __assign_resources_sorted(), we changed dev_res->res->start, then used
resource_start() (which depends on res->start), so the recomputed res->end
was completely bogus. Even if we'd had the correct size, the end would
have been off by one.

Preserve the resource size when we adjust its alignment.

[bhelgaas: changelog]
Fixes: d74b9027a4da ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Wei Yang <weiyang@linux.vnet.ibm.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Yinghai Lu and committed by
Bjorn Helgaas
552bc94e a6b65983

+3 -2
+3 -2
drivers/pci/setup-bus.c
··· 428 428 * consistent. 429 429 */ 430 430 if (add_align > dev_res->res->start) { 431 + resource_size_t r_size = resource_size(dev_res->res); 432 + 431 433 dev_res->res->start = add_align; 432 - dev_res->res->end = add_align + 433 - resource_size(dev_res->res); 434 + dev_res->res->end = add_align + r_size - 1; 434 435 435 436 list_for_each_entry(dev_res2, head, list) { 436 437 align = pci_resource_alignment(dev_res2->dev,