From patchwork Thu Apr 8 15:43:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191757 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.8 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=unavailable 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 BD916C433ED for ; Thu, 8 Apr 2021 15:46:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 654EE61107 for ; Thu, 8 Apr 2021 15:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 654EE61107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=ldMUr+NZxisPs/uXPh1jW505CzmfPt+gkdzEG7aocUY=; b=Afw3STcDYLhBSVR7G8JMCz/zH tkE8qfARKJnBVti5jdDEEXESJFoMLvqbhXhWtUvNwylxSBBJHewVQP24VKQf6uxCsjCGOhPuqa95q h8dT4I8sY3x6flVVnonyQw0ePiyG8qSpiDyeD2rHSJeJK2KPMCPsW6xiOAsa4w3TMlzeCv5gdoXZ7 KHdE4QiF1KAaUIm0hZTQlPQmFJwJT4m8qZRzROXs4v1nWzwbn7so/FgP/lKPhcHl3GdTVmkwRbZDK AUUmec43Wf7Qn9cfTyeBGTk+hrVePRagj8UK16BlbBHtGt+6Gy1fqKUbg+OIMb1NwR6IUGlSOtU70 K7RPYlUhQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpZ-008SIL-0L; Thu, 08 Apr 2021 15:44:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpA-008SC1-72 for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E49E211B3; Thu, 8 Apr 2021 08:44:00 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E3A803F694; Thu, 8 Apr 2021 08:43:59 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 01/10] genirq: Add chip flag to denote automatic IRQ (un)masking Date: Thu, 8 Apr 2021 16:43:17 +0100 Message-Id: <20210408154326.3988781-2-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164405_084037_7535D881 X-CRM114-Status: GOOD ( 11.67 ) 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 Some IRQ chips such as the Arm GICs automagically mask / unmask an IRQ during the handling of said IRQ. This renders further mask / unmask operations within the flow handlers redundant, which we do want to leverage as masking by itself is not cheap (Distributor access via MMIO for GICs). This is different from having a chip->irq_mask_ack() callback as this masking is: - inherent to the chip->irq_ack() and *cannot* be omitted - a *different* masking state than chip->irq_mask() (chip->irq_mask() is idempotent, chip->irq_ack() really isn't) Add a chip flag, IRQCHIP_AUTOMASKS_FLOW, to denote chips with such behaviour. Add a new IRQ data flag, IRQD_IRQ_FLOW_MASKED, to keep this flow-induced mask state separate from regular mask / unmask operations (IRQD_IRQ_MASKED). Signed-off-by: Valentin Schneider --- include/linux/irq.h | 10 ++++++++++ kernel/irq/chip.c | 5 +++++ kernel/irq/debugfs.c | 2 ++ kernel/irq/internals.h | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index bee82809107c..580b1b6b1799 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -219,6 +219,8 @@ struct irq_data { * irq_chip::irq_set_affinity() when deactivated. * IRQD_IRQ_ENABLED_ON_SUSPEND - Interrupt is enabled on suspend by irq pm if * irqchip have flag IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND set. + * IRQD_IRQ_FLOW_MASKED - Interrupt is masked by ACK. Only EOI can + * clear this. */ enum { IRQD_TRIGGER_MASK = 0xf, @@ -245,6 +247,7 @@ enum { IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28), IRQD_AFFINITY_ON_ACTIVATE = (1 << 29), IRQD_IRQ_ENABLED_ON_SUSPEND = (1 << 30), + IRQD_IRQ_FLOW_MASKED = (1 << 31), }; #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) @@ -349,6 +352,11 @@ static inline bool irqd_irq_masked(struct irq_data *d) return __irqd_to_state(d) & IRQD_IRQ_MASKED; } +static inline bool irqd_irq_flow_masked(struct irq_data *d) +{ + return __irqd_to_state(d) & IRQD_IRQ_FLOW_MASKED; +} + static inline bool irqd_irq_inprogress(struct irq_data *d) { return __irqd_to_state(d) & IRQD_IRQ_INPROGRESS; @@ -567,6 +575,7 @@ struct irq_chip { * IRQCHIP_SUPPORTS_NMI: Chip can deliver NMIs, only for root irqchips * IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND: Invokes __enable_irq()/__disable_irq() for wake irqs * in the suspend path if they are in disabled state + * IRQCHIP_AUTOMASKS_FLOW: chip->ack() masks and chip->eoi() unmasks */ enum { IRQCHIP_SET_TYPE_MASKED = (1 << 0), @@ -579,6 +588,7 @@ enum { IRQCHIP_SUPPORTS_LEVEL_MSI = (1 << 7), IRQCHIP_SUPPORTS_NMI = (1 << 8), IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND = (1 << 9), + IRQCHIP_AUTOMASKS_FLOW = (1 << 10), }; #include diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 8cc8e5713287..18c3b0e1568a 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -173,6 +173,11 @@ static void irq_state_clr_masked(struct irq_desc *desc) irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED); } +static void irq_state_clr_flow_masked(struct irq_desc *desc) +{ + irqd_clear(&desc->irq_data, IRQD_IRQ_FLOW_MASKED); +} + static void irq_state_clr_started(struct irq_desc *desc) { irqd_clear(&desc->irq_data, IRQD_IRQ_STARTED); diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index e4cff358b437..3ae83622d701 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -58,6 +58,7 @@ static const struct irq_bit_descr irqchip_flags[] = { BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI), BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI), BIT_MASK_DESCR(IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND), + BIT_MASK_DESCR(IRQCHIP_AUTOMASKS_FLOW), }; static void @@ -103,6 +104,7 @@ static const struct irq_bit_descr irqdata_states[] = { BIT_MASK_DESCR(IRQD_IRQ_STARTED), BIT_MASK_DESCR(IRQD_IRQ_DISABLED), BIT_MASK_DESCR(IRQD_IRQ_MASKED), + BIT_MASK_DESCR(IRQD_IRQ_FLOW_MASKED), BIT_MASK_DESCR(IRQD_IRQ_INPROGRESS), BIT_MASK_DESCR(IRQD_PER_CPU), diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index 54363527feea..b6c1cceddec0 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -245,6 +245,11 @@ static inline void irq_state_set_masked(struct irq_desc *desc) irqd_set(&desc->irq_data, IRQD_IRQ_MASKED); } +static inline void irq_state_set_flow_masked(struct irq_desc *desc) +{ + irqd_set(&desc->irq_data, IRQD_IRQ_FLOW_MASKED); +} + #undef __irqd_to_state static inline void __kstat_incr_irqs_this_cpu(struct irq_desc *desc) From patchwork Thu Apr 8 15:43:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191749 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.8 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 BD1A8C43461 for ; Thu, 8 Apr 2021 15:46:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 49BA561107 for ; Thu, 8 Apr 2021 15:46:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49BA561107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=HY1OIElPpKSJEZYhd6XQlPe9xGFEX0vJK2/EWqhWuqU=; b=ke5rIvZ6WCkv5FYtl1Qlm/zJ1 Ic4i1MIxfa8lFIgd/orIiaHhMVNTeoAVd7Y7MyGQcYALszhaC2iY7sM77TP0iwdJiSj8Wrj4xQ83O Dn5EUPBOaUa91nw6jGPHA5EGB21SH/orl5+DlwDusO+kqW1GiZ2Nt2+9Rv+uAEkL3Z3cbCJWCVATi 2RLNcJpxstpWoH42HiCn4Ro1R31Fbk+Hnl1I3ThzikHjdtaTttPUKT5GpM2t5fmdL6V08tF52mOG9 kLfzH6SY21LT5hv0GayW9hAzfMkS0eWzLTVhG3FMeVO0TAaAcB3B6dIYZh8ljYHOmucoPHpS2lV2I WTNwDRqhQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpM-008SGL-86; Thu, 08 Apr 2021 15:44:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpA-008SC2-7h for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25FE811D4; Thu, 8 Apr 2021 08:44:02 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 24BCE3F694; Thu, 8 Apr 2021 08:44:01 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 02/10] genirq: Define irq_ack() and irq_eoi() helpers Date: Thu, 8 Apr 2021 16:43:18 +0100 Message-Id: <20210408154326.3988781-3-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164405_088786_3F24FB6E X-CRM114-Status: UNSURE ( 8.84 ) X-CRM114-Notice: Please train this message. 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 The newly-added IRQCHIP_AUTOMASKS_FLOW flag requires some additional bookkeeping around chip->{irq_ack, irq_eoi}() calls. Define wrappers around those chip callbacks to drive the IRQD_IRQ_FLOW_MASKED state of an IRQ when the chip has the IRQCHIP_AUTOMASKS_FLOW flag. Signed-off-by: Valentin Schneider --- kernel/irq/chip.c | 16 ++++++++++++++++ kernel/irq/internals.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 18c3b0e1568a..046b4486c88c 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -408,6 +408,22 @@ void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu) cpumask_clear_cpu(cpu, desc->percpu_enabled); } +void ack_irq(struct irq_desc *desc) +{ + desc->irq_data.chip->irq_ack(&desc->irq_data); + + if (desc->irq_data.chip->flags & IRQCHIP_AUTOMASKS_FLOW) + irq_state_set_flow_masked(desc); +} + +void eoi_irq(struct irq_desc *desc) +{ + desc->irq_data.chip->irq_eoi(&desc->irq_data); + + if (desc->irq_data.chip->flags & IRQCHIP_AUTOMASKS_FLOW) + irq_state_clr_flow_masked(desc); +} + static inline void mask_ack_irq(struct irq_desc *desc) { if (desc->irq_data.chip->irq_mask_ack) { diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index b6c1cceddec0..090bd7868845 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -87,6 +87,8 @@ extern void irq_enable(struct irq_desc *desc); extern void irq_disable(struct irq_desc *desc); extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu); extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu); +extern void irq_ack(struct irq_desc *desc); +extern void irq_eoi(struct irq_desc *desc); extern void mask_irq(struct irq_desc *desc); extern void unmask_irq(struct irq_desc *desc); extern void unmask_threaded_irq(struct irq_desc *desc); From patchwork Thu Apr 8 15:43:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191747 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.8 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,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 2A07FC433ED for ; Thu, 8 Apr 2021 15:46:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8B5A961139 for ; Thu, 8 Apr 2021 15:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B5A961139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=c1WmFT8D64WB/F+fw0MA+Jk9LezOkSipo7vWW1qzo8U=; b=bZi2RjBxuzILZtR2aRe+KNIRv V5jcnZvlAi3qCJYp9dWQw1+l08MrWFd7pW2l6p43A/5wZWpM14/pmTGsn9r6qwAgmVpjiU08XXyi4 6WsG9IOog/Kt+OtfgHrMFYyJrJnVgoNJF+HJyxv9zfQv81xravdbDNH+WIldO+10VqQeJ9HuGJFcW X88Tu423RdtsrwE7HafRuFf/6XZn4bo1KJz+8yxQpA4RNxIy0fLKSvziTosR8SbysYpvw4liWbQpN VwCHqk+K53vzXn+ykGYkmEwUFvHuMmiZlWvxn8Eg8QhhyBPZ1gq8wjh34ma3DdcyX0hxfqb++S+VF mf8OMTUiw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpS-008SHG-OH; Thu, 08 Apr 2021 15:44:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpB-008SC5-7s for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AA0013A1; Thu, 8 Apr 2021 08:44:03 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 59F153F694; Thu, 8 Apr 2021 08:44:02 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 03/10] genirq: Employ ack_irq() and eoi_irq() where relevant Date: Thu, 8 Apr 2021 16:43:19 +0100 Message-Id: <20210408154326.3988781-4-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164405_448836_659A5A90 X-CRM114-Status: GOOD ( 10.70 ) 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 This can easily be coccinelle'd to replace all existing chip->irq_{ack, eoi} callsites, however not all callsites benefit from this replacement: fasteoi flow handlers for instance only deal with an ->irq_eoi() callback. Instead, only patch callsites that can benefit from the added functionality. Signed-off-by: Valentin Schneider --- kernel/irq/chip.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 046b4486c88c..936ef247b13d 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -429,10 +429,12 @@ static inline void mask_ack_irq(struct irq_desc *desc) if (desc->irq_data.chip->irq_mask_ack) { desc->irq_data.chip->irq_mask_ack(&desc->irq_data); irq_state_set_masked(desc); + if (desc->irq_data.chip->flags & IRQCHIP_AUTOMASKS_FLOW) + irq_state_set_flow_masked(desc); } else { mask_irq(desc); if (desc->irq_data.chip->irq_ack) - desc->irq_data.chip->irq_ack(&desc->irq_data); + ack_irq(desc); } } @@ -463,7 +465,7 @@ void unmask_threaded_irq(struct irq_desc *desc) struct irq_chip *chip = desc->irq_data.chip; if (chip->flags & IRQCHIP_EOI_THREADED) - chip->irq_eoi(&desc->irq_data); + eoi_irq(desc); unmask_irq(desc); } @@ -680,7 +682,7 @@ 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); + eoi_irq(desc); return; } /* @@ -691,10 +693,10 @@ static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip) */ if (!irqd_irq_disabled(&desc->irq_data) && irqd_irq_masked(&desc->irq_data) && !desc->threads_oneshot) { - chip->irq_eoi(&desc->irq_data); + eoi_irq(desc); unmask_irq(desc); } else if (!(chip->flags & IRQCHIP_EOI_THREADED)) { - chip->irq_eoi(&desc->irq_data); + eoi_irq(desc); } } From patchwork Thu Apr 8 15:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191751 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.8 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=unavailable 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 B88EDC43460 for ; Thu, 8 Apr 2021 15:46:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 4C8EF61139 for ; Thu, 8 Apr 2021 15:46:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C8EF61139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=o87wOLTrHeCA8Q5orw3y2xgh/yNmabsmXCLboe4PAXM=; b=D6NgM7mmn/v1mhI/vb/KduP67 bOZOMl4aBoBL4giZ+Lh1ctpCs5wXzKuwiwiwhqy8s5sSeF0ZdD3/c6p7d2Gm8jgu3IToJfK8nYRre pW9kuNdrVpY0wnXMsGrftQh6H8OZe13OSEgxvySYQYOTdORVFvyRUCkPj4o+Pp/3uHVR+6qZyPrNS 2aKZOAhpA3PAuVU9rySEEbJoMyVgD4RY5i4Gy/biSzia5nJkFSQodwdrUC7OVOxTsi+RBE1WCAvvz 1/VGsLkgrQFYbnlIeEu+C2bOrsHyHTakYKU4vWG2anS8nQ74QIpGbBlIlDqNdJtclxFw/tpCcsdjy QqyuOF6wA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpp-008SNb-Pe; Thu, 08 Apr 2021 15:44:46 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpE-008SDO-PV for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F2E71424; Thu, 8 Apr 2021 08:44:04 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8E9F93F694; Thu, 8 Apr 2021 08:44:03 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 04/10] genirq: Add handle_strict_flow_irq() flow handler Date: Thu, 8 Apr 2021 16:43:20 +0100 Message-Id: <20210408154326.3988781-5-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164409_421285_2D2CF95B X-CRM114-Status: GOOD ( 16.62 ) 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 The GIC family of irqchips have been so far treated as "fasteoi" chips. As handle_fasteoi_irq() states, this implies: * Only a single callback will be issued to the chip: an ->eoi() * call when the interrupt has been serviced. However, the GICs have an operating mode (EOImode=1) which requires an additional chip interaction during the IRQ handling. Said operating mode already has some uses with virtualization, but could also be leveraged to slightly optimize ONESHOT IRQs. This extra interaction is currently hidden away in the drivers, but further exploiting its effects (see IRQD_IRQ_FLOW_MASKED) requires lifting it from the driver code into core code. It so happens that it fits the role of ->irq_ack(); unfortunately, the GICs require both callbacks to be strictly paired with one another: for a given IRQ activation, there must be a single ->irq_ack() followed by a single ->irq_eoi(). No more, no less, and in that order. Introduce a new flow handler which guarantees said ack / eoi pairing. Note that it is strikingly similar to handle_fasteoi_mask_irq() for now, but will be further modified in later patches Signed-off-by: Valentin Schneider --- include/linux/irq.h | 1 + kernel/irq/chip.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 580b1b6b1799..b605f0929d97 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -661,6 +661,7 @@ extern void handle_edge_irq(struct irq_desc *desc); extern void handle_edge_eoi_irq(struct irq_desc *desc); extern void handle_simple_irq(struct irq_desc *desc); extern void handle_untracked_irq(struct irq_desc *desc); +extern void handle_strict_flow_irq(struct irq_desc *desc); extern void handle_percpu_irq(struct irq_desc *desc); extern void handle_percpu_devid_irq(struct irq_desc *desc); extern void handle_bad_irq(struct irq_desc *desc); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 936ef247b13d..6c033b0044cb 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -896,6 +896,54 @@ void handle_edge_eoi_irq(struct irq_desc *desc) } #endif +/** + * handle_strict_flow_irq - irq handler for strict controllers + * @desc: the interrupt description structure for this irq + * + * Ensures strict pairing of ->ack() and ->eoi() for any IRQ passing + * through here. The ->eoi() may be deferred to the tail of the IRQ thread + * for ONESHOT IRQs. + */ +void handle_strict_flow_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = desc->irq_data.chip; + + raw_spin_lock(&desc->lock); + mask_ack_irq(desc); + + if (!irq_may_run(desc)) + goto out; + + desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); + + /* + * If it's disabled or no action available then keep it masked and + * get out of here: + */ + if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { + desc->istate |= IRQS_PENDING; + goto out; + } + + kstat_incr_irqs_this_cpu(desc); + + handle_irq_event(desc); + + cond_unmask_eoi_irq(desc, chip); + + raw_spin_unlock(&desc->lock); + return; +out: + /* + * XXX: this is where IRQCHIP_EOI_IF_HANDLED would be checked, but + * it's conceptually incompatible with this handler (it breaks the + * strict pairing) + */ + eoi_irq(desc); + raw_spin_unlock(&desc->lock); +} +EXPORT_SYMBOL_GPL(handle_strict_flow_irq); + /** * handle_percpu_irq - Per CPU local irq handler * @desc: the interrupt description structure for this irq From patchwork Thu Apr 8 15:43:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191755 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.8 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 4458FC433B4 for ; Thu, 8 Apr 2021 15:46:29 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D973461108 for ; Thu, 8 Apr 2021 15:46:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D973461108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=tzxoF5FyVhMu/CKx17hSBrPTolPA53PqpW9PUlXVauQ=; b=lHmjxxQ5hvMLKOEMUW3xXmewN H15PsY67dxuQyc5c98s1EjNH32se6DHpkN3QPh9omWBixB1L24aREslvdJscsT1nFSGp5yVC+8yH7 kOO4YwfjN9yaUsaCmYpcOOfaSYRH7cCZ8I2J2tf12C5b9NpSrlxmKUuqv1taHMVYJeXvbuUdQvrVP f2Ei2n3H2Rlpojw/h8QTkOmZyG0fMRU8rw4DRKuBOxtt3SieZhT1hIY+wRSyRJJ5ugxRRFQ2BjdL1 AoFkAXXf0q2I/IlaDAT8YMlZtNmgHkOdikeL5qPz5+W9L244srAtL4dGyalW10YpKm4yNPfNX59w4 swZ3Tg3Gg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWqE-008SZE-6N; Thu, 08 Apr 2021 15:45:10 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpF-008SDU-K9 for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD39D1435; Thu, 8 Apr 2021 08:44:05 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C31643F694; Thu, 8 Apr 2021 08:44:04 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 05/10] genirq: Let purely flow-masked ONESHOT irqs through unmask_threaded_irq() Date: Thu, 8 Apr 2021 16:43:21 +0100 Message-Id: <20210408154326.3988781-6-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164409_834017_BD5C085D X-CRM114-Status: UNSURE ( 9.85 ) X-CRM114-Notice: Please train this message. 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 A subsequent patch will let IRQs end up in irq_finalize_oneshot() without IRQD_IRQ_MASKED, but with IRQD_IRQ_FLOW_MASKED set instead. Let such IRQs receive their final ->irq_eoi(). Signed-off-by: Valentin Schneider --- kernel/irq/manage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index e976c4927b25..59c8056d6714 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1076,7 +1076,7 @@ static void irq_finalize_oneshot(struct irq_desc *desc, desc->threads_oneshot &= ~action->thread_mask; if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) && - irqd_irq_masked(&desc->irq_data)) + (irqd_irq_masked(&desc->irq_data) || irqd_irq_flow_masked(&desc->irq_data))) unmask_threaded_irq(desc); out_unlock: From patchwork Thu Apr 8 15:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191761 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.8 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=unavailable 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 9C606C43460 for ; Thu, 8 Apr 2021 15:46:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 3FFCC61139 for ; Thu, 8 Apr 2021 15:46:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FFCC61139 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=UO7aoPN5KogeryKU9uYAlqTRv460rTNkm04IO6o1jbA=; b=AzQgx1wj09nAZG3bpK3lkShiy gNX+lfjSLgLvl5ETx4bZ9ozMJbM52/ACtUJDArMfoWLGt4wQ9pLdqtdKEhEl+bYiWnQVnb5/nIsvo G8P1uPAZn0Wvj237HlfOL3HxBwtkXkAUJoZXSFmhm4OS1CXO2Dff0/qtbr7U+UEjRMJ87IvtJFnO9 N30ZFjRxSA5rTpjgVU6PwRyBFvA633sUAuP98id6gzQRR4K4d/ebUy5OUOZOwimupzKhvrtXiVFJF gXPrwUwX22aWXkYucTDeyAG2SDMQr6XIO2sLtwZ8ZoAet6Xd9V+YPabjeaLMv5FDbSU8Fq4R0ZXrl u811jFucQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpi-008SL0-9c; Thu, 08 Apr 2021 15:44:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpE-008SDP-TY for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E779143B; Thu, 8 Apr 2021 08:44:07 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0D53A3F694; Thu, 8 Apr 2021 08:44:05 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 06/10] genirq: Don't mask IRQ within flow handler if IRQ is flow-masked Date: Thu, 8 Apr 2021 16:43:22 +0100 Message-Id: <20210408154326.3988781-7-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164409_425093_DC0B6D19 X-CRM114-Status: GOOD ( 13.39 ) 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 mask_irq() lets an IRQ with IRQD_IRQ_FLOW_MASKED set be further masked via chip->irq_mask(). This is necessary for unhandled IRQs as we want to keep them masked beyond eoi_irq() (which clears IRQD_IRQ_FLOW_MASKED). This is however not necessary in paths that do end up handling the IRQ and are bounded by a final eoi_irq() - this is the case for chips with IRQCHIP_AUTOMASKS_FLOW and IRQCHIP_EOI_THREADED. Make handle_strict_flow_irq() leverage IRQCHIP_AUTOMASKS_FLOW and issue an ack_irq() rather than a mask_ack_irq() when possible. Signed-off-by: Valentin Schneider --- kernel/irq/chip.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 6c033b0044cb..1add0b4f0662 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -909,10 +909,9 @@ void handle_strict_flow_irq(struct irq_desc *desc) struct irq_chip *chip = desc->irq_data.chip; raw_spin_lock(&desc->lock); - mask_ack_irq(desc); if (!irq_may_run(desc)) - goto out; + goto out_mask; desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); @@ -922,10 +921,21 @@ void handle_strict_flow_irq(struct irq_desc *desc) */ if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { desc->istate |= IRQS_PENDING; - goto out; + goto out_mask; } kstat_incr_irqs_this_cpu(desc); + /* + * Masking is required if IRQ is ONESHOT and we can't rely on the + * flow-masking persisting down to irq_finalize_oneshot() + * (in the IRQ thread). + */ + if ((desc->istate & IRQS_ONESHOT) && + (!(chip->flags & IRQCHIP_AUTOMASKS_FLOW) || + !(chip->flags & IRQCHIP_EOI_THREADED))) + mask_ack_irq(desc); + else + ack_irq(desc); handle_irq_event(desc); @@ -933,7 +943,8 @@ void handle_strict_flow_irq(struct irq_desc *desc) raw_spin_unlock(&desc->lock); return; -out: +out_mask: + mask_ack_irq(desc); /* * XXX: this is where IRQCHIP_EOI_IF_HANDLED would be checked, but * it's conceptually incompatible with this handler (it breaks the From patchwork Thu Apr 8 15:43:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191753 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.8 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=unavailable 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 EAC9EC433ED for ; Thu, 8 Apr 2021 15:46:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8BB5561107 for ; Thu, 8 Apr 2021 15:46:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BB5561107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=C+7nfJ5pUdNsy3yctUZ1f3/+XexG+DNpnCjWrzxyjKY=; b=YpMbveepkQ7nwww3ZwgCj6rP1 7BP5s2jGmo3h7oss5tKn+NBEtspzVCHGC3ylO+8KzRE7X2QkenAi32BQxupzHnH1U78SZY+VDMw9L 3bCFMtBVZ5tmVYGtvCE2FvXJugzYXR04fHo1oeNqFTD18esSB6Suh12HylePpo1jjjNW6+UDzb+JA A0QhMqyMfSM1cxznPDpTSpl2KCCFNKVmhusVsuidP4FHt7QGFGgUbOylFIr2leI8xisDUvrOrGGEi gWV06xGm2HPTdfa99qYz/Z//Cl5CQo5vSkfnD1xfgJb0FVhUlNil+D5sISJVniVIi8m0ICVCU4hBm UKxDgKsRg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWq5-008SVO-Oc; Thu, 08 Apr 2021 15:45:01 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpF-008SDs-Ok for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42F38D6E; Thu, 8 Apr 2021 08:44:08 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 428A13F694; Thu, 8 Apr 2021 08:44:07 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 07/10] genirq, irq-gic-v3: Make NMI flow handlers use ->irq_ack() if available Date: Thu, 8 Apr 2021 16:43:23 +0100 Message-Id: <20210408154326.3988781-8-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164410_112956_93FF7EA9 X-CRM114-Status: GOOD ( 15.22 ) 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 Subsequent patches will make the gic-v3 irqchip use an ->irq_ack() callback. As a preparation, make the NMI flow handlers call said callback if it is available. Since this departs from the fasteoi scheme of only issuing a suffix ->eoi(), rename the NMI flow handlers. Signed-off-by: Valentin Schneider --- drivers/irqchip/irq-gic-v3.c | 4 ++-- include/linux/irq.h | 4 ++-- kernel/irq/chip.c | 25 ++++++++++++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 94b89258d045..242a8fc5ec86 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -484,10 +484,10 @@ static int gic_irq_nmi_setup(struct irq_data *d) /* Setting up PPI as NMI, only switch handler for first NMI */ if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) { refcount_set(&ppi_nmi_refs[idx], 1); - desc->handle_irq = handle_percpu_devid_fasteoi_nmi; + desc->handle_irq = handle_percpu_devid_nmi; } } else { - desc->handle_irq = handle_fasteoi_nmi; + desc->handle_irq = handle_nmi; } gic_irq_set_prio(d, GICD_INT_NMI_PRI); diff --git a/include/linux/irq.h b/include/linux/irq.h index b605f0929d97..c39f46e37487 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -667,8 +667,8 @@ extern void handle_percpu_devid_irq(struct irq_desc *desc); extern void handle_bad_irq(struct irq_desc *desc); extern void handle_nested_irq(unsigned int irq); -extern void handle_fasteoi_nmi(struct irq_desc *desc); -extern void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc); +extern void handle_nmi(struct irq_desc *desc); +extern void handle_percpu_devid_nmi(struct irq_desc *desc); extern int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg); extern int irq_chip_pm_get(struct irq_data *data); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 1add0b4f0662..ea077333d676 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -748,18 +748,16 @@ void handle_fasteoi_irq(struct irq_desc *desc) EXPORT_SYMBOL_GPL(handle_fasteoi_irq); /** - * handle_fasteoi_nmi - irq handler for NMI interrupt lines + * handle_nmi - irq handler for NMI interrupt lines * @desc: the interrupt description structure for this irq * * A simple NMI-safe handler, considering the restrictions * from request_nmi. * - * Only a single callback will be issued to the chip: an ->eoi() - * call when the interrupt has been serviced. This enables support - * for modern forms of interrupt handlers, which handle the flow - * details in hardware, transparently. + * An ->ack() callback will be issued before servicing the interrupt, + * followed by an ->eoi() call. */ -void handle_fasteoi_nmi(struct irq_desc *desc) +void handle_nmi(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct irqaction *action = desc->action; @@ -768,6 +766,9 @@ void handle_fasteoi_nmi(struct irq_desc *desc) __kstat_incr_irqs_this_cpu(desc); + if (chip->irq_ack) + chip->irq_ack(&desc->irq_data); + trace_irq_handler_entry(irq, action); /* * NMIs cannot be shared, there is only one action. @@ -778,7 +779,7 @@ void handle_fasteoi_nmi(struct irq_desc *desc) if (chip->irq_eoi) chip->irq_eoi(&desc->irq_data); } -EXPORT_SYMBOL_GPL(handle_fasteoi_nmi); +EXPORT_SYMBOL_GPL(handle_nmi); /** * handle_edge_irq - edge type IRQ handler @@ -1027,14 +1028,13 @@ void handle_percpu_devid_irq(struct irq_desc *desc) } /** - * handle_percpu_devid_fasteoi_nmi - Per CPU local NMI handler with per cpu + * handle_percpu_devid_nmi - Per CPU local NMI handler with per cpu * dev ids * @desc: the interrupt description structure for this irq * - * Similar to handle_fasteoi_nmi, but handling the dev_id cookie - * as a percpu pointer. + * Similar to handle_nmi, but handling the dev_id cookie as a percpu pointer. */ -void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc) +void handle_percpu_devid_nmi(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct irqaction *action = desc->action; @@ -1043,6 +1043,9 @@ void handle_percpu_devid_fasteoi_nmi(struct irq_desc *desc) __kstat_incr_irqs_this_cpu(desc); + if (chip->irq_ack) + chip->irq_ack(&desc->irq_data); + trace_irq_handler_entry(irq, action); res = action->handler(irq, raw_cpu_ptr(action->percpu_dev_id)); trace_irq_handler_exit(irq, action, res); From patchwork Thu Apr 8 15:43:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191745 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.8 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 42EB7C433B4 for ; Thu, 8 Apr 2021 15:46:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 BBFD061107 for ; Thu, 8 Apr 2021 15:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBFD061107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=p9CkSoHeNIiY1374tAJl1tzH97yghWrUMMB5aIRt1mI=; b=YY1HUT2SFicwk0X35Wj+C4CAT dzLGXOZJMEibvAc8sSO++F0JAzW7ObSx9OGuEk0gaCWK8RhvY+pdV1865ZYR7B9m7n2Xv6E1/kghw PKmcCjMm0BZAN3KFyImxqbsOUwp3mN8LUjAxU5O0QkWqEEok71YNvt8SG2EFFKfaG52Uj+hELPDK+ /Bgd+To6qhxxcZb5YDla5noJPxdTNxVEWkWLvlOhKTwLz9RRMTjdsm2NQeZ/vunMZ3M47T9UC/tvK Htac47+Nc+7DlNhIqo8onbWjOB7OIs4C+CCqAV9H2E5ZAdKPECgRzGEii4bWaIUgMtykQUaSr4i3z +X7yn5zGQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpy-008SS4-4R; Thu, 08 Apr 2021 15:44:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpG-008SEB-Bh for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 78DFF11B3; Thu, 8 Apr 2021 08:44:09 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 770373F694; Thu, 8 Apr 2021 08:44:08 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 08/10] irqchip/gic-v3-its: Use irq_chip_ack_parent() Date: Thu, 8 Apr 2021 16:43:24 +0100 Message-Id: <20210408154326.3988781-9-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164410_586935_C3065F76 X-CRM114-Status: GOOD ( 10.42 ) 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 Subsequent patches will make the GIC irqchips use a flow handler that issues an ->irq_ack(). irqchips of child domains need to handle this. Note: I'm very much not fond of this; this is treacherous and explodes if any parent chip doesn't have an ->ack() callback. It turns out okay with EOImode=0 because handle_fasteoi_irq() doesn't issue any ->ack(), but that is very fragile at best. An alternative would be to o make irq_chip_ack_parent() check the callback against NULL o make irq_chip_ack_parent() the default chip->irq_ack() via MSI_FLAG_USE_DEF_CHIP_OPS. XXX: what about pMSI and fMSI ? Signed-off-by: Valentin Schneider --- drivers/irqchip/irq-gic-v3-its-pci-msi.c | 1 + drivers/irqchip/irq-gic-v3-its.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index ad2810c017ed..5bc2787ee86a 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -27,6 +27,7 @@ static struct irq_chip its_msi_irq_chip = { .name = "ITS-MSI", .irq_unmask = its_unmask_msi_irq, .irq_mask = its_mask_msi_irq, + .irq_ack = irq_chip_ack_parent, .irq_eoi = irq_chip_eoi_parent, .irq_write_msi_msg = pci_msi_domain_write_msg, }; diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index c3485b230d70..d6856750c084 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1971,6 +1971,7 @@ static struct irq_chip its_irq_chip = { .name = "ITS", .irq_mask = its_mask_irq, .irq_unmask = its_unmask_irq, + .irq_ack = irq_chip_ack_parent, .irq_eoi = irq_chip_eoi_parent, .irq_set_affinity = its_set_affinity, .irq_compose_msi_msg = its_irq_compose_msi_msg, From patchwork Thu Apr 8 15:43:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191759 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.8 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=unavailable 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 E8DABC433B4 for ; Thu, 8 Apr 2021 15:46:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 9219D61107 for ; Thu, 8 Apr 2021 15:46:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9219D61107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=F37nbPTFwE5R/AvGvVV1moJcaDcVfrhgWezUzzkcrBI=; b=WxOdbBhIBhJOa+si1wkf3E0uN /doDFOs5HzWrEA3AZM8L7oWuHId7KlVhaqXEF9v2yEN59eKO0Y4aI5RvPo0uUbPB5Ge4PhjN2XDhP SJNAXPUGQ5L23RY1x/a0wyXB61+cIUOeAoGUiu86Amu/0CUczYIgdqfR2IhGqgP8cm+sXGn8HBU+0 wu//AMjlzEReuVxv3RkeiZs/fGSCiWUdkHksHOasio16s4se5JwHjhVz2m30PEb8emKw60m7sK2pk g0QNdjqr95xlv+EfS3BsItp+Ig0u9aiJ7kV1qtkm/ACxv3Y1IWsCBVRFz0+z4eCTCITYXl+GUl1fb wJAx55DBg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWqO-008SfT-QX; Thu, 08 Apr 2021 15:45:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpI-008SDP-Kd for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AEA5E11D4; Thu, 8 Apr 2021 08:44:10 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AD7613F694; Thu, 8 Apr 2021 08:44:09 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 09/10] irqchip/gic: Convert to handle_strict_flow_irq() Date: Thu, 8 Apr 2021 16:43:25 +0100 Message-Id: <20210408154326.3988781-10-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164413_408810_587B39F3 X-CRM114-Status: GOOD ( 14.70 ) 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 Now that the proper infrastructure is in place, convert the irq-gic chip to use handle_strict_flow_irq() along with IRQCHIP_AUTOMASKS_FLOW. For EOImode=1, the Priority Drop is moved from gic_handle_irq() into chip->irq_ack(). This effectively pushes the EOI write down into ->handle_irq(), but doesn't change its ordering wrt the irqaction handling. The EOImode=1 irqchip also gains IRQCHIP_EOI_THREADED, which allows the ->irq_eoi() call to be deferred to the tail of ONESHOT IRQ threads. This means a threaded ONESHOT IRQ can now be handled entirely without a single chip->irq_mask() call. EOImode=0 handling remains unchanged. Signed-off-by: Valentin Schneider --- drivers/irqchip/irq-gic.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index b1d9c22caf2e..4919478c3e41 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -344,8 +344,6 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) if (unlikely(irqnr >= 1020)) break; - if (static_branch_likely(&supports_deactivate_key)) - writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); isb(); /* @@ -1012,7 +1010,9 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, break; default: irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data, - handle_fasteoi_irq, NULL, NULL); + static_branch_likely(&supports_deactivate_key) ? + handle_strict_flow_irq : handle_fasteoi_irq, + NULL, NULL); irq_set_probe(irq); irqd_set_single_target(irqd); break; @@ -1116,8 +1116,16 @@ static void gic_init_chip(struct gic_chip_data *gic, struct device *dev, if (use_eoimode1) { gic->chip.irq_mask = gic_eoimode1_mask_irq; + gic->chip.irq_ack = gic_eoi_irq; gic->chip.irq_eoi = gic_eoimode1_eoi_irq; gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity; + + /* + * eoimode0 shouldn't expose FLOW_MASK because the priority + * drop is undissociable from the deactivation, and we do need + * the priority drop to happen within the flow handler. + */ + gic->chip.flags |= IRQCHIP_AUTOMASKS_FLOW | IRQCHIP_EOI_THREADED; } if (gic == &gic_data[0]) { From patchwork Thu Apr 8 15:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 12191763 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.8 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=unavailable 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 B490CC433ED for ; Thu, 8 Apr 2021 15:47:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 55A9161107 for ; Thu, 8 Apr 2021 15:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55A9161107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=CAtPL89zSqFMHorDKP7oXouoSamU0lAAa9Wt04C2s5o=; b=ZfOqczVTmaGF196pQ8M1UOu3Y ujFR1njt9/YpEacNX1H5h8p5eb/7L7WvArPBBxCejWS2vmhYp9TBeWwlAOfwzuGx1rE4Fv2eFFvAV zHapoardFfhYLrM5q41mtJqo7s7TTNivPHNiHOxOjqT1cseKj1bzYFSIVUSIe4LDCimGqrSdy3Dku DC3X+Ztf/fCUu5/PfXdUu63ljPo1W6V5M25uspEnnemrP6vWEYdiIU27O7fuk4FC2SOaw+WbeF0TQ 7pZXCE2wr94XBl/oheJyx2V0vAlWaVLHFP04qvUBP+YDSY48XNrcvDQDpDedXN/CGPZuCrFU7jBQd NsnNhg/zg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWqX-008SlC-Mi; Thu, 08 Apr 2021 15:45:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWpJ-008SFP-G9 for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:44:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6E2513A1; Thu, 8 Apr 2021 08:44:11 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E41123F694; Thu, 8 Apr 2021 08:44:10 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH 10/10] irqchip/gic-v3: Convert to handle_strict_flow_irq() Date: Thu, 8 Apr 2021 16:43:26 +0100 Message-Id: <20210408154326.3988781-11-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408154326.3988781-1-valentin.schneider@arm.com> References: <20210408154326.3988781-1-valentin.schneider@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_164413_955145_39224ACD X-CRM114-Status: GOOD ( 15.09 ) 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 Now that the proper infrastructure is in place, convert the irq-gic-v3 chip to use handle_strict_flow_irq() along with IRQCHIP_AUTOMASKS_FLOW. For EOImode=1, the Priority Drop is moved from gic_handle_irq() into chip->irq_ack(). This effectively pushes the EOIR write down into ->handle_irq(), but doesn't change its ordering wrt the irqaction handling. The EOImode=1 irqchip also gains IRQCHIP_EOI_THREADED, which allows the ->irq_eoi() call to be deferred to the tail of ONESHOT IRQ threads. This means a threaded ONESHOT IRQ can now be handled entirely without a single chip->irq_mask() call. Despite not having an Active state, LPIs are made to use handle_strict_flow_irq() as well. This lets them re-use gic_eoimode1_chip.irq_ack() as Priority Drop, rather than special-case them in gic_handle_irq(). EOImode=0 handling remains unchanged. Signed-off-by: Valentin Schneider --- drivers/irqchip/irq-gic-v3.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 242a8fc5ec86..da73398117a7 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -626,8 +626,6 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) if (irqs_enabled) nmi_enter(); - if (static_branch_likely(&supports_deactivate_key)) - gic_write_eoir(irqnr); /* * Leave the PSR.I bit set to prevent other NMIs to be * received while handling this one. @@ -663,9 +661,11 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs if ((irqnr >= 1020 && irqnr <= 1023)) return; - if (static_branch_likely(&supports_deactivate_key)) - gic_write_eoir(irqnr); - else + /* + * eoimode1 will give us an isb in handle_domain_irq(), before + * handle_irq_event(). + */ + if (!static_branch_likely(&supports_deactivate_key)) isb(); if (handle_domain_irq(gic_data.domain, irqnr, regs)) { @@ -1276,6 +1276,7 @@ static struct irq_chip gic_eoimode1_chip = { .name = "GICv3", .irq_mask = gic_eoimode1_mask_irq, .irq_unmask = gic_unmask_irq, + .irq_ack = gic_eoi_irq, .irq_eoi = gic_eoimode1_eoi_irq, .irq_set_type = gic_set_type, .irq_set_affinity = gic_set_affinity, @@ -1288,7 +1289,9 @@ static struct irq_chip gic_eoimode1_chip = { .ipi_send_mask = gic_ipi_send_mask, .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE | - IRQCHIP_MASK_ON_SUSPEND, + IRQCHIP_MASK_ON_SUSPEND | + IRQCHIP_AUTOMASKS_FLOW | + IRQCHIP_EOI_THREADED, }; static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, @@ -1312,7 +1315,9 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, case SPI_RANGE: case ESPI_RANGE: irq_domain_set_info(d, irq, hw, chip, d->host_data, - handle_fasteoi_irq, NULL, NULL); + static_branch_likely(&supports_deactivate_key) ? + handle_strict_flow_irq : handle_fasteoi_irq, + NULL, NULL); irq_set_probe(irq); irqd_set_single_target(irqd); break; @@ -1321,7 +1326,9 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq, if (!gic_dist_supports_lpis()) return -EPERM; irq_domain_set_info(d, irq, hw, chip, d->host_data, - handle_fasteoi_irq, NULL, NULL); + static_branch_likely(&supports_deactivate_key) ? + handle_strict_flow_irq : handle_fasteoi_irq, + NULL, NULL); break; default: