From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIqc1-0001H3-PE for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIqbz-0001iE-Dl for qemu-devel@nongnu.org; Mon, 11 Jan 2016 23:31:17 -0500 Date: Tue, 12 Jan 2016 15:19:51 +1100 From: David Gibson Message-ID: <20160112041951.GO22925@voom.redhat.com> References: <1452236119-24452-1-git-send-email-bharata@linux.vnet.ibm.com> <1452236119-24452-8-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+W7ryvxEk4RRyt+P" Content-Disposition: inline In-Reply-To: <1452236119-24452-8-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v6 07/11] xics, xics_kvm: Handle CPU unplug correctly 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, ehabkost@redhat.com --+W7ryvxEk4RRyt+P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 08, 2016 at 12:25:15PM +0530, Bharata B Rao wrote: > XICS is setup for each CPU during initialization. Provide a routine > to undo the same when CPU is unplugged. While here, move ss->cs management > into xics from xics_kvm since there is nothing KVM specific in it. > Also ensure xics reset doesn't set irq for CPUs that are already unplugge= d. >=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 Small suggestion below, but it's not of great importance. > --- > hw/intc/xics.c | 13 +++++++++++++ > hw/intc/xics_kvm.c | 8 ++++---- > include/hw/ppc/xics.h | 1 + > 3 files changed, 18 insertions(+), 4 deletions(-) >=20 > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index 9ff5796..37abaf4 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -44,6 +44,17 @@ 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); > + ICPState *ss =3D &icp->ss[cs->cpu_index]; > + > + assert(cs->cpu_index < icp->nr_servers); Maybe assert that ss->cs matches cs. > + > + ss->output =3D NULL; > + ss->cs =3D NULL; > +} > + > void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu) > { > CPUState *cs =3D CPU(cpu); > @@ -53,6 +64,8 @@ void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu) > =20 > assert(cs->cpu_index < icp->nr_servers); > =20 > + ss->cs =3D cs; > + > if (info->cpu_setup) { > info->cpu_setup(icp, cpu); > } > diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c > index d58729c..049d4e2 100644 > --- a/hw/intc/xics_kvm.c > +++ b/hw/intc/xics_kvm.c > @@ -109,8 +109,10 @@ static void icp_kvm_reset(DeviceState *dev) > icp->pending_priority =3D 0xff; > icp->mfrr =3D 0xff; > =20 > - /* Make all outputs are deasserted */ > - qemu_set_irq(icp->output, 0); > + /* Make all outputs as deasserted only if the CPU thread is in use */ > + if (icp->output) { > + qemu_set_irq(icp->output, 0); > + } > =20 > icp_set_kvm_state(icp, 1); > } > @@ -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) { > diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h > index 355a966..640162f 100644 > --- a/include/hw/ppc/xics.h > +++ b/include/hw/ppc/xics.h > @@ -166,5 +166,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 --+W7ryvxEk4RRyt+P Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWlH7nAAoJEGw4ysog2bOS7lQP/ijyX89sDo+DPrVhGSnk3ADW EqkihvYf+aJnqDe3WlqQ3e0iZ409D3SG8rMYau1cyr0K1ElMgtyH/FmkfxHHLL1w d2IKFvglNuS6GZDO+nT4eiMomDZ2UvyA5VTOPkPKVb4ORb3xxNu5D4E8M7N1Unjh lyywlVbZZZGCduF539Pt6wEd6VR35z3vwdisGWjrv0YxI2om3a6b77DleoFQlTZj 2tNJVrfP7Br8TVoESibFMDk4HKouiM3ofZ8C6VCbGryWv1k/7v/xdRHwGz6KEUNP 7MDZC28Q66mmjptXH9LuuZ5AhnxA+8xScHjgwWHFrYSQNS9zxj7U6OwDYZW+hJWt pF17qb/6ZDJbGaoRC0OUu9ww7ZGf7vFwNgyZPcR9TfbptOIZyC/pOA4RELU2fIkv 2VSeSF+ofMCkcTQsQZmIfOK46a8rHHwoZwVrPj87Ei/DMktgU9ckLP57I5GNbiMG 5JybKEFcI6Ga0NvYOG8AbtOjMWtMdiAXNlvTPxgZQl2Voy+tKezrIaP7WFW7J/fn 1i/3fGB006f0K6nS4MO3r1doSmj4vnHbolrizVxjhtNJxI/VML0fWyfJER6iSIo4 KmUTBs0rNSR+mPKYz6ukhYHyWkWjvtlIPhzg1LDtNJ6iUyT0wAkRW6zDy0Sy5Lfb qpKk5+wrCD+YPQcEa+j9 =hcCF -----END PGP SIGNATURE----- --+W7ryvxEk4RRyt+P--