Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1149028pxm; Thu, 3 Mar 2022 11:16:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsht4YL+9N0WHJmKcbE+wDQVQoOqK+M06DmbWuIJDKDH6JZ43AwOPRHBtt+5p6mxZmWLg9 X-Received: by 2002:a17:90a:d084:b0:1bf:16a7:8c96 with SMTP id k4-20020a17090ad08400b001bf16a78c96mr3033628pju.171.1646334964591; Thu, 03 Mar 2022 11:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646334964; cv=none; d=google.com; s=arc-20160816; b=EJMR2Nl0r2QCI24N1T5/qy7RpZWlDQXG9NEuZMY0lJamLC8T2ewLjGyCVID0M//Uyj tYqXr5ZRDfhgg9btAgYRGXt3+zKCyvx/N1h4liDgT/dh+0fgsLuafOG+UExidQCVAg+a 8Div7idaC8vNryaQAfVoIcfQicDv0M4tZiMUJHacBpRa8OcjC4W+gEqriYzgThPEWbN8 DtVsxHfmA+Ka0aKifY2V24i4osdGHkICP1C7sZMaG8YdU3ffpnaet2jhYRj1Keqr4vEA gfslZHP7kbDrGrvh4hoL6/z9P8qC/OLX3XJ+8JYmeu9bm5KBqUbQTZfeOVz+3xh7ruJ4 ax3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=InGW9sFUdO+qnBfKNzbRqrxIw1fDQUGg83KS53y3WJc=; b=n9B9s/p4Un7DCqMxhUngISHc7vcqm9CFDYbk7Occ7p9vequ0LM9GmcFnslGh9CNgEV s+TJjjE1VyMnKaKJZTWMgn2sZAPS54IVufwE5Pq8s+Z+hYgGjqfuIFCTISjxRmMaFfOb px+5ZLsAyjYM4sKuwR/Y/ko2wTGiD5UjOw5nHw8ARKcN8rbWyXXMLJSb0cdHZJLbEX3W sd5xnAAQuYM/8lAiQo3vUSkiThf9+cv/hkZRnnHtNn5OLQf8T6zp1cx7mYCJRs2ZjECM VfWk435Kg534MEUCeyayfOa6ssiYzuJYgtSD9yzYpVaHc8aR+ZSyGF3oviPLYpPGO3Wg T1fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P4V+RsV6; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a63cf4a000000b00378ccfb4083si2717939pgj.632.2022.03.03.11.15.48; Thu, 03 Mar 2022 11:16:04 -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=@kernel.org header.s=k20201202 header.b=P4V+RsV6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235311AbiCCRYz (ORCPT + 99 others); Thu, 3 Mar 2022 12:24:55 -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 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: 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.