From nobody Fri May 3 06:25:31 2024 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.zohomail.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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515617096674830.3016922180075; Wed, 10 Jan 2018 12:44:56 -0800 (PST) Received: from localhost ([::1]:38794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZNEs-0002re-Ih for importer@patchew.org; Wed, 10 Jan 2018 15:44:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZNDt-0002E2-CE for qemu-devel@nongnu.org; Wed, 10 Jan 2018 15:43:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZNDs-0002Sc-F5 for qemu-devel@nongnu.org; Wed, 10 Jan 2018 15:43:45 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:46853) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZNDs-0002Qc-6D for qemu-devel@nongnu.org; Wed, 10 Jan 2018 15:43:44 -0500 Received: from localhost.localdomain (unknown [IPv6:2a01:e34:eebf:9c0:418e:be1e:e2ef:ab3]) (Authenticated sender: jcd@tribudubois.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id B266CA80CE; Wed, 10 Jan 2018 21:43:41 +0100 (CET) From: Jean-Christophe Dubois To: chouteau@adacore.com Date: Wed, 10 Jan 2018 21:43:27 +0100 Message-Id: <20180110204327.22510-1-jcd@tribudubois.net> X-Mailer: git-send-email 2.14.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4b98:c:538::195 Subject: [Qemu-devel] [PATCH] LEON3 IRQMP: Fix IRQ software ack 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: mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, Jean-Christophe Dubois Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" With the LEON3 IRQ controller IRQs can be acknoledged 2 ways: * Explicitely by software writing to the CLEAR_OFFSET register * Implicitely when the procesor is done running the trap handler attached to the IRQ. The actual IRQMP code only allows the implicit processor triggered IRQ ack. If software write explicitely to the CLEAR_OFFSET register, this will clear the pending bit in the register value but this will not lower the onloing raised IRQ with the processor. The IRQ will be kept raised to the LEON processor until the related trap handler is run and the processor implicite= ly ack the interrupt. So with the actual IRQMP code trap hadler have to be run even if the software has already done its job by clearing the pending bit. This feature has been tested on another LEON3 simulator (tsim_leon3 from Gaisler) and it turns out that the Qemu implementation is not equivalent to the tsim one. In tsim, if software does clear a pending interrupt before the related interrupt handler is triggered the said interrupt handler will not be called. This patch bring the Qemu IRQMP implementation in line with the tsim implementation by allowing IRQ to be acknoledged by software only. Signed-off-by: Jean-Christophe Dubois Reviewed-by: Fabien Chouteau --- hw/intc/grlib_irqmp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c index 94659ee256..d6f9cb3692 100644 --- a/hw/intc/grlib_irqmp.c +++ b/hw/intc/grlib_irqmp.c @@ -106,6 +106,15 @@ static void grlib_irqmp_check_irqs(IRQMPState *state) } } =20 +static void grlib_irqmp_ack_mask(IRQMPState *state, uint32_t mask) +{ + /* Clear registers */ + state->pending &=3D ~mask; + state->force[0] &=3D ~mask; /* Only CPU 0 (No SMP support) */ + + grlib_irqmp_check_irqs(state); +} + void grlib_irqmp_ack(DeviceState *dev, int intno) { IRQMP *irqmp =3D GRLIB_IRQMP(dev); @@ -120,11 +129,7 @@ void grlib_irqmp_ack(DeviceState *dev, int intno) =20 trace_grlib_irqmp_ack(intno); =20 - /* Clear registers */ - state->pending &=3D ~mask; - state->force[0] &=3D ~mask; /* Only CPU 0 (No SMP support) */ - - grlib_irqmp_check_irqs(state); + grlib_irqmp_ack_mask(state, mask); } =20 void grlib_irqmp_set_irq(void *opaque, int irq, int level) @@ -251,7 +256,7 @@ static void grlib_irqmp_write(void *opaque, hwaddr addr, =20 case CLEAR_OFFSET: value &=3D ~1; /* clean up the value */ - state->pending &=3D ~value; + grlib_irqmp_ack_mask(state, value); return; =20 case MP_STATUS_OFFSET: --=20 2.14.1