From patchwork Wed Jul 15 08:51:45 2015 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: 6794701 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 07F18C05AC for ; Wed, 15 Jul 2015 08:50:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1081220603 for ; Wed, 15 Jul 2015 08:50:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DB724205F4 for ; Wed, 15 Jul 2015 08:50:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4306C6EB1C; Wed, 15 Jul 2015 01:50:09 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 724006EB1A for ; Wed, 15 Jul 2015 01:50:08 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 15 Jul 2015 01:50:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,479,1432623600"; d="scan'208";a="762855848" Received: from sourabgu-desktop.iind.intel.com ([10.223.82.35]) by fmsmga002.fm.intel.com with ESMTP; 15 Jul 2015 01:50:05 -0700 From: sourab.gupta@intel.com To: intel-gfx@lists.freedesktop.org Date: Wed, 15 Jul 2015 14:21:45 +0530 Message-Id: <1436950306-14147-8-git-send-email-sourab.gupta@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1436950306-14147-1-git-send-email-sourab.gupta@intel.com> References: <1436950306-14147-1-git-send-email-sourab.gupta@intel.com> Cc: Insoo Woo , Peter Zijlstra , Jabin Wu , Sourab Gupta Subject: [Intel-gfx] [RFC 7/8] drm/i915: Add support for forwarding execbuffer tags in timestamp sample metadata 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.6 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 enables userspace to specify tags (per workload), provided via execbuffer ioctl, which could be added to timestamps samples, to help associate samples with the corresponding workloads. There may be multiple stages within a single context, from a userspace perspective. An ability is needed to individually associate the samples with their corresponding workloads(execbuffers), which may not be possible solely with ctx_id or pid information. This patch enables such this mechanism. Signed-off-by: Sourab Gupta --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_oa_perf.c | 16 ++++++++++++++++ include/uapi/drm/i915_drm.h | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index c23c5be..f2fe8d0 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1684,6 +1684,7 @@ struct i915_gen_pmu_node { u32 ctx_id; u32 ring; u32 pid; + u32 tag; }; extern const struct i915_oa_reg i915_oa_3d_mux_config_hsw[]; @@ -2015,6 +2016,7 @@ struct drm_i915_private { struct work_struct work_event_destroy; #define I915_GEN_PMU_SAMPLE_RING (1<<0) #define I915_GEN_PMU_SAMPLE_PID (1<<1) +#define I915_GEN_PMU_SAMPLE_TAG (1<<2) int sample_info_flags; } gen_pmu; diff --git a/drivers/gpu/drm/i915/i915_oa_perf.c b/drivers/gpu/drm/i915/i915_oa_perf.c index a195c37..1cc16ef 100644 --- a/drivers/gpu/drm/i915/i915_oa_perf.c +++ b/drivers/gpu/drm/i915/i915_oa_perf.c @@ -126,6 +126,8 @@ void i915_gen_insert_cmd_ts(struct intel_ringbuffer *ringbuf, u32 ctx_id, entry->ring = ring_id_mask(ring); if (dev_priv->gen_pmu.sample_info_flags & I915_GEN_PMU_SAMPLE_PID) entry->pid = current->pid; + if (dev_priv->gen_pmu.sample_info_flags & I915_GEN_PMU_SAMPLE_TAG) + entry->tag = tag; i915_gem_request_assign(&entry->req, ring->outstanding_lazy_request); spin_lock_irqsave(&dev_priv->gen_pmu.lock, lock_flags); @@ -559,6 +561,7 @@ static void forward_one_gen_pmu_sample(struct drm_i915_private *dev_priv, struct drm_i915_ts_node_ctx_id *ctx_info; struct drm_i915_ts_node_ring_id *ring_info; struct drm_i915_ts_node_pid *pid_info; + struct drm_i915_ts_node_tag *tag_info; struct perf_raw_record raw; ts_size = sizeof(struct drm_i915_ts_data); @@ -583,6 +586,13 @@ static void forward_one_gen_pmu_sample(struct drm_i915_private *dev_priv, current_ptr = snapshot + snapshot_size; } + if (dev_priv->gen_pmu.sample_info_flags & I915_GEN_PMU_SAMPLE_TAG) { + tag_info = (struct drm_i915_ts_node_tag *)current_ptr; + tag_info->tag = node->tag; + snapshot_size += sizeof(*tag_info); + current_ptr = snapshot + snapshot_size; + } + perf_sample_data_init(&data, 0, event->hw.last_period); /* Note: the combined u32 raw->size member + raw data itself must be 8 @@ -1040,6 +1050,9 @@ static int init_gen_pmu_buffer(struct perf_event *event) if (dev_priv->gen_pmu.sample_info_flags & I915_GEN_PMU_SAMPLE_PID) node_size += sizeof(struct drm_i915_ts_node_pid); + if (dev_priv->gen_pmu.sample_info_flags & I915_GEN_PMU_SAMPLE_TAG) + node_size += sizeof(struct drm_i915_ts_node_tag); + /* size has to be aligned to 8 bytes (required by relevant gpu cmds) */ node_size = ALIGN(node_size, 8); dev_priv->gen_pmu.buffer.node_size = node_size; @@ -1658,6 +1671,9 @@ static int i915_gen_event_init(struct perf_event *event) if (gen_attr.sample_pid) dev_priv->gen_pmu.sample_info_flags |= I915_GEN_PMU_SAMPLE_PID; + if (gen_attr.sample_tag) + dev_priv->gen_pmu.sample_info_flags |= I915_GEN_PMU_SAMPLE_TAG; + /* To avoid the complexity of having to accurately filter * data and marshal to the appropriate client * we currently only allow exclusive access */ diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h index 393f4ec..7ab4972 100644 --- a/include/uapi/drm/i915_drm.h +++ b/include/uapi/drm/i915_drm.h @@ -104,7 +104,8 @@ struct drm_i915_gen_pmu_attr { __u32 size; __u32 sample_ring:1, sample_pid:1, - __reserved_1:30; + sample_tag:1, + __reserved_1:29; }; /* Header for PERF_RECORD_DEVICE type events */ @@ -169,6 +170,11 @@ struct drm_i915_ts_node_pid { __u32 pad; }; +struct drm_i915_ts_node_tag { + __u32 tag; + __u32 pad; +}; + /* Each region is a minimum of 16k, and there are at most 255 of them. */ #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use