From nobody Mon Feb 9 08:10:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621009501; cv=none; d=zohomail.com; s=zohoarc; b=SxVmIFvrXhqGrBhaB6TIgKsx/xXC4K9ptcyK9upivaXQmExhuhqc00DPF/4t4ZtL3bTsPkQuRYb3fWhUxlCrL5z6IjNrlZZIrKvUNuKLuj8DjAwrkJ7bC/VKBkok3B/HUXCK7o6OIA6T0K1sZ8gWIA3Uo17pY3lPUmSeZTecfrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621009501; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=upZeNF4eA0t53yo34zKkvSJygTJZcKC6c3bGqY8MELc=; b=Nz5l5eXD4LrZwsEQzpq/rtwXJcfoK6zDTMhKPLBqHn/4W1A+HcNzhcYOZtoubtFQhyqmHGaoSqiNY4nQ++HY0LuDyMLbt/iWWTo+tgpZN9eh16bqvoYXMsiawtlwFbhyPIQPlScM7ax6s9hWMAvRj7E5vzUW8BKDZ9pi1vxXewI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621009501922706.2168583994817; Fri, 14 May 2021 09:25:01 -0700 (PDT) Received: from localhost ([::1]:39150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhacW-00078p-FS for importer@patchew.org; Fri, 14 May 2021 12:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhaIm-0006lB-96 for qemu-devel@nongnu.org; Fri, 14 May 2021 12:04:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhaIj-0005Qd-TL for qemu-devel@nongnu.org; Fri, 14 May 2021 12:04:35 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-520-nAFIMs7HMWWfUfL-FS43KQ-1; Fri, 14 May 2021 12:04:28 -0400 Received: by mail-wm1-f70.google.com with SMTP id g206-20020a1c39d70000b029016ac627fbe9so6836wma.9 for ; Fri, 14 May 2021 09:04:28 -0700 (PDT) Received: from redhat.com ([2a10:800c:1fa6:0:3809:fe0c:bb87:250e]) by smtp.gmail.com with ESMTPSA id a1sm2782230wmm.7.2021.05.14.09.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 09:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621008273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=upZeNF4eA0t53yo34zKkvSJygTJZcKC6c3bGqY8MELc=; b=HNH0n/vQ4PDExjcUhtSHwDSp7kYtasNxzLIHXScv/FEshEhWsSzfVQfizGULKZ0vjFtRfq 5niZywR1FNr9ZiwneDSHjsp9VlKL9sNnnsNcryHo9F886kJYFLgwVlMSJIyXkvrLjJMAxv LcI+Nn2X7gsh3LKc24UAlGCxSGT39SE= X-MC-Unique: nAFIMs7HMWWfUfL-FS43KQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=upZeNF4eA0t53yo34zKkvSJygTJZcKC6c3bGqY8MELc=; b=Bwg+eb+ulwfv7BNQqNJi/MC3Ltld/i4nODyp6hlZXd2RxjYb0tPt0aXFb6bNoQzz9b afYo1D1GdDiS9QEYI8ZHrm2EAXClACtpyGVh4BNqtp+V6XoYnq6vwNyWc3y4k/tpzDwm yUpqTavu99pJEgMQumJDtp8lfmaMjygz4sOrNcesOWL5aP33uS+olAAEajxykDzI45Y4 L5LKXhfhQGB8eweDzwcslt9H1rrwqyoVJJ+P5QAteDE0t0/CmTDq5VVqPz76FT1HvbM5 q0wq5zOgE++DSxXPDzBnl4/y0NGHcjRYTj/gJ0PlZy28DmPWENecRQ1ehr47YmxwH76w x/ww== X-Gm-Message-State: AOAM531ypNfVbsxV8+s5c7UCYpjTza/oNEyFtUwcTDfdAFuePifi8NLd n+PG1akceSwG98I9nKYpGfZF1bqyQpPL0YKw4fQzqaB2k3Kp65DNOGDHqB1LORaFI51VtOngos6 oooUpzHSgYo/dOGE2iFIEF22eID6eBbJmwRFF24B/GzJKx6ujEE84W69DmLS0 X-Received: by 2002:adf:bc46:: with SMTP id a6mr21656637wrh.232.1621008266673; Fri, 14 May 2021 09:04:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0Ftkp4ILuDFhDMzHUHnw0pIlvv26FuDtrrUezXJtHL7kZeS7jRZHGuz7Y1J54CD9mFK34/w== X-Received: by 2002:adf:bc46:: with SMTP id a6mr21656597wrh.232.1621008266364; Fri, 14 May 2021 09:04:26 -0700 (PDT) Date: Fri, 14 May 2021 12:04:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/16] pc-dimm: remove unnecessary get_vmstate_memory_region() method Message-ID: <20210514160245.91918-8-mst@redhat.com> References: <20210514160245.91918-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210514160245.91918-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Peter Maydell , "Maciej S. Szmigiero" , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable 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. This saves us from having to do an indirect call in order to reach it. Signed-off-by: Maciej S. Szmigiero Message-Id: Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/mem/pc-dimm.h | 5 ----- hw/mem/pc-dimm.c | 33 ++++++++++++++------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 3d3db82641..1473e6db62 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, diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 12b655eda8..a3a2560301 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) { - 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) =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 */ --=20 MST