From nobody Thu May 16 07:28:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1600608403; cv=none; d=zohomail.com; s=zohoarc; b=mKrirs5WVCQzTDE4FHAcSrcTDOKcdnCaO3jx/ZnHnLu1ucXzS5wYl9UGaJYWiiEmB3IkxqChzmaDPjyl+AgWzJMs0pocoVGADIdgkaPfNNAWWMIKB2/+wwvuKh4gYh3SX6YX2yaJ0syPh0KIgv2gZ/TUzbxYh165uNLWtp7DZGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600608403; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=OIhHms1RO1DJG4mwxY+HRWhseInW/kB/zOvQYDnzRSQ=; b=HRRI+r1AKJG7/DCENV4pyzTec3UV0LJfWFx+C7P6xgvkA7i/j9Mu7wcWdDz5/G6QTK+PbSO0V/KiHTZLlVq7BoWhC86Ie0tOhEuMCH4OAuKhWSdoZE+wk43ZptV+dK36W+MIUlMz71XFNEp6nyydHZ7pUgB8IZu/YOks3hoPBNM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600608402882598.9795079901342; Sun, 20 Sep 2020 06:26:42 -0700 (PDT) Received: from localhost ([::1]:37274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJzMW-0005I1-Mg for importer@patchew.org; Sun, 20 Sep 2020 09:26:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJzLb-00044Z-Qx for qemu-devel@nongnu.org; Sun, 20 Sep 2020 09:25:43 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:44286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJzLX-00037p-Ul for qemu-devel@nongnu.org; Sun, 20 Sep 2020 09:25:43 -0400 Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.93.0.4) (envelope-from ) id 1kJzLM-00087M-DX; Sun, 20 Sep 2020 15:25:28 +0200 From: "Maciej S. Szmigiero" To: "Michael S. Tsirkin" , Igor Mammedov Subject: [PATCH] pc-dimm: remove unnecessary get_vmstate_memory_region() method Date: Sun, 20 Sep 2020 15:25:18 +0200 Message-Id: <9476ea5c7dc758b9b083a232eeb8d9b380b5e138.1600556464.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=37.28.154.113; envelope-from=mail@maciej.szmigiero.name; helo=vps-vb.mhejs.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 09:25:30 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Ostrovsky , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Maciej S. Szmigiero" The get_vmstate_memory_region() method from PCDIMMDeviceClass is only ever called from this class and is never overridden, so it can be converted into an ordinary function. Signed-off-by: Maciej S. Szmigiero --- hw/mem/pc-dimm.c | 33 ++++++++++++++------------------- include/hw/mem/pc-dimm.h | 5 ----- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index c30351070bb8..01c133f3b864 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -34,6 +34,16 @@ =20 static int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **e= rrp); =20 +static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error *= *errp) +{ + if (!dimm->hostmem) { + error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property must be set"); + return NULL; + } + + return host_memory_backend_get_memory(dimm->hostmem); +} + void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine, const uint64_t *legacy_align, Error **errp) { @@ -66,9 +76,8 @@ void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *m= achine, =20 void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machine, Error **errp) { - PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, - &error_abort= ); + MemoryRegion *vmstate_mr =3D pc_dimm_get_memory_region(dimm, + &error_abort); =20 memory_device_plug(MEMORY_DEVICE(dimm), machine); vmstate_register_ram(vmstate_mr, DEVICE(dimm)); @@ -76,9 +85,8 @@ void pc_dimm_plug(PCDIMMDevice *dimm, MachineState *machi= ne, Error **errp) =20 void pc_dimm_unplug(PCDIMMDevice *dimm, MachineState *machine) { - PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm, - &error_abort= ); + MemoryRegion *vmstate_mr =3D pc_dimm_get_memory_region(dimm, + &error_abort); =20 memory_device_unplug(MEMORY_DEVICE(dimm), machine); vmstate_unregister_ram(vmstate_mr, DEVICE(dimm)); @@ -205,16 +213,6 @@ static void pc_dimm_unrealize(DeviceState *dev) host_memory_backend_set_mapped(dimm->hostmem, false); } =20 -static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error *= *errp) -{ - if (!dimm->hostmem) { - error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property must be set"); - return NULL; - } - - return host_memory_backend_get_memory(dimm->hostmem); -} - static uint64_t pc_dimm_md_get_addr(const MemoryDeviceState *md) { return object_property_get_uint(OBJECT(md), PC_DIMM_ADDR_PROP, @@ -266,7 +264,6 @@ static void pc_dimm_md_fill_device_info(const MemoryDev= iceState *md, static void pc_dimm_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - PCDIMMDeviceClass *ddc =3D PC_DIMM_CLASS(oc); MemoryDeviceClass *mdc =3D MEMORY_DEVICE_CLASS(oc); =20 dc->realize =3D pc_dimm_realize; @@ -274,8 +271,6 @@ static void pc_dimm_class_init(ObjectClass *oc, void *d= ata) device_class_set_props(dc, pc_dimm_properties); dc->desc =3D "DIMM memory module"; =20 - ddc->get_vmstate_memory_region =3D pc_dimm_get_memory_region; - mdc->get_addr =3D pc_dimm_md_get_addr; mdc->set_addr =3D pc_dimm_md_set_addr; /* for a dimm plugged_size =3D=3D region_size */ diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 1d570defc95b..6874d34943f8 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -56,9 +56,6 @@ struct PCDIMMDevice { * PCDIMMDeviceClass: * @realize: called after common dimm is realized so that the dimm based * devices get the chance to do specified operations. - * @get_vmstate_memory_region: returns #MemoryRegion which indicates the - * memory of @dimm should be kept during live migration. Will not fail - * after the device was realized. */ struct PCDIMMDeviceClass { /* private */ @@ -66,8 +63,6 @@ struct PCDIMMDeviceClass { =20 /* public */ void (*realize)(PCDIMMDevice *dimm, Error **errp); - MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm, - Error **errp); }; =20 void pc_dimm_pre_plug(PCDIMMDevice *dimm, MachineState *machine,