When a bridge window is temporarily released during the rescan, its old
size is not relevant anymore - it will be recreated from pbus_size_*(), so
it's start value should be zero.

If such window can't be reassigned, don't apply reset_resource(), so the
next retry may succeed.

Signed-off-by: Sergey Miroshnichenko <s.miroshniche...@yadro.com>
---
 drivers/pci/setup-bus.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 6cb8b293c576..7c2c57f77c6f 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -295,7 +295,8 @@ static void assign_requested_resources_sorted(struct 
list_head *head,
                                                    0 /* don't care */,
                                                    0 /* don't care */);
                        }
-                       reset_resource(res);
+                       if (!pci_movable_bars_enabled())
+                               reset_resource(res);
                }
        }
 }
@@ -1579,8 +1580,8 @@ static void pci_bridge_release_resources(struct pci_bus 
*bus,
                type = old_flags = r->flags & PCI_RES_TYPE_MASK;
                pci_info(dev, "resource %d %pR released\n",
                         PCI_BRIDGE_RESOURCES + idx, r);
-               /* Keep the old size */
-               r->end = resource_size(r) - 1;
+               /* Don't keep the old size if the bridge will be recalculated */
+               r->end = pci_movable_bars_enabled() ? 0 : (resource_size(r) - 
1);
                r->start = 0;
                r->flags = 0;
 
-- 
2.21.0

Reply via email to