Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp874209pxb; Thu, 21 Oct 2021 11:06:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwirGJZRfekHdGXtadhE0fmwSw58laSpVTU7GQrqlzb0ryoGRrFrwn2hcVqgd8Ifqpgcm7U X-Received: by 2002:a17:902:ecc5:b0:13f:551b:d94 with SMTP id a5-20020a170902ecc500b0013f551b0d94mr6517365plh.70.1634839599325; Thu, 21 Oct 2021 11:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634839599; cv=none; d=google.com; s=arc-20160816; b=ugaxEsBAhN9GVo7/iA27qFTQeMDWSJo1nkAz3TFvfdwVISSTKwGvND0QAIRGd3nwXo xmnXEfQDRKKhX8B7oevbs2gNYFElbrEoSskG1/Olyl6vpq0TccZWpv6ejZ4Pbd9lyEqm cvvYRQoWRIB/wep32zGUH2GsSP9xSDep+JF8nh/6fOtBu60sLk1O9oiXZ5sm+j+oWsrl k/tDnFQF/put8JtnLzF2rBF2Ih8g0U/i+bxs+JvQ2GZPkOno9vH12Hlf3OpB6+eatvUG fn60lNp2wyaoKJ/H9uBilgmnJh7hfqrp4MzjjSeH50/LOMO6bsTzL+28u4iFOkLHrXpA Pfcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=u/KPgwIOpGONWTas6rS2p0eVxDFmyQD9kTsTRlVq/iw=; b=GQLuOqr1oRWHCr/R3xN1vCwV2bdvkM+3EG7Nm/CFTe+umHTHYiBZzKWwN1acFYURvv UvdVEWJQWd5PneFPSWjtrn/gNLkjupu/7ofIIw4s7Ej2d0tR0QaPsolwF24fhxfEw9vH GFxO/nmCA7PFW9pvGB12lgk2/NmsLfLH4k3jjKTiiMaw9Zl1+ogpx2LrjFem2O8Zcp8S qv+faSFice5AhyvEbqvGQuA4wk0RjquzsNcFWnjAlYkz+UVV91oKxRw87sEH5NLNmQEf VMh72SHwUaFAlulxol4AChOG0AiqXj2vp0lL4RkYtodHifCep5jiF1GcFSLh+Vf7JaAl prXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me16si15955905pjb.74.2021.10.21.11.06.23; Thu, 21 Oct 2021 11:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232549AbhJUSFl (ORCPT + 99 others); Thu, 21 Oct 2021 14:05:41 -0400 Received: from foss.arm.com ([217.140.110.172]:46086 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232492AbhJUSFh (ORCPT ); Thu, 21 Oct 2021 14:05:37 -0400 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 18B6FED1; Thu, 21 Oct 2021 11:03:21 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A99B3F70D; Thu, 21 Oct 2021 11:03:18 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: aou@eecs.berkeley.edu, catalin.marinas@arm.com, deanbo422@gmail.com, green.hu@gmail.com, guoren@kernel.org, jonas@southpole.se, kernelfans@gmail.com, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, mark.rutland@arm.com, maz@kernel.org, nickhu@andestech.com, palmer@dabbelt.com, paulmck@kernel.org, paul.walmsley@sifive.com, peterz@infradead.org, shorne@gmail.com, stefan.kristiansson@saunalahti.fi, tglx@linutronix.de, torvalds@linux-foundation.org, tsbogend@alpha.franken.de, vgupta@kernel.org, will@kernel.org Subject: [PATCH 09/15] irq: arm: perform irqentry in entry code Date: Thu, 21 Oct 2021 19:02:30 +0100 Message-Id: <20211021180236.37428-10-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211021180236.37428-1-mark.rutland@arm.com> References: <20211021180236.37428-1-mark.rutland@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for removing HANDLE_DOMAIN_IRQ_IRQENTRY, have arch/arm perform all the irqentry accounting in its entry code. For configurations with CONFIG_GENERIC_IRQ_MULTI_HANDLER, we can use generic_handle_arch_irq(). Other than asm_do_IRQ(), all C calls to handle_IRQ() are from irqchip handlers which will be called from generic_handle_arch_irq(), so to avoid double accounting IRQ entry, the entry logic is moved from handle_IRQ() into asm_do_IRQ(). For ARMv7M the entry assembly is tightly coupled with the NVIC irqchip, and while the entry code should logically live under arch/arm/, moving the entry logic there makes things more convoluted. So for now, place the entry logic in the NVIC irqchip, but separated into a separate function to make the split of responsibility clear. For all other configurations without CONFIG_GENERIC_IRQ_MULTI_HANDLER, IRQ entry is already handled in arch code, and requires no changes. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Marc Zyngier Cc: Russell King Cc: Thomas Gleixner --- arch/arm/Kconfig | 1 - arch/arm/kernel/entry-armv.S | 5 +---- arch/arm/kernel/irq.c | 14 ++++++++------ drivers/irqchip/irq-nvic.c | 19 +++++++++++++++++-- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f18aff82c27b..fc196421b2ce 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -65,7 +65,6 @@ config ARM select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select HANDLE_DOMAIN_IRQ - select HANDLE_DOMAIN_IRQ_IRQENTRY select HARDIRQS_SW_RESEND select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 241b73d64df7..3d0b6169ab86 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -38,14 +38,11 @@ */ .macro irq_handler #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER - ldr r1, =handle_arch_irq mov r0, sp - badr lr, 9997f - ldr pc, [r1] + bl generic_handle_arch_irq #else arch_irq_handler_default #endif -9997: .endm .macro pabt_helper diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c index 20ab1e607522..b79975bd988c 100644 --- a/arch/arm/kernel/irq.c +++ b/arch/arm/kernel/irq.c @@ -63,11 +63,8 @@ int arch_show_interrupts(struct seq_file *p, int prec) */ void handle_IRQ(unsigned int irq, struct pt_regs *regs) { - struct pt_regs *old_regs = set_irq_regs(regs); struct irq_desc *desc; - irq_enter(); - /* * Some hardware gives randomly wrong interrupts. Rather * than crashing, do something sensible. @@ -81,9 +78,6 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs) handle_irq_desc(desc); else ack_bad_irq(irq); - - irq_exit(); - set_irq_regs(old_regs); } /* @@ -92,7 +86,15 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs) asmlinkage void __exception_irq_entry asm_do_IRQ(unsigned int irq, struct pt_regs *regs) { + struct pt_regs *old_regs; + + irq_enter(); + old_regs = set_irq_regs(regs); + handle_IRQ(irq, regs); + + set_irq_regs(old_regs); + irq_exit(); } void __init init_IRQ(void) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index b31c4cff4d3a..ce330880665e 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -37,12 +37,27 @@ static struct irq_domain *nvic_irq_domain; -asmlinkage void __exception_irq_entry -nvic_handle_irq(irq_hw_number_t hwirq, struct pt_regs *regs) +static void __nvic_handle_irq(irq_hw_number_t hwirq, struct pt_regs *regs) { handle_domain_irq(nvic_irq_domain, hwirq, regs); } +/* + * TODO: restructure the ARMv7M entry logic so that this entry logic can live + * in arch code. + */ +asmlinkage void __exception_irq_entry +static void nvic_handle_irq(irq_hw_number_t hwirq, struct pt_regs *regs) +{ + struct pt_regs *old_regs; + + irq_enter(); + old_regs = set_irq_regs(regs); + __nvic_handle_irq(hwirq, regs); + set_irq_regs(old_regs); + irq_exit(); +} + static int nvic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *arg) { -- 2.11.0