Skip to content

Commit a34d748

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Restore assigned resources fully after release
PCI resource fitting code in __assign_resources_sorted() runs in multiple steps. A resource that was successfully assigned may have to be released before the next step attempts assignment again. The assign+release cycle is destructive to a start-aligned struct resource (bridge window or IOV resource) because the start field is overwritten with the real address when the resource got assigned. One symptom: pci 0002:00:00.0: bridge window [mem size 0x00100000]: can't assign; bogus alignment Properly restore the resource after releasing it. The start, end, and flags fields must be stored into the related struct pci_dev_resource in order to be able to restore the resource to its original state. Fixes: 96336ec ("PCI: Perform reset_resource() and build fail list in sync") Reported-by: Guenter Roeck <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Reported-by: Nicolas Frattaroli <[email protected]> Closes: https://lore.kernel.org/r/3578030.5fSG56mABF@workhorse Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Nicolas Frattaroli <[email protected]> Tested-by: Guenter Roeck <[email protected]> Tested-by: Ondrej Jirman <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 0af2f6b commit a34d748

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/pci/setup-bus.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
187187
panic("%s: kzalloc() failed!\n", __func__);
188188
tmp->res = r;
189189
tmp->dev = dev;
190+
tmp->start = r->start;
191+
tmp->end = r->end;
192+
tmp->flags = r->flags;
190193

191194
/* Fallback is smallest one or list is empty */
192195
n = head;
@@ -545,6 +548,7 @@ static void __assign_resources_sorted(struct list_head *head,
545548
pci_dbg(dev, "%s %pR: releasing\n", res_name, res);
546549

547550
release_resource(res);
551+
restore_dev_resource(dev_res);
548552
}
549553
/* Restore start/end/flags from saved list */
550554
list_for_each_entry(save_res, &save_head, list)

0 commit comments

Comments
 (0)