Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1161029imu; Fri, 7 Dec 2018 15:38:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xn/0oCtw1qsSNEUnutPWzcP+2qq7NYFkJVOZV9J1tNS6wL+9b5axptdYdeNPZ5rbpFB0KW X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr4035584plo.50.1544225919564; Fri, 07 Dec 2018 15:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544225919; cv=none; d=google.com; s=arc-20160816; b=JFFyW8SON2tk0w0w0C0urrh/2WdfsB9QMTj8/eXMNVGIlH6CuLuW4NN+V112cH5EMH A0KkN28fY4jb21HTOv1A8sB6Xz/WGCWCO88sxRq3E3IOr5aHXeD+DD+7OkqOWH4+nqFO tLRNycOWGg51WxEsbfnxtQuF3v+IywcMrKyz0uHD6mCEmQ+pboxwx8Y9iEe2PAjBQKzN 8+KcZINvTR3KaqtCfTDCzhhky8e3bl8aEczx3Cm6CEj18p56ZkMwc0ouXhQMuj2v7hLD Rbw1p2tfXe+DEUbZKWScAgzxKj5ftE/PmaQOck9TlgLgtTG2SaesGqOTmJ2/k273CG1d xLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=9DIIMgHbluhn2l2cmwMKPTav0Ijc/pp6y5qKyqSBK5U=; b=bp31xgDPL0dRH71L21smsG6MFQ1HdwQ71yy/hTl0uegy+GvauYH6kskto4T4tyeStU ccWj2ELQr2/axjdggTFoPcNY3anLRD0UkR2Lh30np265dKJ39u0RWnzq0GnrbIlnL9pG gG0gNJruAORul0gawsAKX3vadIXFJj0vKgsMD+QGlSHDuOFzrimyjabuHFf9k+e643js kHFotgMHtwNEdkO/tWa+k5jHzupkwT1Yj+AhwVYQpZxvT/9RiTyAbmqTIZlardlpK5BM pPOZW5YxL7IqR1zwFKqvUrXUV3s2YkRPnLpzbzlj9qNHQk3ChWgwnXzO2/Krk/VnOoo+ Rl0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=F3F+Umbf; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si3901783pgm.467.2018.12.07.15.38.24; Fri, 07 Dec 2018 15:38:39 -0800 (PST) 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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=F3F+Umbf; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726135AbeLGXgw (ORCPT + 99 others); Fri, 7 Dec 2018 18:36:52 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:45057 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbeLGXgv (ORCPT ); Fri, 7 Dec 2018 18:36:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1544225811; x=1575761811; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=oqFqUSGEZ527gvndpmSeiRdE8bBlWDIBdMBjfGtFk8g=; b=F3F+Umbf/otdZ08dtnB1yNO3HhymLgex9fBfYcog5vyEd4eQo4BKWlDl k3c6LxX4BOQFVqumLIg8VR3NDTYI9FDkIzkRY5OBtYVtQHY7mMR4CCF1g HCNJWvKls1GKahKElWRNDH6rLsqHcFT2xe4uyypiVUZ6yHKFX+0F+xa+0 U1dVlPD45WbdMnYrZJTQ82H42VhrWTq9/mKTC1zQgzE5kdasSGqyWwQpA Ai6jBhrpA4uGU7UMJ85qbCkPboisElsFzosX4PcxxZQT+UZIY/Jg4lClV HR1EJ/c366UWIKNQmschOlyzsIXdFOF8mOt94WDX60zGceWmxHPxiHGHX w==; X-IronPort-AV: E=Sophos;i="5.56,327,1539619200"; d="scan'208";a="97338775" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 08 Dec 2018 07:36:51 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 07 Dec 2018 15:19:35 -0800 Received: from gj0bt32.ad.shared (HELO [10.86.57.164]) ([10.86.57.164]) by uls-op-cesaip02.wdc.com with ESMTP; 07 Dec 2018 15:36:50 -0800 Subject: Re: [PATCH 2/4] RISC-V: Support per-hart timebase-frequency To: Palmer Dabbelt Cc: "linux-kernel@vger.kernel.org" , "aou@eecs.berkeley.edu" , "daniel.lezcano@linaro.org" , "devicetree@vger.kernel.org" , "dmitriy@oss-tech.org" , "linux-riscv@lists.infradead.org" , "mark.rutland@arm.com" , "robh+dt@kernel.org" , "tglx@linutronix.de" , "anup@brainfault.org" , Damien Le Moal References: From: Atish Patra Message-ID: Date: Fri, 7 Dec 2018 15:36:49 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/7/18 8:42 AM, Palmer Dabbelt wrote: > On Mon, 03 Dec 2018 12:57:29 PST (-0800), atish.patra@wdc.com wrote: >> Follow the updated DT specs and read the timebase-frequency >> from the boot cpu. Keep the old DT reading as well for backward >> compatibility. This patch is rework of old patch from Palmer. >> >> Signed-off-by: Atish Patra >> --- >> arch/riscv/kernel/time.c | 9 +-------- >> drivers/clocksource/riscv_timer.c | 22 ++++++++++++++++++++++ >> 2 files changed, 23 insertions(+), 8 deletions(-) >> >> diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c >> index 1911c8f6..225fe743 100644 >> --- a/arch/riscv/kernel/time.c >> +++ b/arch/riscv/kernel/time.c >> @@ -20,14 +20,7 @@ unsigned long riscv_timebase; >> >> void __init time_init(void) >> { >> - struct device_node *cpu; >> - u32 prop; >> - >> - cpu = of_find_node_by_path("/cpus"); >> - if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) >> - panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); >> - riscv_timebase = prop; >> + timer_probe(); >> >> lpj_fine = riscv_timebase / HZ; >> - timer_probe(); >> } >> diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c >> index 084e97dc..96af7058 100644 >> --- a/drivers/clocksource/riscv_timer.c >> +++ b/drivers/clocksource/riscv_timer.c >> @@ -83,6 +83,26 @@ void riscv_timer_interrupt(void) >> evdev->event_handler(evdev); >> } >> >> +static long __init riscv_timebase_frequency(struct device_node *node) >> +{ >> + u32 timebase; >> + >> + if (!of_property_read_u32(node, "timebase-frequency", &timebase)) >> + return timebase; >> + >> + /* >> + * As per the DT specification, timebase-frequency should be present >> + * under individual cpu node. Unfortunately, there are already available >> + * HiFive Unleashed devices where the timebase-frequency entry is under >> + * CPUs. check under parent "cpus" node to cover those devices. >> + */ >> + if (!of_property_read_u32(node->parent, "timebase-frequency", >> + &timebase)) >> + return timebase; >> + >> + panic("RISC-V system with no 'timebase-frequency' in DTS\n"); >> +} >> + >> static int __init riscv_timer_init_dt(struct device_node *n) >> { >> int cpuid, hartid, error; >> @@ -94,6 +114,8 @@ static int __init riscv_timer_init_dt(struct device_node *n) >> if (cpuid != smp_processor_id()) >> return 0; >> >> + /* This should be called only for boot cpu */ >> + riscv_timebase = riscv_timebase_frequency(n); >> cs = per_cpu_ptr(&riscv_clocksource, cpuid); >> clocksource_register_hz(cs, riscv_timebase); > > We need to check to make sure the timebase-frequency of each hart is the same. > This is mandated by the RISC-V ISA specification but should be checked in the > code. > Fair enough. I will add a timebase-frequency verification function that will be executed for every cpu instead of boot cpu. If any cpu's timebase-frequency doesn't match with boot cpu, should we just WARN? or Do we need panic given that DT is not following something that is mandated by ISA ? Regards, Atish