]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
LoongArch: Use per-root-bridge PCIH flag to skip mem resource fixup
authorHuacai Chen <chenhuacai@loongson.cn>
Mon, 4 May 2026 01:00:20 +0000 (09:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 May 2026 13:31:19 +0000 (15:31 +0200)
commit 49f33840dcc907d21313d369e34872880846b61c upstream.

When firmware enables 64-bit PCI host bridge support, some root bridges
already provide valid 64-bit mem resource windows through ACPI.

In this case, the LoongArch-specific mem resource high-bits fixup in
acpi_prepare_root_resources() should not be applied unconditionally.
Otherwise, the kernel may override the native resource layout derived
from firmware, and later BAR assignment can fail to place device BARs
into the intended 64-bit address space correctly.

Add a per-root-bridge ACPI flag, PCIH, and evaluate it from the current
root bridge device scope. When PCIH is set, skip the mem resource high-
bits fixup path and let the kernel use the firmware-provided resource
description directly. When PCIH is absent or cleared, keep the existing
behavior and continue filling the high address bits from the host bridge
address.

This makes the behavior per-root-bridge configurable and avoids breaking
valid 64-bit BAR space allocation on bridges whose 64-bit windows have
already been fully described by firmware.

Cc: stable@vger.kernel.org
Suggested-by: Chao Li <lichao@loongson.cn>
Tested-by: Dongyan Qian <qiandongyan@loongson.cn>
Signed-off-by: Dongyan Qian <qiandongyan@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/pci/acpi.c

index 0dde3ddcd5443680ea3a1def36edfc99eb46c295..b02698a338eefeb2c8342bd7fda416dba67af45d 100644 (file)
@@ -61,11 +61,16 @@ static void acpi_release_root_info(struct acpi_pci_root_info *ci)
 static int acpi_prepare_root_resources(struct acpi_pci_root_info *ci)
 {
        int status;
+       unsigned long long pci_h = 0;
        struct resource_entry *entry, *tmp;
        struct acpi_device *device = ci->bridge;
 
        status = acpi_pci_probe_root_resources(ci);
        if (status > 0) {
+               acpi_evaluate_integer(device->handle, "PCIH", NULL, &pci_h);
+               if (pci_h)
+                       return status;
+
                resource_list_for_each_entry_safe(entry, tmp, &ci->resources) {
                        if (entry->res->flags & IORESOURCE_MEM) {
                                entry->offset = ci->root->mcfg_addr & GENMASK_ULL(63, 40);