Patch "PCI: Fix resource double counting on remove & rescan" has been added to the 5.15-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    PCI: Fix resource double counting on remove & rescan

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pci-fix-resource-double-counting-on-remove-rescan.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 65cb9bfcb75323a840e208cfbc3677554e250c43
Author: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Date:   Tue May 7 13:25:16 2024 +0300

    PCI: Fix resource double counting on remove & rescan
    
    [ Upstream commit 903534fa7d30214d8ba840ab1cd9e917e0c88e41 ]
    
    pbus_size_mem() keeps the size of the optional resources in
    children_add_size. When calculating the PCI bridge window size,
    calculate_memsize() lower bounds size by old_size before adding
    children_add_size and performing the window size alignment. This
    results in double counting for the resources in children_add_size
    because old_size may be based on the previous size of the bridge
    window after it has already included children_add_size (that is,
    size1 in pbus_size_mem() from an earlier invocation of that
    function).
    
    As a result, on repeated remove of the bus & rescan cycles the resource
    size keeps increasing when children_add_size is non-zero as can be seen
    from this extract:
    
      iomem0:  23fffd00000-23fffdfffff : PCI Bus 0000:03    # 1MiB
      iomem1:  20000000000-200001fffff : PCI Bus 0000:03    # 2MiB
      iomem2:  20000000000-200002fffff : PCI Bus 0000:03    # 3MiB
      iomem3:  20000000000-200003fffff : PCI Bus 0000:03    # 4MiB
      iomem4:  20000000000-200004fffff : PCI Bus 0000:03    # 5MiB
    
    Solve the double counting by moving old_size check later in
    calculate_memsize() so that children_add_size is already accounted for.
    
    After the patch, the bridge window retains its size as expected:
    
      iomem0:  23fffd00000-23fffdfffff : PCI Bus 0000:03    # 1MiB
      iomem1:  20000000000-200000fffff : PCI Bus 0000:03    # 1MiB
      iomem2:  20000000000-200000fffff : PCI Bus 0000:03    # 1MiB
    
    Fixes: a4ac9fea016f ("PCI : Calculate right add_size")
    Link: https://lore.kernel.org/r/20240507102523.57320-2-ilpo.jarvinen@xxxxxxxxxxxxxxx
    Tested-by: Lidong Wang <lidong.wang@xxxxxxxxx>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
    Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
    Reviewed-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 16d291e10627b..a159bfdfa2512 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -824,11 +824,9 @@ static resource_size_t calculate_memsize(resource_size_t size,
 		size = min_size;
 	if (old_size == 1)
 		old_size = 0;
-	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);
 }
 
 resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux