Message ID | 20230710094321.1378351-2-apatel@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4910961vqx; Mon, 10 Jul 2023 03:04:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlGUU3RvK8vPrbJWFGQjCHBuxhYayAzKn0i1uzsUm7XewexQzOMnJbQOGf4fFAVc868E4qBm X-Received: by 2002:a17:906:7288:b0:993:d9bb:7487 with SMTP id b8-20020a170906728800b00993d9bb7487mr7286686ejl.12.1688983445553; Mon, 10 Jul 2023 03:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688983445; cv=none; d=google.com; s=arc-20160816; b=AZJ5X9JAOaWFyoza4hZwNEH30fibVeIMcHPYg2Acyzccbxs/nK78kDQ+YIz2Ax68le ElrDI65ch3Sb8T1ycD2NlrYGmov0Yh9VQbh7A+UvW7rYXgkiwDIz3mLOSyZQVM2ux8pH Cg2L9PhVErx09r0dTJfWl0pLhaLzdXFMxPf5fY6ZJSKgKvvGADAtHEi1jDUjFm6gP6zd 4C+ZCmg2/50ybW9l19eFZ511543gXQ8OH5kw/aTIAxkETOuTjpb3E9mSxb/4hd69dD4z Mpk+WbmvlweJ82oqSRp38kwzBX3r3itRETDcLArrx/TwwcpBa6O20/FPy4pU7pY7TXPm q1pw== 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=vWvqokmp7r4qpLb1zZr/K+Grf5K67mplcBtMET9ZvCc=; fh=siuReS9O1bGemQ4LZytRoS7QthZ4+BtPZKlxlnFc5fg=; b=ou2Fv9J9jUuLdIs9M1WLUgLNzeOX1J5/n9LW1yo18GstbBQjXdw8i6ch5UMJr4y+TO EXaHg4n7Nibz89jXd8s9SkzR9q8ZavFX8w+eK/3/CfBw9z58RxLOdmbxne4feOto5yuj ynvMouhyggZ+ngZhnWxXLVqZPkqiqtepsSV6lUXSaau9oITEdP9C9D8OCjH60lfebvRs ubaCnVP5K9P+Lar9k2ruSb0OUbg7MjSE6FyErwe5X/nbYrKedTpWVmzUAFB+4YqmdI34 s33IIoMLfAK9rZVMO6QgO9pYmQ/X0x8XUEpRirLQht9EpBLyjuSifQDfeM+p9SM0V/dZ uklw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=GuLbKlzb; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rh12-20020a17090720ec00b00992d0de875dsi8407254ejb.912.2023.07.10.03.03.42; Mon, 10 Jul 2023 03:04:05 -0700 (PDT) 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=GuLbKlzb; 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 S233014AbjGJJtR (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Mon, 10 Jul 2023 05:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbjGJJsM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 10 Jul 2023 05:48:12 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C1F49C4 for <linux-kernel@vger.kernel.org>; Mon, 10 Jul 2023 02:43:46 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id ca18e2360f4ac-78363cc070aso206104839f.1 for <linux-kernel@vger.kernel.org>; Mon, 10 Jul 2023 02:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1688982225; x=1691574225; 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=vWvqokmp7r4qpLb1zZr/K+Grf5K67mplcBtMET9ZvCc=; b=GuLbKlzbbm4+IQ1CE2fG/Sh0nv+IuRFqdVmE9lHlCnzZvCYcJ+fNJwYSnPgIzs+2LV 0IumeDVWpjLHWIAwGn8ZjRZ0r1R1/9vJRUN9TaFiD3zMurfzY5FyomAvdQdAftRrvSlC 72NrgVLlgcFtJggqHFSs+M/7UafyA2H+VYl6h8Yf78Hd3q4y5NOQ7MzGdq0rbQXFNHYo 1NHVjpf9Dy3tZWu5EWaO88c/SG2Q7jQlqvSa6npE0kZuPIOt2Vl03C8cwLz1ojq3wVsL lBJfnTyUc+N4gS4/WzoxhxqCjVAfxLl19R5srAdH//IlLNZqP53SsgxbqhNDM/8ZvGcJ eWrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688982225; x=1691574225; 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=vWvqokmp7r4qpLb1zZr/K+Grf5K67mplcBtMET9ZvCc=; b=I8Ny7/zkEv1cDQWrs9xsj+h22nvq4BEhI35NzDZARmN0PPBkGn7EI/PhL8JrO+qH2z uaZ6M6rFZNwY8swbzjmYDq87WUamCAhRcS9/QmAQUH97lx5kow6kLk9mvLhwECC/lEIk hxDID7VYMPNwnvSEY93jRXdZ4qbcWHmGFFV/Kahv36brdPCyq+lVcAVhfto5GfK+P7hg VaR4YbqPzM+zIFwhINepqI6VXi/nQ5YABh0IuWRe8JkxnwgHHA3ob6DDqBbMLzuF5zxu GPhtHVFMRL0ANQzUcyqSFjnMymNjKKBL2ZLpsyNetdKCMWaq6i6f1Sh+S2i47E4Sd+ak tiEw== X-Gm-Message-State: ABy/qLbDKMt7wmZIEFDGvKIsjlcd9JpDkBkzwmRzD5V8A8qduOq4sEL7 hZzplvyyi+cR37nUwtGbpKkasw== X-Received: by 2002:a5e:df01:0:b0:786:fff8:13c2 with SMTP id f1-20020a5edf01000000b00786fff813c2mr5491462ioq.11.1688982225538; Mon, 10 Jul 2023 02:43:45 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id k1-20020a6b7a41000000b007870c56387dsm936938iop.49.2023.07.10.02.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 02:43:45 -0700 (PDT) From: Anup Patel <apatel@ventanamicro.com> To: Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Thomas Gleixner <tglx@linutronix.de>, Marc Zyngier <maz@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org> Cc: Atish Patra <atishp@atishpatra.org>, Andrew Jones <ajones@ventanamicro.com>, Sunil V L <sunilvl@ventanamicro.com>, Conor Dooley <conor@kernel.org>, Saravana Kannan <saravanak@google.com>, Anup Patel <anup@brainfault.org>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel <apatel@ventanamicro.com> Subject: [PATCH v5 1/9] RISC-V: Add riscv_fw_parent_hartid() function Date: Mon, 10 Jul 2023 15:13:13 +0530 Message-Id: <20230710094321.1378351-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230710094321.1378351-1-apatel@ventanamicro.com> References: <20230710094321.1378351-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_BLOCKED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771027505365679735 X-GMAIL-MSGID: 1771027505365679735 |
Series |
Linux RISC-V AIA Support
|
|
Commit Message
Anup Patel
July 10, 2023, 9:43 a.m. UTC
We add common riscv_fw_parent_hartid() which help device drivers
to get parent hartid of the INTC (i.e. local interrupt controller)
fwnode. This should work for both DT and ACPI.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
arch/riscv/include/asm/processor.h | 3 +++
arch/riscv/kernel/cpu.c | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
Comments
On Mon, Jul 10, 2023 at 03:13:13PM +0530, Anup Patel wrote: > We add common riscv_fw_parent_hartid() which help device drivers > to get parent hartid of the INTC (i.e. local interrupt controller) > fwnode. This should work for both DT and ACPI. > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > --- > arch/riscv/include/asm/processor.h | 3 +++ > arch/riscv/kernel/cpu.c | 16 ++++++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h > index c950a8d9edef..39dc23a18f88 100644 > --- a/arch/riscv/include/asm/processor.h > +++ b/arch/riscv/include/asm/processor.h > @@ -81,6 +81,9 @@ int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); > int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid); > int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid); > > +struct fwnode_handle; > +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid); > + > extern void riscv_fill_hwcap(void); > extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > index a2fc952318e9..9be9b3b1f333 100644 > --- a/arch/riscv/kernel/cpu.c > +++ b/arch/riscv/kernel/cpu.c > @@ -96,6 +96,22 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) > return -1; > } > > +/* Find hart ID of the CPU fwnode under which given fwnode falls. */ This comment matches the comment for riscv_of_parent_hartid(), but I don't think it will be correct for the !is_of_node(node) case since fwnode_property_read_u64_array() isn't obliged to walk up its tree. Looking ahead it appears riscv_fw_parent_hartid() is only called with the parent node, so we could just drop this function and use fwnode_property_read_u64_array() directly at the two call sites. Thanks, drew > +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid) > +{ > + int rc; > + u64 temp; > + > + if (!is_of_node(node)) { > + rc = fwnode_property_read_u64_array(node, "hartid", &temp, 1); > + if (!rc) > + *hartid = temp; > + } else > + rc = riscv_of_parent_hartid(to_of_node(node), hartid); > + > + return rc; > +} > + > DEFINE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); > > unsigned long riscv_cached_mvendorid(unsigned int cpu_id) > -- > 2.34.1 >
On Tue, Jul 11, 2023 at 6:56 PM Andrew Jones <ajones@ventanamicro.com> wrote: > > On Mon, Jul 10, 2023 at 03:13:13PM +0530, Anup Patel wrote: > > We add common riscv_fw_parent_hartid() which help device drivers > > to get parent hartid of the INTC (i.e. local interrupt controller) > > fwnode. This should work for both DT and ACPI. > > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > --- > > arch/riscv/include/asm/processor.h | 3 +++ > > arch/riscv/kernel/cpu.c | 16 ++++++++++++++++ > > 2 files changed, 19 insertions(+) > > > > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h > > index c950a8d9edef..39dc23a18f88 100644 > > --- a/arch/riscv/include/asm/processor.h > > +++ b/arch/riscv/include/asm/processor.h > > @@ -81,6 +81,9 @@ int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); > > int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid); > > int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid); > > > > +struct fwnode_handle; > > +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid); > > + > > extern void riscv_fill_hwcap(void); > > extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); > > > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > > index a2fc952318e9..9be9b3b1f333 100644 > > --- a/arch/riscv/kernel/cpu.c > > +++ b/arch/riscv/kernel/cpu.c > > @@ -96,6 +96,22 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) > > return -1; > > } > > > > +/* Find hart ID of the CPU fwnode under which given fwnode falls. */ > > This comment matches the comment for riscv_of_parent_hartid(), but I don't > think it will be correct for the !is_of_node(node) case since > fwnode_property_read_u64_array() isn't obliged to walk up its tree. > Looking ahead it appears riscv_fw_parent_hartid() is only called with the > parent node, so we could just drop this function and use > fwnode_property_read_u64_array() directly at the two call sites. I think the function name riscv_fw_parent_hartid() is misleading. It should be riscv_get_intc_hartid() because it is retrieving hartid based on INTC fwnode. Currently, this function is used in APLIC and IMSIC drivers but soon it will be also used in PLIC driver with the upcoming PLIC ACPI support. In fact, this patch should also replace riscv_of_parent_hartid() with riscv_get_intc_hartid() in INTC and PLIC. Regards, Anup > > Thanks, > drew > > > +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid) > > +{ > > + int rc; > > + u64 temp; > > + > > + if (!is_of_node(node)) { > > + rc = fwnode_property_read_u64_array(node, "hartid", &temp, 1); > > + if (!rc) > > + *hartid = temp; > > + } else > > + rc = riscv_of_parent_hartid(to_of_node(node), hartid); > > + > > + return rc; > > +} > > + > > DEFINE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); > > > > unsigned long riscv_cached_mvendorid(unsigned int cpu_id) > > -- > > 2.34.1 > >
diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index c950a8d9edef..39dc23a18f88 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -81,6 +81,9 @@ int riscv_of_processor_hartid(struct device_node *node, unsigned long *hartid); int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hartid); int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid); +struct fwnode_handle; +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid); + extern void riscv_fill_hwcap(void); extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index a2fc952318e9..9be9b3b1f333 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -96,6 +96,22 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid) return -1; } +/* Find hart ID of the CPU fwnode under which given fwnode falls. */ +int riscv_fw_parent_hartid(struct fwnode_handle *node, unsigned long *hartid) +{ + int rc; + u64 temp; + + if (!is_of_node(node)) { + rc = fwnode_property_read_u64_array(node, "hartid", &temp, 1); + if (!rc) + *hartid = temp; + } else + rc = riscv_of_parent_hartid(to_of_node(node), hartid); + + return rc; +} + DEFINE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo); unsigned long riscv_cached_mvendorid(unsigned int cpu_id)