From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E2D0C433EF for ; Thu, 3 Mar 2022 17:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233371AbiCCRY4 (ORCPT ); Thu, 3 Mar 2022 12:24:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235306AbiCCRYy (ORCPT ); Thu, 3 Mar 2022 12:24:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED909182D95 for ; Thu, 3 Mar 2022 09:24:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A8F8EB8260E for ; Thu, 3 Mar 2022 17:24:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68A37C004E1; Thu, 3 Mar 2022 17:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646328245; bh=GZ362Y0qUSRyFFpLdb4duoISMS1QflKC2n25Lzoe8G0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=P4V+RsV6L49Igx7yjoqdrFJtGQ+6Vcjlr1volUIgyMrarcFrl6mTdTXvyU97Bhrov A5JUOnnp53/6PHzvAR+XNOlOp/IH1/PXIgtYhDtPQddmJyIpSIkQMsgybsTl6ENVFG cq2T6lRJpvfSP8sFBmUJDfyEA88BajVZZHaV9gbr8V8OyFIVuZkC/1k8UgS47sgr8H xYF86JWHoPsfDFrCNl/dm7GwubVVslyRfevirxZjH+NmDE8OrBNBrFyCgdMf9OdFJw Q2ElhfHUUBmMNkaP9s02pk5BHuUbzvyjtW9QCbRoA/l3JDE7ECFTciHAx/eC/3i2PJ yQVK8ttsW2LSQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nPpBL-00C0z8-27; Thu, 03 Mar 2022 17:24:03 +0000 Date: Thu, 03 Mar 2022 17:24:02 +0000 Message-ID: <87sfrz0x1p.wl-maz@kernel.org> From: Marc Zyngier To: Michal Simek Cc: linux-kernel@vger.kernel.org, monstr@monstr.eu, git@xilinx.com, Robert Hancock , Stefan Asserhall , Thomas Gleixner , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] irqchip: xilinx: Enable generic irq multi handler In-Reply-To: <2a08d6c33e95d5da5d564ed3fbddc835983ef355.1646323896.git.michal.simek@xilinx.com> References: <2a08d6c33e95d5da5d564ed3fbddc835983ef355.1646323896.git.michal.simek@xilinx.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: michal.simek@xilinx.com, linux-kernel@vger.kernel.org, monstr@monstr.eu, git@xilinx.com, robert.hancock@calian.com, stefan.asserhall@xilinx.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 03 Mar 2022 16:11:39 +0000, Michal Simek wrote: > > Register default arch handler via driver instead of directly pointing to > xilinx intc controller. This patch makes architecture code more generic. > > Signed-off-by: Michal Simek > Reviewed-by: Stefan Asserhall > --- > > arch/microblaze/Kconfig | 2 ++ > arch/microblaze/include/asm/irq.h | 3 --- > arch/microblaze/kernel/irq.c | 16 +--------------- > drivers/irqchip/irq-xilinx-intc.c | 22 +++++++++++++++++++++- > 4 files changed, 24 insertions(+), 19 deletions(-) > > diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig > index 59798e43cdb0..da568e981604 100644 > --- a/arch/microblaze/Kconfig > +++ b/arch/microblaze/Kconfig > @@ -45,6 +45,8 @@ config MICROBLAZE > select SET_FS > select ZONE_DMA > select TRACE_IRQFLAGS_SUPPORT > + select GENERIC_IRQ_MULTI_HANDLER > + select HANDLE_DOMAIN_IRQ > > # Endianness selection > choice > diff --git a/arch/microblaze/include/asm/irq.h b/arch/microblaze/include/asm/irq.h > index 0a28e80bbab0..cb6ab55d1d01 100644 > --- a/arch/microblaze/include/asm/irq.h > +++ b/arch/microblaze/include/asm/irq.h > @@ -11,7 +11,4 @@ > struct pt_regs; > extern void do_IRQ(struct pt_regs *regs); > > -/* should be defined in each interrupt controller driver */ > -extern unsigned int xintc_get_irq(void); > - > #endif /* _ASM_MICROBLAZE_IRQ_H */ > diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c > index 903dad822fad..1f8cb4c4f74f 100644 > --- a/arch/microblaze/kernel/irq.c > +++ b/arch/microblaze/kernel/irq.c > @@ -20,27 +20,13 @@ > #include > #include > > -static u32 concurrent_irq; > - > void __irq_entry do_IRQ(struct pt_regs *regs) > { > - unsigned int irq; > struct pt_regs *old_regs = set_irq_regs(regs); > trace_hardirqs_off(); > > irq_enter(); > - irq = xintc_get_irq(); > -next_irq: > - BUG_ON(!irq); > - generic_handle_irq(irq); > - > - irq = xintc_get_irq(); > - if (irq != -1U) { > - pr_debug("next irq: %d\n", irq); > - ++concurrent_irq; > - goto next_irq; > - } > - > + handle_arch_irq(regs); > irq_exit(); > set_irq_regs(old_regs); > trace_hardirqs_on(); > diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c > index 356a59755d63..c6710190c152 100644 > --- a/drivers/irqchip/irq-xilinx-intc.c > +++ b/drivers/irqchip/irq-xilinx-intc.c > @@ -110,7 +110,7 @@ static struct irq_chip intc_dev = { > .irq_mask_ack = intc_mask_ack, > }; > > -unsigned int xintc_get_irq(void) > +static unsigned int xintc_get_irq(void) > { > unsigned int irq = -1; > u32 hwirq; > @@ -164,6 +164,25 @@ static void xil_intc_irq_handler(struct irq_desc *desc) > chained_irq_exit(chip, desc); > } > > +static u32 concurrent_irq; Please kill this. It serves no purpose at all. > + > +static void xil_intc_handle_irq(struct pt_regs *regs) > +{ > + unsigned int irq; > + > + irq = xintc_get_irq(); > +next_irq: > + BUG_ON(!irq); > + generic_handle_irq(irq); > + > + irq = xintc_get_irq(); > + if (irq != -1U) { > + pr_debug("next irq: %d\n", irq); > + ++concurrent_irq; > + goto next_irq; > + } How about writing this in (basic) C code, and use the exiting APIs? diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c index 356a59755d63..18125bb841b2 100644 --- a/drivers/irqchip/irq-xilinx-intc.c +++ b/drivers/irqchip/irq-xilinx-intc.c @@ -110,18 +110,19 @@ static struct irq_chip intc_dev = { .irq_mask_ack = intc_mask_ack, }; -unsigned int xintc_get_irq(void) +#define SPURIOUS_IRQ (-1U) + +static void xil_intc_handle_irq(struct pt_regs *regs) { - unsigned int irq = -1; u32 hwirq; - hwirq = xintc_read(primary_intc, IVR); - if (hwirq != -1U) - irq = irq_find_mapping(primary_intc->root_domain, hwirq); - - pr_debug("irq-xilinx: hwirq=%d, irq=%d\n", hwirq, irq); + do { + hwirq = xintc_read(primary_intc, IVR); + if (unlikely(hwirq == SPURIOUS_IRQ)) + break; - return irq; + generic_handle_domain_irq(primary_intc->root_domain, hwirq); + } while (true); } static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) M. -- Without deviation from the norm, progress is not possible.