From nobody Thu Nov 6 20:31:51 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487745367443310.34781843886606; Tue, 21 Feb 2017 22:36:07 -0800 (PST) Received: from localhost ([::1]:50126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQX0-0004Tg-3z for importer@patchew.org; Wed, 22 Feb 2017 01:36:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQV0-0002wv-3g for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQUx-0007os-1P for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:02 -0500 Received: from ozlabs.org ([103.22.144.67]:34287) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQUw-0007nI-Ks; Wed, 22 Feb 2017 01:33:58 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndG5FkYz9s7g; Wed, 22 Feb 2017 17:33:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745234; bh=02vfp9zMjVVNBKVk6ufayEMr2VJilTxE3FAMBVXWWMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCwV2PZ9PpXelzCJmPukp6G5lYmQSECC/Gd3ZotNnpd6ENTSScX0l5E0hKJuNKNAE +4TD1GHUAWYcg4lFBNRRYP4ee9M+bojOmajeKREGuYzQUESl5vOcrYJQ7PIpogt7yc JDuM2pGn9wYe0JIV/xGZKLma4Km8ni/QwKIVcLX8= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:08 +1100 Message-Id: <20170222063348.32176-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170222063348.32176-1-david@gibson.dropbear.id.au> References: <20170222063348.32176-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 03/43] spapr: make cpu core unplug follow expected hotunplug call flow 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, imammedo@redhat.com, David Gibson 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: Igor Mammedov spapr_core_unplug() were essentially spapr_core_unplug_request() handler that requested CPU removal and registered callback which did actual cpu core removali but it was called from spapr_machine_device_unplug() which is intended for actual object removal. Commit (cf632463 spapr: Memory hot-unplug support) sort of fixed it introducing spapr_machine_device_unplug_request() and calling spapr_core_unplug() but it hasn't renamed callback and by mistake calls it from spapr_machine_device_unplug(). However spapr_machine_device_unplug() isn't ever called for cpu core since spapr_core_release() doesn't follow expected hotunplug call flow which is: 1: device_del() -> hotplug_handler_unplug_request() -> set destroy_cb() 2: destroy_cb() -> hotplug_handler_unplug() -> object_unparent // actual device removal Fix it by renaming spapr_core_unplug() to spapr_core_unplug_request() which is called from spapr_machine_device_unplug_request() and making spapr_core_release() call hotplug_handler_unplug() which will call spapr_machine_device_unplug() -> spapr_core_unplug() to remove cpu core. Signed-off-by: Igor Mammedov Reveiwed-by: Bharata B Rao Signed-off-by: David Gibson --- hw/ppc/spapr.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8c2efd8..37cb338 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2488,7 +2488,8 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int= *fdt_offset, return fdt; } =20 -static void spapr_core_release(DeviceState *dev, void *opaque) +static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v, + Error **errp) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); CPUCore *cc =3D CPU_CORE(dev); @@ -2497,8 +2498,17 @@ static void spapr_core_release(DeviceState *dev, voi= d *opaque) object_unparent(OBJECT(dev)); } =20 -static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v, - Error **errp) +static void spapr_core_release(DeviceState *dev, void *opaque) +{ + HotplugHandler *hotplug_ctrl; + + hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); +} + +static +void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) { CPUCore *cc =3D CPU_CORE(dev); int smt =3D kvmppc_smt_threads(); @@ -2719,7 +2729,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, error_setg(errp, "CPU hot unplug not supported on this machine= "); return; } - spapr_core_unplug(hotplug_dev, dev, errp); + spapr_core_unplug_request(hotplug_dev, dev, errp); } } =20 --=20 2.9.3