From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"Ben Widawsky" <ben@bwidawsk.net>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Ani Sinha" <ani@anisinha.ca>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PULL 42/54] hw/cxl: Move the CXLState from MachineState to machine type specific state.
Date: Fri, 10 Jun 2022 03:59:06 -0400 [thread overview]
Message-ID: <20220610075631.367501-43-mst@redhat.com> (raw)
In-Reply-To: <20220610075631.367501-1-mst@redhat.com>
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
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>
---
include/hw/boards.h | 1 -
include/hw/i386/pc.h | 2 ++
hw/core/machine.c | 6 ------
hw/i386/acpi-build.c | 6 +++---
hw/i386/pc.c | 33 ++++++++++++++++-----------------
5 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index dd9fc56df2..031f5f884d 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -360,7 +360,6 @@ struct MachineState {
CPUArchIdList *possible_cpus;
CpuTopology smp;
struct NVDIMMState *nvdimms_state;
- struct CXLState *cxl_devices_state;
struct NumaState *numa_state;
CXLFixedMemoryWindowOptionsList *cfmws_list;
};
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index dee38cfac4..003a86b721 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -14,6 +14,7 @@
#include "qom/object.h"
#include "hw/i386/sgx-epc.h"
#include "hw/firmware/smbios.h"
+#include "hw/cxl/cxl.h"
#define HPET_INTCAP "hpet-intcap"
@@ -55,6 +56,7 @@ typedef struct PCMachineState {
hwaddr memhp_io_base;
SGXEPCState sgx_epc;
+ CXLState cxl_devices_state;
} PCMachineState;
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 2e589d99e9..a673302cce 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -33,7 +33,6 @@
#include "sysemu/qtest.h"
#include "hw/pci/pci.h"
#include "hw/mem/nvdimm.h"
-#include "hw/cxl/cxl.h"
#include "migration/global_state.h"
#include "migration/vmstate.h"
#include "exec/confidential-guest-support.h"
@@ -1075,10 +1074,6 @@ static void machine_initfn(Object *obj)
"Valid values are cpu, mem-ctrl");
}
- if (mc->cxl_supported) {
- ms->cxl_devices_state = g_new0(CXLState, 1);
- }
-
if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
ms->numa_state = g_new0(NumaState, 1);
object_property_add_bool(obj, "hmat",
@@ -1116,7 +1111,6 @@ static void machine_finalize(Object *obj)
g_free(ms->device_memory);
g_free(ms->nvdimms_state);
g_free(ms->numa_state);
- g_free(ms->cxl_devices_state);
}
bool machine_usb(MachineState *machine)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 663c34b9d1..73d0bf5937 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 9f48d02739..a0c0d69698 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)
--
MST
next prev parent reply other threads:[~2022-06-10 8:50 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 7:56 [PULL 00/54] virtio,pc,pci: fixes,cleanups,features Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 01/54] acpi: add interface to build device specific AML Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 02/54] acpi: make isa_build_aml() support AcpiDevAmlIf interface Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 03/54] acpi: fdc-isa: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 04/54] acpi: parallel port: " Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 05/54] acpi: serial-is: " Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 06/54] acpi: mc146818rtc: " Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 07/54] acpi: pckbd: " Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 08/54] isa-bus: drop no longer used ISADeviceClass::build_aml Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 09/54] tests: acpi: add and whitelist DSDT.ipmismbus expected blob Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 10/54] tests: acpi: q35: add test for smbus-ipmi device Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 11/54] tests: acpi: update expected blob DSDT.ipmismbus Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 12/54] tests: acpi: whitelist DSDT.ipmismbus expected blob Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 13/54] ipmi: acpi: use relative path to resource source Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 14/54] tests: acpi: update expected DSDT.ipmismbus blob Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 15/54] acpi: ich9-smb: add support for AcpiDevAmlIf interface Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 16/54] acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device descriptors Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 17/54] q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 18/54] tests: acpi: white-list to be re-factored pc/q35 DSDT Michael S. Tsirkin
2022-06-10 7:57 ` [PULL 19/54] acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors Michael S. Tsirkin
2023-03-28 12:58 ` Fiona Ebner
2023-03-30 8:22 ` Igor Mammedov
2023-03-30 11:58 ` Fiona Ebner
2023-04-12 12:18 ` Igor Mammedov
2023-04-13 10:32 ` Fiona Ebner
2023-04-13 11:46 ` Mike Maslenkin
2023-04-13 12:09 ` Fiona Ebner
2023-04-14 0:07 ` Mike Maslenkin
2023-04-14 7:19 ` Fiona Ebner
2022-06-10 7:58 ` [PULL 20/54] acpi: q35: " Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 21/54] tests: acpi: update expected blobs Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 22/54] tests: acpi: add and white-list DSDT.applesmc expected blob Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 23/54] tests: acpi: add applesmc testcase Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 24/54] acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 25/54] tests: acpi: update expected blobs Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 26/54] tests: acpi: white-lists expected DSDT.pvpanic-isa blob Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 27/54] tests: acpi: add pvpanic-isa: testcase Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 28/54] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 29/54] tests: acpi: update expected DSDT.pvpanic-isa blob Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 30/54] tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 31/54] acpi: pc/q35: tpm-tis: fix TPM device scope Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 32/54] acpi: pc/q35: remove not needed 'if' condition on pci bus Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 33/54] acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 34/54] tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 35/54] x86: acpi-build: do not include hw/isa/isa.h directly Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 36/54] hw/cxl: Make the CXL fixed memory window setup a machine parameter Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 37/54] hw/acpi/cxl: Pass in the CXLState directly rather than MachineState Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 38/54] hw/cxl: Push linking of CXL targets into i386/pc rather than in machine.c Michael S. Tsirkin
2022-06-10 7:58 ` [PULL 39/54] tests/acpi: Allow modification of q35 CXL CEDT table Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 40/54] pci/pci_expander_bridge: For CXL HB delay the HB register memory region setup Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 41/54] tests/acpi: Update q35/CEDT.cxl for new memory addresses Michael S. Tsirkin
2022-06-10 7:59 ` Michael S. Tsirkin [this message]
2022-06-10 7:59 ` [PULL 43/54] hw/machine: Drop cxl_supported flag as no longer useful Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 44/54] pci: fix overflow in snprintf string formatting Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 45/54] hw/cxl: Fix missing write mask for HDM decoder target list registers Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 46/54] hw/acpi/viot: rename build_pci_range_node() to enumerate_pci_host_bridges() Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 47/54] hw/acpi/viot: move the individual PCI host bridge entry generation to a new function Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 48/54] hw/acpi/viot: build array of PCI host bridges before generating VIOT ACPI table Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 49/54] tests/acpi: virt: allow VIOT acpi table changes Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 50/54] hw/acpi/viot: sort VIOT ACPI table entries by PCI host bridge min_bus Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 51/54] tests/acpi: virt: update golden masters for VIOT Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 52/54] hw/virtio/vhost-user: don't use uninitialized variable Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 53/54] hw/vhost-user-scsi|blk: set `supports_config` flag correctly Michael S. Tsirkin
2022-06-10 7:59 ` [PULL 54/54] crypto: Introduce RSA algorithm Michael S. Tsirkin
2022-06-10 15:55 ` Philippe Mathieu-Daudé via
2022-06-10 18:05 ` Richard Henderson
2022-06-11 0:35 ` Michael S. Tsirkin
2022-06-11 6:17 ` Richard Henderson
2022-06-11 2:03 ` zhenwei pi
2022-06-11 0:29 ` Michael S. Tsirkin
2022-07-14 9:16 ` [PULL 00/54] virtio,pc,pci: fixes,cleanups,features Peter Maydell
2022-07-14 11:41 ` Igor Mammedov
2022-07-14 16:09 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220610075631.367501-43-mst@redhat.com \
--to=mst@redhat.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=ani@anisinha.ca \
--cc=ben@bwidawsk.net \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=wangyanan55@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).