From patchwork Thu Mar 16 06:14:13 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: 9627247 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 93084604A9 for ; Thu, 16 Mar 2017 06:12:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 821A22843D for ; Thu, 16 Mar 2017 06:12:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75C4D285EF; Thu, 16 Mar 2017 06:12:47 +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 1D8A42843D for ; Thu, 16 Mar 2017 06:12:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56F826E9FD; Thu, 16 Mar 2017 06:12:46 +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 E5FF56E9F6 for ; Thu, 16 Mar 2017 06:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489644762; x=1521180762; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=vTtpE837PDugmvlWN65murYVnvw2f+yEnv8djgu0i0A=; b=shhzcZPKQi6Q8msSBSKvREwRWc+jpaT/GB66Br6qAS/TUgKbTEF51AA6 ecOJBTOwJiABEGZ85ma7PTXvtP/e5Q==; 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:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,170,1486454400"; d="scan'208";a="944881983" Received: from sourab-desktop.iind.intel.com ([10.223.82.140]) by orsmga003.jf.intel.com with ESMTP; 15 Mar 2017 23:12:40 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 16 Mar 2017 11:44:13 +0530 Message-Id: <1489644855-25562-7-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 6/8] drm/i915: Populate ctx ID for periodic 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 This adds support for populating the ctx id for the periodic OA reports when requested through the corresponding property. For Gen8, the OA reports itself have the ctx ID and it is the one programmed into HW while submitting workloads. Thus it's retrieved from reports itself. For Gen7, the OA reports don't have any such field, and we can populate this field with the last seen ctx ID while sending CS reports. Signed-off-by: Sourab Gupta --- drivers/gpu/drm/i915/i915_drv.h | 7 ++++++ drivers/gpu/drm/i915/i915_perf.c | 53 +++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0f2a552..7a6dcb3 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2129,6 +2129,12 @@ struct i915_oa_ops { */ u32 (*oa_buffer_num_reports)(struct drm_i915_private *dev_priv, u32 *last_ts); + + /** + * @get_ctx_id: Retrieve the ctx_id associated with the (periodic) OA + * report. + */ + u32 (*get_ctx_id)(struct i915_perf_stream *stream, const u8 *report); }; /* @@ -2613,6 +2619,7 @@ struct drm_i915_private { u32 status; } command_stream_buf; + u32 last_cmd_stream_ctx_id; struct list_head cs_samples; spinlock_t sample_lock; } perf; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 2841d0a..208179f 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -850,6 +850,46 @@ static u32 gen7_oa_buffer_num_reports_unlocked( return aged_tail == INVALID_TAIL_PTR ? 0 : num_reports; } +static u32 gen7_oa_buffer_get_ctx_id(struct i915_perf_stream *stream, + const u8 *report) +{ + struct drm_i915_private *dev_priv = stream->dev_priv; + + if (!stream->cs_mode) + WARN_ONCE(1, + "CTX ID can't be retrieved if command stream mode not enabled"); + + /* + * OA reports generated in Gen7 don't have the ctx ID information. + * Therefore, just rely on the ctx ID information from the last CS + * sample forwarded + */ + return dev_priv->perf.last_cmd_stream_ctx_id; +} + +static u32 gen8_oa_buffer_get_ctx_id(struct i915_perf_stream *stream, + const u8 *report) +{ + struct drm_i915_private *dev_priv = stream->dev_priv; + + /* The ctx ID present in the OA reports have intel_context::hw_id + * present, since this is programmed into the ELSP in execlist mode. + * In non-execlist mode, fall back to retrieving the ctx ID from the + * last saved ctx ID from command stream mode. + */ + if (i915.enable_execlists) { + u32 *report32 = (void *)report; + u32 ctx_id = report32[2] & 0x1fffff; + return ctx_id; + } else { + if (!stream->cs_mode) + WARN_ONCE(1, + "CTX ID can't be retrieved if command stream mode not enabled"); + + return dev_priv->perf.last_cmd_stream_ctx_id; + } +} + /** * append_oa_status - Appends a status record to a userspace read() buffer. * @stream: An i915-perf stream opened for OA metrics @@ -963,18 +1003,15 @@ static int append_oa_buffer_sample(struct i915_perf_stream *stream, char __user *buf, size_t count, size_t *offset, const u8 *report) { + struct drm_i915_private *dev_priv = stream->dev_priv; u32 sample_flags = stream->sample_flags; struct oa_sample_data data = { 0 }; if (sample_flags & SAMPLE_OA_SOURCE_INFO) data.source = I915_PERF_OA_EVENT_SOURCE_PERIODIC; - /* - * FIXME: append_oa_buffer_sample: read ctx ID from report and map - * that to a intel_context::hw_id" - */ if (sample_flags & SAMPLE_CTX_ID) - data.ctx_id = 0; + data.ctx_id = dev_priv->perf.oa.ops.get_ctx_id(stream, report); if (sample_flags & SAMPLE_OA_REPORT) data.report = report; @@ -1547,8 +1584,10 @@ static int append_oa_rcs_sample(struct i915_perf_stream *stream, if (sample_flags & SAMPLE_OA_SOURCE_INFO) data.source = I915_PERF_OA_EVENT_SOURCE_RCS; - if (sample_flags & SAMPLE_CTX_ID) + if (sample_flags & SAMPLE_CTX_ID) { data.ctx_id = node->ctx_id; + dev_priv->perf.last_cmd_stream_ctx_id = node->ctx_id; + } if (sample_flags & SAMPLE_OA_REPORT) data.report = report; @@ -3794,6 +3833,7 @@ void i915_perf_init(struct drm_i915_private *dev_priv) dev_priv->perf.oa.ops.read = gen7_oa_read; dev_priv->perf.oa.ops.oa_buffer_num_reports = gen7_oa_buffer_num_reports_unlocked; + dev_priv->perf.oa.ops.get_ctx_id = gen7_oa_buffer_get_ctx_id; dev_priv->perf.oa.oa_formats = hsw_oa_formats; @@ -3859,6 +3899,7 @@ void i915_perf_init(struct drm_i915_private *dev_priv) dev_priv->perf.oa.ops.read = gen8_oa_read; dev_priv->perf.oa.ops.oa_buffer_num_reports = gen8_oa_buffer_num_reports_unlocked; + dev_priv->perf.oa.ops.get_ctx_id = gen8_oa_buffer_get_ctx_id; dev_priv->perf.oa.oa_formats = gen8_plus_oa_formats; }