From nobody Wed Oct 29 22:59:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525713236279490.2556256110405; Mon, 7 May 2018 10:13:56 -0700 (PDT) Received: from localhost ([::1]:47291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFjhy-00066u-QF for importer@patchew.org; Mon, 07 May 2018 13:13:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fFjY0-0006OZ-67 for qemu-devel@nongnu.org; Mon, 07 May 2018 13:03:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fFjXz-0007ZT-0e for qemu-devel@nongnu.org; Mon, 07 May 2018 13:03:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53616) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fFjXy-0007Yq-Pb for qemu-devel@nongnu.org; Mon, 07 May 2018 13:03:34 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAFA8804E2; Mon, 7 May 2018 17:03:33 +0000 (UTC) Received: from localhost (ovpn-116-33.gru2.redhat.com [10.97.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B979D31320A0; Mon, 7 May 2018 17:03:30 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Mon, 7 May 2018 14:03:06 -0300 Message-Id: <20180507170315.11497-4-ehabkost@redhat.com> In-Reply-To: <20180507170315.11497-1-ehabkost@redhat.com> References: <20180507170315.11497-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 May 2018 17:03:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/12] pc-dimm: no need to pass the memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We can just query it ourselves. When unplugging, we should always be able to the region (as it was previously plugged). E.g. PPC already assumed that and used &error_abort. Signed-off-by: David Hildenbrand Message-Id: <20180423165126.15441-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost --- include/hw/mem/pc-dimm.h | 5 ++--- hw/i386/pc.c | 13 ++----------- hw/mem/pc-dimm.c | 12 +++++++++--- hw/ppc/spapr.c | 9 +++------ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 8bda37adab..1d26e13cef 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -85,7 +85,6 @@ int pc_dimm_get_free_slot(const int *hint, int max_slots,= Error **errp); =20 uint64_t pc_existing_dimms_capacity(Error **errp); void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, - MemoryRegion *mr, uint64_t align, Error **errp); -void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, - MemoryRegion *mr); + uint64_t align, Error **errp); +void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms); #endif diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0aa7885798..e337c6552d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1715,8 +1715,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, goto out; } =20 - pc_dimm_memory_plug(dev, MACHINE(pcms)->device_memory, mr, align, - &local_err); + pc_dimm_memory_plug(dev, MACHINE(pcms)->device_memory, align, &local_e= rr); if (local_err) { goto out; } @@ -1766,17 +1765,9 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); - PCDIMMDevice *dimm =3D PC_DIMM(dev); - PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr; HotplugHandlerClass *hhc; Error *local_err =3D NULL; =20 - mr =3D ddc->get_memory_region(dimm, &local_err); - if (local_err) { - goto out; - } - hhc =3D HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); =20 @@ -1784,7 +1775,7 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_de= v, goto out; } =20 - pc_dimm_memory_unplug(dev, MACHINE(pcms)->device_memory, mr); + pc_dimm_memory_unplug(dev, MACHINE(pcms)->device_memory); object_unparent(OBJECT(dev)); =20 out: diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index ef330628c1..aeff369f6f 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -37,7 +37,7 @@ typedef struct pc_dimms_capacity { } pc_dimms_capacity; =20 void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms, - MemoryRegion *mr, uint64_t align, Error **errp) + uint64_t align, Error **errp) { int slot; MachineState *machine =3D MACHINE(qdev_get_machine()); @@ -46,8 +46,14 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplug= State *hpms, MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); Error *local_err =3D NULL; uint64_t existing_dimms_capacity =3D 0; + MemoryRegion *mr; uint64_t addr; =20 + mr =3D ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + addr =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { @@ -116,12 +122,12 @@ out: error_propagate(errp, local_err); } =20 -void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms, - MemoryRegion *mr) +void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms) { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *vmstate_mr =3D ddc->get_vmstate_memory_region(dimm); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); =20 memory_region_del_subregion(&hpms->mr, mr); vmstate_unregister_ram(vmstate_mr, dev); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 30d634a8a3..d4917e89c6 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3153,7 +3153,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, align =3D memory_region_get_alignment(mr); size =3D memory_region_size(mr); =20 - pc_dimm_memory_plug(dev, MACHINE(ms)->device_memory, mr, align, &local= _err); + pc_dimm_memory_plug(dev, MACHINE(ms)->device_memory, align, &local_err= ); if (local_err) { goto out; } @@ -3174,7 +3174,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, return; =20 out_unplug: - pc_dimm_memory_unplug(dev, MACHINE(ms)->device_memory, mr); + pc_dimm_memory_unplug(dev, MACHINE(ms)->device_memory); out: error_propagate(errp, local_err); } @@ -3292,9 +3292,6 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_sta= te(sPAPRMachineState *ms, void spapr_lmb_release(DeviceState *dev) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_hotplug_handler(de= v)); - PCDIMMDevice *dimm =3D PC_DIMM(dev); - PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); sPAPRDIMMState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 /* This information will get lost if a migration occurs @@ -3314,7 +3311,7 @@ void spapr_lmb_release(DeviceState *dev) * Now that all the LMBs have been removed by the guest, call the * pc-dimm unplug handler to cleanup up the pc-dimm device. */ - pc_dimm_memory_unplug(dev, MACHINE(spapr)->device_memory, mr); + pc_dimm_memory_unplug(dev, MACHINE(spapr)->device_memory); object_unparent(OBJECT(dev)); spapr_pending_dimm_unplugs_remove(spapr, ds); } --=20 2.14.3