From patchwork Thu Mar 16 06:14: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: 9627229 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 DE6A6604A9 for ; Thu, 16 Mar 2017 06:12:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEBA72843D for ; Thu, 16 Mar 2017 06:12:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2AA9285EE; Thu, 16 Mar 2017 06:12:37 +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 7C5AF2863B for ; Thu, 16 Mar 2017 06:12:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23B026E9E9; Thu, 16 Mar 2017 06:12:36 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 864C06E9E9 for ; Thu, 16 Mar 2017 06:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489644753; x=1521180753; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=W4Bp8POxZwcq+Cd8LRnGaA6HsT1L4Aw3TD9MccvDwrg=; b=koPeQ3QarfTov+EZvQNIxk5ih/J9ZW2f4V7gTB8XYdCdesXZvUIU16yJ PeVZZm/f/xfrPY42mk3VIcdajTwTQw==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2017 23:12:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="944881864" Received: from sourab-desktop.iind.intel.com ([10.223.82.140]) by orsmga003.jf.intel.com with ESMTP; 15 Mar 2017 23:12:31 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 16 Mar 2017 11:44:09 +0530 Message-Id: <1489644855-25562-3-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489644855-25562-1-git-send-email-sourab.gupta@intel.com> References: <1489644855-25562-1-git-send-email-sourab.gupta@intel.com> Cc: Daniel Vetter , Sourab Gupta , Matthew Auld Subject: [Intel-gfx] [PATCH 2/8] 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. Signed-off-by: Sourab Gupta Signed-off-by: Robert Bragg --- drivers/gpu/drm/i915/i915_perf.c | 18 ++++++++++++++++++ include/uapi/drm/i915_drm.h | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 4b1db73..540c5b2 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -324,6 +324,7 @@ }; #define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_SOURCE_INFO (1<<1) /** * struct perf_open_properties - for validated properties given to open a stream @@ -659,6 +660,15 @@ 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 = + 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; @@ -2030,6 +2040,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_INFO) { + stream->sample_flags |= SAMPLE_OA_SOURCE_INFO; + stream->sample_size += 4; + } + dev_priv->perf.oa.oa_buffer.format_size = format_size; if (WARN_ON(dev_priv->perf.oa.oa_buffer.format_size == 0)) return -EINVAL; @@ -2814,6 +2829,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; default: MISSING_CASE(id); DRM_DEBUG("Unknown i915 perf property ID\n"); diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 835e711..c597e36 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -1312,6 +1312,12 @@ enum drm_i915_oa_format { I915_OA_FORMAT_MAX /* non-ABI */ }; +enum drm_i915_perf_oa_event_source { + I915_PERF_OA_EVENT_SOURCE_PERIODIC, + + 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 @@ -1346,6 +1352,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 */ }; @@ -1411,6 +1424,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 * }; */