Skip to content

Commit 9d7d5db

Browse files
Vidya Sagarbjorn-helgaas
authored andcommitted
PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_register_host_bridge()
Move the PRESERVE_BOOT_CONFIG _DSM evaluation from acpi_pci_root_create() to pci_register_host_bridge(). This will help unify the ACPI _DSM path and the DT-based "linux,pci-probe-only" paths. This should be safe because it happens earlier than it used to: acpi_pci_root_create pci_create_root_bus pci_register_host_bridge + bridge->preserve_config = pci_preserve_config(bridge) pci_acpi_preserve_config + acpi_evaluate_dsm_typed(DSM_PCI_PRESERVE_BOOT_CONFIG) - acpi_evaluate_dsm_typed(DSM_PCI_PRESERVE_BOOT_CONFIG) No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vidya Sagar <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 1613e60 commit 9d7d5db

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

drivers/acpi/pci_root.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,6 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
10081008
int node = acpi_get_node(device->handle);
10091009
struct pci_bus *bus;
10101010
struct pci_host_bridge *host_bridge;
1011-
union acpi_object *obj;
10121011

10131012
info->root = root;
10141013
info->bridge = device;
@@ -1050,17 +1049,6 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
10501049
if (!(root->osc_ext_control_set & OSC_CXL_ERROR_REPORTING_CONTROL))
10511050
host_bridge->native_cxl_error = 0;
10521051

1053-
/*
1054-
* Evaluate the "PCI Boot Configuration" _DSM Function. If it
1055-
* exists and returns 0, we must preserve any PCI resource
1056-
* assignments made by firmware for this host bridge.
1057-
*/
1058-
obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1,
1059-
DSM_PCI_PRESERVE_BOOT_CONFIG, NULL, ACPI_TYPE_INTEGER);
1060-
if (obj && obj->integer.value == 0)
1061-
host_bridge->preserve_config = 1;
1062-
ACPI_FREE(obj);
1063-
10641052
acpi_dev_power_up_children_with_adr(device);
10651053

10661054
pci_scan_child_bus(bus);

drivers/pci/pci-acpi.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,28 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
119119
return (phys_addr_t)mcfg_addr;
120120
}
121121

122+
bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
123+
{
124+
if (ACPI_HANDLE(&host_bridge->dev)) {
125+
union acpi_object *obj;
126+
127+
/*
128+
* Evaluate the "PCI Boot Configuration" _DSM Function. If it
129+
* exists and returns 0, we must preserve any PCI resource
130+
* assignments made by firmware for this host bridge.
131+
*/
132+
obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(&host_bridge->dev),
133+
&pci_acpi_dsm_guid,
134+
1, DSM_PCI_PRESERVE_BOOT_CONFIG,
135+
NULL, ACPI_TYPE_INTEGER);
136+
if (obj && obj->integer.value == 0)
137+
return true;
138+
ACPI_FREE(obj);
139+
}
140+
141+
return false;
142+
}
143+
122144
/* _HPX PCI Setting Record (Type 0); same as _HPP */
123145
struct hpx_type0 {
124146
u32 revision; /* Not present in _HPP */

drivers/pci/pci.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ static inline void pci_restore_aer_state(struct pci_dev *dev) { }
732732
#endif
733733

734734
#ifdef CONFIG_ACPI
735+
bool pci_acpi_preserve_config(struct pci_host_bridge *bridge);
735736
int pci_acpi_program_hp_params(struct pci_dev *dev);
736737
extern const struct attribute_group pci_dev_acpi_attr_group;
737738
void pci_set_acpi_fwnode(struct pci_dev *dev);
@@ -745,6 +746,10 @@ int acpi_pci_wakeup(struct pci_dev *dev, bool enable);
745746
bool acpi_pci_need_resume(struct pci_dev *dev);
746747
pci_power_t acpi_pci_choose_state(struct pci_dev *pdev);
747748
#else
749+
static inline bool pci_acpi_preserve_config(struct pci_host_bridge *bridge)
750+
{
751+
return false;
752+
}
748753
static inline int pci_dev_acpi_reset(struct pci_dev *dev, bool probe)
749754
{
750755
return -ENOTTY;

drivers/pci/probe.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,14 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus)
889889
dev_set_msi_domain(&bus->dev, d);
890890
}
891891

892+
static bool pci_preserve_config(struct pci_host_bridge *host_bridge)
893+
{
894+
if (pci_acpi_preserve_config(host_bridge))
895+
return true;
896+
897+
return false;
898+
}
899+
892900
static int pci_register_host_bridge(struct pci_host_bridge *bridge)
893901
{
894902
struct device *parent = bridge->dev.parent;
@@ -983,6 +991,9 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
983991
if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE)
984992
dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n");
985993

994+
/* Check if the boot configuration by FW needs to be preserved */
995+
bridge->preserve_config = pci_preserve_config(bridge);
996+
986997
/* Coalesce contiguous windows */
987998
resource_list_for_each_entry_safe(window, n, &resources) {
988999
if (list_is_last(&window->node, &resources))

0 commit comments

Comments
 (0)