From patchwork Wed Jun 13 11:32:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138431 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp597057lji; Wed, 13 Jun 2018 04:33:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3dVWV/FNrw8QSjoIOT/GBnfJmQKdQSEGmTWJsj8w8rhbjyuR3eV+D8hEJDPP/9ZIb5MZt X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr3862591pge.166.1528889592649; Wed, 13 Jun 2018 04:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889592; cv=none; d=google.com; s=arc-20160816; b=dMA/qHMBkVO1t41wzCGwHCyiRfn7dY23y4Z2z+zsbHaxaRrekaaP57OVYgoOIecJ/M pBVDYZopbmMDio61o2Z4efdWTdLg04N6YtRMdmaBzxLo9tL+0O1NA2bzztfJ4nUKOmLG ioENulZ9wIDg2A/ouxASx7uv7A7kE+CT1ui3Zf4453q1H66nkK2RNrw5GnA64Ifo0D8O 20/cuHujvu4svSW81iDLfr/tD0WGRTXPS5uRzsgY5b4cK9ffAESqyvQpmGEgGzti/2U7 2QG3OSu2S5eAWl6P3Ir+74IygwSLYTt50PUuXeoo65jEi4gWGPa7WbLDMG83NumjasBF JJ/A== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TC4aJIvxEIYrPXern0Rc+4UcSzw/M0o3C1R8YeUHl08=; b=c1hsKoCj76VaxHiH/Kg/3+W4qaDD2Dzz86AQnXavb1tjeX3jJKtWfYG7hAGNgwBk80 tlhXEhAK3R63rrd0t/CPrN4d+XNOys/Fm3BC9c5pHesTmQ7vTGFKi0OocW2+yRECV8OV Z4R+6893XIg56Yo5Q7hyyxtyXlEU8p8rFK4sN02mmTZ+IwW7w+Yu+g1T9YyIwOYLCOhZ yJPeTRg84Gp3GCU5Q437q5axN14f/4BIELh2H8jvwGN0xLCNgnuhrwAkgN4iHqQmiMr0 30kxegXJW6VUxfVOcDCN+2AlxdmZDsoRAppfIznfO3C5rRDOIqDRtdE9dB1JENPBLkbi CjHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ToGNKbzt; 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 c11-v6si2211148pgt.686.2018.06.13.04.33.12; Wed, 13 Jun 2018 04:33:12 -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=ToGNKbzt; 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 S935397AbeFMLdK (ORCPT + 30 others); Wed, 13 Jun 2018 07:33:10 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41280 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935374AbeFMLdG (ORCPT ); Wed, 13 Jun 2018 07:33:06 -0400 Received: by mail-pg0-f68.google.com with SMTP id l65-v6so1140215pgl.8 for ; Wed, 13 Jun 2018 04:33:05 -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 :in-reply-to:references; bh=TC4aJIvxEIYrPXern0Rc+4UcSzw/M0o3C1R8YeUHl08=; b=ToGNKbztYKVJuwQfH3NUqwqVSrmWcnJ/V/Lu4lK7tWqUNX0Ycw/fAs4RHZGWn/a6IK NBUwVLSfREgo24d7Kn4dkfX7QlrCb3BAslDCMPbG27P6hndw9NhkdWTqYHhkCMzShVE9 suhwXXANECmrptzVgSivQlR5hb872yGcKAYFs= 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:in-reply-to:references; bh=TC4aJIvxEIYrPXern0Rc+4UcSzw/M0o3C1R8YeUHl08=; b=JWRmkJs1XMOlqjZrrb9IddNpz4g8RFFwvH3Qg3d475dVyIti4wNbVUc1VgUdeJ+9pr gv33YaAccsRwzXC+gwVbwQjwHnAFNKcAsVuMjzXJzvRh/XnUtzg1MBZv8krrDE41/F1m ZJVM2n7Ki3ItznV0he0Mw7Fg20NN3shtin4GkGbcNYHq0MFZkD9a+6AVFAYfjb9nr+S7 NZPDJ3DDq5IoN6wxd0mZ81i3RF3c8BvqMBjA1e56NxRyri2c1PKixPu9ES9zvCZNQ4BH aRAabJk7/0vFIlbkDoTaqJYAYvKn4zY9WsELgfty2CZqdO2lum8Q1pau7q/6duABMhpc CzMA== X-Gm-Message-State: APt69E1cQgQjGhiLVKMk0qGKUJsLv8f0uOJxB2Zu0DlNzKQ9TUAx30Ev oiJ78k38sCnOPnMScv9opjXN3A== X-Received: by 2002:a62:1c43:: with SMTP id c64-v6mr4532860pfc.176.1528889585571; Wed, 13 Jun 2018 04:33:05 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.32.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:33:05 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 1/8] time: Add persistent clock support Date: Wed, 13 Jun 2018 19:32:28 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On our Spreadtrum SC9860 platform, we registered the high resolution ARM generic timer as one clocksource to update the OS time, but the ARM generic timer will be stopped in suspend state. So we use one 64bit always-on timer (but low resolution) of Spreadtrum to calculate the suspend time to compensate the OS time. Though we can register the always-on timer as one clocksource, we need re-calculate the mult/shift with one larger conversion range to calculate the suspend time. But now we have too many different ways of dealing with persistent timekeeping across architectures, and there will be many duplicate code if we register one timer to be one persistent clock. Thus it will be more helpful if we add one common framework for timer drivers to be registered as one persistent clock and implement the common read_persistent_clock64() to compensate the OS time. Moreover we can register the clocksource with CLOCK_SOURCE_SUSPEND_NONSTOP to be one persistent clock, then we can simplify the suspend/resume accounting by removing CLOCK_SOURCE_SUSPEND_NONSTOP timing. After that we can only compensate the OS time by persistent clock or RTC. Signed-off-by: Baolin Wang --- include/linux/persistent_clock.h | 23 +++++ kernel/time/Kconfig | 4 + kernel/time/Makefile | 1 + kernel/time/alarmtimer.c | 4 + kernel/time/persistent_clock.c | 184 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 216 insertions(+) create mode 100644 include/linux/persistent_clock.h create mode 100644 kernel/time/persistent_clock.c -- 1.7.9.5 diff --git a/include/linux/persistent_clock.h b/include/linux/persistent_clock.h new file mode 100644 index 0000000..7d42c1a --- /dev/null +++ b/include/linux/persistent_clock.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef __PERSISTENT_CLOCK_H__ +#define __PERSISTENT_CLOCK_H__ + +#ifdef CONFIG_PERSISTENT_CLOCK +extern int persistent_clock_init_and_register(u64 (*read)(void), + u64 mask, u32 freq, + u64 maxsec); +extern void persistent_clock_cleanup(void); +extern void persistent_clock_start_alarmtimer(void); +#else +static inline int persistent_clock_init_and_register(u64 (*read)(void), + u64 mask, u32 freq, + u64 maxsec) +{ + return 0; +} + +static inline void persistent_clock_cleanup(void) { } +static inline void persistent_clock_start_alarmtimer(void) { } +#endif + +#endif diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 78eabc4..7188600 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -47,6 +47,10 @@ config GENERIC_CLOCKEVENTS_MIN_ADJUST config GENERIC_CMOS_UPDATE bool +# Persistent clock support +config PERSISTENT_CLOCK + bool + if GENERIC_CLOCKEVENTS menu "Timers subsystem" diff --git a/kernel/time/Makefile b/kernel/time/Makefile index f1e46f3..f6d368f 100644 --- a/kernel/time/Makefile +++ b/kernel/time/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_GENERIC_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o tick-sched.o obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o +obj-$(CONFIG_PERSISTENT_CLOCK) += persistent_clock.o diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 639321b..1518fdb 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "posix-timers.h" @@ -892,6 +893,9 @@ static int __init alarmtimer_init(void) error = PTR_ERR(pdev); goto out_drv; } + + /* Start one alarmtimer to update persistent clock */ + persistent_clock_start_alarmtimer(); return 0; out_drv: diff --git a/kernel/time/persistent_clock.c b/kernel/time/persistent_clock.c new file mode 100644 index 0000000..edaa659 --- /dev/null +++ b/kernel/time/persistent_clock.c @@ -0,0 +1,184 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Linaro, Inc. + * + * Author: Baolin Wang + */ + +#include +#include +#include + +/** + * persistent_clock_read_data - data required to read persistent clock + * @read: Returns a cycle value from persistent clock. + * @last_cycles: Clock cycle value at last update. + * @last_ns: Time value (nanoseconds) at last update. + * @mask: Bitmask for two's complement subtraction of non 64bit clocks. + * @mult: Cycle to nanosecond multiplier. + * @shift: Cycle to nanosecond divisor. + */ +struct persistent_clock_read_data { + u64 (*read)(void); + u64 last_cycles; + u64 last_ns; + u64 mask; + u32 mult; + u32 shift; +}; + +/** + * persistent_clock - represent the persistent clock + * @read_data: Data required to read from persistent clock. + * @seq: Sequence counter for protecting updates. + * @freq: The frequency of the persistent clock. + * @wrap: Duration for persistent clock can run before wrapping. + * @alarm: Update timeout for persistent clock wrap. + * @alarm_inited: Indicate if the alarm has been initialized. + */ +struct persistent_clock { + struct persistent_clock_read_data read_data; + seqcount_t seq; + u32 freq; + ktime_t wrap; + struct alarm alarm; + bool alarm_inited; +}; + +static struct persistent_clock p; + +void read_persistent_clock64(struct timespec64 *ts) +{ + struct persistent_clock_read_data *read_data = &p.read_data; + unsigned long seq; + u64 delta, nsecs; + + if (!read_data->read) { + ts->tv_sec = 0; + ts->tv_nsec = 0; + return; + } + + do { + seq = read_seqcount_begin(&p.seq); + delta = (read_data->read() - read_data->last_cycles) & + read_data->mask; + + nsecs = read_data->last_ns + + clocksource_cyc2ns(delta, read_data->mult, + read_data->shift); + *ts = ns_to_timespec64(nsecs); + } while (read_seqcount_retry(&p.seq, seq)); +} + +static void persistent_clock_update(void) +{ + struct persistent_clock_read_data *read_data = &p.read_data; + u64 cycles, delta; + + write_seqcount_begin(&p.seq); + + cycles = read_data->read(); + delta = (cycles - read_data->last_cycles) & read_data->mask; + read_data->last_ns += clocksource_cyc2ns(delta, read_data->mult, + read_data->shift); + read_data->last_cycles = cycles; + + write_seqcount_end(&p.seq); +} + +static enum alarmtimer_restart persistent_clock_alarm_fired(struct alarm *alarm, + ktime_t now) +{ + persistent_clock_update(); + + alarm_forward(&p.alarm, now, p.wrap); + return ALARMTIMER_RESTART; +} + +int persistent_clock_init_and_register(u64 (*read)(void), u64 mask, + u32 freq, u64 maxsec) +{ + struct persistent_clock_read_data *read_data = &p.read_data; + u64 wrap, res, secs = maxsec; + + if (!read || !mask || !freq) + return -EINVAL; + + if (!secs) { + /* + * If the timer driver did not specify the maximum conversion + * seconds of the persistent clock, then we calculate the + * conversion range with the persistent clock's bits and + * frequency. + */ + secs = mask; + do_div(secs, freq); + + /* + * Some persistent counter can be larger than 32bit, so we + * need limit the max suspend time to have a good conversion + * precision. So 24 hours may be enough usually. + */ + if (secs > 86400) + secs = 86400; + } + + /* Calculate the mult/shift to convert cycles to ns. */ + clocks_calc_mult_shift(&read_data->mult, &read_data->shift, freq, + NSEC_PER_SEC, (u32)secs); + + /* Calculate how many nanoseconds until we risk wrapping. */ + wrap = clocks_calc_max_nsecs(read_data->mult, read_data->shift, 0, + mask, NULL); + p.wrap = ns_to_ktime(wrap); + + p.freq = freq; + read_data->mask = mask; + read_data->read = read; + + persistent_clock_update(); + + /* Calculate the ns resolution of this persistent clock. */ + res = clocksource_cyc2ns(1ULL, read_data->mult, read_data->shift); + + pr_info("persistent clock: mask %llu at %uHz, resolution %lluns, wraps every %lluns\n", + mask, freq, res, wrap); + return 0; +} + +void persistent_clock_cleanup(void) +{ + p.read_data.read = NULL; + + if (p.alarm_inited) { + alarm_cancel(&p.alarm); + p.alarm_inited = false; + } +} + +void persistent_clock_start_alarmtimer(void) +{ + struct persistent_clock_read_data *read_data = &p.read_data; + ktime_t now; + + /* + * If no persistent clock function has been provided or the alarmtimer + * has been initialized at that point, just return. + */ + if (!read_data->read || p.alarm_inited) + return; + + persistent_clock_update(); + + /* + * Since the persistent clock will not be stopped when system enters the + * suspend state, thus we need start one alarmtimer to wakeup the system + * to update the persistent clock before wrapping. We should start the + * update alarmtimer after the alarmtimer subsystem was initialized. + */ + alarm_init(&p.alarm, ALARM_BOOTTIME, persistent_clock_alarm_fired); + now = ktime_get_boottime(); + alarm_start(&p.alarm, ktime_add(now, p.wrap)); + p.alarm_inited = true; +} From patchwork Wed Jun 13 11:32:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138433 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp597432lji; Wed, 13 Jun 2018 04:33:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKerVMi4lmv6sU2ZYIZRPui6KfIHIaCn7N5yAC/52cowkfXoK1grSbl4pFTPfqENJRaZqPL X-Received: by 2002:a17:902:6546:: with SMTP id d6-v6mr4801290pln.196.1528889609947; Wed, 13 Jun 2018 04:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889609; cv=none; d=google.com; s=arc-20160816; b=N7twIDyrTTuxV/ZCKgezD+STMsUi9SW96VLDLAzpSBKacWTWNoxpoLw6BUmBOQEtHA rlkPbyd/ZhufSeAGlpISonHpnQ0c1APzO9RA8SnWMM9+ZCTaC0g8D1NBHwtSH/jf2G0Y IM2zrb4RHH44zKTRXwtkHqW8tBRt5ECmgpD+osXKyFmpcGnBqAljcKrsdXJdvoppmczM q4ko6FxSG2xC0o6ebKnpptxgJO0RBH6lFAyNGku9GEmJHVSTHd8bTSQ2g/AVg1XWtbST qmv27te1jlpvWhekEx4CN5xrgeYZMIAag0vUwgJy+tfB+SDVZbZRTtxD3Lk8SjJUPd1e +OLQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=dlPlAQoN9NNMysgct5QnzMP8Q5ACUaR7klOM61JcA8E=; b=WGVBtlqZzlEDv+3oW8T77J9Dz76YLcn5yG2ifK74BmqvGjlp9KL+8SciOpY76iHJ/W 3KrGIFVkEaA9VTASOt992BzLe+KrxS8UCaBA+5BMMe8rNqRKWVSCkOifxtgVNvQwbEgN 9rFDSUz7e8XJGRTXoV1SCggGlGzyI2eOTT88aCFFFJYH8DZVS2dq0/2nDoH59BUSTS/T pi9uzrLfS+xtsPagqpPhzRU0BJbJZimv9dv7rZjm/xnAyjgT3/FgtkfgdYgA3n9y2Cuk e5I0Lb7d0fSg8yenHLgEwRZZKZTJKq7o3A7M+3v0XWyQaBKFT8GoEmwIp7qIchlLd3Gl F82g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CJWTW9VL; 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 q11-v6si2159046pgp.95.2018.06.13.04.33.29; Wed, 13 Jun 2018 04:33:29 -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=CJWTW9VL; 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 S935442AbeFMLd2 (ORCPT + 30 others); Wed, 13 Jun 2018 07:33:28 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38413 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935424AbeFMLdY (ORCPT ); Wed, 13 Jun 2018 07:33:24 -0400 Received: by mail-pg0-f68.google.com with SMTP id c9-v6so1145099pgf.5 for ; Wed, 13 Jun 2018 04:33:24 -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 :in-reply-to:references; bh=dlPlAQoN9NNMysgct5QnzMP8Q5ACUaR7klOM61JcA8E=; b=CJWTW9VL3JbQH/ipPdSBsgXI0FaOtKzHu4oK4amhxjSWJl9SmLw5LODr/Bo/H7oRB7 bkgJeENX7brj2L2v6V/QEex/3Y+aaPz+O/GjkgZNfCNsgmPEV3UU7cE4Rpz2CBqFof3v h6Cq9wjhUZMafTf6Mt2fnfiKTtMGvc0FXGIWw= 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:in-reply-to:references; bh=dlPlAQoN9NNMysgct5QnzMP8Q5ACUaR7klOM61JcA8E=; b=TyN4jR+SFgDCBAv1Zh73JV+2DK6r5uFPhlmSHh2C/B7YjyzhgX4OXxqWCFiJxtyq1V gWeJmFCoQv0ufQ4VpWKI3vCDe4x/sGtzuC0MMHTt49kvwUPCt8ZYVOhWKnrJqJKC1VkH 2GW8TogR8tTb7ny/bsqSF6FL9ome4Yo8lbl8dfbBcN8yEmwbM9MzJNtCUcApL4JFylKt jx44kKjjkAokXbwMoRCayLlTcu9XwkVSuhOwoVJgZcrgqFvbMqsA/riwSYNS8HP3L+gl F85+l2UArRVvg5fc2WYUrG6tEdpMTA4tzGo/W56BxlcqGIKVWbxYHqWk8ZU1n3FRdqNQ dWCg== X-Gm-Message-State: APt69E1DjzxGe25FQxIarjGlN1DgYP4poSeq28GfAEGIDWb8znGcPnhr It2R5o49ZIPIO+Y0VVDo3pnfGw== X-Received: by 2002:a62:e310:: with SMTP id g16-v6mr4593998pfh.25.1528889603725; Wed, 13 Jun 2018 04:33:23 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.33.15 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:33:23 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 3/8] arm: time: Remove the persistent clock support for ARM architecture Date: Wed, 13 Jun 2018 19:32:30 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have introduced the persistent clock framework to support the OS time compensating from persistent clock, and we will convert all drivers to use common persistent clock framework instead of the persistent clock support used only for the ARM architecture. So we can remove these code with converting the Omap 32k counter and tegra20 timer. Moreover there are no drivers will register read_boot_clock64(), so remove it too. Signed-off-by: Baolin Wang --- arch/arm/include/asm/mach/time.h | 4 ---- arch/arm/kernel/time.c | 36 ---------------------------- arch/arm/plat-omap/Kconfig | 1 + arch/arm/plat-omap/counter_32k.c | 44 ++++++----------------------------- drivers/clocksource/tegra20_timer.c | 12 +++++++--- 5 files changed, 17 insertions(+), 80 deletions(-) -- 1.7.9.5 diff --git a/arch/arm/include/asm/mach/time.h b/arch/arm/include/asm/mach/time.h index 0f79e4d..3cbcafc 100644 --- a/arch/arm/include/asm/mach/time.h +++ b/arch/arm/include/asm/mach/time.h @@ -12,8 +12,4 @@ extern void timer_tick(void); -typedef void (*clock_access_fn)(struct timespec64 *); -extern int register_persistent_clock(clock_access_fn read_boot, - clock_access_fn read_persistent); - #endif diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c index cf2701c..713905c 100644 --- a/arch/arm/kernel/time.c +++ b/arch/arm/kernel/time.c @@ -76,42 +76,6 @@ void timer_tick(void) } #endif -static void dummy_clock_access(struct timespec64 *ts) -{ - ts->tv_sec = 0; - ts->tv_nsec = 0; -} - -static clock_access_fn __read_persistent_clock = dummy_clock_access; -static clock_access_fn __read_boot_clock = dummy_clock_access; - -void read_persistent_clock64(struct timespec64 *ts) -{ - __read_persistent_clock(ts); -} - -void read_boot_clock64(struct timespec64 *ts) -{ - __read_boot_clock(ts); -} - -int __init register_persistent_clock(clock_access_fn read_boot, - clock_access_fn read_persistent) -{ - /* Only allow the clockaccess functions to be registered once */ - if (__read_persistent_clock == dummy_clock_access && - __read_boot_clock == dummy_clock_access) { - if (read_boot) - __read_boot_clock = read_boot; - if (read_persistent) - __read_persistent_clock = read_persistent; - - return 0; - } - - return -EINVAL; -} - void __init time_init(void) { if (machine_desc->init_time) { diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index c0a242c..073a80f 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 config ARCH_OMAP + select PERSISTENT_CLOCK bool if ARCH_OMAP diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c index 2438b96..5d52f7c 100644 --- a/arch/arm/plat-omap/counter_32k.c +++ b/arch/arm/plat-omap/counter_32k.c @@ -19,8 +19,7 @@ #include #include #include - -#include +#include #include @@ -44,33 +43,6 @@ static u64 notrace omap_32k_read_sched_clock(void) } /** - * omap_read_persistent_clock64 - Return time from a persistent clock. - * - * Reads the time from a source which isn't disabled during PM, the - * 32k sync timer. Convert the cycles elapsed since last read into - * nsecs and adds to a monotonically increasing timespec64. - */ -static struct timespec64 persistent_ts; -static cycles_t cycles; -static unsigned int persistent_mult, persistent_shift; - -static void omap_read_persistent_clock64(struct timespec64 *ts) -{ - unsigned long long nsecs; - cycles_t last_cycles; - - last_cycles = cycles; - cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; - - nsecs = clocksource_cyc2ns(cycles - last_cycles, - persistent_mult, persistent_shift); - - timespec64_add_ns(&persistent_ts, nsecs); - - *ts = persistent_ts; -} - -/** * omap_init_clocksource_32k - setup and register counter 32k as a * kernel clocksource * @pbase: base addr of counter_32k module @@ -95,13 +67,6 @@ int __init omap_init_clocksource_32k(void __iomem *vbase) else sync32k_cnt_reg = vbase + OMAP2_32KSYNCNT_CR_OFF_LOW; - /* - * 120000 rough estimate from the calculations in - * __clocksource_update_freq_scale. - */ - clocks_calc_mult_shift(&persistent_mult, &persistent_shift, - 32768, NSEC_PER_SEC, 120000); - ret = clocksource_mmio_init(sync32k_cnt_reg, "32k_counter", 32768, 250, 32, clocksource_mmio_readl_up); if (ret) { @@ -110,7 +75,12 @@ int __init omap_init_clocksource_32k(void __iomem *vbase) } sched_clock_register(omap_32k_read_sched_clock, 32, 32768); - register_persistent_clock(NULL, omap_read_persistent_clock64); + /* + * 120000 rough estimate from the calculations in + * __clocksource_update_freq_scale. + */ + persistent_clock_init_and_register(omap_32k_read_sched_clock, + CLOCKSOURCE_MASK(32), 32768, 120000); pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n"); return 0; diff --git a/drivers/clocksource/tegra20_timer.c b/drivers/clocksource/tegra20_timer.c index c337a81..97a34cb 100644 --- a/drivers/clocksource/tegra20_timer.c +++ b/drivers/clocksource/tegra20_timer.c @@ -124,7 +124,7 @@ static u64 tegra_rtc_read_ms(void) } /* - * tegra_read_persistent_clock64 - Return time from a persistent clock. + * read_persistent_clock64 - Return time from a persistent clock. * * Reads the time from a source which isn't disabled during PM, the * 32k sync timer. Convert the cycles elapsed since last read into @@ -133,10 +133,16 @@ static u64 tegra_rtc_read_ms(void) * tegra_rtc driver could be executing to avoid race conditions * on the RTC shadow register */ -static void tegra_read_persistent_clock64(struct timespec64 *ts) +void read_persistent_clock64(struct timespec64 *ts) { u64 delta; + if (!rtc_base) { + ts->tv_sec = 0; + ts->tv_nsec = 0; + return; + } + last_persistent_ms = persistent_ms; persistent_ms = tegra_rtc_read_ms(); delta = persistent_ms - last_persistent_ms; @@ -259,6 +265,6 @@ static int __init tegra20_init_rtc(struct device_node *np) else clk_prepare_enable(clk); - return register_persistent_clock(NULL, tegra_read_persistent_clock64); + return 0; } TIMER_OF_DECLARE(tegra20_rtc, "nvidia,tegra20-rtc", tegra20_init_rtc); From patchwork Wed Jun 13 11:32:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138434 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp597568lji; Wed, 13 Jun 2018 04:33:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK/joORwzHYONAEGb+d8s20ky7PvbWflyWux5pOhjqFHjD7+mLiSwNzocztVaG1AlFWlSXC X-Received: by 2002:a17:902:8e87:: with SMTP id bg7-v6mr4772555plb.129.1528889618916; Wed, 13 Jun 2018 04:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889618; cv=none; d=google.com; s=arc-20160816; b=0tWYyU7qDYFU7IBVW9Uijg0StaLxnfPC7Qcon+Rm1CZJG5sDZzqtEap9VH6L4aN3HD AQqeaDDAjiV1ka/fP6ruF9hYaAq+2EulFhE3xhcVuUihC3ZbWKMrqxl5ioNggrW4migo oo9tdAl+z6aba7ApBFayYlzWObsElutSEpvTWHQSbPEVvVv5wu33Dmo3WwlxTpfjDn55 HCdWjiEYfjXFNWw9/VyZY5SpfPRvza0dAr9jCmJ29DoglOkShUZqLn5f6YIZO6N4JZND SZe2eaGzV+KGF+wca2uMRsghKK7/d+gq8iSoZkpU96XsVsibJ7fugAFgtmkDiKUgi8Vy tYcg== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=qOl0Hf/KoVxPAWSJiEHR+kwcAVrdVGSBzW6sJ8SSmik=; b=G9bO+giSfmDmbUv+ZKctoIOWZld66uVNLt5VIvNzEo3rvCpm5a8sB8g4rUhbqWqG/Z 8Au9tmg9IV+Ab4SrKWz63C7/Z5qGMeB4X3IN3QyDYMkaLatN+uAbC+nwJoLHEb8VQKFy CHFaNvI6Vxmop9sVBeLhMF/XmmCzek3ZCt4hD+Bij9LH2I/DPsnt7AQmvcDsfWbSruuA UI6942sVrY4Jk9NdERM4EUnd2Y+d5ifofyT+ExtTc85hOFta3Ix+D5MCZy8mB7C68iCJ erUYrTFvBA9e/uLN41PAg7b7PU36iXqrg6z07e5Q87bZ5M7QetYjv11xCOyFBAMVfEZK CZ3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bZJ4yF8M; 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 r18-v6si2195665pgd.143.2018.06.13.04.33.38; Wed, 13 Jun 2018 04:33:38 -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=bZJ4yF8M; 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 S935457AbeFMLdh (ORCPT + 30 others); Wed, 13 Jun 2018 07:33:37 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:44182 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935424AbeFMLdd (ORCPT ); Wed, 13 Jun 2018 07:33:33 -0400 Received: by mail-pg0-f65.google.com with SMTP id p21-v6so1135787pgd.11 for ; Wed, 13 Jun 2018 04:33:32 -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 :in-reply-to:references; bh=qOl0Hf/KoVxPAWSJiEHR+kwcAVrdVGSBzW6sJ8SSmik=; b=bZJ4yF8MMucwePX4a2IL1gLw8HXA4kU2ZXmm73QuocsMJp+baefw2Ul6QlDdUiuluL r27hCR61+zLb0kh9JNg814I/JuiMAWUR4JtblPFzDxjaC/L9A24KcXAJZ4SfUqDZwYQv X2ahTQwc6puDorhfLWf/IvIjAvFFtPVsZccnU= 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:in-reply-to:references; bh=qOl0Hf/KoVxPAWSJiEHR+kwcAVrdVGSBzW6sJ8SSmik=; b=CmXnuMMkHUIZ4Ls//XICW9H92D8KWq+EK4GTfFElDTev9gmh1GiqXSFXNtdng6sARD IJ/JVIntHlpFfPMSTskOHgijYbcBdqkY8OoNn/dovcvMVSbEa+s2FEw/+fDi3as1rqud BFk2DpLZV6sJhyi+SpsoDDh5DtRZ5f3lGwwcqgtN/LoisrhafhzIlsmL1zU3E6Aqj2Zm 5dfCjSeigeFYukg2VyfXacnPwuWNV9DUjKJLFVyEwMuE331Sqf6cef1mealj4DAsb/tl W4yZIPVmswO72YftbeaR0FsUYM1wnnChay+zHhhuLYQ/79mXbVp9Nfe1aIHHfIBVy9Da EZlw== X-Gm-Message-State: APt69E2jZ4WBuKzQ7rikY+xNJ4WBoGvTvlXnJqdqc10BOpHWczezYpiI o5ePek531VeLKzkPJxPIFTqn7w== X-Received: by 2002:a62:f551:: with SMTP id n78-v6mr4618811pfh.200.1528889612370; Wed, 13 Jun 2018 04:33:32 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.33.24 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:33:31 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 4/8] clocksource: arm_arch_timer: Register the persistent clock Date: Wed, 13 Jun 2018 19:32:31 +0800 Message-Id: <5b450836ee0db88de27d47e43368de02c550425b.1528878545.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register the persistent clock to compensate the suspend time for OS time, if the ARM counter clocksource will not be stopped in suspend state. Signed-off-by: Baolin Wang --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 10 ++++++++++ 2 files changed, 11 insertions(+) -- 1.7.9.5 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 7f11c6c..5e51fcf 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -308,6 +308,7 @@ config ARC_TIMERS_64BIT config ARM_ARCH_TIMER bool + select PERSISTENT_CLOCK select TIMER_OF if OF select TIMER_ACPI if ACPI diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 57cb2f0..671be63 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -32,6 +32,7 @@ #include #include +#include #undef pr_fmt #define pr_fmt(fmt) "arch_timer: " fmt @@ -950,6 +951,15 @@ static void __init arch_counter_register(unsigned type) /* 56 bits minimum, so we assume worst case rollover */ sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate); + + /* + * Register the persistent clock if the clocksource will not be stopped + * in suspend state. + */ + if (!arch_counter_suspend_stop) + persistent_clock_init_and_register(arch_timer_read_counter, + CLOCKSOURCE_MASK(56), + arch_timer_rate, 0); } static void arch_timer_stop(struct clock_event_device *clk) From patchwork Wed Jun 13 11:32:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138435 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp597675lji; Wed, 13 Jun 2018 04:33:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLVJyRKgXvtmQlyPuUJH7ELKrNpDtEdYIWZbnTJKBXZBtCW1o/8fT69549KSKX+dDzeYZkS X-Received: by 2002:a62:2044:: with SMTP id g65-v6mr4599073pfg.40.1528889625639; Wed, 13 Jun 2018 04:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889625; cv=none; d=google.com; s=arc-20160816; b=mAZroSs4HGf+RVAyPLxSe11Mn+Hv/RDkElZejlpQNJJSAbIEgTLGNcVGYQspudodAS Q0/MwsY6kIr1ZvWSb/aIlsxvJqTnoWXCptgHKhsNIcnOYSyXY6a1nNdbQAjRFYaCsSJs siXkRmOgshJqml3kQjCSDxv8FZL0mpO8zj3r+DAGBBom0yO9fMrDUx3NjrK2oRzF9j4U DC+SP2ZSpSV9deIqYJDS8O3kQUyR//YdQoVcLS4n0jfOWoQHoHlHmku4UCPFbBjzgV6x zVvGPTlYdFS9hyU4Q263/3CQ6uPcUnBOUkRVNNQQSbIjGk8JAYWxM61X9X6kItlcuUXL us2g== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=VFxhbhsSuXUmiZ9cQAUkdhNUFAU4y120/7wyv8wzRCU=; b=rQjzMOW41LlNSRxq/P5kyn/3gTm66SbaqgFnNb+qU9I2CDSuxkNOMktSknKnUbXs2P flcbSqeblaxt6Vz9CJq+GjIwVePWMcUtD5+DMl8eUVQ4hyz+YiNq7V370YiOOva+xz4g y+YczekIgDzKOVfAFVbDpZ8Ogiwiutvo9djxq3/DMpibVgPHv62TTMZjuP+YeNeS7Xsh GT4KIhxNpdkMIuvSJw5xspcjBPv2UdcurPaJCN3pSEaeHOYWX7WbtwPRKUcmuTwjSGC5 BYqPwuBPqP3xb01K4RuxaAqzX5CmrBpSn2Q8uilHFY2CcwPQqDV2Q0mvljnHnzFbN93P BU8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GwSPbK0O; 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 y124-v6si2148447pgb.61.2018.06.13.04.33.45; Wed, 13 Jun 2018 04:33:45 -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=GwSPbK0O; 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 S935475AbeFMLdo (ORCPT + 30 others); Wed, 13 Jun 2018 07:33:44 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34794 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935459AbeFMLdl (ORCPT ); Wed, 13 Jun 2018 07:33:41 -0400 Received: by mail-pl0-f66.google.com with SMTP id g20-v6so1388594plq.1 for ; Wed, 13 Jun 2018 04:33:41 -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 :in-reply-to:references; bh=VFxhbhsSuXUmiZ9cQAUkdhNUFAU4y120/7wyv8wzRCU=; b=GwSPbK0OGf/jDreDhJlTg4vRKQl2zMu36mc/NSHeoDaHQ8K0xkwMYZBWZamkImUBzo qWOOGdi/faD9AkLS16WjIwAahe+/R5LAloQxJ1UBATQ6iz27y0U66bAh/7Ll9Td1xoi+ 6nOFrd3OlxGVfclu7h330U4UkuZTY/m8deJE8= 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:in-reply-to:references; bh=VFxhbhsSuXUmiZ9cQAUkdhNUFAU4y120/7wyv8wzRCU=; b=IRlKGgbHUOdfHh1nHFNCyxp1YDb7LpH3AIrCN5ZxsiVaz2sTso19v06quPEw5Yrdrx SDiC1LJEj8CSDyl7XrjLKc6FUZ305dYD2txAK7RJxsi+L35XwyIQNtETi2JlM+Jdy7JA Ol4o7TgzoVRcqCMwExgASNNILQdwAABEENpflpYUoENfPrFr6b1ImLAMWStMU3q2rkOw DiJxpwtBMMXLXe7ciiNqdaKNfnDF3Mzy9mJRIJiINGSJqA9T7eEjNX/omeb/Xw7XfTsY zpRV4UgG5xFlojbNiH73cNYWGjLieJfRQ6KlMmIXOvR5V0xWFwe+fZK9Gee/Sh2gsM3U G8dA== X-Gm-Message-State: APt69E3Bl6L9MKKtr1PzPJaRrU/P8UhaETokCpU8qSQ0ShnzVjLmuyv/ kjKvtYVbe8GbbwY13mOcZpCzkg== X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr4745245pll.90.1528889620901; Wed, 13 Jun 2018 04:33:40 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.33.32 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:33:40 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 5/8] clocksource: timer-ti-32k: Register the persistent clock Date: Wed, 13 Jun 2018 19:32:32 +0800 Message-Id: <904493423cadb90576a712acdb3b512b4ed44887.1528878545.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the 32K counter is always available, then we can register the persistent clock to compensate the suspend time for the OS time. Signed-off-by: Baolin Wang --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/timer-ti-32k.c | 4 ++++ 2 files changed, 5 insertions(+) -- 1.7.9.5 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 5e51fcf..3cd136f 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -262,6 +262,7 @@ config CLKSRC_TI_32K bool "Texas Instruments 32.768 Hz Clocksource" if COMPILE_TEST depends on GENERIC_SCHED_CLOCK select TIMER_OF if OF + select PERSISTENT_CLOCK help This option enables support for Texas Instruments 32.768 Hz clocksource available on many OMAP-like platforms. diff --git a/drivers/clocksource/timer-ti-32k.c b/drivers/clocksource/timer-ti-32k.c index 880a861..353ff9d 100644 --- a/drivers/clocksource/timer-ti-32k.c +++ b/drivers/clocksource/timer-ti-32k.c @@ -41,6 +41,7 @@ #include #include #include +#include /* * 32KHz clocksource ... always available, on pretty most chips except @@ -120,6 +121,9 @@ static int __init ti_32k_timer_init(struct device_node *np) } sched_clock_register(omap_32k_read_sched_clock, 32, 32768); + persistent_clock_init_and_register(omap_32k_read_sched_clock, + CLOCKSOURCE_MASK(32), 32768, 0); + pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n"); return 0; From patchwork Wed Jun 13 11:32:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138436 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp597829lji; Wed, 13 Jun 2018 04:33:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL7K3UL5eLIX3kKEpjvx0E2pNTLZNunpX6NdL/pGqMYFxI85ajwt6nKWeP61Yioe/xX1RtI X-Received: by 2002:a65:5844:: with SMTP id s4-v6mr3825306pgr.417.1528889634741; Wed, 13 Jun 2018 04:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889634; cv=none; d=google.com; s=arc-20160816; b=yj2kQitQ18Bau2xcVormvj2sDFPRRsXreC4Ae1TgN7yMvf0VoEydcxqduoEF1dNEiw n4vYWO2k6Sb5nsqT6v8S+zWz08FhAiSn8bTV24eN+apQBkTFitikCGCESsPgo5/tHoIR blcJcTAWtJWFscRpiymDDEBPwShHNSDDrgf3jQDBdmp8oe4DTgu5nFcXL+DuHf5vSUDL YhuJeNHAT+hGWoIk/UgBSxSGHNKh35ntZ/U1JB9KlXwkp+6ZVtuMSEuDe3vepQQr6ENh pWMRhj+rT6oN79/iICfCV3rSLA3RtB+M3K/A6CBRbMn2/2IfSDlu4h+wqhj4rYU0HYfP hzlQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2jKomMyu3aPBvQwHnJ5xi/PxkWHSmOUr0jIrlPwlqUo=; b=uRIE+SafIWp6kGBsPurbsjjToon2viSi+pjhWwFmvAG4nzQAdoxJBTDOHt9r8N38OF ZNAi6+2KBqkYOiVT1Uh29Yi3HSZH1CjqUXqBwewgIh5VpRe7lT3on+3kC8UNafQ0evhH oGWj4KJChdKJIdtsGTfKek3FSZFM4JG1q8Z72rRwUhAFRCZdO7cKzkDb3n8WJNwXk2Re hjEKyQ6pOWnkOda2OJ4e0VaYLHuL/WJ5L0HdTcEm/4GwLBoNGY2iq6cF0If0OOkymcVl /V85Vp3rvIVw8IUzpDawXXxI41tERDzuNuTJu8NQO0jNZkoYsmJ/cbppNtVVcgYrCXtY SCRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHjcCH44; 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 y124-v6si2148447pgb.61.2018.06.13.04.33.54; Wed, 13 Jun 2018 04:33:54 -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=DHjcCH44; 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 S935491AbeFMLdx (ORCPT + 30 others); Wed, 13 Jun 2018 07:33:53 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33936 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935459AbeFMLdu (ORCPT ); Wed, 13 Jun 2018 07:33:50 -0400 Received: by mail-pg0-f66.google.com with SMTP id q4-v6so1152903pgr.1 for ; Wed, 13 Jun 2018 04:33:49 -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 :in-reply-to:references; bh=2jKomMyu3aPBvQwHnJ5xi/PxkWHSmOUr0jIrlPwlqUo=; b=DHjcCH44PAE//jlj19ah6Lf6VjIsxwDZljyjvo8mQDpaISZEmORUdgHGSx4ht3wvIo pNE8+itgpZQ4tEBXVSCgOJGMq8RAxczNzXxO4kOtXjs0s0uoyPuMMkwm2LD6nr6tiWdT 1b9HW6mWoxEHvbOSLIhKIRT/00Lf48AZgpap0= 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:in-reply-to:references; bh=2jKomMyu3aPBvQwHnJ5xi/PxkWHSmOUr0jIrlPwlqUo=; b=bhwHpXf9j11tDi0ZwO1VTKW5XVthSmjAvJDc+XMvq4QsEvcRDP9/YoL6qD3qiG1FZ/ zqNEDRRshv4CGjvUS9GWECHao1fLaDwHUqx5rj194cMjxM5bCl7iengk8hBTZayidGYa sDLqkjvxRdHWAO/H1uHV9Kw8OxxyOeELFd1IXVv7gCxCCLsryfed5RlI/pUtLkdfc9dR CzQjl0Vbm4RyqyXKvFntJWbol6BOH5wxN9oFZzJi6l0mOmQw/OE9ZKsQr0yJt9rU7h4m 6eIsg6cY5H62Ttc60rfrN0zWPbXFyOx34hZlfQI+r38DYTXxA1ClaqugXNO8bFlJuokO FuGg== X-Gm-Message-State: APt69E1AjDoq8usrrjZsyat9U/eRkFOHIiNK/xWAtVfB5YV86zzhDi4o gHJiUVWGY6ihAJqOvTgxS+DZhQ== X-Received: by 2002:a63:7707:: with SMTP id s7-v6mr3862017pgc.426.1528889629540; Wed, 13 Jun 2018 04:33:49 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.33.41 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:33:49 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 6/8] clocksource: time-pistachio: Register the persistent clock Date: Wed, 13 Jun 2018 19:32:33 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the timer on pistachio platform is always available, we can register it as one persistent clock to compensate the suspend time for the OS time. Signed-off-by: Baolin Wang --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/time-pistachio.c | 3 +++ 2 files changed, 4 insertions(+) -- 1.7.9.5 diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 3cd136f..af552ba 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -255,6 +255,7 @@ config CLKSRC_PISTACHIO bool "Clocksource for Pistachio SoC" if COMPILE_TEST depends on HAS_IOMEM select TIMER_OF + select PERSISTENT_CLOCK help Enables the clocksource for the Pistachio SoC. diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c index a2dd85d..5c3eb71 100644 --- a/drivers/clocksource/time-pistachio.c +++ b/drivers/clocksource/time-pistachio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -212,6 +213,8 @@ static int __init pistachio_clksrc_of_init(struct device_node *node) raw_spin_lock_init(&pcs_gpt.lock); sched_clock_register(pistachio_read_sched_clock, 32, rate); + persistent_clock_init_and_register(pistachio_read_sched_clock, + CLOCKSOURCE_MASK(32), rate, 0); return clocksource_register_hz(&pcs_gpt.cs, rate); } TIMER_OF_DECLARE(pistachio_gptimer, "img,pistachio-gptimer", From patchwork Wed Jun 13 11:32:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 138438 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp598188lji; Wed, 13 Jun 2018 04:34:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI8AMmBkcKnjHGNPP4u5H2Tuonl2CzLQRuEyh4AExOHY/d2N5C9CvzUuoRwBCXnB8/6u4Ud X-Received: by 2002:a65:6343:: with SMTP id p3-v6mr3818025pgv.63.1528889655487; Wed, 13 Jun 2018 04:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528889655; cv=none; d=google.com; s=arc-20160816; b=sRTWyLLbPUSlTmzdOuwWsezJ+Bvx+2r0RQ3esRQrZvSCI7hECHFnrFER4qtvpcnIXf O5ABVU+tghAX6foGoaB/D6o5IrbLWoPl2sdorVU93YSMdaiXsCZ5UzDprQ+GWrpJlspt F783fiUvSPKX3db1asNBjyV+VwojV/tnaiBAv4pstxt0zdQKddboSboVMARkkajxIkDx eC1WVHigJjJ+VWyML4LV0nh80i6btNYp0PGmY1yJfrXXjPFGU6EGK7o3GHul8AAY5js2 vN2nDXfpb8aKXYwZPEZ9gOx/Mc8DCkmIdaCAALgu4nhcw4PNtzn3jghC6bstA9QhEOqx GcIw== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=96RSIq0UKsniTsrwhV4W30c30m0HqKjh/VL2LbphPg0=; b=bZu3FeXIOrZeWlZX2WIiWtbNNBKF1j0vmK3w+u/RbsbJMxIRU7McJlCwgz0TFxqP9+ 4AkBTD2DNtGBEGhnKkP0lGGWwm8BgQ/OcwoGhHzu+rRnBFQ/hsH4tiXwBeLZ1mSPvkpD uCJTbn1SuzukTP8uy/XeZlELxz0kzPYNhfqnganO2R5Leejn1GquFkDZQVyNKQoac0HY tbyyAyrNwT6auoaTKTdvMsgShy+rhyXdnwQ79wCt8HyTBEUzXsVbM1jafCfVgnqsIeuj z3Apu2Iud+sOKqsgdiX8nErNtepK0amqzbnibvZ3Luotgn8wgF+7Y+C41L3zOctlPIeb ep+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VxFoDyXw; 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 r5-v6si2204814pgr.491.2018.06.13.04.34.15; Wed, 13 Jun 2018 04:34:15 -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=VxFoDyXw; 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 S935529AbeFMLeO (ORCPT + 30 others); Wed, 13 Jun 2018 07:34:14 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:45802 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935498AbeFMLeH (ORCPT ); Wed, 13 Jun 2018 07:34:07 -0400 Received: by mail-pf0-f194.google.com with SMTP id a22-v6so1261740pfo.12 for ; Wed, 13 Jun 2018 04:34:07 -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 :in-reply-to:references; bh=96RSIq0UKsniTsrwhV4W30c30m0HqKjh/VL2LbphPg0=; b=VxFoDyXwmJHA73Z0m3RSWXMUpyPaomU7g5p4cpz7wjL8jLFhq/BrQ2LQwkWKDv5Zl/ 6Y8dmiGd2X3kecr9oyEoDg7C2HSSjy/aEHncpDh5YkQKqz7nH7hr0yOIx46tTVb+ud60 VQaf6bqw/QEaQsOvbeGbEQDh9KnJ5WtHLeITk= 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:in-reply-to:references; bh=96RSIq0UKsniTsrwhV4W30c30m0HqKjh/VL2LbphPg0=; b=TYTxz3kg4wmN3g7AfMUEz37P9NGqI5a5U6qE1wEabdF+JWS4JKd0wm4dmkDQQzRy2R t+4qD0z99gJqruz+cxM/qj3OFEjDWePq/hNKkIz7dY53QR5cc6zP4xxvPjyVQZmPxKH2 7BeNlx//n6/ZFZ86awt+oW9pFZqSgbJUhM39mtY4gy/X2uVdwZPezyhunAbYLWQS0NDU hzBuZ2E4ii7CiTDcCYZW6GId/3TU9D9rXjor7YjpcKZC2kgXy3w59tbJ1kq02SkNlI63 FU5i4sdNCTpGSyvWGTImoinNExurwWfDIzVuwml+BRF5vQpErU/6Blt06Es2etOa0SXY Ax2w== X-Gm-Message-State: APt69E2/abtH9SxJr2aLEUccCAgLs2u/TJaHhgDyfLSlCiFLk+r2HvLU LcWrDsCk4gIrYi5Q6dCQHA7Zsw== X-Received: by 2002:a62:86c3:: with SMTP id x186-v6mr4587177pfd.4.1528889646727; Wed, 13 Jun 2018 04:34:06 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id h8-v6sm2745370pgq.35.2018.06.13.04.33.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jun 2018 04:34:06 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de, john.stultz@linaro.org, daniel.lezcano@linaro.org, arnd@arndb.de, tony@atomide.com, aaro.koskinen@iki.fi, linux@armlinux.org.uk, mark.rutland@arm.com, marc.zyngier@arm.com Cc: baolin.wang@linaro.org, broonie@kernel.org, paulmck@linux.vnet.ibm.com, mlichvar@redhat.com, rdunlap@infradead.org, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, thierry.reding@gmail.com, jonathanh@nvidia.com, heiko@sntech.de, linus.walleij@linaro.org, viresh.kumar@linaro.org, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, douly.fnst@cn.fujitsu.com, len.brown@intel.com, rajvi.jingar@intel.com, alexandre.belloni@bootlin.com, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 8/8] time: timekeeping: Remove time compensating from nonstop clocksources Date: Wed, 13 Jun 2018 19:32:35 +0800 Message-Id: <7901216d145d942553641c74f5ee6241acf18976.1528878545.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we have converted all nonstop clocksources to use persistent clock, thus we can simplify the time compensating by removing the nonstop clocksources. Now we can compensate the suspend time for the OS time from the persistent clock or rtc device. Signed-off-by: Baolin Wang --- kernel/time/timekeeping.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) -- 1.7.9.5 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4786df9..3026d98 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1666,7 +1666,6 @@ void timekeeping_inject_sleeptime64(struct timespec64 *delta) void timekeeping_resume(void) { struct timekeeper *tk = &tk_core.timekeeper; - struct clocksource *clock = tk->tkr_mono.clock; unsigned long flags; struct timespec64 ts_new, ts_delta; u64 cycle_now; @@ -1682,27 +1681,17 @@ void timekeeping_resume(void) /* * After system resumes, we need to calculate the suspended time and - * compensate it for the OS time. There are 3 sources that could be - * used: Nonstop clocksource during suspend, persistent clock and rtc - * device. + * compensate it for the OS time. There are 2 sources that could be + * used: persistent clock and rtc device. * * One specific platform may have 1 or 2 or all of them, and the * preference will be: - * suspend-nonstop clocksource -> persistent clock -> rtc + * persistent clock -> rtc * The less preferred source will only be tried if there is no better * usable source. The rtc part is handled separately in rtc core code. */ cycle_now = tk_clock_read(&tk->tkr_mono); - if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) && - cycle_now > tk->tkr_mono.cycle_last) { - u64 nsec, cyc_delta; - - cyc_delta = clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, - tk->tkr_mono.mask); - nsec = mul_u64_u32_shr(cyc_delta, clock->mult, clock->shift); - ts_delta = ns_to_timespec64(nsec); - sleeptime_injected = true; - } else if (timespec64_compare(&ts_new, &timekeeping_suspend_time) > 0) { + if (timespec64_compare(&ts_new, &timekeeping_suspend_time) > 0) { ts_delta = timespec64_sub(ts_new, timekeeping_suspend_time); sleeptime_injected = true; }