Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7438781imu; Mon, 3 Dec 2018 12:58:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/VVc+XhAIgCWrWeeO83gtof7+4AbpBNWX+99TLuKGm4K4Uvp77/a6jjhf/NhjKUZ4ohSagT X-Received: by 2002:a63:4d:: with SMTP id 74mr14842079pga.248.1543870737177; Mon, 03 Dec 2018 12:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543870737; cv=none; d=google.com; s=arc-20160816; b=aZDT6HClXjbOd2fqZUdEEJvgs1Ordb3zfRQENH1g92liptSMCTBb/WVBYS4xtuaPC+ 4gu+fWJOg15m6w/Voa5Z/M6yF3r5eNDTbbnFcSHOp3SxTBnk/Q2TRh9ZU4bH7Jjoio7q hlIXShyJ86GsqlyMx+e2RNbvX0IJFCNdaXjoaebYmUtFOdV7Wjq5QrDXQN64ugeZaex6 PoOXuRGgqsAbb3lLjT0MU13o5aUmBTkJX714lGTg1Fn4dpBfK2Sz09jhghI+Yedn1hEm EdYZ/v+rla5IcAaxO0l91Y6/f5yGpVs7bOjWS1nUKYxg10LRrH1MbivMPG0QTcWlzLok zBsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=t83e/2Z4CdfKT5iQhKQnVUi4z7e+JAi6ntFA9IwyRB4=; b=ef231/qWznnyNR+X8XHX+T/O8aMD4uYUTqZW8ro1go2d95rgEBURTXVO9z/iBxUylA 2yQAvqYSPrZxmtCLqo2KjpZc0tEjqavl6BFn+vCvfepciKuqyisjJCu28Sx9maJtg3EX ykdgEsi6TQcXFD+WTZnNX9i7CQIZNqKwJvHDoqqCYdpPFk7IbBAiVT4sIAN7xURJC5g3 Ldt4pop1a6P1+qmJwPHoOHJomZ+7eWNVI+TPmnMa+Q02xyFqZZbRdl4CHfz4+6DUEEG7 okURjsTUCccBK5sA0sEb/7ognADctEXr6PNIVPT2W603XJyla5iML24FkZqIaZcuQTMJ Yn8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=T5H3EayT; 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 g12si12081909pgh.368.2018.12.03.12.58.41; Mon, 03 Dec 2018 12:58:57 -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=T5H3EayT; 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 S1726096AbeLCU5z (ORCPT + 99 others); Mon, 3 Dec 2018 15:57:55 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19087 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbeLCU5k (ORCPT ); Mon, 3 Dec 2018 15:57:40 -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=1543870660; x=1575406660; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lowe9NWClqF4E9Y9BpuPy3f7/a/C7Daf2aZ8bK5IdEg=; b=T5H3EayTfLgQn7BluF7cj9Z++NZH/KcMymlz/7Wi/RHyy8sfuOKaS3Ni 4YpxGg9e2kNV2adTe+R4CQH/J5ZhYMYA26dDRgVNQTYjkJ/qb77N0T0H/ mOk1OaBkyN11hiVpNcmoA2BYO4r9WYjLylZ1I4OHILwoXqTzToNVax9zH 3y4DdhAl+u4JPZoDeshS0p/juyfnsaFnR1i1D/WTxCxoBg+CghG2pw6zL xRcifJfqtG7LgU68JGtVyyd1qtTA7ICtDM99m8XwOGd+4gFHwYKFw1+Cr U7AfVmlg1cpZDFb+k0QtlomBklnWol5FwfF3sUIlq5jDYtZS2UEZQinPW g==; X-IronPort-AV: E=Sophos;i="5.56,311,1539619200"; d="scan'208";a="100519859" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Dec 2018 04:57:39 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Dec 2018 12:39:55 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Dec 2018 12:57:39 -0800 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Daniel Lezcano , devicetree@vger.kernel.org, Dmitriy Cherkasov , linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Rob Herring , Thomas Gleixner , Anup Patel , Damien Le Moal Subject: [PATCH 2/4] RISC-V: Support per-hart timebase-frequency Date: Mon, 3 Dec 2018 12:57:29 -0800 Message-Id: <1543870651-16669-3-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543870651-16669-1-git-send-email-atish.patra@wdc.com> References: <1543870651-16669-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4