From patchwork Thu May 9 11:10:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 163704 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp818575ilr; Thu, 9 May 2019 04:11:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwFYevjjZ90Co4t5xwLmVTgmVQvMt2NeTqWSNqR6YkAzChYOuHZxR2cz2ks5CpQGa792Bw X-Received: by 2002:a62:ae05:: with SMTP id q5mr4079688pff.13.1557400306097; Thu, 09 May 2019 04:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557400306; cv=none; d=google.com; s=arc-20160816; b=PpgF9ydfj2KP5UcgVranczKfsR6FXctzslHj173mqZZ9yyoAUEbswBemncrsnrdWCs b9rOz/Ik8bunIwrYRaCnhO/Mcgm4qz9kwEn2rXrmYQm0PKLngogTtlvCRIBkLFTHwGiM MJUJtpyfQo6DURQosHwnuVu3t6ns3gfY/dIHFTT7WizuDHgiW1to7hySjM1wzUeAYw9/ qO0+dkLijx73yjoshCZrtN27AdivBcJhjbDK1vG+7Y1NucDam8Mxqe4FGbn21EZf3hKK H8H26Zz1mPlUf6TEwLr8wR+6L8NX/qGAylQMfQiSbrCB9tUL5mIzpHwX74XW8Ge/m+xj 0hGA== 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=uXE39cHm/ePcze6cpMzENlQKnSZwc2KOJnys2n77A3I=; b=vwBlBFPOBpzIf+nw5pPur9+8EeWBWYCZsbc5NFuH4UGRdCTrapGSLXNhq5iX/UuItS lzW2hPWEGDlSfYglm1qe/ZCZufssKKjtpFQw25ixPyp5oWJ0aVjYRG4AAgTxbqoDq8qr C4uzI36vDGuUMm4tstfYLib6SdGS7xi1YkcdYygUGqPQey2EtpBaLgswFqOv1Vadafem vYBeq6c4cc8rnc51ypkanPUU4WmZnNLZpQDTbLe+eJeIn6lBNqCvbKJkGx3qG+ilokEY WfTSJhMD/NdxSVacaHGXbbIvmhUzxtd/bRNLSEJ+ngbJDj4r9r6V3+OD4O3niD4oS47T 7+Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fBGeZQwy; 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 y22si2288208pfe.141.2019.05.09.04.11.45; Thu, 09 May 2019 04:11:46 -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=@linaro.org header.s=google header.b=fBGeZQwy; 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 S1726749AbfEILLo (ORCPT + 30 others); Thu, 9 May 2019 07:11:44 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35622 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbfEILLk (ORCPT ); Thu, 9 May 2019 07:11:40 -0400 Received: by mail-wr1-f66.google.com with SMTP id w12so2495084wrp.2 for ; Thu, 09 May 2019 04:11:39 -0700 (PDT) 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=uXE39cHm/ePcze6cpMzENlQKnSZwc2KOJnys2n77A3I=; b=fBGeZQwyL/GXofUWkHPptZvFcDgg6iRQ++N6BG24UZql7XkRmLSIX4wGmFMKMv4h3k 4A2HvUQ0oG01QZkjGdkGZdsU8wVM0kW1i0xpcdINkL9OTkEysMjKwlfM2f2xjtVkJ5M1 vyIL7PeHONfja5TfFdesuMUyT5Gf9aeKARGKfnkaCoN040fl1ZhlP57jcMFhfjU1lU8A 8DOqB1GVLAYA02p2ACgceWtoWXflDkJ/sZTSCWrYUzESvuQDmtVOqvV5iH4SmGNIAhT2 zpUUUrjdvSIH3exFamyAB5SdEg0+58LvjhYcCwdzvOZ5jOglUzEGuFNYeKHgZtAecmBj t3ow== 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=uXE39cHm/ePcze6cpMzENlQKnSZwc2KOJnys2n77A3I=; b=bNN/r6ImfFGajaXAdGC38ESTPNXSiY8CcIzzqEavkRsMYatNK4Bo/NFOjzbx0nqNJs WqmStAd8O/sWQzwbZcxLB/0bZvfgWP0OGTFcik+3IuLChmLrWy7qm9hvSSJlaKPYNfGR 1dvoxDWOelNvQggztkMn8vW/AlM3uIQCOHNcPfxrfZsDMtxhSa3oWSubp1HMUqTDBcPK DpyFxptT2WGKKR7W6GuZf06IEmSZwK3toMNiAZgSy7Pi2LyCJaNtIFRS7YKEknZeUwbj HEutBX5PkWBIi/mxknpJntJzh+q5G4alnzz0xHh0NRzFnPfhwy7eaf5DHDqX0/YK4FWb EKvw== X-Gm-Message-State: APjAAAWEpGtvO2tp1xqYT6jGW3FemH3YbT52T3O3RnBRou5zf+U0pari pzDt79Mo16OdIeeROW2ABZRs6Q== X-Received: by 2002:a5d:518d:: with SMTP id k13mr889239wrv.285.1557400298313; Thu, 09 May 2019 04:11:38 -0700 (PDT) Received: from mai.irit.fr ([141.115.39.235]) by smtp.gmail.com with ESMTPSA id z7sm2299778wme.26.2019.05.09.04.11.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 04:11:37 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Alexandre Belloni , Nicolas Ferre , linux-arm-kernel@lists.infradead.org (moderated list:MICROCHIP TIMER COUNTER (TC) AND CLOCKSOURCE DR...) Subject: [PATCH 09/15] clocksource/drivers/tcb_clksrc: Use tcb as sched_clock Date: Thu, 9 May 2019 13:10:42 +0200 Message-Id: <20190509111048.11151-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509111048.11151-1-daniel.lezcano@linaro.org> References: <7e786ba3-a664-8fd9-dd17-6a5be996a712@linaro.org> <20190509111048.11151-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: Alexandre Belloni 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 Signed-off-by: Daniel Lezcano --- drivers/clocksource/tcb_clksrc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.17.1 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: