From patchwork Wed Sep 12 05:58:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 183251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3E15C2C0089 for ; Wed, 12 Sep 2012 15:58:09 +1000 (EST) Received: from localhost ([::1]:40011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBfxf-0001uo-EO for incoming@patchwork.ozlabs.org; Wed, 12 Sep 2012 01:58:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBfxX-0001ug-7i for qemu-devel@nongnu.org; Wed, 12 Sep 2012 01:58:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBfxV-0003Tz-MQ for qemu-devel@nongnu.org; Wed, 12 Sep 2012 01:57:59 -0400 Received: from ozlabs.org ([203.10.76.45]:35212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBfxV-0003TR-2S; Wed, 12 Sep 2012 01:57:57 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 6DB562C0095; Wed, 12 Sep 2012 15:57:53 +1000 (EST) Date: Wed, 12 Sep 2012 15:58:23 +1000 From: David Gibson To: agraf@suse.de Message-ID: <20120912055823.GY12554@truffula.fritz.box> References: <1347259132-31184-1-git-send-email-david@gibson.dropbear.id.au> <1347259132-31184-8-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1347259132-31184-8-git-send-email-david@gibson.dropbear.id.au> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 7/7] pseries: Fix XICS reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Mon, Sep 10, 2012 at 04:38:51PM +1000, David Gibson wrote: > The XICS interrupt controller used on the pseries machine currently has no > reset handler. We can get away with this under some circumstances, but > it's not correct, and can cause failures if the XICS happens to be in the > wrong state at the time of reset. > > This patch adds a hook to properly reset the XICS state. > > Signed-off-by: David Gibson Oops, don't apply that one. It has a bug which will break level sensitive interrupts. Here's a fixed version. From 353b529cf2049347356e3479f5e48dc2597e4fbb Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 22 Aug 2012 15:20:41 +1000 Subject: [PATCH] pseries: Fix XICS reset The XICS interrupt controller used on the pseries machine currently has no reset handler. We can get away with this under some circumstances, but it's not correct, and can cause failures if the XICS happens to be in the wrong state at the time of reset. This patch adds a hook to properly reset the XICS state. Signed-off-by: David Gibson --- hw/xics.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/hw/xics.c b/hw/xics.c index b674771..a8a08ce 100644 --- a/hw/xics.c +++ b/hw/xics.c @@ -489,11 +489,36 @@ static void rtas_int_on(sPAPREnvironment *spapr, uint32_t token, rtas_st(rets, 0, 0); /* Success */ } +static void xics_reset(void *opaque) +{ + struct icp_state *icp = (struct icp_state *)opaque; + struct ics_state *ics = icp->ics; + int i; + + for (i = 0; i < icp->nr_servers; i++) { + icp->ss[i].xirr = 0; + icp->ss[i].pending_priority = 0; + icp->ss[i].mfrr = 0xff; + /* Make all outputs are deasserted */ + qemu_set_irq(icp->ss[i].output, 0); + } + + for (i = 0; i < ics->nr_irqs; i++) { + /* Reset everything *except* the type */ + ics->irqs[i].server = 0; + ics->irqs[i].asserted = 0; + ics->irqs[i].sent = 0; + ics->irqs[i].rejected = 0; + ics->irqs[i].masked_pending = 0; + ics->irqs[i].priority = 0xff; + ics->irqs[i].saved_priority = 0xff; + } +} + struct icp_state *xics_system_init(int nr_irqs) { CPUPPCState *env; int max_server_num; - int i; struct icp_state *icp; struct ics_state *ics; @@ -508,10 +533,6 @@ struct icp_state *xics_system_init(int nr_irqs) icp->nr_servers = max_server_num + 1; icp->ss = g_malloc0(icp->nr_servers*sizeof(struct icp_server_state)); - for (i = 0; i < icp->nr_servers; i++) { - icp->ss[i].mfrr = 0xff; - } - for (env = first_cpu; env != NULL; env = env->next_cpu) { struct icp_server_state *ss = &icp->ss[env->cpu_index]; @@ -539,11 +560,6 @@ struct icp_state *xics_system_init(int nr_irqs) icp->ics = ics; ics->icp = icp; - for (i = 0; i < nr_irqs; i++) { - ics->irqs[i].priority = 0xff; - ics->irqs[i].saved_priority = 0xff; - } - ics->qirqs = qemu_allocate_irqs(ics_set_irq, ics, nr_irqs); spapr_register_hypercall(H_CPPR, h_cppr); @@ -556,5 +572,7 @@ struct icp_state *xics_system_init(int nr_irqs) spapr_rtas_register("ibm,int-off", rtas_int_off); spapr_rtas_register("ibm,int-on", rtas_int_on); + qemu_register_reset(xics_reset, icp); + return icp; }