Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3755201pxb; Mon, 21 Feb 2022 05:13:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwge3HePvp0D8CxuAIFacexsOF1xyuPAEJBANtB/e6Sw4ONKi/uBq0n7lSFrESLdiKUNZHG X-Received: by 2002:a62:8c8f:0:b0:4cf:4c5:b2ad with SMTP id m137-20020a628c8f000000b004cf04c5b2admr20113930pfd.71.1645449183354; Mon, 21 Feb 2022 05:13:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645449183; cv=none; d=google.com; s=arc-20160816; b=yEFQJLH+JFjd4uNNfryX0W3H97CK1sAKuxyWJKDaKHjJGWdArRmzwbuDk40U0JLmdy w9d9Vcys7eKm26PrvulJuqIndHMSNnPsOnbMMWpSNItQ8gAidUZ0yHQ7BQuCpzdZJZtm 8Io4ezYDYjXgTm1H7VGJiYPnRDJguWMVHYS4jE51WiQEs6MA5NKS7RlLdT4BtAjn+IL6 ytXckHzqg/MjzECULHRA+IoqnS8t2JweP2145OGipyJaKJX05Jy9CwF35U1BjZpJ4FWV E66h5vlJ+HdGUQIQDaBn45menGcOSuaDDDwbzII7ZzZoX/PkmGgodPSPU9MYnn265Ou+ JwtA== 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=Dl3Xn1n3x8XKLwgUs4DCDgHav5Z0O8Un8dLwnuWzYl0=; b=C2OmYtG9dJW52A1eya2ttTwB0vvQAF9TrG5vBGGctp7h0yTULzUiMb+8K/k5zXK028 SNiBt1DQ8JAev4gJVkCFaJxAyjzahRCZyg4236+mEqTx+Qz4zjyDtWsSEKzd+IRKSPiy 7S8YkVOQgZWxO6Av+W7EUQQZDK16kPx5miv0wnRnXKKhf5eRtHFNcmLbmwt4W1Y51xdN 2LTIhZgGJ2z55sMr6qVCRWJvP8EINmpKFXu/NVbQ9h7QCzgZXuRWxjKAAhoYqzXNiR94 nXVOc5XKPleAYsWKrcV2717ADsDMtS9jaAeJndtOODRc5EavwMPyul7edg9r0aWrXyEc x78A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sxxu7mfd; 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 5-20020a17090a08c500b001b924b91f21si6194682pjn.127.2022.02.21.05.12.48; Mon, 21 Feb 2022 05:13:03 -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=Sxxu7mfd; 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 S1354883AbiBUKaX (ORCPT + 99 others); Mon, 21 Feb 2022 05:30:23 -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 X-Spam-Status: No, score=-7.1 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 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.