aboutsummaryrefslogtreecommitdiff
path: root/hw/i386
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2022-06-08 15:54:39 +0100
committerMichael S. Tsirkin <mst@redhat.com>2022-06-09 19:32:49 -0400
commit1ebf9001fb2701e3c00b401334c8f3900a46adaa (patch)
tree1b866f90c9de4da6a76644a826ae8c9446460ee4 /hw/i386
parent3546b0529a5799d1a13397fa3586711b3da52190 (diff)
downloadqemu-1ebf9001fb2701e3c00b401334c8f3900a46adaa.zip
qemu-1ebf9001fb2701e3c00b401334c8f3900a46adaa.tar.gz
qemu-1ebf9001fb2701e3c00b401334c8f3900a46adaa.tar.bz2
hw/cxl: Move the CXLState from MachineState to machine type specific state.
This removes the last of the CXL code from the MachineState where it is visible to all Machines to only those that support CXL (currently i386/pc) As i386/pc always support CXL now, stop allocating the state independently. Note the pxb register hookup code runs even if cxl=off in order to detect pxb_cxl host bridges and fail to start if any are present as they won't have the control registers available. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Ben Widawsky <ben@bwidawsk.net> Message-Id: <20220608145440.26106-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r--hw/i386/acpi-build.c6
-rw-r--r--hw/i386/pc.c33
2 files changed, 19 insertions, 20 deletions
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 663c34b..73d0bf5 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1631,7 +1631,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
/* Handle the ranges for the PXB expanders */
if (pci_bus_is_cxl(bus)) {
- MemoryRegion *mr = &machine->cxl_devices_state->host_mr;
+ MemoryRegion *mr = &pcms->cxl_devices_state.host_mr;
uint64_t base = mr->addr;
cxl_present = true;
@@ -2614,9 +2614,9 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
machine->nvdimms_state, machine->ram_slots,
x86ms->oem_id, x86ms->oem_table_id);
}
- if (machine->cxl_devices_state->is_enabled) {
+ if (pcms->cxl_devices_state.is_enabled) {
cxl_build_cedt(table_offsets, tables_blob, tables->linker,
- x86ms->oem_id, x86ms->oem_table_id, machine->cxl_devices_state);
+ x86ms->oem_id, x86ms->oem_table_id, &pcms->cxl_devices_state);
}
acpi_add_table(table_offsets, tables_blob);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 9f48d02..a0c0d69 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -733,12 +733,12 @@ void pc_machine_done(Notifier *notifier, void *data)
PCMachineState *pcms = container_of(notifier,
PCMachineState, machine_done);
X86MachineState *x86ms = X86_MACHINE(pcms);
- MachineState *ms = MACHINE(pcms);
- if (ms->cxl_devices_state) {
- cxl_hook_up_pxb_registers(pcms->bus, ms->cxl_devices_state,
- &error_fatal);
- cxl_fmws_link_targets(ms->cxl_devices_state, &error_fatal);
+ cxl_hook_up_pxb_registers(pcms->bus, &pcms->cxl_devices_state,
+ &error_fatal);
+
+ if (pcms->cxl_devices_state.is_enabled) {
+ cxl_fmws_link_targets(&pcms->cxl_devices_state, &error_fatal);
}
/* set the number of CPUs */
@@ -908,8 +908,8 @@ void pc_memory_init(PCMachineState *pcms,
&machine->device_memory->mr);
}
- if (machine->cxl_devices_state->is_enabled) {
- MemoryRegion *mr = &machine->cxl_devices_state->host_mr;
+ if (pcms->cxl_devices_state.is_enabled) {
+ MemoryRegion *mr = &pcms->cxl_devices_state.host_mr;
hwaddr cxl_size = MiB;
if (pcmc->has_reserved_memory && machine->device_memory->base) {
@@ -927,12 +927,12 @@ void pc_memory_init(PCMachineState *pcms,
memory_region_init(mr, OBJECT(machine), "cxl_host_reg", cxl_size);
memory_region_add_subregion(system_memory, cxl_base, mr);
cxl_resv_end = cxl_base + cxl_size;
- if (machine->cxl_devices_state->fixed_windows) {
+ if (pcms->cxl_devices_state.fixed_windows) {
hwaddr cxl_fmw_base;
GList *it;
cxl_fmw_base = ROUND_UP(cxl_base + cxl_size, 256 * MiB);
- for (it = machine->cxl_devices_state->fixed_windows; it; it = it->next) {
+ for (it = pcms->cxl_devices_state.fixed_windows; it; it = it->next) {
CXLFixedWindow *fw = it->data;
fw->base = cxl_fmw_base;
@@ -974,7 +974,7 @@ void pc_memory_init(PCMachineState *pcms,
res_mem_end += memory_region_size(&machine->device_memory->mr);
}
- if (machine->cxl_devices_state->is_enabled) {
+ if (pcms->cxl_devices_state.is_enabled) {
res_mem_end = cxl_resv_end;
}
*val = cpu_to_le64(ROUND_UP(res_mem_end, 1 * GiB));
@@ -1010,12 +1010,12 @@ uint64_t pc_pci_hole64_start(void)
X86MachineState *x86ms = X86_MACHINE(pcms);
uint64_t hole64_start = 0;
- if (ms->cxl_devices_state->host_mr.addr) {
- hole64_start = ms->cxl_devices_state->host_mr.addr +
- memory_region_size(&ms->cxl_devices_state->host_mr);
- if (ms->cxl_devices_state->fixed_windows) {
+ if (pcms->cxl_devices_state.host_mr.addr) {
+ hole64_start = pcms->cxl_devices_state.host_mr.addr +
+ memory_region_size(&pcms->cxl_devices_state.host_mr);
+ if (pcms->cxl_devices_state.fixed_windows) {
GList *it;
- for (it = ms->cxl_devices_state->fixed_windows; it; it = it->next) {
+ for (it = pcms->cxl_devices_state.fixed_windows; it; it = it->next) {
CXLFixedWindow *fw = it->data;
hole64_start = fw->mr.addr + memory_region_size(&fw->mr);
}
@@ -1691,7 +1691,6 @@ static void pc_machine_set_max_fw_size(Object *obj, Visitor *v,
static void pc_machine_initfn(Object *obj)
{
PCMachineState *pcms = PC_MACHINE(obj);
- MachineState *ms = MACHINE(obj);
#ifdef CONFIG_VMPORT
pcms->vmport = ON_OFF_AUTO_AUTO;
@@ -1716,7 +1715,7 @@ static void pc_machine_initfn(Object *obj)
pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
OBJECT(pcms->pcspk), "audiodev");
- cxl_machine_init(obj, ms->cxl_devices_state);
+ cxl_machine_init(obj, &pcms->cxl_devices_state);
}
static void pc_machine_reset(MachineState *machine)