From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Zxx-00074C-ST for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Zxw-0001Ag-4D for qemu-devel@nongnu.org; Mon, 30 Nov 2015 20:42:49 -0500 Date: Tue, 1 Dec 2015 12:01:36 +1100 From: David Gibson Message-ID: <20151201010136.GE31343@voom.redhat.com> References: <1448024079-20808-1-git-send-email-bharata@linux.vnet.ibm.com> <1448024079-20808-7-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CGDBiGfvSTbxKZlW" Content-Disposition: inline In-Reply-To: <1448024079-20808-7-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 06/10] xics_kvm: Add cpu_destroy method to XICS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de --CGDBiGfvSTbxKZlW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 20, 2015 at 06:24:35PM +0530, Bharata B Rao wrote: > XICS is setup for each CPU during initialization. Provide a routine > to undo the same when CPU is unplugged. >=20 > This allows reboot of a VM that has undergone CPU hotplug and unplug > to work correctly. >=20 > Signed-off-by: Bharata B Rao > Reviewed-by: David Gibson > --- > hw/intc/xics.c | 12 ++++++++++++ > hw/intc/xics_kvm.c | 13 +++++++++++-- > include/hw/ppc/xics.h | 2 ++ > 3 files changed, 25 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index 9ff5796..e1161b2 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -44,6 +44,18 @@ static int get_cpu_index_by_dt_id(int cpu_dt_id) > return -1; > } > =20 > +void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu) > +{ > + CPUState *cs =3D CPU(cpu); > + XICSStateClass *info =3D XICS_COMMON_GET_CLASS(icp); > + > + assert(cs->cpu_index < icp->nr_servers); > + > + if (info->cpu_destroy) { > + info->cpu_destroy(icp, cpu); > + } > +} > + > void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu) > { > CPUState *cs =3D CPU(cpu); > diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c > index d58729c..cb96f69 100644 > --- a/hw/intc/xics_kvm.c > +++ b/hw/intc/xics_kvm.c > @@ -331,6 +331,8 @@ static void xics_kvm_cpu_setup(XICSState *icp, PowerP= CCPU *cpu) > abort(); > } > =20 > + ss->cs =3D cs; > + Actually, it probably makes more sense to move the management of ss->cs to the base xics code. There's nothing really kvm specific about it. > /* > * If we are reusing a parked vCPU fd corresponding to the CPU > * which was hot-removed earlier we don't have to renable > @@ -343,8 +345,6 @@ static void xics_kvm_cpu_setup(XICSState *icp, PowerP= CCPU *cpu) > if (icpkvm->kernel_xics_fd !=3D -1) { > int ret; > =20 > - ss->cs =3D cs; > - > ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0, > icpkvm->kernel_xics_fd, kvm_arch_vcpu_= id(cs)); > if (ret < 0) { > @@ -356,6 +356,14 @@ static void xics_kvm_cpu_setup(XICSState *icp, Power= PCCPU *cpu) > } > } > =20 > +static void xics_kvm_cpu_destroy(XICSState *icp, PowerPCCPU *cpu) > +{ > + CPUState *cs =3D CPU(cpu); > + ICPState *ss =3D &icp->ss[cs->cpu_index]; > + > + ss->cs =3D NULL; > +} > + > static void xics_kvm_set_nr_irqs(XICSState *icp, uint32_t nr_irqs, Error= **errp) > { > icp->nr_irqs =3D icp->ics->nr_irqs =3D nr_irqs; > @@ -486,6 +494,7 @@ static void xics_kvm_class_init(ObjectClass *oc, void= *data) > =20 > dc->realize =3D xics_kvm_realize; > xsc->cpu_setup =3D xics_kvm_cpu_setup; > + xsc->cpu_destroy =3D xics_kvm_cpu_destroy; > xsc->set_nr_irqs =3D xics_kvm_set_nr_irqs; > xsc->set_nr_servers =3D xics_kvm_set_nr_servers; > } > diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h > index 355a966..2faad48 100644 > --- a/include/hw/ppc/xics.h > +++ b/include/hw/ppc/xics.h > @@ -68,6 +68,7 @@ struct XICSStateClass { > DeviceClass parent_class; > =20 > void (*cpu_setup)(XICSState *icp, PowerPCCPU *cpu); > + void (*cpu_destroy)(XICSState *icp, PowerPCCPU *cpu); > void (*set_nr_irqs)(XICSState *icp, uint32_t nr_irqs, Error **errp); > void (*set_nr_servers)(XICSState *icp, uint32_t nr_servers, Error **= errp); > }; > @@ -166,5 +167,6 @@ int xics_alloc_block(XICSState *icp, int src, int num= , bool lsi, bool align); > void xics_free(XICSState *icp, int irq, int num); > =20 > void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu); > +void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu); > =20 > #endif /* __XICS_H__ */ --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --CGDBiGfvSTbxKZlW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWXPFwAAoJEGw4ysog2bOS5iwQAIVXuf6yC217XorqFffWgN4V ISsNqU1ri1dflOEHxcj3O6VOH285xAISGqC79D9ST1FlbsBEIN7bb+rCSLbRbWhl XI1U/I2tG0RE63qeYt+sXyd7snh2h6SJO82LPPCNcmFYZDqKYoF2IZuLX4AenQCM N1Vk2dHv3fifyh10/iTXacqtTX65LmDliqeLotGnZ1UcPQZdrasy/9+sFo2TEGzf zkm/fMfSAv00WYsWmG9W5MJXGRIsu7Bme8nTu3i+gQq0s8yJtDwe2/rEM5/szlSE R+MPuZL13goRCCQEy6slW0l7EoJEepRyu7bDCr5zhc4cSeZyxp6PtIMnYxePKbFY ifR1pdrh2DqNwV0IVN4DPyASeRCdgr2rEDfcjfg81lRi40T3VeC3St8J9DUmDgp/ Oj/jqfPhguDMBlw0bmF8gG/aGmRijV4dEdHoiOUFgQOu3f7cO2P99IEJrdxM1tdp vyey/CF5FiCfZLP/CSzTTEHiBUapBDRvag5/PeH4e4EWaP91FbxW4GrPvrruMS9+ 0TnL6+Lp3drI2m/W2XHzpw5wh5DT3QsMgG9QX2abz81AjOl3EJf4aRFi7Ku9IQqq hmoE3zfB9G8ZSEDbgGrBYKgqPMEQBGmgfmqGCXqPCivXgM9tg1IVfgwRE7aj603+ P57jmIrGpAeaiSWdOCjc =d7tm -----END PGP SIGNATURE----- --CGDBiGfvSTbxKZlW--