Message ID | 20221126234134.32660-2-samuel@sholland.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4869357wrr; Sat, 26 Nov 2022 15:44:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5OVHGrJ58xr66HYFqteger5On5UvU12q+CSdA449yTkXJKU8lG42gRbJL2qbQANvJi1Um0 X-Received: by 2002:a05:6a00:1624:b0:573:993b:ea6d with SMTP id e4-20020a056a00162400b00573993bea6dmr27039571pfc.10.1669506281544; Sat, 26 Nov 2022 15:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669506281; cv=none; d=google.com; s=arc-20160816; b=o0TNS8M/HCt9ANCBw0iiP49XfABWW/2mZGkOyZW38hxGvmWG34UVUT2YTXdO5A3L3s thsy6DEFskBb2383/nlhzhPRRPCYzzxDWFzd0RC2042cMyejLSmfKOB2aaIEv2nFuGHi lsosbfGurzLmK3yn5Z/MMP3H/wPfcrdLokpxTHG8Ek/3guHJd7D5h1sERc8p7Z/5NI4G XKceXYsNFOnnwI5KcARAi6eEi2xOc9Ea2Blp+vYurSCghaLVAWFvfkpov2pdumNTe3kQ wwTACldvPZ5QG4RTPjtNTQj50TbYhFuETKITHlsL2LS5AcpDyTiRXbB/Gk1V0RSGPEXD 9Png== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=hdUvaq3eie+r9PF0OlqmeKbt0IxTHeoQ0MpLNYqZ+Rw=; b=FbBWJ5+/20hTOaZW1BcSWhKLYTL3BttvZKRyYItQZyXQIk2vyJE//yv7Ek0Cib4Lgu NKgO/+O1+U+zSPIfyMYANbfMAwX8rnNAP8QIycQMVOEO91N6gnGPlcMrm8uAExDrUEtG A3oZ9JnWSXsC27Qn7V75ybqeKT+j9VzgqchX+kCkL24PUZ8xoPSo7v2AP8mB7ncKcOg1 MVw/pjpUZGM1Kv3ASoL/0qvcEEmJob0h+2W3x+hy/wPihtLdVMqsKBPyxSjbFisr77fq m4FJwjfpkphtEaRcQI5Fyl6LMquvxMeTy9R4ApbPDVgEZLrrHLSzjjNs9+4d7ddaKmaC EJBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=v3pJv01h; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gsAnqY0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr3-20020a17090b4b8300b002190e2130ffsi6039673pjb.56.2022.11.26.15.44.27; Sat, 26 Nov 2022 15:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=v3pJv01h; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gsAnqY0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbiKZXlm (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Sat, 26 Nov 2022 18:41:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbiKZXlk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 26 Nov 2022 18:41:40 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9862BF73 for <linux-kernel@vger.kernel.org>; Sat, 26 Nov 2022 15:41:38 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 77DCB5C0086; Sat, 26 Nov 2022 18:41:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 26 Nov 2022 18:41:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1669506097; x=1669592497; bh=hd Uvaq3eie+r9PF0OlqmeKbt0IxTHeoQ0MpLNYqZ+Rw=; b=v3pJv01hvFZgVgBf5i f0EYSp/uRP5bRKPb98jG6wyoGjDKJ86s44lYOshly4tSHC15PscpRd+EEOGs4leV Kylk+B8QrUMURrXM72wEpRBocB5F4O1d+Y3WJ+RlOFo0o2yXvXwIh7IdbCIV8LcP MvJBVEjRe1PXCzCI5x4X6i4DBWfPimFgbAkZY9Wb0GMKgut45UI7IMK0zgxuPp61 iX0Fo2/ibcF+34L7MkzqjRUfQ83Y5k9/YpQ3KpUQAx5Lk5xBuQiOSB5pZIzZaprU KfA/iD9EnafJsPX2qXv8koGWTxj+rcdkhm/aOgq7vnBMWc/da3Q6l586EBjo4eCc Dw1Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1669506097; x=1669592497; bh=hdUvaq3eie+r9 PF0OlqmeKbt0IxTHeoQ0MpLNYqZ+Rw=; b=gsAnqY0Nb/awF1P2O2Lu59+V0m/rj vJ015EBWac5kpbqbWosQPU22cCGZYUQ6bl64nYCS4EyXRj6zTXwSxuzBoexycv6Q mMKZTYhNFgoATjx0gVEZc4qR3SIeGcuxHFvE7/6ilfL4p5iPYJWxSplua99Xs2J5 R/RUeiJwYO27i8ShLujxXBwjH/qDqNeHh52/re4iRY00jL9JLOLWsnZRbunS6xrw OVpXik5R1Hv24F25g34GPXu7PRku0qI2to9HefDSP4UI09XWbEteuE1KWVmqr39k XVXPYW23FwRNkDE4JUP4F0RJz6ANQSYKkD8akM65xgCnzIwCvV0G2I32Q== X-ME-Sender: <xms:MaSCY4sf3l963pYo5lT7QckfoxVaq0Cx-MRt0laeF3Dqe4BUJCdpeA> <xme:MaSCY1dsBEgK6GeVePj697u2VDlw8XvfFi9xcvPtA7zcdXMFib8x2nFh97hU5ztzt vNblKkCn2VG5S3DTg> X-ME-Received: <xmr:MaSCYzyjzOxh5WEoBe1xuDi-xajHdJxt3g9p3bkxqklGugYw32QXN3tLMIB1c8FaKctINHBYTWuZRjkJifmI9sm97ev5-h3ELXbGh9WzD2ukHTDOiP4Hxq69gtDUi4TbpgHfOg> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrieekgdduudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: <xmx:MaSCY7PU_HUhJ7nalq7PYIYoBekOPTqMQjh4IW34T71yTnS-PRKY6A> <xmx:MaSCY48mB--425paSDSrUVYdJyhsODkcTZEKDxSUNwJJtMQQ7Mg-DQ> <xmx:MaSCYzWBakHwFaRfdE4cSDsJpbf1r4MtkOPvcOAdjlssBDKDhpzcLA> <xmx:MaSCY3mX9aq-Dk3jgUL_yAGCb3uxcImGx7fsaw5twbk4eI_S3UfQXw> Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 26 Nov 2022 18:41:36 -0500 (EST) From: Samuel Holland <samuel@sholland.org> To: Marc Zyngier <maz@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Palmer Dabbelt <palmer@dabbelt.com> Cc: linux-riscv@lists.infradead.org, Samuel Holland <samuel@sholland.org>, Paul Walmsley <paul.walmsley@sifive.com>, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] genirq: Simplify cond_unmask_eoi_irq() Date: Sat, 26 Nov 2022 17:41:32 -0600 Message-Id: <20221126234134.32660-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221126234134.32660-1-samuel@sholland.org> References: <20221126234134.32660-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750604218772707714?= X-GMAIL-MSGID: =?utf-8?q?1750604218772707714?= |
Series |
genirq: oneshot-safe threaded EOIs
|
|
Commit Message
Samuel Holland
Nov. 26, 2022, 11:41 p.m. UTC
This function calls .irq_eoi in three places, making the logic hard to
follow. Rearrange the function so that .irq_eoi is called only once.
The only time .irq_eoi is not called is when all three if checks fail,
so return early in that case. threads_oneshot can only be nonzero if
IRQS_ONESHOT is set, so the IRQS_ONESHOT check can be omitted there.
The IRQS_ONESHOT condition from the first if statement must then be
copied to the unmask_irq() condition.
Furthermore, if IRQS_ONESHOT is set, mask_irq() must have been called
in the parent function, so the irqd_irq_masked() check is redundant.
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
kernel/irq/chip.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
Comments
Samuel! On Sat, Nov 26 2022 at 17:41, Samuel Holland wrote: > This function calls .irq_eoi in three places, making the logic hard to > follow. Rearrange the function so that .irq_eoi is called only once. > > The only time .irq_eoi is not called is when all three if checks fail, > so return early in that case. threads_oneshot can only be nonzero if > IRQS_ONESHOT is set, so the IRQS_ONESHOT check can be omitted there. > > The IRQS_ONESHOT condition from the first if statement must then be > copied to the unmask_irq() condition. > > Furthermore, if IRQS_ONESHOT is set, mask_irq() must have been called > in the parent function, so the irqd_irq_masked() check is redundant. Not really convinced that all this is functionaly equivalent. > static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip) > { > - if (!(desc->istate & IRQS_ONESHOT)) { > - chip->irq_eoi(&desc->irq_data); > + /* > + * Do not send an EOI if the thread will do it later in > + * unmask_threaded_irq(). > + */ > + if ((chip->flags & IRQCHIP_EOI_THREADED) && desc->threads_oneshot) > return; > - } > + > + chip->irq_eoi(&desc->irq_data); This now issues EOI when the interrupt is in disabled state, which was not done before. That's probably a non-issue, but clearly a undocumented change. > + > /* > * We need to unmask in the following cases: > * - Oneshot irq which did not wake the thread (caused by a > @@ -669,12 +674,8 @@ static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip) > * completely). > */ > if (!irqd_irq_disabled(&desc->irq_data) && > - irqd_irq_masked(&desc->irq_data) && !desc->threads_oneshot) { > - chip->irq_eoi(&desc->irq_data); > + (desc->istate & IRQS_ONESHOT) && !desc->threads_oneshot) > unmask_irq(desc); This breaks the mask logic of handle_fasteoi_mask_irq() for an interrupt which does not have IRQS_ONESHOT set. So no, it's not the same and it even breaks stuff. Thanks, tglx
On Wed, Nov 30 2022 at 15:48, Thomas Gleixner wrote: > On Sat, Nov 26 2022 at 17:41, Samuel Holland wrote: >> + (desc->istate & IRQS_ONESHOT) && !desc->threads_oneshot) >> unmask_irq(desc); > > This breaks the mask logic of handle_fasteoi_mask_irq() for an interrupt > which does not have IRQS_ONESHOT set. Ignore this one. That handler is broken by design.
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 8ac37e8e738a..672bad021a1f 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -658,10 +658,15 @@ EXPORT_SYMBOL_GPL(handle_level_irq); static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip) { - if (!(desc->istate & IRQS_ONESHOT)) { - chip->irq_eoi(&desc->irq_data); + /* + * Do not send an EOI if the thread will do it later in + * unmask_threaded_irq(). + */ + if ((chip->flags & IRQCHIP_EOI_THREADED) && desc->threads_oneshot) return; - } + + chip->irq_eoi(&desc->irq_data); + /* * We need to unmask in the following cases: * - Oneshot irq which did not wake the thread (caused by a @@ -669,12 +674,8 @@ static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip) * completely). */ if (!irqd_irq_disabled(&desc->irq_data) && - irqd_irq_masked(&desc->irq_data) && !desc->threads_oneshot) { - chip->irq_eoi(&desc->irq_data); + (desc->istate & IRQS_ONESHOT) && !desc->threads_oneshot) unmask_irq(desc); - } else if (!(chip->flags & IRQCHIP_EOI_THREADED)) { - chip->irq_eoi(&desc->irq_data); - } } /**