From patchwork Tue Dec 18 21:28:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 154194 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4203722ljp; Tue, 18 Dec 2018 13:30:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/X07N6vqyuArE259SxqKuX8zVh68dqpzYhMpvlKFGBaGziKT4H9dX3Vg8Yuh3qvbruu8M/X X-Received: by 2002:a62:cec6:: with SMTP id y189mr4516506pfg.100.1545168623565; Tue, 18 Dec 2018 13:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545168623; cv=none; d=google.com; s=arc-20160816; b=wtwLEbL5LrTUjA6YCYPG+1A1BYWudgfd/NFnOCAxu+lxCcD1JmhSDo1dWd++fveJn3 I1AdfRr6XN/HAX64IanEXJBEiK0PuwNnKb68nlIABVtClZdiz+0up1IOwV0aJwH1QXTk VyyCo7OVQdcl8eOVRQ9AFsljmxVr0rYA/DQuR2DgGNHBE617cHaZZgs4IXUlD6r6WI4T xCz+zUE/Djonc+FxKMCna961s92E0+Hj4C05rBeDILEUIJzAAy4OjTMQE8PFEZ4SkfGE 3GbqqcFbhim7Ng3UQIE+SGWkKeRgUqRLtiJ30Hk+SMFVWGlghMaVjpLjrH663epS4m5F aIVA== 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=HuxNRSLo1Y/SD7lAUX6QeRhvOXk945RDrLuI7e8huwc=; b=X34jpLhA/qj/rtDqnBmXz8ACBbaT0RdXD1RIXCtoLm5EHSWUkJDoFfZEO/jqFbYfgN ARq/5Zo+qLXDFmi13N5SjCeoD1ocg3hh/TsL5dO01wZV2RVG0SgVtPMq32pr+0ISA8y+ Y9G9f3hnCJOja0AGlvKE9mH1bFnvVh5Itz1Mm2QwgaRxxZ6bZd/SGZbmey1zOJBLtR4C 9eVmknR3N79SUQh5zm9olC9Xcna7LejRvQFKV/NyAXNCWqJgy680QSq2k5w8gu/PxqQR eitCIC1bc99+9wYuM790+kJvICwG500NionYYWkAhrJnShsbov9lf05nBZRITmItdsvE 3QAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=atusBLcC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b60si14175609plc.95.2018.12.18.13.30.23; Tue, 18 Dec 2018 13:30:23 -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=pass header.i=@linaro.org header.s=google header.b=atusBLcC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbeLRVaW (ORCPT + 31 others); Tue, 18 Dec 2018 16:30:22 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37133 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727652AbeLRV3k (ORCPT ); Tue, 18 Dec 2018 16:29:40 -0500 Received: by mail-wm1-f66.google.com with SMTP id g67so4271827wmd.2 for ; Tue, 18 Dec 2018 13:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HuxNRSLo1Y/SD7lAUX6QeRhvOXk945RDrLuI7e8huwc=; b=atusBLcCLc2S/PnQIGuPkwaWqoeJ6o1qCwBPOsDx85VjmTYC0rvdf+OkM/cQ4XNNXZ +DFmvR9qAtYuhV268U9V2pz7MRJ+VD4qoh1mN8iP143Vl8F7cpqVUCdwHiT5VbSmQQr0 i1FOfio58SrDoVxkYVf7dJskuiT8wr9xmN764= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HuxNRSLo1Y/SD7lAUX6QeRhvOXk945RDrLuI7e8huwc=; b=DSUdq34C68ElQNEPGSgtmwvr7iRauPzx+lp41JS7mouINy0Ta9dG+QVE+Fezb0qkYG DECiKXkfzVcHpXCn6TObAv3ph3oEijhmCEuhYqqB/Lqr4ZpquR/3wWHBfHY9b/sucwsm Ycyw6w2BelX7wOrkNP0mKiSPbgpsl6wbm2eRzYNQ7KZVIGaRaCdU/bNVjsOUKfsbHnh2 ohCzzAyhTer0pNIKTRKdMVZr11oANZtomgnvxdPTR0Aq3rRnoGcprYgSbu1M0YHN8Pt5 /mbPax9sG42NAq5VVViXucdTEcNsdjNkkhKFjXp2CmKItolbmnXEgG8f3yKWsVoQd85p qZZQ== X-Gm-Message-State: AA+aEWZZTJLXKJOwv4ntlbUbNIg/pMBi7OsZm8B2cy1TpLfuyQ6CF/rS LDQiXHkV7AMyGX7IvQ06+Vj4G7yaxTM= X-Received: by 2002:a1c:5892:: with SMTP id m140mr4706654wmb.60.1545168578695; Tue, 18 Dec 2018 13:29:38 -0800 (PST) Received: from localhost.localdomain (105.50.92.92.rev.sfr.net. [92.92.50.105]) by smtp.gmail.com with ESMTPSA id o4sm4153485wrq.66.2018.12.18.13.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 13:29:38 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Anup Patel , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE) Subject: [PATCH 19/25] clocksource/drivers/riscv_timer: Provide the sched_clock Date: Tue, 18 Dec 2018 22:28:37 +0100 Message-Id: <20181218212844.30445-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181218212844.30445-1-daniel.lezcano@linaro.org> References: <20181218212844.30445-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anup Patel Currently, we don't have a sched_clock registered for RISC-V systems. This means Linux time keeping will use jiffies (running at HZ) as the default sched_clock. To avoid this, we explicity provide sched_clock using RISC-V rdtime instruction (similar to riscv_timer clocksource). Signed-off-by: Anup Patel Reviewed-by: Palmer Dabbelt Signed-off-by: Daniel Lezcano --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/riscv_timer.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index c57b156f49a2..a4ae339e0101 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -599,7 +599,7 @@ config ATCPIT100_TIMER config RISCV_TIMER bool "Timer for the RISC-V platform" - depends on RISCV + depends on GENERIC_SCHED_CLOCK && RISCV default y select TIMER_PROBE select TIMER_OF diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c index 084e97dc10ed..431892200a08 100644 --- a/drivers/clocksource/riscv_timer.c +++ b/drivers/clocksource/riscv_timer.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,11 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) return get_cycles64(); } +static u64 riscv_sched_clock(void) +{ + return get_cycles64(); +} + static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = { .name = "riscv_clocksource", .rating = 300, @@ -97,6 +103,9 @@ static int __init riscv_timer_init_dt(struct device_node *n) cs = per_cpu_ptr(&riscv_clocksource, cpuid); clocksource_register_hz(cs, riscv_timebase); + sched_clock_register(riscv_sched_clock, + BITS_PER_LONG, riscv_timebase); + error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, "clockevents/riscv/timer:starting", riscv_timer_starting_cpu, riscv_timer_dying_cpu);