Message ID | 20191004155302.4632-4-shameerali.kolothum.thodi@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ARM virt: Add NVDIMM support | expand |
On Fri, 4 Oct 2019 16:53:00 +0100 Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> wrote: > From: Kwangwoo Lee <kwangwoo.lee@sk.com> > > Pre-plug and plug handlers are prepared for NVDIMM support. Prepare pre-plug and plug handlers for NVDIMM support. > Please note nvdimm_support is not yet enabled. > > Signed-off-by: Eric Auger <eric.auger@redhat.com> > Signed-off-by: Kwangwoo Lee <kwangwoo.lee@sk.com> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> > --- > hw/arm/Kconfig | 1 + > hw/arm/virt-acpi-build.c | 6 ++++++ > hw/arm/virt.c | 22 +++++++++++++++++++++- > hw/mem/Kconfig | 2 +- > include/hw/arm/virt.h | 1 + > 5 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig > index c6e7782580..851dd81289 100644 > --- a/hw/arm/Kconfig > +++ b/hw/arm/Kconfig > @@ -24,6 +24,7 @@ config ARM_VIRT > select DIMM > select ACPI_MEMORY_HOTPLUG > select ACPI_HW_REDUCED > + select ACPI_NVDIMM > > config CHEETAH > bool > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index 074e0c858e..4e63f5da48 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -44,6 +44,7 @@ > #include "hw/pci/pcie_host.h" > #include "hw/pci/pci.h" > #include "hw/arm/virt.h" > +#include "hw/mem/nvdimm.h" > #include "sysemu/numa.h" > #include "sysemu/reset.h" > #include "kvm_arm.h" > @@ -835,6 +836,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) > } > } > > + if (ms->nvdimms_state->is_enabled) { > + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, > + ms->nvdimms_state, ms->ram_slots); > + } > + > if (its_class_name() && !vmc->no_its) { > acpi_add_table(table_offsets, tables_blob); > build_iort(tables_blob, tables->linker, vms); > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index d4bedc2607..30bc8a7803 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -143,6 +143,7 @@ static const MemMapEntry base_memmap[] = { > [VIRT_SMMU] = { 0x09050000, 0x00020000 }, > [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, > [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, > + [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, > [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, > /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ > [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, > @@ -1750,6 +1751,18 @@ static void machvirt_init(MachineState *machine) > > create_platform_bus(vms, pic); > > + if (machine->nvdimms_state->is_enabled) { > + const struct AcpiGenericAddress arm_virt_nvdimm_acpi_dsmio = { > + .space_id = AML_AS_SYSTEM_MEMORY, > + .address = vms->memmap[VIRT_NVDIMM_ACPI].base, > + .bit_width = NVDIMM_ACPI_IO_LEN << 3 > + }; > + > + nvdimm_init_acpi_state(machine->nvdimms_state, sysmem, > + arm_virt_nvdimm_acpi_dsmio, > + vms->fw_cfg, OBJECT(vms)); > + } > + > vms->bootinfo.ram_size = machine->ram_size; > vms->bootinfo.nb_cpus = smp_cpus; > vms->bootinfo.board_id = -1; > @@ -1916,9 +1929,10 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, > Error **errp) > { > VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); > + MachineState *ms = MACHINE(hotplug_dev); > const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); > > - if (is_nvdimm) { > + if (is_nvdimm && (!ms->nvdimms_state->is_enabled)) { shouldn't shouldn't this hunk go to 5/5 where functionality is eventually enabled and use the same error message as in pc_memory_pre_plug() > error_setg(errp, "nvdimm is not yet supported"); > return; > } > @@ -1937,6 +1951,8 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, > { > HotplugHandlerClass *hhc; > VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); > + MachineState *ms = MACHINE(hotplug_dev); > + bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); > Error *local_err = NULL; > > pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); > @@ -1944,6 +1960,10 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, > goto out; > } > > + if (is_nvdimm) { > + nvdimm_plug(ms->nvdimms_state); > + } > + > hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); > hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort); > out: > diff --git a/hw/mem/Kconfig b/hw/mem/Kconfig > index 620fd4cb59..0d5f8f321a 100644 > --- a/hw/mem/Kconfig > +++ b/hw/mem/Kconfig > @@ -8,4 +8,4 @@ config MEM_DEVICE > config NVDIMM > bool > default y > - depends on PC > + depends on PC || ARM_VIRT > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h > index 0b41083e9d..06d5e75611 100644 > --- a/include/hw/arm/virt.h > +++ b/include/hw/arm/virt.h > @@ -79,6 +79,7 @@ enum { > VIRT_SECURE_MEM, > VIRT_PCDIMM_ACPI, > VIRT_ACPI_GED, > + VIRT_NVDIMM_ACPI, > VIRT_LOWMEMMAP_LAST, > }; >
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index c6e7782580..851dd81289 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -24,6 +24,7 @@ config ARM_VIRT select DIMM select ACPI_MEMORY_HOTPLUG select ACPI_HW_REDUCED + select ACPI_NVDIMM config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 074e0c858e..4e63f5da48 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -44,6 +44,7 @@ #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" +#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" #include "kvm_arm.h" @@ -835,6 +836,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) } } + if (ms->nvdimms_state->is_enabled) { + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, + ms->nvdimms_state, ms->ram_slots); + } + if (its_class_name() && !vmc->no_its) { acpi_add_table(table_offsets, tables_blob); build_iort(tables_blob, tables->linker, vms); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d4bedc2607..30bc8a7803 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -143,6 +143,7 @@ static const MemMapEntry base_memmap[] = { [VIRT_SMMU] = { 0x09050000, 0x00020000 }, [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, + [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -1750,6 +1751,18 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); + if (machine->nvdimms_state->is_enabled) { + const struct AcpiGenericAddress arm_virt_nvdimm_acpi_dsmio = { + .space_id = AML_AS_SYSTEM_MEMORY, + .address = vms->memmap[VIRT_NVDIMM_ACPI].base, + .bit_width = NVDIMM_ACPI_IO_LEN << 3 + }; + + nvdimm_init_acpi_state(machine->nvdimms_state, sysmem, + arm_virt_nvdimm_acpi_dsmio, + vms->fw_cfg, OBJECT(vms)); + } + vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.nb_cpus = smp_cpus; vms->bootinfo.board_id = -1; @@ -1916,9 +1929,10 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + MachineState *ms = MACHINE(hotplug_dev); const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); - if (is_nvdimm) { + if (is_nvdimm && (!ms->nvdimms_state->is_enabled)) { error_setg(errp, "nvdimm is not yet supported"); return; } @@ -1937,6 +1951,8 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, { HotplugHandlerClass *hhc; VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + MachineState *ms = MACHINE(hotplug_dev); + bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); Error *local_err = NULL; pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); @@ -1944,6 +1960,10 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, goto out; } + if (is_nvdimm) { + nvdimm_plug(ms->nvdimms_state); + } + hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &error_abort); out: diff --git a/hw/mem/Kconfig b/hw/mem/Kconfig index 620fd4cb59..0d5f8f321a 100644 --- a/hw/mem/Kconfig +++ b/hw/mem/Kconfig @@ -8,4 +8,4 @@ config MEM_DEVICE config NVDIMM bool default y - depends on PC + depends on PC || ARM_VIRT diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 0b41083e9d..06d5e75611 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -79,6 +79,7 @@ enum { VIRT_SECURE_MEM, VIRT_PCDIMM_ACPI, VIRT_ACPI_GED, + VIRT_NVDIMM_ACPI, VIRT_LOWMEMMAP_LAST, };