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 A7299C433F5 for ; Mon, 21 Feb 2022 10:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354675AbiBUKa2 (ORCPT ); Mon, 21 Feb 2022 05:30:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354769AbiBUKaE (ORCPT ); Mon, 21 Feb 2022 05:30:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8567388A for ; Mon, 21 Feb 2022 01:51:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 70F9661287 for ; Mon, 21 Feb 2022 09:51:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF43AC340E9; Mon, 21 Feb 2022 09:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645437089; bh=jSVcifAMDPVThIKGzy0uf6Y6fAYbzhFp8WjCr7BfUzw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Sxxu7mfdBf0kvpnjbd2MnvMv/koS9mwya2dPlPOAbhwpd1dByF2wuTpK1jjGXXbRh t3mcp6HP/v34YzkV7raSU/pNTgXXUF+kOFviP5AyJfpkuF58fUqoKG1yfve5Al0vZz HpcVbAB+YuqRoFMVuY1pdYCPjc/njROVf+SLXRCbQciAUkNIcMQtg7tVt785TG1Ckx olIsUTnBRDe4oJaJhQ8oV0ZD2p+E+rQkQupJSmdESdfSiVB7Xlm2pUqPRU2qinID18 UAqDfq1yTNGVMZgWLEAwNcw82JdogidZO7ZKvqNElEeDbffKXmdYYtH2MSM6RlZraW mX2EtbJjjPqng== 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 1nM5Lr-009FfY-M0; Mon, 21 Feb 2022 09:51:27 +0000 Date: Mon, 21 Feb 2022 09:51:27 +0000 Message-ID: <87czjg4kf4.wl-maz@kernel.org> From: Marc Zyngier To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Daniel Lezcano , Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/6] irqchip/riscv-intc: Allow drivers to directly discover INTC hwnode In-Reply-To: <20220220050854.743420-3-apatel@ventanamicro.com> References: <20220220050854.743420-1-apatel@ventanamicro.com> <20220220050854.743420-3-apatel@ventanamicro.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: apatel@ventanamicro.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, daniel.lezcano@linaro.org, atishp@atishpatra.org, Alistair.Francis@wdc.com, anup@brainfault.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.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 Sun, 20 Feb 2022 05:08:50 +0000, Anup Patel wrote: > > Various RISC-V drivers (such as SBI IPI, SBI Timer, SBI PMU, and > KVM RISC-V) don't have associated DT node but these drivers need > standard per-CPU (local) interrupts defined by the RISC-V privileged > specification. > > We add riscv_get_intc_hwnode() in arch/riscv which allows RISC-V > drivers not having DT node to discover INTC hwnode which in-turn > helps these drivers to map per-CPU (local) interrupts provided > by the INTC driver. > > Signed-off-by: Anup Patel > --- > arch/riscv/include/asm/irq.h | 4 ++++ > arch/riscv/kernel/irq.c | 19 +++++++++++++++++++ > drivers/irqchip/irq-riscv-intc.c | 7 +++++++ > 3 files changed, 30 insertions(+) > > diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h > index e4c435509983..43b9ebfbd943 100644 > --- a/arch/riscv/include/asm/irq.h > +++ b/arch/riscv/include/asm/irq.h > @@ -12,6 +12,10 @@ > > #include > > +void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)); > + > +struct fwnode_handle *riscv_get_intc_hwnode(void); > + > extern void __init init_IRQ(void); > > #endif /* _ASM_RISCV_IRQ_H */ > diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c > index 7207fa08d78f..ead92432df8c 100644 > --- a/arch/riscv/kernel/irq.c > +++ b/arch/riscv/kernel/irq.c > @@ -7,9 +7,28 @@ > > #include > #include > +#include > +#include > #include > #include > > +static struct fwnode_handle *(*__get_intc_node)(void); > + > +void riscv_set_intc_hwnode_fn(struct fwnode_handle *(*fn)(void)) > +{ > + __get_intc_node = fn; > +} > +EXPORT_SYMBOL_GPL(riscv_set_intc_hwnode_fn); We're talking about the root interrupt controller here. How can this ever be implemented as a module? > + > +struct fwnode_handle *riscv_get_intc_hwnode(void) > +{ > + if (__get_intc_node) > + return __get_intc_node(); > + > + return NULL; > +} > +EXPORT_SYMBOL_GPL(riscv_get_intc_hwnode); > + > int arch_show_interrupts(struct seq_file *p, int prec) > { > show_ipi_stats(p, prec); > diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c > index b65bd8878d4f..fa24ecd01d39 100644 > --- a/drivers/irqchip/irq-riscv-intc.c > +++ b/drivers/irqchip/irq-riscv-intc.c > @@ -92,6 +92,11 @@ static const struct irq_domain_ops riscv_intc_domain_ops = { > .xlate = irq_domain_xlate_onecell, > }; > > +static struct fwnode_handle *riscv_intc_hwnode(void) > +{ > + return (intc_domain) ? intc_domain->fwnode : NULL; > +} This makes no sense. Either you have found the interrupt controller and allocated the domain, or you haven't. But you don't register a callback without having found it. And you have totally ignored my previous comments about the multitude of irq domains for the INTC. Either you get rid of all but one and you can register a single fwnode, or you stay with what you have today, You can't have it both ways. M. -- Without deviation from the norm, progress is not possible.