mirror-linux/arch
Ilpo Järvinen 9036bd0efc PCI: Align head space better
When a bridge window contains big and small resource(s), the small
resource(s) may not amount to the half of the size of the big resource
which would allow calculate_head_align() to shrink the head alignment.
This results in always placing the small resource(s) after the big
resource.

In general, it would be good to be able to place the small resource(s)
before the big resource to achieve better utilization of the address space.
In the cases where the large resource can only fit at the end of the
window, it is even required.

However, carrying the information over from pbus_size_mem() and
calculate_head_align() to __pci_assign_resource() and
pcibios_align_resource() is not easy with the current data structures.

A somewhat hacky way to move the non-aligning tail part to the head is
possible within pcibios_align_resource(). The free space between the start
of the free space span and the aligned start address can be compared with
the non-aligning remainder of the size. If the free space is larger than
the remainder, placing the remainder before the start address is possible.
This relocation should generally work, because PCI resources consist only
power-of-2 atoms.

Various arch requirements may still need to override the relocation, so the
relocation is only applied selectively in such cases.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221205
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Xifer <xiferdev@gmail.com>
Link: https://patch.msgid.link/20260324165633.4583-10-ilpo.jarvinen@linux.intel.com
2026-03-27 10:19:08 -05:00
..
alpha resource: Pass full extent of empty space to resource_alignf callback 2026-03-27 10:18:39 -05:00
arc Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
arm PCI: Align head space better 2026-03-27 10:19:08 -05:00
arm64 Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
csky Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hexagon mm.git review status for linus..mm-stable 2026-02-12 11:32:37 -08:00
loongarch Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
m68k PCI: Align head space better 2026-03-27 10:19:08 -05:00
microblaze mm.git review status for linus..mm-stable 2026-02-12 11:32:37 -08:00
mips PCI: Align head space better 2026-03-27 10:19:08 -05:00
nios2 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
openrisc OpenRISC updates for 6.20 2026-02-12 14:04:43 -08:00
parisc PCI: Align head space better 2026-03-27 10:19:08 -05:00
powerpc PCI: Align head space better 2026-03-27 10:19:08 -05:00
riscv Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
s390 resource: Pass full extent of empty space to resource_alignf callback 2026-03-27 10:18:39 -05:00
sh PCI: Align head space better 2026-03-27 10:19:08 -05:00
sparc Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
um Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
x86 PCI: Align head space better 2026-03-27 10:19:08 -05:00
xtensa PCI: Align head space better 2026-03-27 10:19:08 -05:00
.gitignore
Kconfig