Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2263628yba; Mon, 15 Apr 2019 08:11:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQkZs4Pvsr0bMbj224Srx/2UPAxKAffMiBi79d2GUyzgIWVGTiR0ZTfJiQSPXYhtfmEsfR X-Received: by 2002:a17:902:b210:: with SMTP id t16mr71147868plr.84.1555341090343; Mon, 15 Apr 2019 08:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555341090; cv=none; d=google.com; s=arc-20160816; b=ImQXn+58xC8sPNOlHmWW3RJt4rCoRL9RTbzyAJXQ2a04ZoEtE9HroYQef5xeog2Z/k OV1Vtnt6VfQiHPyI2WicBIwDrSF2zkWypuKggaaoiPjFPF/usIiE5z90WJUIo5+0vT7O dI/QCUD4D+gnzSQK6O9I59YsJwkGF/8hR05fnTNJnReOgmKNW4TA2L5VsupMdJao96W/ M6uSRpc/Ffi2VdItOUTfy6IBJpAOQsHB2aYd2tk8smjLwXeo2GkD9xgjXOiNUywveCD9 1fzC2yuUGIPR4XdRtnjjS/qLc49JljU+rKWdDEGK+op4bg7RcKxzN6J/+FF6KuzDgqQ9 OfVw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+XgFljwAGN6vfDwKGxqLwPUoAN/+VWoiGMxCVIJCYi4=; b=nlsIFUDOK5cSUWeflqk7+r2RBeEzatgIidZxvBnSiLXjNPnf0wbxksGkfZbHbJT/5G DB3zzCuaOAaouqeF8PzQP0xZ1oBv+4n3Ybb+bdAnP6bPmwrADebu3nnMaXHvC8kQ07/N 8P/O8m+Nl2yp85/pn2POGwuK38Wx/cfy0RkkNviTxHnvlBaRXOSn2eCVnm0drDGOXs7F Wdw2fY2eYMfmi88MsSh+rFo6yxzjHQmMbkLQtQRm2ki9nNA+8FX+dZrMvZNkGX0Bv2mL MUxhI2DwRo4DOCWjYoxC2gmjksa5ruxN40157X3k3AP/qGejO3FVNLAyy2QNBIOfKkQu 8HaA== ARC-Authentication-Results: i=1; mx.google.com; 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 g11si43131149pgs.503.2019.04.15.08.11.13; Mon, 15 Apr 2019 08:11:30 -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; 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 S1727687AbfDOPJS (ORCPT + 99 others); Mon, 15 Apr 2019 11:09:18 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:54025 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbfDOPJQ (ORCPT ); Mon, 15 Apr 2019 11:09:16 -0400 X-Originating-IP: 109.212.207.226 Received: from localhost (alyon-652-1-176-226.w109-212.abo.wanadoo.fr [109.212.207.226]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id F33E4C0006; Mon, 15 Apr 2019 15:09:13 +0000 (UTC) From: Alexandre Belloni To: Daniel Lezcano Cc: Thomas Gleixner , Nicolas Ferre , Alexander Dahl , Sebastian Andrzej Siewior , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Belloni Subject: [PATCH v2 3/9] clocksource/drivers/tcb_clksrc: Use tcb as sched_clock Date: Mon, 15 Apr 2019 17:08:50 +0200 Message-Id: <20190415150856.9384-4-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190415150856.9384-1-alexandre.belloni@bootlin.com> References: <20190415150856.9384-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the driver is registered early enough, use the TCB as the sched_clock which is much more accurate than the jiffies implementation. Signed-off-by: Alexandre Belloni --- drivers/clocksource/tcb_clksrc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c index bf68504da94a..9de8c10ab546 100644 --- a/drivers/clocksource/tcb_clksrc.c +++ b/drivers/clocksource/tcb_clksrc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,16 @@ static struct clocksource clksrc = { .resume = tc_clksrc_resume, }; +static u64 notrace tc_sched_clock_read(void) +{ + return tc_get_cycles(&clksrc); +} + +static u64 notrace tc_sched_clock_read32(void) +{ + return tc_get_cycles32(&clksrc); +} + #ifdef CONFIG_GENERIC_CLOCKEVENTS struct tc_clkevt_device { @@ -335,6 +346,7 @@ static int __init tcb_clksrc_init(struct device_node *node) struct atmel_tc tc; struct clk *t0_clk; const struct of_device_id *match; + u64 (*tc_sched_clock)(void); u32 rate, divided_rate = 0; int best_divisor_idx = -1; int clk32k_divisor_idx = -1; @@ -419,6 +431,7 @@ static int __init tcb_clksrc_init(struct device_node *node) clksrc.read = tc_get_cycles32; /* setup ony channel 0 */ tcb_setup_single_chan(&tc, best_divisor_idx); + tc_sched_clock = tc_sched_clock_read32; } else { /* we have three clocks no matter what the * underlying platform supports. @@ -430,6 +443,7 @@ static int __init tcb_clksrc_init(struct device_node *node) } /* setup both channel 0 & 1 */ tcb_setup_dual_chan(&tc, best_divisor_idx); + tc_sched_clock = tc_sched_clock_read; } /* and away we go! */ @@ -442,6 +456,8 @@ static int __init tcb_clksrc_init(struct device_node *node) if (ret) goto err_unregister_clksrc; + sched_clock_register(tc_sched_clock, 32, divided_rate); + return 0; err_unregister_clksrc: -- 2.20.1