PCI: Fix old_size lower bound in calculate_iosize() too
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 16 Dec 2024 17:56:12 +0000 (19:56 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 18 Feb 2025 21:40:52 +0000 (15:40 -0600)
Commit 903534fa7d30 ("PCI: Fix resource double counting on remove &
rescan") fixed double counting of mem resources because of old_size being
applied too early.

Fix a similar counting bug on the io resource side.

Link: https://lore.kernel.org/r/20241216175632.4175-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Xiaochun Lee <lixc17@lenovo.com>
drivers/pci/setup-bus.c

index 447f3aa1037c74c2942e75ae4e5ba6eb8fac24f3..7c966e3f5060d90bdadb0e7fb8603e65ed519a46 100644 (file)
@@ -814,11 +814,9 @@ static resource_size_t calculate_iosize(resource_size_t size,
        size = (size & 0xff) + ((size & ~0xffUL) << 2);
 #endif
        size = size + size1;
-       if (size < old_size)
-               size = old_size;
 
-       size = ALIGN(max(size, add_size) + children_add_size, align);
-       return size;
+       size = max(size, add_size) + children_add_size;
+       return ALIGN(max(size, old_size), align);
 }
 
 static resource_size_t calculate_memsize(resource_size_t size,