From nobody Sat May 4 09:14:45 2024 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 1486049534319920.6056741582147; Thu, 2 Feb 2017 07:32:14 -0800 (PST) Received: from localhost ([::1]:57294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJMp-0007xA-GQ for importer@patchew.org; Thu, 02 Feb 2017 10:32:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIuL-0006Od-0l for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIuH-0001Tk-Qu for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIuH-0001TK-L5; Thu, 02 Feb 2017 10:02:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF936A89D; Thu, 2 Feb 2017 15:02:41 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12F2cLB030842; Thu, 2 Feb 2017 10:02:40 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 16:02:33 +0100 Message-Id: <1486047755-93584-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1486047755-93584-1-git-send-email-imammedo@redhat.com> References: <1486047755-93584-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 02 Feb 2017 15:02:41 +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] [PATCH 1/3] spapr: cpu core: separate child threads destruction from machine state operations 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: Bharata B Rao , qemu-ppc@nongnu.org, Alexander Graf , 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" Signed-off-by: Igor Mammedov --- hw/ppc/spapr_cpu_core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 9dddaeb..b9e5f80 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -111,11 +111,19 @@ char *spapr_get_cpu_core_type(const char *model) =20 static void spapr_core_release(DeviceState *dev, void *opaque) { + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + CPUCore *cc =3D CPU_CORE(dev); + + spapr->cores[cc->core_id / smp_threads] =3D NULL; + object_unparent(OBJECT(dev)); +} + +static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) +{ sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_GET_CLASS(OBJECT(dev)); const char *typename =3D object_class_get_name(scc->cpu_class); size_t size =3D object_type_get_instance_size(typename); - sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); CPUCore *cc =3D CPU_CORE(dev); int i; =20 @@ -129,11 +137,7 @@ static void spapr_core_release(DeviceState *dev, void = *opaque) cpu_remove_sync(cs); object_unparent(obj); } - - spapr->cores[cc->core_id / smp_threads] =3D NULL; - g_free(sc->threads); - object_unparent(OBJECT(dev)); } =20 void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, @@ -368,6 +372,7 @@ void spapr_cpu_core_class_init(ObjectClass *oc, void *d= ata) sPAPRCPUCoreClass *scc =3D SPAPR_CPU_CORE_CLASS(oc); =20 dc->realize =3D spapr_cpu_core_realize; + dc->unrealize =3D spapr_cpu_core_unrealizefn; scc->cpu_class =3D cpu_class_by_name(TYPE_POWERPC_CPU, data); g_assert(scc->cpu_class); } --=20 2.7.4 From nobody Sat May 4 09:14:45 2024 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 1486049791233726.6249239658775; Thu, 2 Feb 2017 07:36:31 -0800 (PST) Received: from localhost ([::1]:57315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJQx-0003R8-Pn for importer@patchew.org; Thu, 02 Feb 2017 10:36:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIuL-0006Oh-2x for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIuJ-0001Uu-FJ for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIuJ-0001UA-7r; Thu, 02 Feb 2017 10:02:43 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45005C04D2F2; Thu, 2 Feb 2017 15:02:43 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12F2cLC030842; Thu, 2 Feb 2017 10:02:42 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 16:02:34 +0100 Message-Id: <1486047755-93584-3-git-send-email-imammedo@redhat.com> In-Reply-To: <1486047755-93584-1-git-send-email-imammedo@redhat.com> References: <1486047755-93584-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 Feb 2017 15:02:43 +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] [PATCH 2/3] spapr: move spapr_core_[foo]plug() callbacks close to machine code in spapr.c 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: Bharata B Rao , qemu-ppc@nongnu.org, Alexander Graf , 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" spapr_core_pre_plug/spapr_core_plug/spapr_core_unplug() are managing wiring CPU core into spapr machine state and not internal CPU core state. So move them from spapr_cpu_core.c to spapr.c where other similar (spapr_memory_[foo]plug()) callbacks are located, which also matches x86 target practice. Signed-off-by: Igor Mammedov --- include/hw/ppc/spapr_cpu_core.h | 6 -- hw/ppc/spapr.c | 138 ++++++++++++++++++++++++++++++++++++= ++++ hw/ppc/spapr_cpu_core.c | 138 ------------------------------------= ---- 3 files changed, 138 insertions(+), 144 deletions(-) diff --git a/include/hw/ppc/spapr_cpu_core.h b/include/hw/ppc/spapr_cpu_cor= e.h index 50292f4..3c35665 100644 --- a/include/hw/ppc/spapr_cpu_core.h +++ b/include/hw/ppc/spapr_cpu_core.h @@ -34,12 +34,6 @@ typedef struct sPAPRCPUCoreClass { ObjectClass *cpu_class; } sPAPRCPUCoreClass; =20 -void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp); char *spapr_get_cpu_core_type(const char *model); -void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp); -void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp); void spapr_cpu_core_class_init(ObjectClass *oc, void *data); #endif diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e465d7a..8c2efd8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2488,6 +2488,144 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, i= nt *fdt_offset, return fdt; } =20 +static void spapr_core_release(DeviceState *dev, void *opaque) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + CPUCore *cc =3D CPU_CORE(dev); + + spapr->cores[cc->core_id / smp_threads] =3D NULL; + object_unparent(OBJECT(dev)); +} + +static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v, + Error **errp) +{ + CPUCore *cc =3D CPU_CORE(dev); + int smt =3D kvmppc_smt_threads(); + int index =3D cc->core_id / smp_threads; + sPAPRDRConnector *drc =3D + spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt); + sPAPRDRConnectorClass *drck; + Error *local_err =3D NULL; + + if (index =3D=3D 0) { + error_setg(errp, "Boot CPU core may not be unplugged"); + return; + } + + g_assert(drc); + + drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + drck->detach(drc, dev, spapr_core_release, NULL, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + spapr_hotplug_req_remove_by_index(drc); +} + +static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + MachineClass *mc =3D MACHINE_GET_CLASS(spapr); + sPAPRCPUCore *core =3D SPAPR_CPU_CORE(OBJECT(dev)); + CPUCore *cc =3D CPU_CORE(dev); + CPUState *cs =3D CPU(core->threads); + sPAPRDRConnector *drc; + Error *local_err =3D NULL; + void *fdt =3D NULL; + int fdt_offset =3D 0; + int index =3D cc->core_id / smp_threads; + int smt =3D kvmppc_smt_threads(); + + drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); + spapr->cores[index] =3D OBJECT(dev); + + g_assert(drc || !mc->query_hotpluggable_cpus); + + /* + * Setup CPU DT entries only for hotplugged CPUs. For boot time or + * coldplugged CPUs DT entries are setup in spapr_build_fdt(). + */ + if (dev->hotplugged) { + fdt =3D spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr); + } + + if (drc) { + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_e= rr); + if (local_err) { + g_free(fdt); + spapr->cores[index] =3D NULL; + error_propagate(errp, local_err); + return; + } + } + + if (dev->hotplugged) { + /* + * Send hotplug notification interrupt to the guest only in case + * of hotplugged CPUs. + */ + spapr_hotplug_req_add_by_index(drc); + } else { + /* + * Set the right DRC states for cold plugged CPU. + */ + if (drc) { + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); + drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); + drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); + } + } +} + +static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, + Error **errp) +{ + MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); + MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + int spapr_max_cores =3D max_cpus / smp_threads; + int index; + Error *local_err =3D NULL; + CPUCore *cc =3D CPU_CORE(dev); + char *base_core_type =3D spapr_get_cpu_core_type(machine->cpu_model); + const char *type =3D object_get_typename(OBJECT(dev)); + + if (dev->hotplugged && !mc->query_hotpluggable_cpus) { + error_setg(&local_err, "CPU hotplug not supported for this machine= "); + goto out; + } + + if (strcmp(base_core_type, type)) { + error_setg(&local_err, "CPU core type should be %s", base_core_typ= e); + goto out; + } + + if (cc->core_id % smp_threads) { + error_setg(&local_err, "invalid core id %d", cc->core_id); + goto out; + } + + index =3D cc->core_id / smp_threads; + if (index < 0 || index >=3D spapr_max_cores) { + error_setg(&local_err, "core id %d out of range", cc->core_id); + goto out; + } + + if (spapr->cores[index]) { + error_setg(&local_err, "core %d already populated", cc->core_id); + goto out; + } + +out: + g_free(base_core_type); + error_propagate(errp, local_err); +} + static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index b9e5f80..55cd045 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -109,15 +109,6 @@ char *spapr_get_cpu_core_type(const char *model) return core_type; } =20 -static void spapr_core_release(DeviceState *dev, void *opaque) -{ - sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); - CPUCore *cc =3D CPU_CORE(dev); - - spapr->cores[cc->core_id / smp_threads] =3D NULL; - object_unparent(OBJECT(dev)); -} - static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) { sPAPRCPUCore *sc =3D SPAPR_CPU_CORE(OBJECT(dev)); @@ -140,135 +131,6 @@ static void spapr_cpu_core_unrealizefn(DeviceState *d= ev, Error **errp) g_free(sc->threads); } =20 -void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) -{ - CPUCore *cc =3D CPU_CORE(dev); - int smt =3D kvmppc_smt_threads(); - int index =3D cc->core_id / smp_threads; - sPAPRDRConnector *drc =3D - spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * smt); - sPAPRDRConnectorClass *drck; - Error *local_err =3D NULL; - - if (index =3D=3D 0) { - error_setg(errp, "Boot CPU core may not be unplugged"); - return; - } - - g_assert(drc); - - drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->detach(drc, dev, spapr_core_release, NULL, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - spapr_hotplug_req_remove_by_index(drc); -} - -void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) -{ - sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); - MachineClass *mc =3D MACHINE_GET_CLASS(spapr); - sPAPRCPUCore *core =3D SPAPR_CPU_CORE(OBJECT(dev)); - CPUCore *cc =3D CPU_CORE(dev); - CPUState *cs =3D CPU(core->threads); - sPAPRDRConnector *drc; - Error *local_err =3D NULL; - void *fdt =3D NULL; - int fdt_offset =3D 0; - int index =3D cc->core_id / smp_threads; - int smt =3D kvmppc_smt_threads(); - - drc =3D spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index * = smt); - spapr->cores[index] =3D OBJECT(dev); - - g_assert(drc || !mc->query_hotpluggable_cpus); - - /* - * Setup CPU DT entries only for hotplugged CPUs. For boot time or - * coldplugged CPUs DT entries are setup in spapr_build_fdt(). - */ - if (dev->hotplugged) { - fdt =3D spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr); - } - - if (drc) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, &local_e= rr); - if (local_err) { - g_free(fdt); - spapr->cores[index] =3D NULL; - error_propagate(errp, local_err); - return; - } - } - - if (dev->hotplugged) { - /* - * Send hotplug notification interrupt to the guest only in case - * of hotplugged CPUs. - */ - spapr_hotplug_req_add_by_index(drc); - } else { - /* - * Set the right DRC states for cold plugged CPU. - */ - if (drc) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); - } - } -} - -void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) -{ - MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); - MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); - sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); - int spapr_max_cores =3D max_cpus / smp_threads; - int index; - Error *local_err =3D NULL; - CPUCore *cc =3D CPU_CORE(dev); - char *base_core_type =3D spapr_get_cpu_core_type(machine->cpu_model); - const char *type =3D object_get_typename(OBJECT(dev)); - - if (dev->hotplugged && !mc->query_hotpluggable_cpus) { - error_setg(&local_err, "CPU hotplug not supported for this machine= "); - goto out; - } - - if (strcmp(base_core_type, type)) { - error_setg(&local_err, "CPU core type should be %s", base_core_typ= e); - goto out; - } - - if (cc->core_id % smp_threads) { - error_setg(&local_err, "invalid core id %d", cc->core_id); - goto out; - } - - index =3D cc->core_id / smp_threads; - if (index < 0 || index >=3D spapr_max_cores) { - error_setg(&local_err, "core id %d out of range", cc->core_id); - goto out; - } - - if (spapr->cores[index]) { - error_setg(&local_err, "core %d already populated", cc->core_id); - goto out; - } - -out: - g_free(base_core_type); - error_propagate(errp, local_err); -} - static void spapr_cpu_core_realize_child(Object *child, Error **errp) { Error *local_err =3D NULL; --=20 2.7.4 From nobody Sat May 4 09:14:45 2024 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 1486051866410527.6546671385184; Thu, 2 Feb 2017 08:11:06 -0800 (PST) Received: from localhost ([::1]:57525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZJyS-0003oZ-Lk for importer@patchew.org; Thu, 02 Feb 2017 11:11:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZIuL-0006Pl-ML for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZIuK-0001Wr-Uc for qemu-devel@nongnu.org; Thu, 02 Feb 2017 10:02:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZIuK-0001VJ-Lj; Thu, 02 Feb 2017 10:02:44 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2923C051674; Thu, 2 Feb 2017 15:02:44 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12F2cLD030842; Thu, 2 Feb 2017 10:02:43 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2017 16:02:35 +0100 Message-Id: <1486047755-93584-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1486047755-93584-1-git-send-email-imammedo@redhat.com> References: <1486047755-93584-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 Feb 2017 15:02:44 +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] [PATCH 3/3] 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: Bharata B Rao , qemu-ppc@nongnu.org, Alexander Graf , 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" 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 --- 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.7.4