From patchwork Wed Nov 15 12:13:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 10059279 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 D94DD6019D for ; Wed, 15 Nov 2017 12:10:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D10A929F2C for ; Wed, 15 Nov 2017 12:10:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5EF929F31; Wed, 15 Nov 2017 12:10:31 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 8078429F2C for ; Wed, 15 Nov 2017 12:10:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 131026E4EC; Wed, 15 Nov 2017 12:10:31 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5381D6E4D7 for ; Wed, 15 Nov 2017 12:10:28 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2017 04:10:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,399,1505804400"; d="scan'208";a="149720765" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by orsmga004.jf.intel.com with ESMTP; 15 Nov 2017 04:10:26 -0800 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 15 Nov 2017 17:43:53 +0530 Message-Id: <1510748034-14034-4-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1510748034-14034-1-git-send-email-sagar.a.kamble@intel.com> References: <1510748034-14034-1-git-send-email-sagar.a.kamble@intel.com> Cc: Sourab Gupta , Matthew Auld Subject: [Intel-gfx] [RFC 3/4] drm/i915/perf: Extract raw GPU timestamps from OA reports 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 The OA reports contain the least significant 32 bits of the gpu timestamp. This patch enables retrieval of the timestamp field from OA reports, to forward as 64 bit raw gpu timestamps in the perf samples. v2: Rebase w.r.t new timecounter support. Signed-off-by: Sourab Gupta Signed-off-by: Sagar Arun Kamble Cc: Lionel Landwerlin Cc: Chris Wilson Cc: Sourab Gupta Cc: Matthew Auld --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_perf.c | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index e08bc85..5534cd2 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2151,6 +2151,8 @@ struct i915_perf_stream { */ struct i915_oa_config *oa_config; + u64 last_gpu_ts; + /** * System time correlation variables. */ diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index f7e748c..3b721d7 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -575,6 +575,26 @@ static int append_oa_status(struct i915_perf_stream *stream, } /** + * get_gpu_ts_from_oa_report - Retrieve absolute gpu timestamp from OA report + * + * Note: We are assuming that we're updating last_gpu_ts frequently enough so + * that it's never possible to see multiple overflows before we compare + * sample_ts to last_gpu_ts. Since this is significantly large duration + * (~6min for 80ns ts base), we can safely assume so. + */ +static u64 get_gpu_ts_from_oa_report(struct i915_perf_stream *stream, + const u8 *report) +{ + u32 sample_ts = *(u32 *)(report + 4); + u32 delta; + + delta = sample_ts - (u32)stream->last_gpu_ts; + stream->last_gpu_ts += delta; + + return stream->last_gpu_ts; +} + +/** * append_oa_sample - Copies single OA report into userspace read() buffer. * @stream: An i915-perf stream opened for OA metrics * @buf: destination buffer given by userspace @@ -622,7 +642,9 @@ static int append_oa_sample(struct i915_perf_stream *stream, } if (sample_flags & SAMPLE_GPU_TS) { - /* Timestamp to be populated from OA report */ + /* Timestamp populated from OA report */ + gpu_ts = get_gpu_ts_from_oa_report(stream, report); + if (copy_to_user(buf, &gpu_ts, I915_PERF_TS_SAMPLE_SIZE)) return -EFAULT; } @@ -2421,6 +2443,8 @@ static u64 i915_cyclecounter_read(const struct cyclecounter *cc) GEN7_TIMESTAMP_UDW); intel_runtime_pm_put(dev_priv); + stream->last_gpu_ts = ts_count; + return ts_count; }