pcie: Adapt PCIe address space for AMD GPU on K1-X

1. In the Device Tree, merge the PCIe I/O and memory address
windows.The AMD GPU requires a large, contiguous BAR space,
which the previous separate windows could not satisfy.
2. Add a hack to correct the BAR space size calculation. The K1-X platform
reserves a total of 384MB (0x18000000) for PCIe devices (including BAR
and config space). However, the Linux kernel's allocation logic,
influenced by 128MB alignment, attempts to request a full 384MB BAR space
for the GPU.This commit reduces the requested size to 0x16000000,
ensuring the allocation succeeds, as the GPU itself only requires 258MB.

Signed-off-by: liyeshan <yeshan.li@spacemit.com>
Change-Id: Ic5610b455aac5b0dc97ac4904037865f83ad1c2c
This commit is contained in:
liyeshan
2025-07-24 10:19:02 +08:00
committed by 张猛
parent db0d3fc566
commit 786e008e00
2 changed files with 5 additions and 2 deletions

View File

@@ -2372,8 +2372,7 @@
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x01000000 0x0 0xb7002000 0 0xb7002000 0x0 0x100000>,
<0x42000000 0x0 0xa0000000 0 0xa0000000 0x0 0x10000000>,
<0x02000000 0x0 0xb0000000 0 0xb0000000 0x0 0x7000000>;
<0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x17000000>;
interconnects = <&dram_range7>;
interconnect-names = "dma-mem";

View File

@@ -1067,6 +1067,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
min_align = calculate_mem_align(aligns, max_order);
min_align = max(min_align, window_alignment(bus, b_res->flags));
size0 = calculate_memsize(size, min_size, 0, 0, resource_size(b_res), min_align);
#ifdef CONFIG_SOC_SPACEMIT_K1X
if (size0 == 0x18000000U)
size0 = 0x16000000U;
#endif
add_align = max(min_align, add_align);
size1 = (!realloc_head || (realloc_head && !add_size && !children_add_size)) ? size0 :
calculate_memsize(size, min_size, add_size, children_add_size,