Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp888998rwb; Tue, 29 Nov 2022 06:36:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4GxtUWeyOVZLPLfQ6P42DSwBHuS2+kXHlPhFw2YdsxlS5rcppPPbmsebS+pJ+ISHNGXlKE X-Received: by 2002:a17:902:cec8:b0:189:30cd:8f9d with SMTP id d8-20020a170902cec800b0018930cd8f9dmr38618058plg.144.1669732588600; Tue, 29 Nov 2022 06:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669732588; cv=none; d=google.com; s=arc-20160816; b=ADub55UUbJooQ/10N/Uv7bWkUK243L/YWpnaE+Ep01k14JcHJYA/DcZMqT975sTOjF /Bd8BWKljIf4iZeQgu8tsD0BfHIe5n8HBuyP5NfAGJLOCMrxs4E4qbHhAftcqdzlohmn aoc2gqOo46TN0/lMTa4M8n7+/kVdr1mmWMEg44/PoEljZT+wFq7dnn3jpltHkbs4rL25 Hfw0e4xxhGf0Uuyy8YvDEesx43BT8TEJXHaBid+lcBN8tsdUYKC3JC4/aPNlMLUYx8/2 Jf4icv2IRq9e2oaRra9/h+JL9ZE/loDdPtrtbkp9yhEBvKjt3FLbFIMue+9qF/S6IBRk dI7Q== 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=eKXt5EsGtl4Y2wORGNgdQeY9TPdZTpynE+kjc1Hlcybqjs0s48jIrlXOwprIKtU8hU tAkKPiWoZDNk8NC0wkDyomE8odVa/swlkaxRfqgNjiaPZLBNYHODbtL1lfH1K6knGKOt mth08We5wy/jGSmiqg7muirUqecea/3S9+PsVt9eNdsnieQw2llVrVj15fwIifKJEprL oPKgSA/+aSW8EjVWR+CNrK4A0ITrPnrVZcrCr+7nYHMwUIaHX4pFc+/OLGLFCIl2iEhH NOpFWWsffRAQXAfBxcHbb7DqmbwbWqXj7O+6zHYzqj3tUaqEB9DX/Q6L9Awokdt4eJuD w2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="MCBPj1/g"; 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 w10-20020a170902e88a00b0017f577878edsi16730802plg.368.2022.11.29.06.36.15; Tue, 29 Nov 2022 06:36:28 -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="MCBPj1/g"; 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 S235228AbiK2OZP (ORCPT + 84 others); Tue, 29 Nov 2022 09:25:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234698AbiK2OZH (ORCPT ); Tue, 29 Nov 2022 09:25:07 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 278D1266F for ; Tue, 29 Nov 2022 06:25:07 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso17530410pjt.0 for ; Tue, 29 Nov 2022 06:25:07 -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=MCBPj1/g120Iv1kMjeuMVMrddfHIEvaxRkOp/ainQWEfZaR+H8Me+9I6DCNqlm+T0U xJNT5M0QZZ8806GKqxPZeqtWvYNQIFtnHI+bYxXGwoz69DA/ftjhtga+RJhJj0sC0jxw OSbcf/jRQfVJhCA1mW2yPiEPdzSanu2CHsMLpm95kyas7FCvqxsZWDMJEwlecjovJ6wZ IeOIT6ug2PteDDDHCzEuMxVuiy5F/0FCdnTZN12aSxiWELz9hYRwIn7Gt2oNCijWu1U+ 1AOqbsplUFy6XRes+Xvcacp2+J+5vIgLrhWUzaVghN2aRLGD7oVDDWgZVVugZRtsVTYv p7Pg== 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=Ov98LWhV8egoZ3qC7MR3xUa448qU4CM3GlxLpXXZLDumvtCZ3PCK2DpZsKeBtL/wTd DdJIVtPjPeOrRqdkT9sVroadKQJECsLZ4o2gFlsJ9a//ozfegVatXk/PVwYRM4GSchlN I8d63QvpS8IBoehMTlkAoAIIZUzNia19407TRr0ZSDXxG7N2O5GxvQLO1CjUtWcvGbRW J0//PAa2zgNn0bcSdKVmNZjlyxXfOqnq42RE0XxZDQMswg9CGy7dXCu9YiAQJBjWPEh7 NEoemdy3vnt5d8+YCKdjt3q1Scq4oxjZPhl/3Yhy2wPNm9jkaWJRFqOiZqkyeiy1mOTY ZrCQ== X-Gm-Message-State: ANoB5pkiT7/SAvUMJCNiLawXEKfOxHH82I+9a5hHwOhoaHTb18ZGPXKZ P73/YQtnjwCeGxkE35LEh5v4bg== X-Received: by 2002:a17:902:ef4c:b0:189:8b14:55bd with SMTP id e12-20020a170902ef4c00b001898b1455bdmr10500197plx.25.1669731906522; Tue, 29 Nov 2022 06:25:06 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.84.98]) by smtp.gmail.com with ESMTPSA id l12-20020a170903120c00b00176a2d23d1asm11039076plh.56.2022.11.29.06.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 06:25:06 -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 v13 2/7] irqchip/riscv-intc: Allow drivers to directly discover INTC hwnode Date: Tue, 29 Nov 2022 19:54:44 +0530 Message-Id: <20221129142449.886518-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221129142449.886518-1-apatel@ventanamicro.com> References: <20221129142449.886518-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