From patchwork Wed Nov 15 12:13:52 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: 10059273 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 A1B356056E for ; Wed, 15 Nov 2017 12:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B10029F31 for ; Wed, 15 Nov 2017 12:10:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 900C329F33; Wed, 15 Nov 2017 12:10:29 +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 2F81829F30 for ; Wed, 15 Nov 2017 12:10:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60BA16E4E3; Wed, 15 Nov 2017 12:10:28 +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 04E1F6E4B8 for ; Wed, 15 Nov 2017 12:10:25 +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:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,399,1505804400"; d="scan'208";a="149720753" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by orsmga004.jf.intel.com with ESMTP; 15 Nov 2017 04:10:23 -0800 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Wed, 15 Nov 2017 17:43:52 +0530 Message-Id: <1510748034-14034-3-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 2/4] drm/i915/perf: Add support for collecting 64 bit timestamps with 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 With this patch, for RCS, timestamps and OA reports can be collected together, and provided to userspace in separate sample fields. Next patch adds changes to derive timestamp from OA report. v2: Rebase. Limiting the changes to only OA sample read. Updated sample flag name. 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_perf.c | 20 +++++++++++++++++++- include/uapi/drm/i915_drm.h | 7 +++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 72ddc34..f7e748c 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -293,6 +293,7 @@ #define OAREPORT_REASON_CTX_SWITCH (1<<3) #define OAREPORT_REASON_CLK_RATIO (1<<5) +#define I915_PERF_TS_SAMPLE_SIZE 8 /* For sysctl proc_dointvec_minmax of i915_oa_max_sample_rate * @@ -333,7 +334,8 @@ [I915_OA_FORMAT_C4_B8] = { 7, 64 }, }; -#define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_REPORT BIT(0) +#define SAMPLE_GPU_TS BIT(1) /** * struct perf_open_properties - for validated properties given to open a stream @@ -599,6 +601,7 @@ static int append_oa_sample(struct i915_perf_stream *stream, int report_size = dev_priv->perf.oa.oa_buffer.format_size; struct drm_i915_perf_record_header header; u32 sample_flags = stream->sample_flags; + u64 gpu_ts = 0; header.type = DRM_I915_PERF_RECORD_SAMPLE; header.pad = 0; @@ -615,6 +618,13 @@ static int append_oa_sample(struct i915_perf_stream *stream, if (sample_flags & SAMPLE_OA_REPORT) { if (copy_to_user(buf, report, report_size)) return -EFAULT; + buf += report_size; + } + + if (sample_flags & SAMPLE_GPU_TS) { + /* Timestamp to be populated from OA report */ + if (copy_to_user(buf, &gpu_ts, I915_PERF_TS_SAMPLE_SIZE)) + return -EFAULT; } (*offset) += header.size; @@ -2100,6 +2110,11 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, stream->sample_flags |= SAMPLE_OA_REPORT; stream->sample_size += format_size; + if (props->sample_flags & SAMPLE_GPU_TS) { + stream->sample_flags |= SAMPLE_GPU_TS; + stream->sample_size += I915_PERF_TS_SAMPLE_SIZE; + } + dev_priv->perf.oa.oa_buffer.format_size = format_size; if (WARN_ON(dev_priv->perf.oa.oa_buffer.format_size == 0)) return -EINVAL; @@ -2815,6 +2830,9 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, case DRM_I915_PERF_PROP_SAMPLE_OA: props->sample_flags |= SAMPLE_OA_REPORT; break; + case DRM_I915_PERF_PROP_SAMPLE_GPU_TS: + props->sample_flags |= SAMPLE_GPU_TS; + break; case DRM_I915_PERF_PROP_OA_METRICS_SET: if (value == 0) { DRM_DEBUG("Unknown OA metric set ID\n"); diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index b579859..0b9249e 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -1447,6 +1447,12 @@ enum drm_i915_perf_property_id { DRM_I915_PERF_PROP_SAMPLE_OA, /** + * The value of this property set to 1 requests inclusion of GPU + * timestamp in the perf sample data. + */ + DRM_I915_PERF_PROP_SAMPLE_GPU_TS, + + /** * The value specifies which set of OA unit metrics should be * be configured, defining the contents of any OA unit reports. */ @@ -1532,6 +1538,7 @@ enum drm_i915_perf_record_type { * struct drm_i915_perf_record_header header; * * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA + * { u64 gpu_timestamp; } && DRM_I915_PERF_PROP_SAMPLE_GPU_TS * }; */ DRM_I915_PERF_RECORD_SAMPLE = 1,