From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJG4I-0002fV-Hc for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJG4E-0001uY-7r for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:14:25 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:8727 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJG4E-0001uG-2i for qemu-devel@nongnu.org; Sat, 02 Jul 2016 04:14:22 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6288ePB034783 for ; Sat, 2 Jul 2016 04:14:21 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0b-001b2d01.pphosted.com with ESMTP id 23x9sxg59x-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 02 Jul 2016 04:14:21 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 2 Jul 2016 18:14:18 +1000 Date: Sat, 2 Jul 2016 13:44:08 +0530 From: Bharata B Rao Reply-To: bharata@linux.vnet.ibm.com References: <146741287399.948.15988269239450224065.stgit@bahia.lan> <146741292480.948.3408923676233078960.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <146741292480.948.3408923676233078960.stgit@bahia.lan> Message-Id: <20160702081408.GI21596@in.ibm.com> Subject: Re: [Qemu-devel] [PATCH v2 6/7] spapr: use ppc_set_vcpu_dt_id() in CPU hotplug code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: David Gibson , Benjamin Herrenschmidt , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Cedric Le Goater , Scott Wood , Igor Mammedov On Sat, Jul 02, 2016 at 12:42:04AM +0200, Greg Kurz wrote: > Starting with version 2.7, pseries machine now support hotplug of > cpu cores. The implementation requires to open code cpu creation > and thus does not call ppc_cpu_init(). > > This patch does all the plumbing to allow pseries machine types > with version >= 2.7 to generate cpu DT ids out of the indexes > of the cores and threads in their respective arrays. > > Suggested-by: Igor Mammedov > Signed-off-by: Greg Kurz > --- > hw/ppc/ppc.c | 2 +- > hw/ppc/spapr_cpu_core.c | 11 +++++++++-- > include/hw/ppc/ppc.h | 1 + > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c > index dbc8ac7b3a9b..12de255fb211 100644 > --- a/hw/ppc/ppc.c > +++ b/hw/ppc/ppc.c > @@ -1352,7 +1352,7 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id) > return NULL; > } > > -static void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp) > +void ppc_set_vcpu_dt_id(PowerPCCPU *cpu, int cpu_index, Error **errp) > { > ; > } > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > index 70b6b0b5ee17..475c8063f086 100644 > --- a/hw/ppc/spapr_cpu_core.c > +++ b/hw/ppc/spapr_cpu_core.c > @@ -259,13 +259,20 @@ out: > error_propagate(errp, local_err); > } > > -static void spapr_cpu_core_realize_child(Object *child, Error **errp) > +static void spapr_cpu_core_realize_child(Object *child, int cpu_index, > + Error **errp) > { > Error *local_err = NULL; > sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); > CPUState *cs = CPU(child); > PowerPCCPU *cpu = POWERPC_CPU(cs); > > + ppc_set_vcpu_dt_id(cpu, cpu_index, &local_err); > + if (local_err) { > + error_propagate(errp, local_err); > + return; > + } > + > object_property_set_bool(child, true, "realized", &local_err); > if (local_err) { > error_propagate(errp, local_err); > @@ -306,7 +313,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) > for (j = 0; j < cc->nr_threads; j++) { > obj = sc->threads + j * size; > > - spapr_cpu_core_realize_child(obj, &local_err); > + spapr_cpu_core_realize_child(obj, cc->core_id + j, &local_err); cc->core_id is essentially the cpu_dt_id. For boot time cores, we set this (via core-id prop) explicitly. For hotplugged cores, we expect user to set this mandatorily on -device/device_add. The value that the user is expected to provide as core-id is in fact supplied by us via query-hotpluggable-cpus. So there are two places (ppc_spapr_init & spapr_query_hotpluggable_cpus) where we generate the cpu_dt_id by open coding as (core_index * smt). Can we have consolidate this logic into some well defined routine like ppc_core_index_to_dt_id() ? Regards, Bharata.