From patchwork Fri Apr 22 11:33:54 2016 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: 8910961 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A5BF1BF4C7 for ; Fri, 22 Apr 2016 11:32:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67A4D20254 for ; Fri, 22 Apr 2016 11:32:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6742A20220 for ; Fri, 22 Apr 2016 11:32:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E60D6EEA0; Fri, 22 Apr 2016 11:32:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 50CC16E324 for ; Fri, 22 Apr 2016 11:32:30 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 22 Apr 2016 04:32:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,517,1455004800"; d="scan'208";a="690445817" Received: from sourab-desktop.iind.intel.com ([10.223.82.63]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2016 04:32:28 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 22 Apr 2016 17:03:54 +0530 Message-Id: <1461324845-25755-6-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461324845-25755-1-git-send-email-sourab.gupta@intel.com> References: <1461324845-25755-1-git-send-email-sourab.gupta@intel.com> Cc: Daniel Vetter , Sourab Gupta , Deepak S Subject: [Intel-gfx] [PATCH 05/16] drm/i915: Expose OA sample source to userspace 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-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sourab Gupta This patch exposes a new sample source field to userspace. This field can be populated to specify the origin of the OA report. For e.g. for internally triggerred reports (non MI_RPC reports), the RPT_ID field has bitfields for specifying the origin such as timer, or render ctx switch, etc. Likewise this field can be used to specify the source as MI_RPC when such support is added. Signed-off-by: Sourab Gupta Signed-off-by: Robert Bragg --- drivers/gpu/drm/i915/i915_perf.c | 55 ++++++++++++++++++++++++++++++++++------ include/uapi/drm/i915_drm.h | 16 ++++++++++++ 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 383a698..f86cd15 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -73,6 +73,13 @@ static u32 i915_perf_stream_paranoid = true; */ #define OA_EXPONENT_MAX 31 +#define GEN8_OAREPORT_REASON_TIMER (1<<19) +#define GEN8_OAREPORT_REASON_TRIGGER1 (1<<20) +#define GEN8_OAREPORT_REASON_TRIGGER2 (1<<21) +#define GEN8_OAREPORT_REASON_CTX_SWITCH (1<<22) +#define GEN8_OAREPORT_REASON_GO_TRANSITION (1<<23) +#define GEN9_OAREPORT_REASON_CLK_RATIO (1<<24) + /* for sysctl proc_dointvec_minmax of i915_oa_min_timer_exponent */ static int zero; static int oa_exponent_max = OA_EXPONENT_MAX; @@ -112,7 +119,8 @@ static struct i915_oa_format gen8_plus_oa_formats[I915_OA_FORMAT_MAX] = { [I915_OA_FORMAT_C4_B8] = { 7, 64 }, }; -#define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_SOURCE_INFO (1<<1) struct perf_open_properties { u32 sample_flags; @@ -214,6 +222,27 @@ static int append_oa_sample(struct i915_perf_stream *stream, return -EFAULT; buf += sizeof(header); + if (sample_flags & SAMPLE_OA_SOURCE_INFO) { + enum drm_i915_perf_oa_event_source source; + + if (INTEL_INFO(dev_priv)->gen >= 8) { + u32 reason = *(u32 *)report; + + if (reason & GEN8_OAREPORT_REASON_CTX_SWITCH) + source = + I915_PERF_OA_EVENT_SOURCE_CONTEXT_SWITCH; + else if (reason & GEN8_OAREPORT_REASON_TIMER) + source = I915_PERF_OA_EVENT_SOURCE_PERIODIC; + else + source = I915_PERF_OA_EVENT_SOURCE_UNDEFINED; + } else + source = I915_PERF_OA_EVENT_SOURCE_PERIODIC; + + if (copy_to_user(buf, &source, 4)) + return -EFAULT; + buf += 4; + } + if (sample_flags & SAMPLE_OA_REPORT) { if (copy_to_user(buf, report, report_size)) return -EFAULT; @@ -1130,11 +1159,6 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, int format_size; int ret; - if (!(props->sample_flags & SAMPLE_OA_REPORT)) { - DRM_ERROR("Only OA report sampling supported\n"); - return -EINVAL; - } - if (!dev_priv->perf.oa.ops.init_oa_buffer) { DRM_ERROR("OA unit not supported\n"); return -ENODEV; @@ -1163,8 +1187,20 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, format_size = dev_priv->perf.oa.oa_formats[props->oa_format].size; - stream->sample_flags |= SAMPLE_OA_REPORT; - stream->sample_size += format_size; + if (props->sample_flags & SAMPLE_OA_REPORT) { + stream->sample_flags |= SAMPLE_OA_REPORT; + stream->sample_size += format_size; + } + + if (props->sample_flags & SAMPLE_OA_SOURCE_INFO) { + if (!(props->sample_flags & SAMPLE_OA_REPORT)) { + DRM_ERROR( + "OA source type can't be sampled without OA report"); + return -EINVAL; + } + stream->sample_flags |= SAMPLE_OA_SOURCE_INFO; + stream->sample_size += 4; + } dev_priv->perf.oa.oa_buffer.format_size = format_size; BUG_ON(dev_priv->perf.oa.oa_buffer.format_size == 0); @@ -1817,6 +1853,9 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, props->oa_periodic = true; props->oa_period_exponent = value; break; + case DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE: + props->sample_flags |= SAMPLE_OA_SOURCE_INFO; + break; case DRM_I915_PERF_PROP_MAX: BUG(); } diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 7e24ec4..2139f73 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -1192,6 +1192,14 @@ enum drm_i915_oa_format { I915_OA_FORMAT_MAX /* non-ABI */ }; +enum drm_i915_perf_oa_event_source { + I915_PERF_OA_EVENT_SOURCE_UNDEFINED, + I915_PERF_OA_EVENT_SOURCE_PERIODIC, + I915_PERF_OA_EVENT_SOURCE_CONTEXT_SWITCH, + + I915_PERF_OA_EVENT_SOURCE_MAX /* non-ABI */ +}; + enum drm_i915_perf_property_id { /** * Open the stream for a specific context handle (as used with @@ -1226,6 +1234,13 @@ enum drm_i915_perf_property_id { */ DRM_I915_PERF_PROP_OA_EXPONENT, + /** + * The value of this property set to 1 requests inclusion of sample + * source field to be given to userspace. The sample source field + * specifies the origin of OA report. + */ + DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE, + DRM_I915_PERF_PROP_MAX /* non-ABI */ }; @@ -1290,6 +1305,7 @@ enum drm_i915_perf_record_type { * struct { * struct drm_i915_perf_record_header header; * + * { u32 source_info; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */