All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Bragg <robert@sixbynine.org>
To: intel-gfx@lists.freedesktop.org
Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Subject: [PATCH v4 14/15] drm/i915/perf: per-gen timebase for checking sample freq
Date: Wed, 12 Apr 2017 16:55:55 +0100	[thread overview]
Message-ID: <20170412155556.6602-15-robert@sixbynine.org> (raw)
In-Reply-To: <20170412155556.6602-1-robert@sixbynine.org>

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.5MHz
timebase as we did for Haswell.

Accordingly the oa_sample_rate_hard_limit value that's referenced by
proc_dointvec_minmax defining the absolute limit for the OA sampling
frequency is now initialized to (timestamp_frequency / 2) instead of the
6.25MHz constant for Haswell.

v2:
    Specify frequency of 19.2MHz for BXT (Ville)
    Initialize oa_sample_rate_hard_limit per-gen too (Lionel)

Signed-off-by: Robert Bragg <robert@sixbynine.org>
Cc: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  1 +
 drivers/gpu/drm/i915/i915_perf.c | 37 ++++++++++++++++++++++++++-----------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b8dcf281db53..59dcce3b40a9 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2457,6 +2457,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 611f996bece7..5de8d57e0b77 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -288,10 +288,12 @@ static u32 i915_perf_stream_paranoid = true;
 
 /* For sysctl proc_dointvec_minmax of i915_oa_max_sample_rate
  *
- * 160ns is the smallest sampling period we can theoretically program the OA
- * unit with on Haswell, corresponding to 6.25MHz.
+ * The highest sampling frequency we can theoretically program the OA unit
+ * with is always half the timestamp frequency: E.g. 6.25Mhz for Haswell.
+ *
+ * Initialized just before we register the sysctl parameter.
  */
-static int oa_sample_rate_hard_limit = 6250000;
+static int oa_sample_rate_hard_limit;
 
 /* Theoretically we can program the OA unit to sample every 160ns but don't
  * allow that by default unless root...
@@ -2560,6 +2562,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
@@ -2656,16 +2664,13 @@ 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)
+			 * e.g. every 160ns for HSW, 167ns for BDW/SKL or 104ns
+			 * for BXT. We don't allow such high sampling
+			 * frequencies by default unless root.
 			 */
+
 			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
@@ -2921,6 +2926,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 =
@@ -2934,6 +2941,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);
@@ -2950,6 +2959,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);
@@ -2970,6 +2981,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 = 19200000;
+
 				dev_priv->perf.oa.n_builtin_sets =
 					i915_oa_n_builtin_metric_sets_bxt;
 				dev_priv->perf.oa.ops.select_metric_set =
@@ -3004,6 +3017,8 @@ void i915_perf_init(struct drm_i915_private *dev_priv)
 		spin_lock_init(&dev_priv->perf.hook_lock);
 		spin_lock_init(&dev_priv->perf.oa.oa_buffer.ptr_lock);
 
+		oa_sample_rate_hard_limit =
+			dev_priv->perf.oa.timestamp_frequency / 2;
 		dev_priv->perf.sysctl_header = register_sysctl_table(dev_root);
 
 		dev_priv->perf.initialized = true;
-- 
2.12.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-04-12 15:57 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 15:55 [PATCH v4 00/15] Enable OA unit for Gen 8 and 9 in i915 perf Robert Bragg
2017-04-12 15:55 ` [PATCH v4 01/15] drm/i915/perf: fix gen7_append_oa_reports comment Robert Bragg
2017-04-12 15:55 ` [PATCH v4 02/15] drm/i915/perf: avoid poll, read, EAGAIN busy loops Robert Bragg
2017-04-12 15:55 ` [PATCH v4 03/15] drm/i915/perf: avoid read back of head register Robert Bragg
2017-04-12 15:55 ` [PATCH v4 04/15] drm/i915/perf: no head/tail ref in gen7_oa_read Robert Bragg
2017-04-12 15:55 ` [PATCH v4 05/15] drm/i915/perf: improve tail race workaround Robert Bragg
2017-04-12 15:55 ` [PATCH v4 06/15] drm/i915/perf: improve invalid OA format debug message Robert Bragg
2017-04-12 15:55 ` [PATCH v4 07/15] drm/i915/perf: better pipeline aged/aging tail updates Robert Bragg
2017-04-12 15:55 ` [PATCH v4 08/15] drm/i915/perf: rate limit spurious oa report notice Robert Bragg
2017-04-12 15:55 ` [PATCH v4 09/15] drm/i915: expose _SLICE_MASK GETPARM Robert Bragg
2017-04-12 15:55 ` [PATCH v4 10/15] drm/i915: expose _SUBSLICE_MASK GETPARM Robert Bragg
2017-04-12 15:55 ` [PATCH v4 11/15] drm/i915/perf: Add 'render basic' Gen8+ OA unit configs Robert Bragg
2017-04-12 15:55 ` [PATCH v4 12/15] drm/i915/perf: Add OA unit support for Gen 8+ Robert Bragg
2017-04-12 17:47   ` Matthew Auld
2017-04-12 15:55 ` [PATCH v4 13/15] drm/i915/perf: Add more OA configs for BDW, CHV, SKL + BXT Robert Bragg
2017-04-12 15:55 ` Robert Bragg [this message]
2017-04-12 15:55 ` [PATCH v4 15/15] drm/i915/perf: remove perf.hook_lock Robert Bragg
2017-04-12 17:33 ` ✓ Fi.CI.BAT: success for Enable OA unit for Gen 8 and 9 in i915 perf (rev6) Patchwork
2017-04-24  7:17 ` [PATCH 00/15] Enable OA unit for Gen 8 and 9 in i915 perf Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 01/15] drm/i915/perf: fix gen7_append_oa_reports comment Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 02/15] drm/i915/perf: avoid poll, read, EAGAIN busy loops Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 03/15] drm/i915/perf: avoid read back of head register Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 04/15] drm/i915/perf: no head/tail ref in gen7_oa_read Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 05/15] drm/i915/perf: improve tail race workaround Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 06/15] drm/i915/perf: improve invalid OA format debug message Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 07/15] drm/i915/perf: better pipeline aged/aging tail updates Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 08/15] drm/i915/perf: rate limit spurious oa report notice Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 09/15] drm/i915: expose _SLICE_MASK GETPARM Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 10/15] drm/i915: expose _SUBSLICE_MASK GETPARM Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 11/15] drm/i915/perf: Add 'render basic' Gen8+ OA unit configs Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 12/15] drm/i915/perf: Add OA unit support for Gen 8+ Lionel Landwerlin
2017-04-24 10:35     ` Chris Wilson
2017-04-24 18:49       ` [PATCH v6 " Lionel Landwerlin
2017-04-25 16:20         ` Lionel Landwerlin
2017-04-25 16:42         ` Matthew Auld
2017-04-25 17:10           ` Lionel Landwerlin
2017-04-25 17:47             ` Matthew Auld
2017-04-25 17:30           ` [PATCH v7 " Lionel Landwerlin
2017-04-27  8:53             ` Chris Wilson
2017-05-02  1:17               ` [PATCH v9 " Lionel Landwerlin
2017-05-02 20:14                 ` Chris Wilson
2017-05-02 21:44                   ` [PATCH v10 " Lionel Landwerlin
2017-05-03 10:31                     ` Chris Wilson
2017-04-24  7:17   ` [PATCH v5 13/15] drm/i915/perf: Add more OA configs for BDW, CHV, SKL + BXT Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 14/15] drm/i915/perf: per-gen timebase for checking sample freq Lionel Landwerlin
2017-04-24  7:17   ` [PATCH v5 15/15] drm/i915/perf: remove perf.hook_lock Lionel Landwerlin
2017-05-03 16:23   ` [PATCH v2 9/15] drm/i915: expose _SLICE_MASK GETPARM Lionel Landwerlin
2017-05-03 16:23     ` [PATCH v2 9/15] drm/i915: expose _SUBSLICE_MASK GETPARM Lionel Landwerlin
2017-05-03 16:33     ` [PATCH v2 9/15] drm/i915: expose _SLICE_MASK GETPARM Chris Wilson
2017-05-03 18:14       ` Lionel Landwerlin
2017-05-26 11:56   ` [PATCH v14 00/14] Enable OA unit for Gen 8 and 9 in i915 perf Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 01/14] drm/i915: Record both min/max eu_per_subslice in sseu_dev_info Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 02/14] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 03/14] drm/i915: Record the sseu configuration per-context & engine Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 04/14] drm/i915/perf: rework mux configurations queries Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 05/14] drm/i915/perf: Add 'render basic' Gen8+ OA unit configs Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 06/14] drm/i915/perf: Add OA unit support for Gen 8+ Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 07/14] drm/i915/perf: Add more OA configs for BDW, CHV, SKL + BXT Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 08/14] drm/i915/perf: per-gen timebase for checking sample freq Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 09/14] drm/i915/perf: remove perf.hook_lock Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 10/14] drm/i915: add KBL GT2/GT3 check macros Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 11/14] drm/i915/perf: add KBL support Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 12/14] drm/i915/perf: add GLK support Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 13/14] drm/i915/perf: reprogram NOA muxes at the beginning of each workload Lionel Landwerlin
2017-05-30 18:51       ` Lionel Landwerlin
2017-05-26 11:56     ` [PATCH v14 14/14] drm/i915/perf: notify sseu configuration changes Lionel Landwerlin
2017-05-26 12:28   ` ✓ Fi.CI.BAT: success for series starting with [v2,9/15] drm/i915: expose _SLICE_MASK GETPARM (rev2) Patchwork
2017-05-31 12:33   ` [PATCH v15 00/14] Enable OA unit for Gen 8 and 9 in i915 perf Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 01/14] drm/i915: Record both min/max eu_per_subslice in sseu_dev_info Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 02/14] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 03/14] drm/i915: Record the sseu configuration per-context & engine Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 04/14] drm/i915/perf: rework mux configurations queries Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 05/14] drm/i915/perf: Add 'render basic' Gen8+ OA unit configs Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 06/14] drm/i915/perf: Add OA unit support for Gen 8+ Lionel Landwerlin
2017-06-01 11:48       ` Chris Wilson
2017-05-31 12:33     ` [PATCH v15 07/14] drm/i915/perf: Add more OA configs for BDW, CHV, SKL + BXT Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 08/14] drm/i915/perf: per-gen timebase for checking sample freq Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 09/14] drm/i915/perf: remove perf.hook_lock Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 10/14] drm/i915: add KBL GT2/GT3 check macros Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 11/14] drm/i915/perf: add KBL support Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 12/14] drm/i915/perf: add GLK support Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 13/14] drm/i915/perf: reprogram NOA muxes at the beginning of each workload Lionel Landwerlin
2017-05-31 12:33     ` [PATCH v15 14/14] drm/i915/perf: notify sseu configuration changes Lionel Landwerlin
2017-06-01 11:50       ` Chris Wilson
2017-06-01 11:52       ` Chris Wilson
2017-04-24 18:52 ` ✗ Fi.CI.BAT: failure for Enable OA unit for Gen 8 and 9 in i915 perf (rev7) Patchwork
2017-04-25 17:35 ` ✗ Fi.CI.BAT: failure for Enable OA unit for Gen 8 and 9 in i915 perf (rev8) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170412155556.6602-15-robert@sixbynine.org \
    --to=robert@sixbynine.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lionel.g.landwerlin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.