From patchwork Fri Dec 4 16:47:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 11952063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5A0C433FE for ; Fri, 4 Dec 2020 18:16:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D73522B2E for ; Fri, 4 Dec 2020 18:16:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D73522B2E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klFdI-00065R-9Q for qemu-devel@archiver.kernel.org; Fri, 04 Dec 2020 13:16:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klEPN-0003C6-O4; Fri, 04 Dec 2020 11:58:13 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:33051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klEPK-0002pu-Gx; Fri, 04 Dec 2020 11:58:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1607101090; x=1638637090; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tXaaNI9ekjpZnUCKv7I8tJpHkOtOggoLq6N+Kl7YbkU=; b=L/OXtKi1DHwTfHLqUd3OWBWkcGHsVrS87W1xJB0SDaczGvsaB4M7BCmh FkF2EYfyieYra+GuV/Xb3rnybSq8ZyexZT9anOuMZhoRiOv38jaMlxA17 UTxw1ufiwagGXXqNwHGDuGMyrktDdzXhtelQZ5ZFOqZ3zYezKjLiOa00x U15LBzl/c3kVh/+swMG9Wlkni9tulHGq2uYxAD1QNNj666QLCh//8F94O uFpWjUPfTtnGVkOin22wbSXeZxkdBglWwrR2/qVPni8CAwQaEAnlHU0Fi SqHKNjkaxw9M+wd+nQCzeLZg7LOgOFd6n4/QdY8PTCLHHBCxKOwHfiQgf Q==; IronPort-SDR: YXULDF105/w3TSpgsPlwxWA04Iqpk5q1EMJCpcZiRnXRGEix7dXbNfUDQ3ey8wlg9ssrRs0SFE Q3/cYdN6Gnh7XAoXLLkIbpVm2rUKZ+/icz+2dgMbH395vHi5wLyvqQXNUJnDhbZ3sE4mnNrKly 5ZLl5xSPVXUiQvXU7/7DUv6eRbWG2zd6qk3UXm+dtOCkMlaq7sd9qy0VORVgDCh8LhHjeMrCOL GeF2x7V9TgPbdXMPUMvb3Zl3cczlgp+BoEFsPq6JfbjtNPW5MBKH65gbg1S/kcTFnrPET69spa Hx0= X-IronPort-AV: E=Sophos;i="5.78,393,1599494400"; d="scan'208";a="158919471" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 05 Dec 2020 00:47:38 +0800 IronPort-SDR: EGrgEwyTEsXSLy0VHBsj1DXR4BSSpn3tudfiF+rGe+ri6UxZgHBZkiz2zzV3k6yKVtc5laojlo JMLbvH9bmWofA/RIzqA/S92AbBCq7d+24= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2020 08:33:10 -0800 IronPort-SDR: ROFtwLik8ByshmcCwLHxyhI5k9W+TqQz8/Dh3TEI55A/lIufHSF0pwlg/GG1szY7MaDhg2d5B1 vRNmX0jzpi3Q== WDCIronportException: Internal Received: from uscrq8cg2.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.61.182]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Dec 2020 08:47:38 -0800 From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v1 1/1] intc/ibex_plic: Clear interrupts that occur during claim process Date: Fri, 4 Dec 2020 08:47:37 -0800 Message-Id: <4e9786084a86f220689123cc8a7837af8fa071cf.1607100423.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=6009f06ea=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, jackieke724@hotmail.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Previously if an interrupt occured during the claim process (after the interrupt is claimed but before it's completed) it would never be cleared. This patch ensures that we also clear the hidden_pending bits as well. Signed-off-by: Alistair Francis Tested-by: Jackie Ke --- hw/intc/ibex_plic.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index 341c9db405..c1b72fcab0 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -43,16 +43,23 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level) { int pending_num = irq / 32; + if (!level) { + /* + * If the level is low make sure we clear the hidden_pending. + */ + s->hidden_pending[pending_num] &= ~(1 << (irq % 32)); + } + if (s->claimed[pending_num] & 1 << (irq % 32)) { /* * The interrupt has been claimed, but not completed. * The pending bit can't be set. + * Save the pending level for after the interrupt is completed. */ s->hidden_pending[pending_num] |= level << (irq % 32); - return; + } else { + s->pending[pending_num] |= level << (irq % 32); } - - s->pending[pending_num] |= level << (irq % 32); } static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context)