Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3164570rwb; Fri, 2 Dec 2022 23:38:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5wb1O6MF9Epqm1iv7OxKsMbzAGn1eufUHXKaq3sMDTpy6F8UTpcNt0Q/3r2k7gH+vfC0lf X-Received: by 2002:aa7:cc12:0:b0:462:79ec:55eb with SMTP id q18-20020aa7cc12000000b0046279ec55ebmr65220470edt.151.1670053112979; Fri, 02 Dec 2022 23:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670053112; cv=none; d=google.com; s=arc-20160816; b=a+hcUEC9fAFebUITLFCW1UGhXVaDsdJp9oQBy28lR/xFfCd0Ewo1hk5iVi/EYweTWW 4qINmy9Z73R1DqusEiIEUbNacFdVYM5Vfwbxye+cTL6A760/u6UVQAKj52o4LLoAoS0i VWVG7cLtkRTo8iuUlFRP8FXtOJux82H/Kq+uFPrxf40cvaPCBk3TTKZEZLZt+OerJMO7 /lur+FooTUT9YQVHVA0U+SZ4wtAQuX8nHu80yYIyeA9lPXC5GEkCR934vAqe6sodaZE2 L9NYGS1bJedknqaLElN1dOgQ57cZG8wxtCPCclR1FWYm6LDD30V9gbDW+9Ks9vwlfZb1 XSEA== 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=oZFc8On9KwpbIAO67GbUGul6h+8WBCokcR+4bcWdEswtW/ozYP3BRN19Ug6KOpBg+6 2U9pTcK4DSVTRGfuRcOv6ABPe3Y6Uf0DcfDN9BQ1C9xvu/fWcbLf8nYqlzEcUb3NQIWb /qTecOt3Ik9uLrUcliWJnUKCNwKe0xKeRqkioGD1Be6ua9LxdK3lWhL+2OItpWTwVccR g6c1V80nDdpjllvTkjKjRYy9+Aj3S4u4Ytyamhi5uAuHaeE1HNbNwOkBJ2nZmYPvt4Yh v9mLManqvgMhFgjmcOfz1/EXQaWfwSjfdEnu9aZhNzQuyOjEivElRjxrJ0wm0oBlC0Cb uXVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=fSswA9uO; 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 j21-20020a50ed15000000b0046b1c38c13dsi7410716eds.122.2022.12.02.23.38.11; Fri, 02 Dec 2022 23:38:32 -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=fSswA9uO; 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 S231469AbiLCGrI (ORCPT + 82 others); Sat, 3 Dec 2022 01:47:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbiLCGq6 (ORCPT ); Sat, 3 Dec 2022 01:46:58 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A4FBC59A for ; Fri, 2 Dec 2022 22:46:56 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id 140so6849932pfz.6 for ; Fri, 02 Dec 2022 22:46:56 -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=fSswA9uOyLO7+iG41F51EDzOcAdHwKmbN8WPzhf2TrDubxetJOnIE+FMiTQEKcXStr HZo1MOAVw6HcbafX4D0m6W2qCQ4csLwgX+6HDz5w23bWScbN8wJFv3UBIxQRcm3W8lX6 1r+TEW4k9YZvQqiMYGSWO9kG3RsaPNh1gdb6Fiyy7UaHV+oIxAUuqQrNRG8d0GfNK1kw z5n88aC2Z3ODHPG+H26yyvpmkLMUIsmvp1oBjVx6a1YELv7HhsQYKPuaE0TtRmA+wXmp T6+jH6CanK8ZI95tJr9UHgGLGMqoOZYSShc9xUpFlbLtP/Hse7sX4hcJRXsJ/L6sDgfs F9og== 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=NDNuxE/RYEdZlcYyudJM9BnwPA8pq8UOFvIVd6uCpEPPmytIT8eSLlwRU8NH4a0bR/ jkSLFHYHpHTihGYxKoJ+RWOJso2YWKvR3hvoGcvmJnu3uZPxnDIq20D+BefKAxZHvCuK hEE4/+UeFlY7KpM0AHmdjG+r8Cl91u6N+EILWoJbeuwrDkhTCyaotdqGYGn9Tw3Zo6cl saJeGtnolzAZYXWxQsc5EiNqJpM5K3lntrOfgT3pomCEnLl7rEwBfUB34cXaBu0+hJh3 5bZ5Ve62UwL7g6EAisISvIwio2c+GSrjcYZWKl1/7RdEWB9ru9xEmJSk+Ja/vf9bqjCN 4XLw== X-Gm-Message-State: ANoB5pk1/bOSdxEQz5A4nwHW4UVlFhftXyC/hMhimQjQmVYbRSFFz6s7 07IQm9+xvGWJylcy+197H7K+MQ== X-Received: by 2002:a05:6a00:1c8f:b0:574:6880:e76f with SMTP id y15-20020a056a001c8f00b005746880e76fmr47038664pfw.35.1670050016056; Fri, 02 Dec 2022 22:46:56 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id t17-20020aa79471000000b00575c8242849sm6102091pfq.69.2022.12.02.22.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 22:46:55 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Daniel Lezcano Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Anup Patel , Atish Patra Subject: [PATCH v15 2/9] irqchip/riscv-intc: Allow drivers to directly discover INTC hwnode Date: Sat, 3 Dec 2022 12:16:22 +0530 Message-Id: <20221203064629.1601299-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221203064629.1601299-1-apatel@ventanamicro.com> References: <20221203064629.1601299-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