120 lines
4.2 KiB
Diff
120 lines
4.2 KiB
Diff
|
|
From 37308e60d43323c0ea65d734487ce6542f8a9d3b Mon Sep 17 00:00:00 2001
|
||
|
|
From: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Date: Tue, 5 Oct 2021 10:53:12 +0200
|
||
|
|
Subject: [PATCH] hw/pci-host/gpex: [needs kernel fix] Allow to generate
|
||
|
|
preserve boot config DSM #5
|
||
|
|
|
||
|
|
Add a 'preserve_config' field in struct GPEXConfig and
|
||
|
|
if set, generate the DSM #5 for preserving PCI boot configurations.
|
||
|
|
The DSM presence is needed to expose RMRs.
|
||
|
|
|
||
|
|
At the moment the DSM generation is not yet enabled.
|
||
|
|
|
||
|
|
Signed-off-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
---
|
||
|
|
hw/pci-host/gpex-acpi.c | 35 +++++++++++++++++++++++++++++++----
|
||
|
|
include/hw/pci-host/gpex.h | 1 +
|
||
|
|
2 files changed, 32 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
|
||
|
|
index ac5d229757..ce424fc9da 100644
|
||
|
|
--- a/hw/pci-host/gpex-acpi.c
|
||
|
|
+++ b/hw/pci-host/gpex-acpi.c
|
||
|
|
@@ -49,9 +49,10 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
-static void acpi_dsdt_add_pci_osc(Aml *dev)
|
||
|
|
+static void acpi_dsdt_add_pci_osc(Aml *dev, bool preserve_config)
|
||
|
|
{
|
||
|
|
Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf;
|
||
|
|
+ uint8_t byte_list[1] = {0};
|
||
|
|
|
||
|
|
/* Declare an _OSC (OS Control Handoff) method */
|
||
|
|
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
|
||
|
|
@@ -113,10 +114,24 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)
|
||
|
|
UUID = aml_touuid("E5C937D0-3553-4D7A-9117-EA4D19C3434D");
|
||
|
|
ifctx = aml_if(aml_equal(aml_arg(0), UUID));
|
||
|
|
ifctx1 = aml_if(aml_equal(aml_arg(2), aml_int(0)));
|
||
|
|
- uint8_t byte_list[1] = {0};
|
||
|
|
+ if (preserve_config) {
|
||
|
|
+ /* support for functions other than function 0 and function 5 */
|
||
|
|
+ byte_list[0] = 0x21;
|
||
|
|
+ }
|
||
|
|
buf = aml_buffer(1, byte_list);
|
||
|
|
aml_append(ifctx1, aml_return(buf));
|
||
|
|
aml_append(ifctx, ifctx1);
|
||
|
|
+
|
||
|
|
+ if (preserve_config) {
|
||
|
|
+ Aml *ifctx2 = aml_if(aml_equal(aml_arg(2), aml_int(5)));
|
||
|
|
+ /*
|
||
|
|
+ * 0 - The operating system must not ignore the PCI configuration that
|
||
|
|
+ * firmware has done at boot time.
|
||
|
|
+ */
|
||
|
|
+ aml_append(ifctx2, aml_return(aml_int(0)));
|
||
|
|
+ aml_append(ifctx, ifctx2);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
aml_append(method, ifctx);
|
||
|
|
|
||
|
|
byte_list[0] = 0;
|
||
|
|
@@ -174,6 +189,12 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
|
||
|
|
aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node)));
|
||
|
|
}
|
||
|
|
|
||
|
|
+ if (cfg->preserve_config) {
|
||
|
|
+ method = aml_method("_DSM", 5, AML_SERIALIZED);
|
||
|
|
+ aml_append(method, aml_return(aml_int(0)));
|
||
|
|
+ aml_append(dev, method);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
acpi_dsdt_add_pci_route_table(dev, cfg->irq);
|
||
|
|
|
||
|
|
/*
|
||
|
|
@@ -188,7 +209,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
|
||
|
|
if (is_cxl) {
|
||
|
|
build_cxl_osc_method(dev);
|
||
|
|
} else {
|
||
|
|
- acpi_dsdt_add_pci_osc(dev);
|
||
|
|
+ acpi_dsdt_add_pci_osc(dev, cfg->preserve_config);
|
||
|
|
}
|
||
|
|
|
||
|
|
aml_append(scope, dev);
|
||
|
|
@@ -205,6 +226,12 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
|
||
|
|
aml_append(dev, aml_name_decl("_STR", aml_unicode("PCIe 0 Device")));
|
||
|
|
aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
|
||
|
|
|
||
|
|
+ if (cfg->preserve_config) {
|
||
|
|
+ method = aml_method("_DSM", 5, AML_SERIALIZED);
|
||
|
|
+ aml_append(method, aml_return(aml_int(0)));
|
||
|
|
+ aml_append(dev, method);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
acpi_dsdt_add_pci_route_table(dev, cfg->irq);
|
||
|
|
|
||
|
|
method = aml_method("_CBA", 0, AML_NOTSERIALIZED);
|
||
|
|
@@ -263,7 +290,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
|
||
|
|
}
|
||
|
|
aml_append(dev, aml_name_decl("_CRS", rbuf));
|
||
|
|
|
||
|
|
- acpi_dsdt_add_pci_osc(dev);
|
||
|
|
+ acpi_dsdt_add_pci_osc(dev, cfg->preserve_config);
|
||
|
|
|
||
|
|
Aml *dev_res0 = aml_device("%s", "RES0");
|
||
|
|
aml_append(dev_res0, aml_name_decl("_HID", aml_string("PNP0C02")));
|
||
|
|
diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h
|
||
|
|
index b0240bd768..65475f7f9d 100644
|
||
|
|
--- a/include/hw/pci-host/gpex.h
|
||
|
|
+++ b/include/hw/pci-host/gpex.h
|
||
|
|
@@ -64,6 +64,7 @@ struct GPEXConfig {
|
||
|
|
MemMapEntry pio;
|
||
|
|
int irq;
|
||
|
|
PCIBus *bus;
|
||
|
|
+ bool preserve_config;
|
||
|
|
};
|
||
|
|
|
||
|
|
int gpex_set_irq_num(GPEXHost *s, int index, int gsi);
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|