lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1513323522-15021-17-git-send-email-sagar.a.kamble@intel.com>
Date:   Fri, 15 Dec 2017 13:08:31 +0530
From:   Sagar Arun Kamble <sagar.a.kamble@...el.com>
To:     linux-kernel@...r.kernel.org
Cc:     Sagar Arun Kamble <sagar.a.kamble@...el.com>,
        Richard Cochran <richardcochran@...il.com>,
        Chris Wilson <chris@...is-wilson.co.uk>,
        John Stultz <john.stultz@...aro.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Stephen Boyd <sboyd@...eaurora.org>
Subject: [PATCH 16/27] timecounter: Introduce timecounter_reset

timecounter_init initializes the cyclecounter and sets the start time.
Sometimes drivers using timecounter just want to update start time.
This patch creates new function timecounter_reset that just resets the
timecounter start time and associated state.

Suggested-by: Richard Cochran <richardcochran@...il.com>
Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@...el.com>
Cc: Richard Cochran <richardcochran@...il.com>
Cc: Chris Wilson <chris@...is-wilson.co.uk>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Stephen Boyd <sboyd@...eaurora.org>
Cc: linux-kernel@...r.kernel.org
---
 include/linux/timecounter.h | 17 +++++++++++++++--
 kernel/time/timecounter.c   |  9 +++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/include/linux/timecounter.h b/include/linux/timecounter.h
index 59d3fd7..e0fd741 100644
--- a/include/linux/timecounter.h
+++ b/include/linux/timecounter.h
@@ -98,7 +98,7 @@ static inline void timecounter_adjtime(struct timecounter *tc, s64 delta)
 
 /**
  * timecounter_init - initialize a time counter
- * @tc:			Pointer to time counter which is to be initialized/reset
+ * @tc:			Pointer to time counter which is to be initialized
  * @start_tstamp:	Arbitrary initial time stamp.
  *
  * After this call the current cycle register (roughly) corresponds to
@@ -131,8 +131,21 @@ extern void timecounter_initialize(struct timecounter *tc,
 				   u64 start_tstamp);
 
 /**
+ * timecounter_reset - reset a time counter
+ * @tc:			Pointer to time counter which is to be reset
+ * @start_tstamp:	Arbitrary initial time stamp.
+ *
+ * After this call the current cycle register (roughly) corresponds to
+ * the supplied time stamp. Every call to timecounter_read() increments
+ * the time stamp counter by the number of elapsed nanoseconds.
+ */
+extern void timecounter_reset(struct timecounter *tc,
+			      u64 start_tstamp);
+
+/**
  * timecounter_read - return nanoseconds elapsed since timecounter_init() or
- *                    timecounter_initialize() plus the initial time stamp
+ *                    timecounter_initialize() or timecounter_reset() plus
+ *		      the initial time stamp
  * @tc:          Pointer to time counter.
  *
  * In other words, keeps track of time since the same epoch as
diff --git a/kernel/time/timecounter.c b/kernel/time/timecounter.c
index 6d915752..3f62fe0 100644
--- a/kernel/time/timecounter.c
+++ b/kernel/time/timecounter.c
@@ -47,6 +47,15 @@ void timecounter_initialize(struct timecounter *tc,
 }
 EXPORT_SYMBOL_GPL(timecounter_initialize);
 
+void timecounter_reset(struct timecounter *tc,
+		       u64 start_tstamp)
+{
+	tc->cycle_last = tc->cc.read(&tc->cc);
+	tc->nsec = start_tstamp;
+	tc->frac = 0;
+}
+EXPORT_SYMBOL_GPL(timecounter_reset);
+
 /**
  * timecounter_read_delta - get nanoseconds since last call of this function
  * @tc:         Pointer to time counter
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ