From patchwork Thu Aug 12 10:09:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12433205 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 9CABDC4338F for ; Thu, 12 Aug 2021 10:13:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 55B0061038 for ; Thu, 12 Aug 2021 10:13:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55B0061038 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=GfEyPphXxctRcaqeIzZdvMw/9bMmuEwhjfLzgC7O6pI=; b=0dNRRJPbjBb0K8 FBP1dyeXHpOhVk6r6QSb0J/vBKoiSj1MGqNXtTnpCkHuuYNU97M9QT92YIQOSShF6Y+liPhoczpu6 a/XCGQ0C5VXHvE4HAsjaqpy5pYgVPjfJsJYSAroTNqiG5UGqCwwcNWiy7K+P7iZzEWk0mQ7uTd78G EaqjThjj8xAOJNO16sbWbv7dL9QlW6KN8C9bGytXxCgFQ1+KXsLtz+WJutNrOrdlDGRG7IfcbZ3d0 s+asgcOIJWn5o6LNFyf6iCyzpddY4my1Xkjs3qMFa4++YLoJ1mlSYZ4S6Axaralxn8giDAzhbG6an e3nYdWkGz6VbGbPi6n1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mE7fk-009ch8-4c; Thu, 12 Aug 2021 10:10:48 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mE7fc-009cdC-Jw for linux-arm-kernel@lists.infradead.org; Thu, 12 Aug 2021 10:10:45 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id C235A320079B; Thu, 12 Aug 2021 06:10:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 12 Aug 2021 06:10:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=SwJEYo/gCeYJ1PODsUSdC0nhKr VM+B8+h8O+pAj/MfY=; b=DnQVGsoz5xG5380WBCtyD2kmRGa9Ucy9JgFJ9TIlJ8 hRpyAvDN+GJFZyp9ezJnZgoTBRjg3eYf9s8LDvVgTtu4EOyPdBJHEmm5cA2si18E g5kLjUN/ogg+RhFWbZLIF0LWB7Npl2FJFKjnyEDyuRRSebVxps8kpg9f4HhF+/RM jENuv3RHIpwK7nRTIN5IPY5U+SmEcWEPusg5bozDUTHsw7A4yUUJ/JDn8bAGWacP k3x/uyniU5QSz33TsZvEHimmqi3/x0hCOJnzb3LNB5GE5lEfM1Cl2CZYFkeZCCix KiVmCHuFSyNPtlkTo3vP9JbT6151vxzbokQKcoeBGE9A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=SwJEYo/gCeYJ1PODs USdC0nhKrVM+B8+h8O+pAj/MfY=; b=b9TPXfkMSPwfpJ2xtqfIk9eD9GU0ncOiC kTR73NZ5PcPPDOVi2c/SgBXKVYfvV3zNq7yjuvQZpE349oL43AuJWZfBkAQ4ltMK GFNnJnArCZc4T4iQ6CVwMaQ2jt50VPl/lcPUPK8EriZLC9/7XRIXd9CT6whVHJmI sYNEap/rwX+TmqLdrxWyOkWJh0xWQg0r3TRAolyi8O159e6Nwcs+3GwjsbiRkUNO wrLXexFIfSrMPbTzJQx1JDJTnpiHoGQJPArssq+nzw67+4QPJU7ab1cG8/eWrVBM ZhB2NKaYKlKRmHw60CNvKWnHjV4UXIJitxY+NNcfuIh2s+McbQtvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeefgddvvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufhvvghnucfrvght vghruceoshhvvghnsehsvhgvnhhpvghtvghrrdguvghvqeenucggtffrrghtthgvrhhnpe eugfelkedvtdejffefjeehveelfeevkefgudduhfeghfefgedtheevjeefffffgfenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsvhgvnhessh hvvghnphgvthgvrhdruggvvh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Aug 2021 06:10:33 -0400 (EDT) From: Sven Peter To: Hector Martin Cc: Sven Peter , Thomas Gleixner , Marc Zyngier , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] irqchip/apple-aic: fix irq_disable from within irq handlers Date: Thu, 12 Aug 2021 12:09:42 +0200 Message-Id: <20210812100942.17206-1-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210812_031040_882755_2E4EE7D2 X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When disable_irq_nosync for an interrupt is called from within its interrupt handler, this interrupt is only marked as disabled with the intention to mask it when it triggers again. The AIC hardware however automatically masks the interrupt when it is read. aic_irq_eoi then unmasks it again if it's not disabled *and* not masked. This results in a state mismatch between the hardware state and the state kept in irq_data: The hardware interrupt is masked but IRQD_IRQ_MASKED is not set. Any further calls to unmask_irq will directly return and the interrupt can never be enabled again. Fix this by keeping the hardware and irq_data state in sync by unmasking in aic_irq_eoi if and only if the irq_data state also assumes the interrupt to be unmasked. Fixes: 76cde2639411 ("irqchip/apple-aic: Add support for the Apple Interrupt Controller") Signed-off-by: Sven Peter Acked-by: Hector Martin --- drivers/irqchip/irq-apple-aic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index b8c06bd8659e..6fc145aacaf0 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -226,7 +226,7 @@ static void aic_irq_eoi(struct irq_data *d) * Reading the interrupt reason automatically acknowledges and masks * the IRQ, so we just unmask it here if needed. */ - if (!irqd_irq_disabled(d) && !irqd_irq_masked(d)) + if (!irqd_irq_masked(d)) aic_irq_unmask(d); }