From patchwork Wed Apr 5 16:23:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9664663 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 420A4602B8 for ; Wed, 5 Apr 2017 16:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 34B8D28395 for ; Wed, 5 Apr 2017 16:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 292FB2859F; Wed, 5 Apr 2017 16:23:58 +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 9D06228395 for ; Wed, 5 Apr 2017 16:23:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C5786E830; Wed, 5 Apr 2017 16:23:57 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 249CA6E841 for ; Wed, 5 Apr 2017 16:23:55 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id w43so4108645wrb.1 for ; Wed, 05 Apr 2017 09:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=r6C90rdiYkQ+siT5Wikdq5Iwd0K9CnK4O/5wZRoGeiU=; b=kI+cm1Dz1t2JjaloWbquF6qQO4dNDdKehJqeNviRu+N9ejbr3B1tc4hFRzfvRQhRuN JaCnjxNrcVu83odKrwa9A9Ui1UX75gwtsprI7eIVx8Fq4vaD6SO8EtrEldUGwJrR5gxY 71ElWRWa19UPDxe/6P7UuiJ/uQkf/ZuW/vQfic53i/lQonmVczgD8MwiJ6dDNs8IHoo5 gnuS9QuHeykE8OGCVZVf61qVWxO7fzXOybQ0mzCJdyWuBPbYaO/x0V9+7k2sg+rJS0wE ji4ktBQmEwRUCvwdlHI4jwvQ8pdCHcRpAGECd58/FQJgoyHrIYysAklEG+xdLrxuR+3E Rdxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=r6C90rdiYkQ+siT5Wikdq5Iwd0K9CnK4O/5wZRoGeiU=; b=XadGejfY6R81FAn9UBFy+ZvskbxxCFtJPM6ZlM26uBBaRw7RXWlbt41BpbqKVFrNLj Bmb9QyDx1pvll7ez0JqvG5SMpHlidFeVxoAsum+/t+uK70I5OrpISU+ZdFJ7AUIcu6TU aURkz+iAhTRdiyawbhkKk6NpGF/5aKF8Apzve2VmSLaU3MnjmD1lQMoTKW9CTI4/bwwN BLv77BGNLdMw7cUtK0TW96Yrk1GcoI4mrDzmRUod+S62YRNpTdcXY99sUEqNKvysiVvI jA3EH5aVf82sxeXtmV2RBGfJzxzgJbBX6MwwzZCuAvMCZsIPYuCPc8Zwe6XUbRJJoICl xK2g== X-Gm-Message-State: AFeK/H1G7I3dM/6TrML9RxvlLsFiKTWqVVXmMmV/nmapD8AVkGd5I866 zBZD6cQnv/jquw== X-Received: by 10.28.216.141 with SMTP id p135mr20593009wmg.71.1491409433822; Wed, 05 Apr 2017 09:23:53 -0700 (PDT) Received: from sixbynine.org (host-78-151-19-25.as13285.net. [78.151.19.25]) by smtp.gmail.com with ESMTPSA id m83sm22981851wmc.7.2017.04.05.09.23.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Apr 2017 09:23:53 -0700 (PDT) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Wed, 5 Apr 2017 17:23:19 +0100 Message-Id: <20170405162320.30094-7-robert@sixbynine.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170405162320.30094-1-robert@sixbynine.org> References: <20170405162320.30094-1-robert@sixbynine.org> Cc: Lionel Landwerlin Subject: [Intel-gfx] [PATCH v3 6/7] drm/i915/perf: per-gen timebase for checking sample freq 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 An oa_exponent_to_ns() utility and per-gen timebase constants where recently removed when updating the tail pointer race condition WA, and this restores those so we can update the _PROP_OA_EXPONENT validation done in read_properties_unlocked() to not assume we have a 12.5KHz timebase as we did for Haswell. Signed-off-by: Robert Bragg Cc: Lionel Landwerlin Reviewed-by: Lionel Landwerlin --- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_perf.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 3a22b6fd0ee6..48b07d706f06 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2463,6 +2463,7 @@ struct drm_i915_private { bool periodic; int period_exponent; + int timestamp_frequency; int metrics_set; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 98eb6415b63a..87c0d1ce1b9f 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -2549,6 +2549,12 @@ i915_perf_open_ioctl_locked(struct drm_i915_private *dev_priv, return ret; } +static u64 oa_exponent_to_ns(struct drm_i915_private *dev_priv, int exponent) +{ + return div_u64(1000000000ULL * (2ULL << exponent), + dev_priv->perf.oa.timestamp_frequency); +} + /** * read_properties_unlocked - validate + copy userspace stream open properties * @dev_priv: i915 device instance @@ -2647,14 +2653,9 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, /* Theoretically we can program the OA unit to sample * every 160ns but don't allow that by default unless * root. - * - * On Haswell the period is derived from the exponent - * as: - * - * period = 80ns * 2^(exponent + 1) */ BUILD_BUG_ON(sizeof(oa_period) != 8); - oa_period = 80ull * (2ull << value); + oa_period = oa_exponent_to_ns(dev_priv, value); /* This check is primarily to ensure that oa_period <= * UINT32_MAX (before passing to do_div which only @@ -2910,6 +2911,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv) dev_priv->perf.oa.ops.oa_hw_tail_read = gen7_oa_hw_tail_read; + dev_priv->perf.oa.timestamp_frequency = 12500000; + dev_priv->perf.oa.oa_formats = hsw_oa_formats; dev_priv->perf.oa.n_builtin_sets = @@ -2923,6 +2926,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv) */ if (IS_GEN8(dev_priv)) { + dev_priv->perf.oa.timestamp_frequency = 12500000; + dev_priv->perf.oa.ctx_oactxctrl_offset = 0x120; dev_priv->perf.oa.ctx_flexeu0_offset = 0x2ce; dev_priv->perf.oa.gen8_valid_ctx_bit = (1<<25); @@ -2939,6 +2944,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv) i915_oa_select_metric_set_chv; } } else if (IS_GEN9(dev_priv)) { + dev_priv->perf.oa.timestamp_frequency = 12000000; + dev_priv->perf.oa.ctx_oactxctrl_offset = 0x128; dev_priv->perf.oa.ctx_flexeu0_offset = 0x3de; dev_priv->perf.oa.gen8_valid_ctx_bit = (1<<16); @@ -2959,6 +2966,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv) dev_priv->perf.oa.ops.select_metric_set = i915_oa_select_metric_set_sklgt4; } else if (IS_BROXTON(dev_priv)) { + dev_priv->perf.oa.timestamp_frequency = 19200123; + dev_priv->perf.oa.n_builtin_sets = i915_oa_n_builtin_metric_sets_bxt; dev_priv->perf.oa.ops.select_metric_set =