123 lines
4.8 KiB
Diff
123 lines
4.8 KiB
Diff
|
|
From 06837491e2ece2fdd6fe6cc8572aaab52fbdcb3e Mon Sep 17 00:00:00 2001
|
||
|
|
From: Keqian Zhu <zhukeqian1@huawei.com>
|
||
|
|
Date: Wed, 22 Apr 2020 15:58:27 +0800
|
||
|
|
Subject: [PATCH] arm/virt/acpi: Factor out CPPC building from DSDT CPU aml
|
||
|
|
|
||
|
|
When CPU hotplug is enabled, we will use build_cpus_aml instead of
|
||
|
|
acpi_dsdt_add_cpus, so factor out CPPC building and we can reuse it
|
||
|
|
in build_cpus_aml.
|
||
|
|
|
||
|
|
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
||
|
|
---
|
||
|
|
hw/arm/virt-acpi-build.c | 33 +++++++++++++++++-----------
|
||
|
|
hw/arm/virt.c | 1 +
|
||
|
|
include/hw/acpi/acpi_dev_interface.h | 2 ++
|
||
|
|
include/hw/arm/virt.h | 2 ++
|
||
|
|
4 files changed, 25 insertions(+), 13 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
|
||
|
|
index 64b1ed8672..a93d223879 100644
|
||
|
|
--- a/hw/arm/virt-acpi-build.c
|
||
|
|
+++ b/hw/arm/virt-acpi-build.c
|
||
|
|
@@ -120,8 +120,24 @@ static void acpi_dsdt_add_cppc(Aml *dev, uint64_t cpu_base, int *regs_offset)
|
||
|
|
aml_append(dev, aml_name_decl("_CPC", cpc));
|
||
|
|
}
|
||
|
|
|
||
|
|
-static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms,
|
||
|
|
- const MemMapEntry *cppc_memmap)
|
||
|
|
+void virt_acpi_dsdt_cpu_cppc(AcpiDeviceIf *adev, int ncpu, int num_cpu, Aml *dev)
|
||
|
|
+{
|
||
|
|
+ VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine());
|
||
|
|
+ const MemMapEntry *cppc_memmap = &vms->memmap[VIRT_CPUFREQ];
|
||
|
|
+
|
||
|
|
+ /*
|
||
|
|
+ * Append _CPC and _PSD to support CPU frequence show
|
||
|
|
+ * Check CPPC available by DESIRED_PERF register
|
||
|
|
+ */
|
||
|
|
+ if (cppc_regs_offset[DESIRED_PERF] != -1) {
|
||
|
|
+ acpi_dsdt_add_cppc(dev,
|
||
|
|
+ cppc_memmap->base + ncpu * CPPC_REG_PER_CPU_STRIDE,
|
||
|
|
+ cppc_regs_offset);
|
||
|
|
+ acpi_dsdt_add_psd(dev, num_cpu);
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
|
||
|
|
{
|
||
|
|
MachineState *ms = MACHINE(vms);
|
||
|
|
uint16_t i;
|
||
|
|
@@ -131,16 +147,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms,
|
||
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
|
||
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
|
||
|
|
|
||
|
|
- /*
|
||
|
|
- * Append _CPC and _PSD to support CPU frequence show
|
||
|
|
- * Check CPPC available by DESIRED_PERF register
|
||
|
|
- */
|
||
|
|
- if (cppc_regs_offset[DESIRED_PERF] != -1) {
|
||
|
|
- acpi_dsdt_add_cppc(dev,
|
||
|
|
- cppc_memmap->base + i * CPPC_REG_PER_CPU_STRIDE,
|
||
|
|
- cppc_regs_offset);
|
||
|
|
- acpi_dsdt_add_psd(dev, ms->smp.cpus);
|
||
|
|
- }
|
||
|
|
+ virt_acpi_dsdt_cpu_cppc(NULL, i, ms->smp.cpus, dev);
|
||
|
|
|
||
|
|
aml_append(scope, dev);
|
||
|
|
}
|
||
|
|
@@ -940,7 +947,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||
|
|
* the RTC ACPI device at all when using UEFI.
|
||
|
|
*/
|
||
|
|
scope = aml_scope("\\_SB");
|
||
|
|
- acpi_dsdt_add_cpus(scope, vms, &memmap[VIRT_CPUFREQ]);
|
||
|
|
+ acpi_dsdt_add_cpus(scope, vms);
|
||
|
|
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
|
||
|
|
(irqmap[VIRT_UART] + ARM_SPI_BASE));
|
||
|
|
if (vmc->acpi_expose_flash) {
|
||
|
|
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
||
|
|
index 44c29070c4..3299d674c8 100644
|
||
|
|
--- a/hw/arm/virt.c
|
||
|
|
+++ b/hw/arm/virt.c
|
||
|
|
@@ -702,6 +702,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)
|
||
|
|
|
||
|
|
adevc = ACPI_DEVICE_IF_GET_CLASS(dev);
|
||
|
|
adevc->madt_cpu = virt_madt_cpu_entry;
|
||
|
|
+ adevc->cpu_cppc = virt_acpi_dsdt_cpu_cppc;
|
||
|
|
|
||
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
|
||
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
|
||
|
|
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
|
||
|
|
index ea6056ab92..601931433a 100644
|
||
|
|
--- a/include/hw/acpi/acpi_dev_interface.h
|
||
|
|
+++ b/include/hw/acpi/acpi_dev_interface.h
|
||
|
|
@@ -5,6 +5,7 @@
|
||
|
|
#include "qom/object.h"
|
||
|
|
#include "hw/boards.h"
|
||
|
|
#include "hw/qdev-core.h"
|
||
|
|
+#include "hw/acpi/aml-build.h"
|
||
|
|
|
||
|
|
/* These values are part of guest ABI, and can not be changed */
|
||
|
|
typedef enum {
|
||
|
|
@@ -55,5 +56,6 @@ struct AcpiDeviceIfClass {
|
||
|
|
void (*madt_cpu)(AcpiDeviceIf *adev, int uid,
|
||
|
|
const CPUArchIdList *apic_ids, GArray *entry,
|
||
|
|
bool force_enabled);
|
||
|
|
+ void (*cpu_cppc)(AcpiDeviceIf *adev, int uid, int num_cpu, Aml *dev);
|
||
|
|
};
|
||
|
|
#endif
|
||
|
|
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
|
||
|
|
index 36639e8d3e..fe26709e1a 100644
|
||
|
|
--- a/include/hw/arm/virt.h
|
||
|
|
+++ b/include/hw/arm/virt.h
|
||
|
|
@@ -185,6 +185,8 @@ bool virt_is_acpi_enabled(VirtMachineState *vms);
|
||
|
|
void virt_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
|
||
|
|
const CPUArchIdList *cpu_list, GArray *entry,
|
||
|
|
bool force_enabled);
|
||
|
|
+void virt_acpi_dsdt_cpu_cppc(AcpiDeviceIf *adev, int uid,
|
||
|
|
+ int num_cpu, Aml *dev);
|
||
|
|
|
||
|
|
/* Return the number of used redistributor regions */
|
||
|
|
static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|