Skip to content

Commit

Permalink
PCI: Preserve resource size during alignment reordering
Browse files Browse the repository at this point in the history
In d74b902 ("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: d74b902 ("PCI: Consider additional PF's IOV BAR alignment in sizing and assigning")
Signed-off-by: Yinghai Lu <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Wei Yang <[email protected]>
CC: Benjamin Herrenschmidt <[email protected]>
  • Loading branch information
Yinghai Lu authored and bjorn-helgaas committed Jun 1, 2015
1 parent a6b6598 commit 552bc94
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/pci/setup-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,10 @@ static void __assign_resources_sorted(struct list_head *head,
* consistent.
*/
if (add_align > dev_res->res->start) {
resource_size_t r_size = resource_size(dev_res->res);

dev_res->res->start = add_align;
dev_res->res->end = add_align +
resource_size(dev_res->res);
dev_res->res->end = add_align + r_size - 1;

list_for_each_entry(dev_res2, head, list) {
align = pci_resource_alignment(dev_res2->dev,
Expand Down

0 comments on commit 552bc94

Please sign in to comment.