From nobody Wed Nov 5 17:46:08 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 1496856257543855.459628613308; Wed, 7 Jun 2017 10:24:17 -0700 (PDT) Received: from localhost ([::1]:45350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIedz-0004nt-Ny for importer@patchew.org; Wed, 07 Jun 2017 13:21:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIeZx-0000Um-HQ for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIeZt-0000a2-Es for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:17:09 -0400 Received: from 7.mo178.mail-out.ovh.net ([46.105.58.91]:53045) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIeZt-0000Ze-7l for qemu-devel@nongnu.org; Wed, 07 Jun 2017 13:17:05 -0400 Received: from player728.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 3684E3E5E7 for ; Wed, 7 Jun 2017 19:17:04 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player728.ha.ovh.net (Postfix) with ESMTPA id E83DB540098; Wed, 7 Jun 2017 19:17:00 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 07 Jun 2017 19:17:00 +0200 Message-ID: <149685582071.12025.6876143197982490443.stgit@bahia.lan> In-Reply-To: <149685579678.12025.9278446121024037161.stgit@bahia.lan> References: <149685579678.12025.9278446121024037161.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3823556084192877030 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeljedriedugdduuddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.58.91 Subject: [Qemu-devel] [PATCH v3 2/5] xics: add reset() handler to ICPStateClass 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: qemu-ppc@nongnu.org, Cedric Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Taking into account that qemu_set_irq() returns immediatly if its first argument is NULL, icp_kvm_reset() largely duplicates icp_reset(). This patch introduces a reset() handler, so that the common logic can be implemented in icp_reset() only. While there we can also drop icp_kvm_realize() and icp_kvm_unrealize(). This causes icp-kvm to be realized in icp_realize(), which sets icp->xics, but it has no impact. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/intc/xics.c | 5 +++++ hw/intc/xics_kvm.c | 27 ++------------------------- include/hw/ppc/xics.h | 1 + 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index ea3516794af7..ec73f02144c9 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -325,6 +325,7 @@ static const VMStateDescription vmstate_icp_server =3D { static void icp_reset(void *dev) { ICPState *icp =3D ICP(dev); + ICPStateClass *icpc =3D ICP_GET_CLASS(icp); =20 icp->xirr =3D 0; icp->pending_priority =3D 0xff; @@ -332,6 +333,10 @@ static void icp_reset(void *dev) =20 /* Make all outputs are deasserted */ qemu_set_irq(icp->output, 0); + + if (icpc->reset) { + icpc->reset(icp); + } } =20 static void icp_realize(DeviceState *dev, Error **errp) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 14b8f6f6e478..45bf110b51e6 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -110,19 +110,8 @@ static int icp_set_kvm_state(ICPState *icp, int versio= n_id) return 0; } =20 -static void icp_kvm_reset(void *dev) +static void icp_kvm_reset(ICPState *icp) { - ICPState *icp =3D ICP(dev); - - icp->xirr =3D 0; - icp->pending_priority =3D 0xff; - icp->mfrr =3D 0xff; - - /* Make all outputs as deasserted only if the CPU thread is in use */ - if (icp->output) { - qemu_set_irq(icp->output, 0); - } - icp_set_kvm_state(icp, 1); } =20 @@ -159,26 +148,14 @@ static void icp_kvm_cpu_setup(ICPState *icp, PowerPCC= PU *cpu) QLIST_INSERT_HEAD(&kvm_enabled_icps, enabled_icp, node); } =20 -static void icp_kvm_realize(DeviceState *dev, Error **errp) -{ - qemu_register_reset(icp_kvm_reset, dev); -} - -static void icp_kvm_unrealize(DeviceState *dev, Error **errp) -{ - qemu_unregister_reset(icp_kvm_reset, dev); -} - static void icp_kvm_class_init(ObjectClass *klass, void *data) { - DeviceClass *dc =3D DEVICE_CLASS(klass); ICPStateClass *icpc =3D ICP_CLASS(klass); =20 - dc->realize =3D icp_kvm_realize; - dc->unrealize =3D icp_kvm_unrealize; icpc->pre_save =3D icp_get_kvm_state; icpc->post_load =3D icp_set_kvm_state; icpc->cpu_setup =3D icp_kvm_cpu_setup; + icpc->reset =3D icp_kvm_reset; } =20 static const TypeInfo icp_kvm_info =3D { diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index a3073f90533a..40a506eacfb4 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -69,6 +69,7 @@ struct ICPStateClass { void (*pre_save)(ICPState *s); int (*post_load)(ICPState *s, int version_id); void (*cpu_setup)(ICPState *icp, PowerPCCPU *cpu); + void (*reset)(ICPState *icp); }; =20 struct ICPState {