From patchwork Thu Mar 16 06:20:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sourab.gupta@intel.com X-Patchwork-Id: 9627281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EAB2604A9 for ; Thu, 16 Mar 2017 06:18:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EAAB28543 for ; Thu, 16 Mar 2017 06:18:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53943285EF; Thu, 16 Mar 2017 06:18:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB81F28543 for ; Thu, 16 Mar 2017 06:18:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 342736E9F7; Thu, 16 Mar 2017 06:18:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8FF96E9F2 for ; Thu, 16 Mar 2017 06:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489645091; x=1521181091; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=gxfjaWfXmVDkG0ynqx7hk/ASCgXNskjUmGyA3mw6wRA=; b=RtZCElF+EsIl+uFMOc1OTCzpeQSRUl3JmJGFnNoYOvCimDp5rVQU1wh1 pNSHdsHownnDzikVUfc7Pq0DptdygQ==; Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 23:18:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="75987546" Received: from sourab-desktop.iind.intel.com ([10.223.82.140]) by orsmga005.jf.intel.com with ESMTP; 15 Mar 2017 23:18:09 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 16 Mar 2017 11:50:09 +0530 Message-Id: <1489645211-25729-5-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489645211-25729-1-git-send-email-sourab.gupta@intel.com> References: <1489645211-25729-1-git-send-email-sourab.gupta@intel.com> Cc: "Christopher S . Hall" , Daniel Vetter , Sourab Gupta , John Stultz , Matthew Auld , Thomas Gleixner Subject: [Intel-gfx] [PATCH 4/6] time: Expose current clocksource in use by timekeeping framework X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Sourab Gupta For the drivers to be able to use the cross timestamp framework, they need the information of current clocksource being used by the kernel timekeeping. This is needed since the callback given by driver into the get_device_system_crosststamp(), in order to synchronously read the device time and system counter value, requires the knowledge of the clocksource being used to read system counter value (as a part of struct system_counterval_t). Cc: John Stultz Cc: Thomas Gleixner Signed-off-by: Sourab Gupta --- include/linux/timekeeping.h | 5 +++++ kernel/time/timekeeping.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index d2e804e..d62bb0e 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -337,6 +337,11 @@ extern int get_device_system_crosststamp( struct system_device_crosststamp *xtstamp); /* + * Get current clocksource used by system timekeeping framework + */ +struct clocksource *get_current_clocksource(void); + +/* * Simultaneously snapshot realtime and monotonic raw clocks */ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 95b258d..bd85d14 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1167,6 +1167,18 @@ int get_device_system_crosststamp(int (*get_time_fn) EXPORT_SYMBOL_GPL(get_device_system_crosststamp); /** + * get_current_clocksource - Returns the current clocksource in used by tk_core + * + */ +struct clocksource *get_current_clocksource(void) +{ + struct timekeeper *tk = &tk_core.timekeeper; + + return tk->tkr_mono.clock; +} +EXPORT_SYMBOL_GPL(get_current_clocksource); + +/** * do_gettimeofday - Returns the time of day in a timeval * @tv: pointer to the timeval to be set *