Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5268973rwb; Mon, 14 Nov 2022 01:50:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vSKFidCzsXfTNaCYjR99073TFSihsFbIoxO1MDxdM0Ki4U8ykPnnoAhcGl760YiCvGTZd X-Received: by 2002:a05:6a00:2985:b0:56b:f0ef:10aa with SMTP id cj5-20020a056a00298500b0056bf0ef10aamr13418244pfb.6.1668419425731; Mon, 14 Nov 2022 01:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668419425; cv=none; d=google.com; s=arc-20160816; b=XtFnhRqlGWNYXg8AXjL5EJYmvEQABdiJ0DWaXKbAZx7rkhE5FL/EmqL6u50Do47GNo /GWxGNSVlVRB/eK7/STX/W1A0j8V7QfGdU+zaJkTrak0HeyoNYkeTSbOYKe0/9+1BWO3 m8AtX84XUnjNLMKduKhjEyw/A6KQAPxOMAWI3WHr06Sly7gY5fhn7H5bDweOAQIPt9kK 56LTb73a35sdlrWvXumrO2JPcAIh6BwGM61mmj9jjscidn9ULLVelPL858VuL/5YiMtO OIryYVUnPUFsZLnkYphWgCfFJpxdD6GJ6+s2o2yviE7Ya0sZdNU715u25RFG0fcfISjW 8c8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GBh16wlKK1pVBXMjv15TuW7j92X6+xaNPp74Ke5cwzg=; b=FWCw1oSXK5z4QRZnE2soPZuC2gLjodTEO+mdE7uCcH6cjrnDwXU6M9hZ8DguAEfRoB 626cnj85ceuEeGJFPjL7VcsbyMz8TaTZNokEhCocQInJjGg2TGliYmzbN9z2G/D5UwLw Ltc+9oEqlBuvFpEJ2J1yNmNC71QtHtSnNgZvUeCXh8/h03dj3cK46ZU0qYx1ioUHet+c 6kJtn1VJsOzybUWRr9PjxW/GX8vpy2dJRxS6bzrbpWk17OPZZn4m9p7mkkUoUnrimM+1 vSWEEfpJFFcLbkHB3cdpL9lY1UYF2jrzGCUAuzrmUBHLbju8JOvfVPZOr7Gxu4eN+pVX 72sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=hF9X0WTg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a637456000000b00461f10556b9si9111890pgn.319.2022.11.14.01.50.14; Mon, 14 Nov 2022 01:50:25 -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=@ventanamicro.com header.s=google header.b=hF9X0WTg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236883AbiKNJjt (ORCPT + 88 others); Mon, 14 Nov 2022 04:39:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236872AbiKNJjo (ORCPT ); Mon, 14 Nov 2022 04:39:44 -0500 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF5A41B7A6 for ; Mon, 14 Nov 2022 01:39:43 -0800 (PST) Received: by mail-oi1-x234.google.com with SMTP id t62so10800832oib.12 for ; Mon, 14 Nov 2022 01:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GBh16wlKK1pVBXMjv15TuW7j92X6+xaNPp74Ke5cwzg=; b=hF9X0WTgoZ15u6lCmpBzIOPBVWdzZ3Vw6JoG3tBTJMXOxDAbfHLS87qMIOnUrcirpE 15GwdmZNiXKXSAp/+97TmqtsCq8sWpHrik7QY+mGtyzU23KDDYyW6Bc+hJP1I8uacoGi yBKZ0NDVqyowQHvNM7xCWU1p3K6dRd12GuI5Iel2uRZ+bYb6ec3PvFT9+UGbc6GLbNcN 5zTsnvLBy/GwWCiBK0/dRG/akuPjk9nRZ7G2/yGZ+MCvhyqXyB2ymFHfJ0dZ2xzJSTsp tWMdAJ9+y5NAIxWnraV5913SjMHGQ0rQuB2XnCNyD8xVMjDROSASmZnl/reobC6MlCgw fhsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GBh16wlKK1pVBXMjv15TuW7j92X6+xaNPp74Ke5cwzg=; b=sTzB5p8ixR0LeF9cTVUSLR669EPumTiHib5vLJDgZMKDOcAJ9Oq152cVIVYAnRJiw7 mJsmFI2Olp7KKesT1VFxQp3kmdmlZYpH4BgpNSKPjLC2+sCAndcZJUoHPmk8qxo6rl4E +HHKlfkKG23eoq0CD8LrGe04nlsWHF4IQ8eUvmVWstF156WfIRCaPLhKmTxYL+bsDp1m uKVtSAWbIiOU1KKaZavTE01+QAlpyY5xjOXqj5lmHcJMo6zJqFhvCm8KzKa+Bsk7P0FG QZX13R5DXAdmc3/9YM4RoyP1LCXtzmHECaaNlVyhC0IwMOGiISRPFwyyFGTCK9dRwzXH WV7A== X-Gm-Message-State: ANoB5pn34LFqItGGiP6FDWhuXKA+iGehAe+cBagPMmko6EHG9rDOIOxX NxMAYEaCBVNEI4OdWh1mEUzmKQ== X-Received: by 2002:a05:6808:b0b:b0:350:a7b7:9ac5 with SMTP id s11-20020a0568080b0b00b00350a7b79ac5mr5401912oij.4.1668418783088; Mon, 14 Nov 2022 01:39:43 -0800 (PST) Received: from anup-ubuntu64-vm.. ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id l12-20020a4ae38c000000b0049f3bdd791esm3222677oov.26.2022.11.14.01.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 01:39:42 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Daniel Lezcano Cc: Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Atish Patra Subject: [PATCH v11 2/7] irqchip/riscv-intc: Allow drivers to directly discover INTC hwnode Date: Mon, 14 Nov 2022 15:08:59 +0530 Message-Id: <20221114093904.1669461-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221114093904.1669461-1-apatel@ventanamicro.com> References: <20221114093904.1669461-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 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 Reviewed-by: Atish Patra --- arch/riscv/include/asm/irq.h | 4 ++++ arch/riscv/kernel/irq.c | 18 ++++++++++++++++++ drivers/irqchip/irq-riscv-intc.c | 7 +++++++ 3 files changed, 29 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..96d3171f0ca1 100644 --- a/arch/riscv/kernel/irq.c +++ b/arch/riscv/kernel/irq.c @@ -7,9 +7,27 @@ #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; +} + +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 499e5f81b3fe..9066467e99e4 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->fwnode; +} + static int __init riscv_intc_init(struct device_node *node, struct device_node *parent) { @@ -126,6 +131,8 @@ static int __init riscv_intc_init(struct device_node *node, return rc; } + riscv_set_intc_hwnode_fn(riscv_intc_hwnode); + cpuhp_setup_state(CPUHP_AP_IRQ_RISCV_STARTING, "irqchip/riscv/intc:starting", riscv_intc_cpu_starting, -- 2.34.1