
From: Gao Qihang <gaoqihang@loongson.cn> LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IC10DU CVE: NA -------------------------------- According to PCI Firmware Specification, if ACPI DSM#5 function returns 0, the OS must retain the resource allocation for PCI in the firmware; if ACPI DSM#5 function returns 1, the OS can ignore the resource allocation for PCI and reallocate it. Change-Id: I692bcbc4269b2321aff80fe352bfe3aef5340424 Signed-off-by: Gao Qihang <gaoqihang@loongson.cn> Signed-off-by: Juxin Gao <gaojuxin@loongson.cn> --- arch/loongarch/pci/acpi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c index 5ba4d3a169b2..38b2a45473e0 100644 --- a/arch/loongarch/pci/acpi.c +++ b/arch/loongarch/pci/acpi.c @@ -346,6 +346,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) struct acpi_pci_root_ops *root_ops; int domain = root->segment; int busnum = root->secondary.start; + struct pci_host_bridge *host; info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { @@ -386,8 +387,17 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) return NULL; } - pci_bus_size_bridges(bus); - pci_bus_assign_resources(bus); + /* If we must preserve the resource configuration, claim now */ + host = pci_find_host_bridge(bus); + if (host->preserve_config) + pci_bus_claim_resources(bus); + + /* + * Assign whatever was left unassigned. If we didn't claim above, + * this will reassign everything. + */ + pci_assign_unassigned_root_bus_resources(bus); + list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); } -- 2.43.0