[PATCH RFC 3/4] PCI: Invalidate the released BAR resources

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Otherwise after release_child_resources() there can be resources
with the IORESOURCE_STARTALIGN flag remaining, but with start
dropped to zero, that makes them not valid for re-assigning.

Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@xxxxxxxxx>
---
 drivers/pci/setup-bus.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index fd5675bb501f..ec88461462b8 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1521,7 +1521,7 @@ static void __pci_bridge_assign_resources(const struct pci_dev *bridge,
 static void pci_bridge_release_resources(struct pci_bus *bus,
 					  unsigned long type)
 {
-	struct pci_dev *dev = bus->self;
+	struct pci_dev *dev = bus->self, *child_dev;
 	struct resource *r;
 	unsigned old_flags = 0;
 	struct resource *b_res;
@@ -1564,6 +1564,25 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
 	 *  all
 	 */
 	release_child_resources(r);
+	list_for_each_entry(child_dev, &bus->devices, bus_list) {
+		int i;
+
+		if (child_dev->subordinate)
+			continue;
+
+		for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
+			struct resource *res = &child_dev->resource[i];
+			resource_size_t size = resource_size(res);
+
+			if (!res->flags)
+				continue;
+
+			res->end = size - 1;
+			res->start = 0;
+			res->flags &= ~IORESOURCE_STARTALIGN;
+			res->flags |= IORESOURCE_SIZEALIGN;
+		}
+	}
 	if (!release_resource(r)) {
 		type = old_flags = r->flags & PCI_RES_TYPE_MASK;
 		pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n",
-- 
2.17.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux