From patchwork Thu Sep 7 10:06:02 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: 9941961 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 9B5D1602CC for ; Thu, 7 Sep 2017 10:02:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACB9F28606 for ; Thu, 7 Sep 2017 10:02:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1BA528608; Thu, 7 Sep 2017 10:02:59 +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 F0F3D28607 for ; Thu, 7 Sep 2017 10:02:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 365EC6E8C5; Thu, 7 Sep 2017 10:02:58 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 355046E8C5 for ; Thu, 7 Sep 2017 10:02:57 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2017 03:02:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,357,1500966000"; d="scan'208";a="126439685" Received: from sakamble-desktop.iind.intel.com ([10.223.26.118]) by orsmga004.jf.intel.com with ESMTP; 07 Sep 2017 03:02:55 -0700 From: Sagar Arun Kamble To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Sep 2017 15:36:02 +0530 Message-Id: <1504778774-18117-3-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1504778774-18117-1-git-send-email-sagar.a.kamble@intel.com> References: <1504778774-18117-1-git-send-email-sagar.a.kamble@intel.com> Cc: Sourab Gupta Subject: [Intel-gfx] [PATCH 02/14] 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-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. Currently, the OA samples are being generated only periodically, and hence there's only source flag enum definition right now, but there are other means of generating OA samples, such as via MI_RPC commands. The OA_SOURCE sample type is introducing a mechanism (for userspace) to distinguish various OA reports generated via different sources. This is not intended as a replacement for the reason field that's part of Gen8+ OA reports. For automatically triggered reports written to the OABUFFER the reason field will distinguish e.g. periodic vs ctx-switch vs GO transition reasons for the OA unit writing a report. However, The reason field is overloaded as the RPT_ID field for MI_RPC reports so we need our own way of tracking the difference. v2: Renamed the source enum type and values. Updated commit description. (Robert). Changed payload field source to u64 to keep all sample data aligned at 8 bytes. (Lionel) Testcase: igt/intel_perf_dapc/oa-source Signed-off-by: Sourab Gupta Signed-off-by: Robert Bragg Signed-off-by: Sagar Arun Kamble --- drivers/gpu/drm/i915/i915_perf.c | 25 +++++++++++++++++++++++++ include/uapi/drm/i915_drm.h | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 94185d6..0133e09 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -330,6 +330,7 @@ }; #define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_SOURCE (1<<1) /** * struct perf_open_properties - for validated properties given to open a stream @@ -608,6 +609,22 @@ static int append_oa_sample(struct i915_perf_stream *stream, return -EFAULT; buf += sizeof(header); + /* + * Sample has metadata containting OA_SOURCE followed by OA_REPORT. + * Need to maintain this uapi w.r.t any reorganizing later not realizing + * the ordering. + * Currently there are a number of different automatic triggers for + * writing OA reports to the OABUFFER like periodic, ctx-switch, go + * transition. These are considered as source 'OABUFFER'. + */ + if (sample_flags & SAMPLE_OA_SOURCE) { + u64 source = I915_PERF_SAMPLE_OA_SOURCE_OABUFFER; + + if (copy_to_user(buf, &source, 8)) + return -EFAULT; + buf += 8; + } + if (sample_flags & SAMPLE_OA_REPORT) { if (copy_to_user(buf, report, report_size)) return -EFAULT; @@ -2087,6 +2104,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_OA_SOURCE) { + stream->sample_flags |= SAMPLE_OA_SOURCE; + stream->sample_size += 8; + } + dev_priv->perf.oa.oa_buffer.format_size = format_size; if (WARN_ON(dev_priv->perf.oa.oa_buffer.format_size == 0)) return -EINVAL; @@ -2805,6 +2827,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; + break; case DRM_I915_PERF_PROP_MAX: MISSING_CASE(id); return -EINVAL; diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 92acfc2..8ff5631 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -1379,6 +1379,11 @@ enum drm_i915_oa_format { I915_OA_FORMAT_MAX /* non-ABI */ }; +enum drm_i915_perf_sample_oa_source { + I915_PERF_SAMPLE_OA_SOURCE_OABUFFER, + I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ +}; + enum drm_i915_perf_property_id { /** * Open the stream for a specific context handle (as used with @@ -1413,6 +1418,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 */ }; @@ -1478,6 +1490,7 @@ enum drm_i915_perf_record_type { * struct { * struct drm_i915_perf_record_header header; * + * { u64 source; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */