This patch is generated by this script: find ./ -name "*.[ch]" -o -name "*.json" -o -name "trace-events" -type f \ | xargs sed -i "s/PC_DIMM/DIMM/g" find ./ -name "*.[ch]" -o -name "*.json" -o -name "trace-events" -type f \ | xargs sed -i "s/PCDIMM/DIMM/g" find ./ -name "*.[ch]" -o -name "*.json" -o -name "trace-events" -type f \ | xargs sed -i "s/pc_dimm/dimm/g" find ./ -name "trace-events" -type f | xargs sed -i "s/pc-dimm/dimm/g" It prepares the work which abstracts dimm device type for both pc-dimm and nvdimm Signed-off-by: Xiao Guangrong <guangrong.xiao@xxxxxxxxxxxxxxx> --- hmp.c | 2 +- hw/acpi/ich9.c | 6 +- hw/acpi/memory_hotplug.c | 16 ++--- hw/acpi/piix4.c | 6 +- hw/i386/pc.c | 32 ++++----- hw/mem/pc-dimm.c | 148 ++++++++++++++++++++-------------------- hw/ppc/spapr.c | 18 ++--- include/hw/mem/pc-dimm.h | 62 ++++++++--------- numa.c | 2 +- qapi-schema.json | 8 +-- qmp.c | 2 +- stubs/qmp_pc_dimm_device_list.c | 2 +- trace-events | 8 +-- 13 files changed, 156 insertions(+), 156 deletions(-) diff --git a/hmp.c b/hmp.c index 5048eee..5c617d2 100644 --- a/hmp.c +++ b/hmp.c @@ -1952,7 +1952,7 @@ void hmp_info_memory_devices(Monitor *mon, const QDict *qdict) MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err); MemoryDeviceInfoList *info; MemoryDeviceInfo *value; - PCDIMMDeviceInfo *di; + DIMMDeviceInfo *di; for (info = info_list; info; info = info->next) { value = info->value; diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 1c7fcfa..b0d6a67 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -440,7 +440,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { if (pm->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_plug_cb(&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { @@ -455,7 +455,7 @@ void ich9_pm_device_unplug_request_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { if (pm->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_unplug_request_cb(&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug, dev, errp); } else { @@ -468,7 +468,7 @@ void ich9_pm_device_unplug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) { if (pm->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_unplug_cb(&pm->acpi_memory_hotplug, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 2ff0d5c..1f6cccc 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -54,23 +54,23 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr, o = OBJECT(mdev->dimm); switch (addr) { case 0x0: /* Lo part of phys address where DIMM is mapped */ - val = o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) : 0; + val = o ? object_property_get_int(o, DIMM_ADDR_PROP, NULL) : 0; trace_mhp_acpi_read_addr_lo(mem_st->selector, val); break; case 0x4: /* Hi part of phys address where DIMM is mapped */ - val = o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) >> 32 : 0; + val = o ? object_property_get_int(o, DIMM_ADDR_PROP, NULL) >> 32 : 0; trace_mhp_acpi_read_addr_hi(mem_st->selector, val); break; case 0x8: /* Lo part of DIMM size */ - val = o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) : 0; + val = o ? object_property_get_int(o, DIMM_SIZE_PROP, NULL) : 0; trace_mhp_acpi_read_size_lo(mem_st->selector, val); break; case 0xc: /* Hi part of DIMM size */ - val = o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) >> 32 : 0; + val = o ? object_property_get_int(o, DIMM_SIZE_PROP, NULL) >> 32 : 0; trace_mhp_acpi_read_size_hi(mem_st->selector, val); break; case 0x10: /* node proximity for _PXM method */ - val = o ? object_property_get_int(o, PC_DIMM_NODE_PROP, NULL) : 0; + val = o ? object_property_get_int(o, DIMM_NODE_PROP, NULL) : 0; trace_mhp_acpi_read_pxm(mem_st->selector, val); break; case 0x14: /* pack and return is_* fields */ @@ -151,13 +151,13 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data, /* call pc-dimm unplug cb */ hotplug_handler_unplug(hotplug_ctrl, dev, &local_err); if (local_err) { - trace_mhp_acpi_pc_dimm_delete_failed(mem_st->selector); + trace_mhp_acpi_dimm_delete_failed(mem_st->selector); qapi_event_send_mem_unplug_error(dev->id, error_get_pretty(local_err), &error_abort); break; } - trace_mhp_acpi_pc_dimm_deleted(mem_st->selector); + trace_mhp_acpi_dimm_deleted(mem_st->selector); } break; default: @@ -206,7 +206,7 @@ acpi_memory_slot_status(MemHotplugState *mem_st, DeviceState *dev, Error **errp) { Error *local_err = NULL; - int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, + int slot = object_property_get_int(OBJECT(dev), DIMM_SLOT_PROP, &local_err); if (local_err) { diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 2cd2fee..0b2cb6e 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -344,7 +344,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, PIIX4PMState *s = PIIX4_PM(hotplug_dev); if (s->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_plug_cb(&s->ar, s->irq, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { acpi_pcihp_device_plug_cb(&s->ar, s->irq, &s->acpi_pci_hotplug, dev, @@ -363,7 +363,7 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, PIIX4PMState *s = PIIX4_PM(hotplug_dev); if (s->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_unplug_request_cb(&s->ar, s->irq, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { @@ -381,7 +381,7 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, PIIX4PMState *s = PIIX4_PM(hotplug_dev); if (s->acpi_memory_hotplug.is_enabled && - object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { acpi_memory_unplug_cb(&s->acpi_memory_hotplug, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 682867a..d6b9fa7 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1609,15 +1609,15 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name) } } -static void pc_dimm_plug(HotplugHandler *hotplug_dev, +static void dimm_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; Error *local_err = NULL; PCMachineState *pcms = PC_MACHINE(hotplug_dev); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); - PCDIMMDevice *dimm = PC_DIMM(dev); - PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); + DIMMDevice *dimm = DIMM(dev); + DIMMDeviceClass *ddc = DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t align = TARGET_PAGE_SIZE; @@ -1631,7 +1631,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, goto out; } - pc_dimm_memory_plug(dev, &pcms->hotplug_memory, mr, align, + dimm_memory_plug(dev, &pcms->hotplug_memory, mr, align, pcmc->inter_dimm_gap, &local_err); if (local_err) { goto out; @@ -1643,7 +1643,7 @@ out: error_propagate(errp, local_err); } -static void pc_dimm_unplug_request(HotplugHandler *hotplug_dev, +static void dimm_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { HotplugHandlerClass *hhc; @@ -1663,12 +1663,12 @@ out: error_propagate(errp, local_err); } -static void pc_dimm_unplug(HotplugHandler *hotplug_dev, +static void dimm_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms = PC_MACHINE(hotplug_dev); - PCDIMMDevice *dimm = PC_DIMM(dev); - PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); + DIMMDevice *dimm = DIMM(dev); + DIMMDeviceClass *ddc = DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); HotplugHandlerClass *hhc; Error *local_err = NULL; @@ -1680,7 +1680,7 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_dev, goto out; } - pc_dimm_memory_unplug(dev, &pcms->hotplug_memory, mr); + dimm_memory_unplug(dev, &pcms->hotplug_memory, mr); object_unparent(OBJECT(dev)); out: @@ -1719,8 +1719,8 @@ out: static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_plug(hotplug_dev, dev, errp); + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { + dimm_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { pc_cpu_plug(hotplug_dev, dev, errp); } @@ -1729,8 +1729,8 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug_request(hotplug_dev, dev, errp); + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { + dimm_unplug_request(hotplug_dev, dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -1740,8 +1740,8 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - pc_dimm_unplug(hotplug_dev, dev, errp); + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { + dimm_unplug(hotplug_dev, dev, errp); } else { error_setg(errp, "acpi: device unplug for not supported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -1753,7 +1753,7 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine, { PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine); - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { return HOTPLUG_HANDLER(machine); } diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index a581622..9e26bf7 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -26,21 +26,21 @@ #include "sysemu/kvm.h" #include "trace.h" -typedef struct pc_dimms_capacity { +typedef struct dimms_capacity { uint64_t size; Error **errp; -} pc_dimms_capacity; +} dimms_capacity; static int existing_dimms_capacity_internal(Object *obj, void *opaque) { - pc_dimms_capacity *cap = opaque; + dimms_capacity *cap = opaque; uint64_t *size = &cap->size; - if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { + if (object_dynamic_cast(obj, TYPE_DIMM)) { DeviceState *dev = DEVICE(obj); if (dev->realized) { - (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP, + (*size) += object_property_get_int(obj, DIMM_SIZE_PROP, cap->errp); } @@ -54,7 +54,7 @@ static int existing_dimms_capacity_internal(Object *obj, void *opaque) static uint64_t existing_dimms_capacity(Error **errp) { - pc_dimms_capacity cap; + dimms_capacity cap; cap.size = 0; cap.errp = errp; @@ -63,23 +63,23 @@ static uint64_t existing_dimms_capacity(Error **errp) return cap.size; } -void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, +void dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, bool gap, Error **errp) { int slot; MachineState *machine = MACHINE(qdev_get_machine()); - PCDIMMDevice *dimm = PC_DIMM(dev); + DIMMDevice *dimm = DIMM(dev); Error *local_err = NULL; uint64_t dimms_capacity = 0; uint64_t addr; - addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); + addr = object_property_get_int(OBJECT(dimm), DIMM_ADDR_PROP, &local_err); if (local_err) { goto out; } - addr = pc_dimm_get_free_addr(hpms->base, + addr = dimm_get_free_addr(hpms->base, memory_region_size(&hpms->mr), !addr ? NULL : &addr, align, gap, memory_region_size(mr), &local_err); @@ -100,27 +100,27 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, goto out; } - object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err); + object_property_set_int(OBJECT(dev), addr, DIMM_ADDR_PROP, &local_err); if (local_err) { goto out; } - trace_mhp_pc_dimm_assigned_address(addr); + trace_mhp_dimm_assigned_address(addr); - slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err); + slot = object_property_get_int(OBJECT(dev), DIMM_SLOT_PROP, &local_err); if (local_err) { goto out; } - slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot, + slot = dimm_get_free_slot(slot == DIMM_UNASSIGNED_SLOT ? NULL : &slot, machine->ram_slots, &local_err); if (local_err) { goto out; } - object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err); + object_property_set_int(OBJECT(dev), slot, DIMM_SLOT_PROP, &local_err); if (local_err) { goto out; } - trace_mhp_pc_dimm_assigned_slot(slot); + trace_mhp_dimm_assigned_slot(slot); if (kvm_enabled() && !kvm_has_free_slot(machine)) { error_setg(&local_err, "hypervisor has no free memory slots left"); @@ -135,29 +135,29 @@ out: error_propagate(errp, local_err); } -void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, +void dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr) { - PCDIMMDevice *dimm = PC_DIMM(dev); + DIMMDevice *dimm = DIMM(dev); numa_unset_mem_node_id(dimm->addr, memory_region_size(mr), dimm->node); memory_region_del_subregion(&hpms->mr, mr); vmstate_unregister_ram(mr, dev); } -int qmp_pc_dimm_device_list(Object *obj, void *opaque) +int qmp_dimm_device_list(Object *obj, void *opaque) { MemoryDeviceInfoList ***prev = opaque; - if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { + if (object_dynamic_cast(obj, TYPE_DIMM)) { DeviceState *dev = DEVICE(obj); if (dev->realized) { MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1); MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1); - PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1); + DIMMDeviceInfo *di = g_new0(DIMMDeviceInfo, 1); DeviceClass *dc = DEVICE_GET_CLASS(obj); - PCDIMMDevice *dimm = PC_DIMM(obj); + DIMMDevice *dimm = DIMM(obj); if (dev->id) { di->has_id = true; @@ -168,7 +168,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque) di->addr = dimm->addr; di->slot = dimm->slot; di->node = dimm->node; - di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, + di->size = object_property_get_int(OBJECT(dimm), DIMM_SIZE_PROP, NULL); di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem)); @@ -180,7 +180,7 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque) } } - object_child_foreach(obj, qmp_pc_dimm_device_list, opaque); + object_child_foreach(obj, qmp_dimm_device_list, opaque); return 0; } @@ -191,7 +191,7 @@ ram_addr_t get_current_ram_size(void) MemoryDeviceInfoList *info; ram_addr_t size = ram_size; - qmp_pc_dimm_device_list(qdev_get_machine(), &prev); + qmp_dimm_device_list(qdev_get_machine(), &prev); for (info = info_list; info; info = info->next) { MemoryDeviceInfo *value = info->value; @@ -210,28 +210,28 @@ ram_addr_t get_current_ram_size(void) return size; } -static int pc_dimm_slot2bitmap(Object *obj, void *opaque) +static int dimm_slot2bitmap(Object *obj, void *opaque) { unsigned long *bitmap = opaque; - if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { + if (object_dynamic_cast(obj, TYPE_DIMM)) { DeviceState *dev = DEVICE(obj); if (dev->realized) { /* count only realized DIMMs */ - PCDIMMDevice *d = PC_DIMM(obj); + DIMMDevice *d = DIMM(obj); set_bit(d->slot, bitmap); } } - object_child_foreach(obj, pc_dimm_slot2bitmap, opaque); + object_child_foreach(obj, dimm_slot2bitmap, opaque); return 0; } -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp) +int dimm_get_free_slot(const int *hint, int max_slots, Error **errp) { unsigned long *bitmap = bitmap_new(max_slots); int slot = 0; - object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap); + object_child_foreach(qdev_get_machine(), dimm_slot2bitmap, bitmap); /* check if requested slot is not occupied */ if (hint) { @@ -256,10 +256,10 @@ out: return slot; } -static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b) +static gint dimm_addr_sort(gconstpointer a, gconstpointer b) { - PCDIMMDevice *x = PC_DIMM(a); - PCDIMMDevice *y = PC_DIMM(b); + DIMMDevice *x = DIMM(a); + DIMMDevice *y = DIMM(b); Int128 diff = int128_sub(int128_make64(x->addr), int128_make64(y->addr)); if (int128_lt(diff, int128_zero())) { @@ -270,22 +270,22 @@ static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b) return 0; } -static int pc_dimm_built_list(Object *obj, void *opaque) +static int dimm_built_list(Object *obj, void *opaque) { GSList **list = opaque; - if (object_dynamic_cast(obj, TYPE_PC_DIMM)) { + if (object_dynamic_cast(obj, TYPE_DIMM)) { DeviceState *dev = DEVICE(obj); if (dev->realized) { /* only realized DIMMs matter */ - *list = g_slist_insert_sorted(*list, dev, pc_dimm_addr_sort); + *list = g_slist_insert_sorted(*list, dev, dimm_addr_sort); } } - object_child_foreach(obj, pc_dimm_built_list, opaque); + object_child_foreach(obj, dimm_built_list, opaque); return 0; } -uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, +uint64_t dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, bool gap, uint64_t size, Error **errp) @@ -315,7 +315,7 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, } assert(address_space_end > address_space_start); - object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); + object_child_foreach(qdev_get_machine(), dimm_built_list, &list); if (hint) { new_addr = *hint; @@ -325,9 +325,9 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, /* find address range that will fit new DIMM */ for (item = list; item; item = g_slist_next(item)) { - PCDIMMDevice *dimm = item->data; + DIMMDevice *dimm = item->data; uint64_t dimm_size = object_property_get_int(OBJECT(dimm), - PC_DIMM_SIZE_PROP, + DIMM_SIZE_PROP, errp); if (errp && *errp) { goto out; @@ -359,20 +359,20 @@ out: return ret; } -static Property pc_dimm_properties[] = { - DEFINE_PROP_UINT64(PC_DIMM_ADDR_PROP, PCDIMMDevice, addr, 0), - DEFINE_PROP_UINT32(PC_DIMM_NODE_PROP, PCDIMMDevice, node, 0), - DEFINE_PROP_INT32(PC_DIMM_SLOT_PROP, PCDIMMDevice, slot, - PC_DIMM_UNASSIGNED_SLOT), +static Property dimm_properties[] = { + DEFINE_PROP_UINT64(DIMM_ADDR_PROP, DIMMDevice, addr, 0), + DEFINE_PROP_UINT32(DIMM_NODE_PROP, DIMMDevice, node, 0), + DEFINE_PROP_INT32(DIMM_SLOT_PROP, DIMMDevice, slot, + DIMM_UNASSIGNED_SLOT), DEFINE_PROP_END_OF_LIST(), }; -static void pc_dimm_get_size(Object *obj, Visitor *v, void *opaque, +static void dimm_get_size(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { int64_t value; MemoryRegion *mr; - PCDIMMDevice *dimm = PC_DIMM(obj); + DIMMDevice *dimm = DIMM(obj); mr = host_memory_backend_get_memory(dimm->hostmem, errp); value = memory_region_size(mr); @@ -380,7 +380,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, void *opaque, visit_type_int(v, &value, name, errp); } -static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name, +static void dimm_check_memdev_is_busy(Object *obj, const char *name, Object *val, Error **errp) { MemoryRegion *mr; @@ -395,65 +395,65 @@ static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name, } } -static void pc_dimm_init(Object *obj) +static void dimm_init(Object *obj) { - PCDIMMDevice *dimm = PC_DIMM(obj); + DIMMDevice *dimm = DIMM(obj); - object_property_add(obj, PC_DIMM_SIZE_PROP, "int", pc_dimm_get_size, + object_property_add(obj, DIMM_SIZE_PROP, "int", dimm_get_size, NULL, NULL, NULL, &error_abort); - object_property_add_link(obj, PC_DIMM_MEMDEV_PROP, TYPE_MEMORY_BACKEND, + object_property_add_link(obj, DIMM_MEMDEV_PROP, TYPE_MEMORY_BACKEND, (Object **)&dimm->hostmem, - pc_dimm_check_memdev_is_busy, + dimm_check_memdev_is_busy, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); } -static void pc_dimm_realize(DeviceState *dev, Error **errp) +static void dimm_realize(DeviceState *dev, Error **errp) { - PCDIMMDevice *dimm = PC_DIMM(dev); + DIMMDevice *dimm = DIMM(dev); if (!dimm->hostmem) { - error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set"); + error_setg(errp, "'" DIMM_MEMDEV_PROP "' property is not set"); return; } if (((nb_numa_nodes > 0) && (dimm->node >= nb_numa_nodes)) || (!nb_numa_nodes && dimm->node)) { - error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %" + error_setg(errp, "'DIMM property " DIMM_NODE_PROP " has value %" PRIu32 "' which exceeds the number of numa nodes: %d", dimm->node, nb_numa_nodes ? nb_numa_nodes : 1); return; } } -static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm) +static MemoryRegion *dimm_get_memory_region(DIMMDevice *dimm) { return host_memory_backend_get_memory(dimm->hostmem, &error_abort); } -static void pc_dimm_class_init(ObjectClass *oc, void *data) +static void dimm_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); - PCDIMMDeviceClass *ddc = PC_DIMM_CLASS(oc); + DIMMDeviceClass *ddc = DIMM_CLASS(oc); - dc->realize = pc_dimm_realize; - dc->props = pc_dimm_properties; + dc->realize = dimm_realize; + dc->props = dimm_properties; dc->desc = "DIMM memory module"; - ddc->get_memory_region = pc_dimm_get_memory_region; + ddc->get_memory_region = dimm_get_memory_region; } -static TypeInfo pc_dimm_info = { - .name = TYPE_PC_DIMM, +static TypeInfo dimm_info = { + .name = TYPE_DIMM, .parent = TYPE_DEVICE, - .instance_size = sizeof(PCDIMMDevice), - .instance_init = pc_dimm_init, - .class_init = pc_dimm_class_init, - .class_size = sizeof(PCDIMMDeviceClass), + .instance_size = sizeof(DIMMDevice), + .instance_init = dimm_init, + .class_init = dimm_class_init, + .class_size = sizeof(DIMMDeviceClass), }; -static void pc_dimm_register_types(void) +static void dimm_register_types(void) { - type_register_static(&pc_dimm_info); + type_register_static(&dimm_info); } -type_init(pc_dimm_register_types) +type_init(dimm_register_types) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d1b0e53..4fb91a5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2083,8 +2083,8 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, { Error *local_err = NULL; sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev); - PCDIMMDevice *dimm = PC_DIMM(dev); - PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); + DIMMDevice *dimm = DIMM(dev); + DIMMDeviceClass *ddc = DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t align = memory_region_get_alignment(mr); uint64_t size = memory_region_size(mr); @@ -2096,14 +2096,14 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, goto out; } - pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, false, &local_err); + dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, false, &local_err); if (local_err) { goto out; } - addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); + addr = object_property_get_int(OBJECT(dimm), DIMM_ADDR_PROP, &local_err); if (local_err) { - pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr); + dimm_memory_unplug(dev, &ms->hotplug_memory, mr); goto out; } @@ -2118,14 +2118,14 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, { sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine()); - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { int node; if (!smc->dr_lmb_enabled) { error_setg(errp, "Memory hotplug not supported for this machine"); return; } - node = object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP, errp); + node = object_property_get_int(OBJECT(dev), DIMM_NODE_PROP, errp); if (*errp) { return; } @@ -2159,7 +2159,7 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { error_setg(errp, "Memory hot unplug not supported by sPAPR"); } } @@ -2167,7 +2167,7 @@ static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev, static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_DIMM)) { return HOTPLUG_HANDLER(machine); } return NULL; diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index c1e5774..5ddbf08 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -13,39 +13,39 @@ * */ -#ifndef QEMU_PC_DIMM_H -#define QEMU_PC_DIMM_H +#ifndef QEMU_DIMM_H +#define QEMU_DIMM_H #include "exec/memory.h" #include "sysemu/hostmem.h" #include "hw/qdev.h" -#define TYPE_PC_DIMM "pc-dimm" -#define PC_DIMM(obj) \ - OBJECT_CHECK(PCDIMMDevice, (obj), TYPE_PC_DIMM) -#define PC_DIMM_CLASS(oc) \ - OBJECT_CLASS_CHECK(PCDIMMDeviceClass, (oc), TYPE_PC_DIMM) -#define PC_DIMM_GET_CLASS(obj) \ - OBJECT_GET_CLASS(PCDIMMDeviceClass, (obj), TYPE_PC_DIMM) +#define TYPE_DIMM "pc-dimm" +#define DIMM(obj) \ + OBJECT_CHECK(DIMMDevice, (obj), TYPE_DIMM) +#define DIMM_CLASS(oc) \ + OBJECT_CLASS_CHECK(DIMMDeviceClass, (oc), TYPE_DIMM) +#define DIMM_GET_CLASS(obj) \ + OBJECT_GET_CLASS(DIMMDeviceClass, (obj), TYPE_DIMM) -#define PC_DIMM_ADDR_PROP "addr" -#define PC_DIMM_SLOT_PROP "slot" -#define PC_DIMM_NODE_PROP "node" -#define PC_DIMM_SIZE_PROP "size" -#define PC_DIMM_MEMDEV_PROP "memdev" +#define DIMM_ADDR_PROP "addr" +#define DIMM_SLOT_PROP "slot" +#define DIMM_NODE_PROP "node" +#define DIMM_SIZE_PROP "size" +#define DIMM_MEMDEV_PROP "memdev" -#define PC_DIMM_UNASSIGNED_SLOT -1 +#define DIMM_UNASSIGNED_SLOT -1 /** - * PCDIMMDevice: - * @addr: starting guest physical address, where @PCDIMMDevice is mapped. + * DIMMDevice: + * @addr: starting guest physical address, where @DIMMDevice is mapped. * Default value: 0, means that address is auto-allocated. - * @node: numa node to which @PCDIMMDevice is attached. - * @slot: slot number into which @PCDIMMDevice is plugged in. + * @node: numa node to which @DIMMDevice is attached. + * @slot: slot number into which @DIMMDevice is plugged in. * Default value: -1, means that slot is auto-allocated. - * @hostmem: host memory backend providing memory for @PCDIMMDevice + * @hostmem: host memory backend providing memory for @DIMMDevice */ -typedef struct PCDIMMDevice { +typedef struct DIMMDevice { /* private */ DeviceState parent_obj; @@ -54,19 +54,19 @@ typedef struct PCDIMMDevice { uint32_t node; int32_t slot; HostMemoryBackend *hostmem; -} PCDIMMDevice; +} DIMMDevice; /** - * PCDIMMDeviceClass: + * DIMMDeviceClass: * @get_memory_region: returns #MemoryRegion associated with @dimm */ -typedef struct PCDIMMDeviceClass { +typedef struct DIMMDeviceClass { /* private */ DeviceClass parent_class; /* public */ - MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm); -} PCDIMMDeviceClass; + MemoryRegion *(*get_memory_region)(DIMMDevice *dimm); +} DIMMDeviceClass; /** * MemoryHotplugState: @@ -79,17 +79,17 @@ typedef struct MemoryHotplugState { MemoryRegion mr; } MemoryHotplugState; -uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, +uint64_t dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t align, bool gap, uint64_t size, Error **errp); -int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp); +int dimm_get_free_slot(const int *hint, int max_slots, Error **errp); -int qmp_pc_dimm_device_list(Object *obj, void *opaque); -void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, +int qmp_dimm_device_list(Object *obj, void *opaque); +void dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr, uint64_t align, bool gap, Error **errp); -void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, +void dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, MemoryRegion *mr); #endif diff --git a/numa.c b/numa.c index e9b18f5..cb69965 100644 --- a/numa.c +++ b/numa.c @@ -482,7 +482,7 @@ static void numa_stat_memory_devices(uint64_t node_mem[]) MemoryDeviceInfoList **prev = &info_list; MemoryDeviceInfoList *info; - qmp_pc_dimm_device_list(qdev_get_machine(), &prev); + qmp_dimm_device_list(qdev_get_machine(), &prev); for (info = info_list; info; info = info->next) { MemoryDeviceInfo *value = info->value; diff --git a/qapi-schema.json b/qapi-schema.json index 8b0520c..d8dd8b9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3684,9 +3684,9 @@ { 'command': 'query-memdev', 'returns': ['Memdev'] } ## -# @PCDIMMDeviceInfo: +# @DIMMDeviceInfo: # -# PCDIMMDevice state information +# DIMMDevice state information # # @id: #optional device's ID # @@ -3706,7 +3706,7 @@ # # Since: 2.1 ## -{ 'struct': 'PCDIMMDeviceInfo', +{ 'struct': 'DIMMDeviceInfo', 'data': { '*id': 'str', 'addr': 'int', 'size': 'int', @@ -3725,7 +3725,7 @@ # # Since: 2.1 ## -{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} } +{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'DIMMDeviceInfo'} } ## # @query-memory-devices diff --git a/qmp.c b/qmp.c index 057a7cb..6709aea 100644 --- a/qmp.c +++ b/qmp.c @@ -699,7 +699,7 @@ MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) MemoryDeviceInfoList *head = NULL; MemoryDeviceInfoList **prev = &head; - qmp_pc_dimm_device_list(qdev_get_machine(), &prev); + qmp_dimm_device_list(qdev_get_machine(), &prev); return head; } diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c index b584bd8..b2704c6 100644 --- a/stubs/qmp_pc_dimm_device_list.c +++ b/stubs/qmp_pc_dimm_device_list.c @@ -1,7 +1,7 @@ #include "qom/object.h" #include "hw/mem/pc-dimm.h" -int qmp_pc_dimm_device_list(Object *obj, void *opaque) +int qmp_dimm_device_list(Object *obj, void *opaque) { return 0; } diff --git a/trace-events b/trace-events index b813ae4..06c76f2 100644 --- a/trace-events +++ b/trace-events @@ -1639,12 +1639,12 @@ mhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "slot[0x%"PRIx32"] OST EVENT: mhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "slot[0x%"PRIx32"] OST STATUS: 0x%"PRIx32 mhp_acpi_clear_insert_evt(uint32_t slot) "slot[0x%"PRIx32"] clear insert event" mhp_acpi_clear_remove_evt(uint32_t slot) "slot[0x%"PRIx32"] clear remove event" -mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted" -mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm delete failed" +mhp_acpi_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] dimm deleted" +mhp_acpi_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] dimm delete failed" # hw/i386/pc.c -mhp_pc_dimm_assigned_slot(int slot) "0x%d" -mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64 +mhp_dimm_assigned_slot(int slot) "0x%d" +mhp_dimm_assigned_address(uint64_t addr) "0x%"PRIx64 # target-s390x/kvm.c kvm_enable_cmma(int rc) "CMMA: enabling with result code %d" -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html