From patchwork Tue Jul 18 14:36:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9848577 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 87C21602A7 for ; Tue, 18 Jul 2017 14:36:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D5F52621B for ; Tue, 18 Jul 2017 14:36:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72040262AE; Tue, 18 Jul 2017 14:36:43 +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 27C562621B for ; Tue, 18 Jul 2017 14:36:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A095A6E35E; Tue, 18 Jul 2017 14:36:42 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE0406E35E for ; Tue, 18 Jul 2017 14:36:40 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id y43so3946151wrd.0 for ; Tue, 18 Jul 2017 07:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xiAh2NsDEgES1jlRWUT3LpynJDEbBSF17hNNQ7x9HcQ=; b=c3g1NxUVE1D2eWob716ePk+ewbUEpNbz0+VWTGc5H3w+bzQh6b4nS1djqVJIJBpkun uSkY/cR4i21Ix/PVtQB/ICzFeBCQ/jCrItDg9IBtBFrMQfG+nouBcLj9WkLFwQVAEKkx IPOxLXjmn20hegg3xSiTytUj9vOjWtJ2q5L1b59jB0P1HaKM/PblZzNC60IwqQY/KslK We/bTQ3brbbLjpAV/AjzLvomeTd6bGP1uPk6XeNvnF4hXywossfo/hJForglr+SupYTX pEoLcAg/nlT8wC/2Rs7xWevT4d0UDXXTzwp7cQcDouFTSHn3EnOVB5sTtxT9e8ic7ui0 F7IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xiAh2NsDEgES1jlRWUT3LpynJDEbBSF17hNNQ7x9HcQ=; b=dtKtb88i5qSj68iGQUDIt8RJY4Q51HnfE7scR6AJwNJqX8LVnj9ISum9jNAiPL2TYi 2UIr3aO9HI55TcgDCKLioopl70cFv6U9mO2GIu//huRDjxfjY/IOiojDBh+3SqoOCYZe AMv15CYcmEF//amqfn0ezd1/exFA29twb4Gm1q7LW7Kujgxztgpa9aRBb+wpR4GWMXDF knuTln0bZlKM3CTKw22J4OSDuwo+p8waxGriu0iYKx0CsCns8PIuN4N8tjNExPj3Ng0O xOUqRUd2GbQEnZol64JZUGUgwzv9IzcQVBl03BCoKugPmyeZ77iszfq4dpWFbfXFOjfB T4uw== X-Gm-Message-State: AIVw113Yt3OmL2fwz65KIVw+o9Z4PpMq+Ce3W2cFC4pcd0vgkRUmPeqW qU/FmyOq9pzOz1UvRbY= X-Received: by 10.223.130.229 with SMTP id 92mr1316091wrc.119.1500388599484; Tue, 18 Jul 2017 07:36:39 -0700 (PDT) Received: from t460p.intel ([95.146.144.225]) by smtp.gmail.com with ESMTPSA id s30sm2944959wrc.13.2017.07.18.07.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 07:36:35 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Tue, 18 Jul 2017 15:36:08 +0100 Message-Id: <20170718143618.12254-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170718143618.12254-1-tvrtko.ursulin@linux.intel.com> References: <20170718143618.12254-1-tvrtko.ursulin@linux.intel.com> Cc: Ben Widawsky Subject: [Intel-gfx] [RFC 04/14] drm/i915/pmu: Decouple uAPI engine ids 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: Tvrtko Ursulin As elsewhere in the code we have to decouple the binary engine identifiers for easier maintenance. Also the sampler mask was incorrect in the timer callback. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_pmu.c | 44 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index f03ddad44da6..9a8208dba7a9 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -10,6 +10,25 @@ #define RING_MASK 0xffffffff #define RING_MAX 32 +#define ENGINE_SAMPLE_MASK (0xf) +#define ENGINE_SAMPLE_BITS (4) + +static const unsigned int engine_map[I915_NUM_ENGINES] = { + [RCS] = I915_SAMPLE_RCS, + [BCS] = I915_SAMPLE_BCS, + [VCS] = I915_SAMPLE_VCS, + [VCS2] = I915_SAMPLE_VCS2, + [VECS] = I915_SAMPLE_VECS, +}; + +static const unsigned int user_engine_map[I915_NUM_ENGINES] = { + [I915_SAMPLE_RCS] = RCS, + [I915_SAMPLE_BCS] = BCS, + [I915_SAMPLE_VCS] = VCS, + [I915_SAMPLE_VCS2] = VCS2, + [I915_SAMPLE_VECS] = VECS, +}; + static void engines_sample(struct drm_i915_private *dev_priv) { struct intel_engine_cs *engine; @@ -26,9 +45,16 @@ static void engines_sample(struct drm_i915_private *dev_priv) return; for_each_engine(engine, dev_priv, id) { + unsigned int user_engine = engine_map[id]; u32 val; - if ((dev_priv->pmu.enable & (0x7 << (4*id))) == 0) + if (WARN_ON_ONCE(id >= ARRAY_SIZE(engine_map))) + continue; + else + user_engine = engine_map[id]; + + if (!(dev_priv->pmu.enable & + (ENGINE_SAMPLE_MASK << (ENGINE_SAMPLE_BITS * user_engine)))) continue; if (i915_seqno_passed(intel_engine_get_seqno(engine), @@ -112,6 +138,11 @@ static int engine_event_init(struct perf_event *event) int engine = event->attr.config >> 2; int sample = event->attr.config & 3; + if (WARN_ON_ONCE(engine >= ARRAY_SIZE(user_engine_map))) + return -ENOENT; + else + engine = user_engine_map[engine]; + switch (sample) { case I915_SAMPLE_QUEUED: case I915_SAMPLE_BUSY: @@ -125,9 +156,6 @@ static int engine_event_init(struct perf_event *event) return -ENOENT; } - if (engine >= I915_NUM_ENGINES) - return -ENOENT; - if (!i915->engine[engine]) return -ENODEV; @@ -369,7 +397,13 @@ static void i915_pmu_event_read(struct perf_event *event) if (event->attr.config < 32) { int engine = event->attr.config >> 2; int sample = event->attr.config & 3; - val = i915->engine[engine]->pmu_sample[sample]; + + if (WARN_ON_ONCE(engine >= ARRAY_SIZE(user_engine_map))) { + /* Do nothing */ + } else { + engine = user_engine_map[engine]; + val = i915->engine[engine]->pmu_sample[sample]; + } } else switch (event->attr.config) { case I915_PMU_ACTUAL_FREQUENCY: val = i915->pmu.sample[__I915_SAMPLE_FREQ_ACT];