Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2387596ybh; Mon, 9 Mar 2020 05:00:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuPLSRLGoTgEN8KGxEegFSc7BB/yr6Q2ofvWK/lWylEwA3ZXvzwboXsGaeC8YXE1neoWp7O X-Received: by 2002:a54:4099:: with SMTP id i25mr11211491oii.129.1583755258866; Mon, 09 Mar 2020 05:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583755258; cv=none; d=google.com; s=arc-20160816; b=Jyar0JcFzr+hIBbzJVdAKp98G6zaI6OF9V3/TgohVF+KIscjSNVA7AZgoqSlzguvcm wSXVG5fkZpO1sdh15rqMhCfLBHC+PLJFWKqPos5W85aDY8RhZuEAwswc4Ge+YUS+PP5z LFeUhTZjfZcx5I+z2OV0wR7eqs5T4GDehNkG1kU46MIbOSuGoiaPw4beZQ9kTH2h45Ba PiKU1Rc1rOgnROtrdEnkcRewPumJ+UIJOUcDw119fsciO5PJhxdxWQpdAqrEmYSCuziL U2ktDjsN1ac85WLP0er6CDtRhN87ykAdwp3ddbsHXXsuYRfv6Br2oDZK4nBytn/G5G19 0mvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HKmPOFNtNKhOUxrBtZH5/PcOP5JpmW7NzOHUh/0ofj4=; b=u6TrO/JRsv3tW0jTa+ZNvzjo4I0wILPP8Z43EF5L23IYljNSAbKdazhiyfyeG7+E5y sczDPz2cdhg6dX34/tIfPpCSPVhGULhiFvvTfJmcdHEu9NWtMW7WBSX6ZYmpEuqA5JYp oX6RTHS4oki3u9qD0l7nzkQCoX0YZe1HUIQL304vqwIfB7/hrW8+HpMQlB+TQtDPoWep KXP1/c+skkJ4mFqtDcx0riLEZh6SC9sW3tYM26El9ndvLGcrz6swzW1SMl6OOwh8VYX3 3sfUI/qVRlYWOE53LOLOlbLbAO/qLLxSvbdVbgvjopSYu5pcwwtbzTsJcpzCeChYNRuq QMWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=0lWcvhhe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m138si707599oig.53.2020.03.09.05.00.47; Mon, 09 Mar 2020 05:00:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=0lWcvhhe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbgCIL7K (ORCPT + 99 others); Mon, 9 Mar 2020 07:59:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38134 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbgCIL7K (ORCPT ); Mon, 9 Mar 2020 07:59:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id t11so10728573wrw.5 for ; Mon, 09 Mar 2020 04:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HKmPOFNtNKhOUxrBtZH5/PcOP5JpmW7NzOHUh/0ofj4=; b=0lWcvhhenS7r9ioqD+cOH8VnAb/YTLj+dpwAVIlaLYoxMjz7tp2ZXBtMlNiJz81A3Y d2e1cUD205lLiuRQlTy879Qklwo3HwDmlpp4hyL2b7pVyyeFuo0w30VFwpE0SWU4pioR Kn8VsJbJQmBbnGv8sSsYq+n0lMtokU4rBDqHj18lVIYq87OqrGLhF/cGJnRgcFRSAkeY e+RUHW7V/6WZGW+MyshvLcbmpwfSLTtaHp6K1cAvGodnDMSBcfMmoowXKe2ndUIXuKJC Mp+rzoB/UYi8LdFW+KvUVTY1JU/RL4hWWMQzgOf6OUrZD587JvE9icooAHDb9Pps9H6D 2B6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HKmPOFNtNKhOUxrBtZH5/PcOP5JpmW7NzOHUh/0ofj4=; b=gvvd6HsUrSaKFGejbQEltUiekSK51lhpIBcwOfr2oDvGIWdX49Mef4ZFpyZS+hoD8C rX3cG5uCBt031KHZdQ4wkyc7watQOU+wL1FkHMVvtERR30tcHf60/8PwGUTOyhqcYEDj ELDD5k4QA4i6O+wG9A/iLxhlWmRW+gdBPrQYcHKH9flR9KaUDzLQF+NmmDT9LsQW7sUp UJGkQH8/bSgQo8SCwvWQ97KYy5GYh4vOoyjIamMeYWtM8kle97bZd43TYWyIu5/nWi8o 0VYb0S1dAdD1HsqIASuTq6DFxOK4QI0QZgxOtUASo4PoL2atnGpoJMWiOieSCh8GM820 A0WA== X-Gm-Message-State: ANhLgQ0W8/A8UTTN2EynCDi6jhWSbSA7VlP/MjRbNN4403Yb+Kb7q3Jv B7vnGjMnTEGOa/pfFZpcPU4BEHqsS6HSNDD2xCnUGA== X-Received: by 2002:a05:6000:4a:: with SMTP id k10mr19657020wrx.381.1583755146375; Mon, 09 Mar 2020 04:59:06 -0700 (PDT) MIME-Version: 1.0 References: <20200309110211.91130-1-anup.patel@wdc.com> <20200309110211.91130-3-anup.patel@wdc.com> In-Reply-To: <20200309110211.91130-3-anup.patel@wdc.com> From: Anup Patel Date: Mon, 9 Mar 2020 17:28:54 +0530 Message-ID: Subject: Re: [PATCH v4 2/5] RISC-V: Rename and move plic_find_hart_id() to arch directory To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Atish Patra , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" , Marc Zyngier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixed Marc's email address. On Mon, Mar 9, 2020 at 4:33 PM Anup Patel wrote: > > The plic_find_hart_id() can be useful to other interrupt controller > drivers (such as RISC-V local interrupt driver) so we rename this > function to riscv_of_parent_hartid() and place it in arch directory > along with riscv_of_processor_hartid(). > > Signed-off-by: Anup Patel > --- > arch/riscv/include/asm/processor.h | 1 + > arch/riscv/kernel/cpu.c | 16 ++++++++++++++++ > drivers/irqchip/irq-sifive-plic.c | 16 +--------------- > 3 files changed, 18 insertions(+), 15 deletions(-) > > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h > index 3ddb798264f1..b1efd840003c 100644 > --- a/arch/riscv/include/asm/processor.h > +++ b/arch/riscv/include/asm/processor.h > @@ -75,6 +75,7 @@ static inline void wait_for_interrupt(void) > > struct device_node; > int riscv_of_processor_hartid(struct device_node *node); > +int riscv_of_parent_hartid(struct device_node *node); > > extern void riscv_fill_hwcap(void); > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > index 40a3c442ac5f..6d59e6906fdd 100644 > --- a/arch/riscv/kernel/cpu.c > +++ b/arch/riscv/kernel/cpu.c > @@ -44,6 +44,22 @@ int riscv_of_processor_hartid(struct device_node *node) > return hart; > } > > +/* > + * Find hart ID of the CPU DT node under which given DT node falls. > + * > + * To achieve this, we walk up the DT tree until we find an active > + * RISC-V core (HART) node and extract the cpuid from it. > + */ > +int riscv_of_parent_hartid(struct device_node *node) > +{ > + for (; node; node = node->parent) { > + if (of_device_is_compatible(node, "riscv")) > + return riscv_of_processor_hartid(node); > + } > + > + return -1; > +} > + > #ifdef CONFIG_PROC_FS > > static void print_isa(struct seq_file *f, const char *isa) > diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c > index c34fb3ae0ff8..be05d13e30e8 100644 > --- a/drivers/irqchip/irq-sifive-plic.c > +++ b/drivers/irqchip/irq-sifive-plic.c > @@ -236,20 +236,6 @@ static void plic_handle_irq(struct pt_regs *regs) > csr_set(CSR_IE, IE_EIE); > } > > -/* > - * Walk up the DT tree until we find an active RISC-V core (HART) node and > - * extract the cpuid from it. > - */ > -static int plic_find_hart_id(struct device_node *node) > -{ > - for (; node; node = node->parent) { > - if (of_device_is_compatible(node, "riscv")) > - return riscv_of_processor_hartid(node); > - } > - > - return -1; > -} > - > static void plic_set_threshold(struct plic_handler *handler, u32 threshold) > { > /* priority must be > threshold to trigger an interrupt */ > @@ -328,7 +314,7 @@ static int __init plic_init(struct device_node *node, > if (parent.args[0] != RV_IRQ_EXT) > continue; > > - hartid = plic_find_hart_id(parent.np); > + hartid = riscv_of_parent_hartid(parent.np); > if (hartid < 0) { > pr_warn("failed to parse hart ID for context %d.\n", i); > continue; > -- > 2.17.1 >