hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arm64/kernel/pci.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Code borrowed from powerpc/kernel/pci-common.c
34 *
45 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
56 * Copyright (C) 2014 ARM Ltd.
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * version 2 as published by the Free Software Foundation.
10
- *
117 */
128
139 #include <linux/acpi.h>
....@@ -121,7 +117,7 @@
121117 struct device *dev = &root->device->dev;
122118 struct resource *bus_res = &root->secondary;
123119 u16 seg = root->segment;
124
- struct pci_ecam_ops *ecam_ops;
120
+ const struct pci_ecam_ops *ecam_ops;
125121 struct resource cfgres;
126122 struct acpi_device *adev;
127123 struct pci_config_window *cfg;
....@@ -165,16 +161,16 @@
165161 /* Interface called from ACPI code to setup PCI host controller */
166162 struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
167163 {
168
- int node = acpi_get_node(root->device->handle);
169164 struct acpi_pci_generic_root_info *ri;
170165 struct pci_bus *bus, *child;
171166 struct acpi_pci_root_ops *root_ops;
167
+ struct pci_host_bridge *host;
172168
173
- ri = kzalloc_node(sizeof(*ri), GFP_KERNEL, node);
169
+ ri = kzalloc(sizeof(*ri), GFP_KERNEL);
174170 if (!ri)
175171 return NULL;
176172
177
- root_ops = kzalloc_node(sizeof(*root_ops), GFP_KERNEL, node);
173
+ root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL);
178174 if (!root_ops) {
179175 kfree(ri);
180176 return NULL;
....@@ -189,13 +185,21 @@
189185
190186 root_ops->release_info = pci_acpi_generic_release_info;
191187 root_ops->prepare_resources = pci_acpi_root_prepare_resources;
192
- root_ops->pci_ops = &ri->cfg->ops->pci_ops;
188
+ root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops;
193189 bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg);
194190 if (!bus)
195191 return NULL;
196192
197
- pci_bus_size_bridges(bus);
198
- pci_bus_assign_resources(bus);
193
+ /* If we must preserve the resource configuration, claim now */
194
+ host = pci_find_host_bridge(bus);
195
+ if (host->preserve_config)
196
+ pci_bus_claim_resources(bus);
197
+
198
+ /*
199
+ * Assign whatever was left unassigned. If we didn't claim above,
200
+ * this will reassign everything.
201
+ */
202
+ pci_assign_unassigned_root_bus_resources(bus);
199203
200204 list_for_each_entry(child, &bus->children, node)
201205 pcie_bus_configure_settings(child);