.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Code borrowed from powerpc/kernel/pci-common.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM |
---|
5 | 6 | * 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 | | - * |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <linux/acpi.h> |
---|
.. | .. |
---|
121 | 117 | struct device *dev = &root->device->dev; |
---|
122 | 118 | struct resource *bus_res = &root->secondary; |
---|
123 | 119 | u16 seg = root->segment; |
---|
124 | | - struct pci_ecam_ops *ecam_ops; |
---|
| 120 | + const struct pci_ecam_ops *ecam_ops; |
---|
125 | 121 | struct resource cfgres; |
---|
126 | 122 | struct acpi_device *adev; |
---|
127 | 123 | struct pci_config_window *cfg; |
---|
.. | .. |
---|
165 | 161 | /* Interface called from ACPI code to setup PCI host controller */ |
---|
166 | 162 | struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) |
---|
167 | 163 | { |
---|
168 | | - int node = acpi_get_node(root->device->handle); |
---|
169 | 164 | struct acpi_pci_generic_root_info *ri; |
---|
170 | 165 | struct pci_bus *bus, *child; |
---|
171 | 166 | struct acpi_pci_root_ops *root_ops; |
---|
| 167 | + struct pci_host_bridge *host; |
---|
172 | 168 | |
---|
173 | | - ri = kzalloc_node(sizeof(*ri), GFP_KERNEL, node); |
---|
| 169 | + ri = kzalloc(sizeof(*ri), GFP_KERNEL); |
---|
174 | 170 | if (!ri) |
---|
175 | 171 | return NULL; |
---|
176 | 172 | |
---|
177 | | - root_ops = kzalloc_node(sizeof(*root_ops), GFP_KERNEL, node); |
---|
| 173 | + root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL); |
---|
178 | 174 | if (!root_ops) { |
---|
179 | 175 | kfree(ri); |
---|
180 | 176 | return NULL; |
---|
.. | .. |
---|
189 | 185 | |
---|
190 | 186 | root_ops->release_info = pci_acpi_generic_release_info; |
---|
191 | 187 | 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; |
---|
193 | 189 | bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg); |
---|
194 | 190 | if (!bus) |
---|
195 | 191 | return NULL; |
---|
196 | 192 | |
---|
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); |
---|
199 | 203 | |
---|
200 | 204 | list_for_each_entry(child, &bus->children, node) |
---|
201 | 205 | pcie_bus_configure_settings(child); |
---|