Skip to content

Commit 712e6a9

Browse files
committed
LoongArch: Preserve firmware configuration when desired
If we must preserve the firmware resource assignments, claim the existing resources rather than reassigning everything. 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. Signed-off-by: Qihang Gao <gaoqihang@loongson.cn> Signed-off-by: Juxin Gao <gaojuxin@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 52c2266 commit 712e6a9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/loongarch/pci/acpi.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
194194
{
195195
struct pci_bus *bus;
196196
struct pci_root_info *info;
197+
struct pci_host_bridge *host;
197198
struct acpi_pci_root_ops *root_ops;
198199
int domain = root->segment;
199200
int busnum = root->secondary.start;
@@ -237,8 +238,17 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
237238
return NULL;
238239
}
239240

240-
pci_bus_size_bridges(bus);
241-
pci_bus_assign_resources(bus);
241+
/* If we must preserve the resource configuration, claim now */
242+
host = pci_find_host_bridge(bus);
243+
if (host->preserve_config)
244+
pci_bus_claim_resources(bus);
245+
246+
/*
247+
* Assign whatever was left unassigned. If we didn't claim above,
248+
* this will reassign everything.
249+
*/
250+
pci_assign_unassigned_root_bus_resources(bus);
251+
242252
list_for_each_entry(child, &bus->children, node)
243253
pcie_bus_configure_settings(child);
244254
}

0 commit comments

Comments
 (0)