[PATCH 07/10] drm/i915/perf: allowing opening the perf stream without sampling
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Thu Mar 22 15:34:57 UTC 2018
We want to allow a user to configure the OA hardware so that
MI_RECORD_PERF_COUNT is functional but without having to deal with the
OA buffer.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
drivers/gpu/drm/i915/i915_perf.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 5abc54dff1ad..c1d95101ed81 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -453,6 +453,8 @@ static bool oa_buffer_check_unlocked(struct drm_i915_private *dev_priv)
u32 head, hw_tail, aged_tail, aging_tail;
u64 now;
+ GEM_BUG_ON(!dev_priv->perf.oa.exclusive_stream->sample_flags);
+
/* We have to consider the (unlikely) possibility that read() errors
* could result in an OA buffer reset which might reset the head,
* tails[] and aged_tail state.
@@ -1818,6 +1820,7 @@ static int gen8_enable_metric_set(struct drm_i915_private *dev_priv,
const struct i915_perf_stream *stream)
{
struct i915_oa_config *oa_config = stream->oa_config;
+ u32 oa_debug_value = 0;
int ret;
/*
@@ -1844,11 +1847,22 @@ static int gen8_enable_metric_set(struct drm_i915_private *dev_priv,
* RPT_ID field.
*/
if (IS_GEN9(dev_priv) || IS_GEN10(dev_priv)) {
- I915_WRITE(GEN8_OA_DEBUG,
- _MASKED_BIT_ENABLE(GEN9_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS |
- GEN9_OA_DEBUG_INCLUDE_CLK_RATIO));
+ oa_debug_value |=
+ _MASKED_BIT_ENABLE(GEN9_OA_DEBUG_DISABLE_CLK_RATIO_REPORTS |
+ GEN9_OA_DEBUG_INCLUDE_CLK_RATIO);
}
+ /*
+ * If the user didn't require OA reports, instruct the hardware not to
+ * emit ctx switch reports.
+ */
+ oa_debug_value |=
+ (stream->sample_flags & SAMPLE_OA_REPORT) ?
+ _MASKED_BIT_ENABLE(GEN9_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS) :
+ _MASKED_BIT_DISABLE(GEN9_OA_DEBUG_DISABLE_CTX_SWITCH_REPORTS);
+
+ I915_WRITE(GEN8_OA_DEBUG, oa_debug_value);
+
/*
* Update all contexts prior writing the mux configurations as we need
* to make sure all slices/subslices are ON before writing to NOA
@@ -2033,11 +2047,6 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
return -EINVAL;
}
- if (!(props->sample_flags & SAMPLE_OA_REPORT)) {
- DRM_DEBUG("Only OA report sampling supported\n");
- return -EINVAL;
- }
-
if (!dev_priv->perf.oa.ops.enable_metric_set) {
DRM_DEBUG("OA unit not supported\n");
return -ENODEV;
@@ -2081,8 +2090,10 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
format_size = dev_priv->perf.oa.oa_formats[props->oa_format].size;
- stream->sample_flags |= SAMPLE_OA_REPORT;
- stream->sample_size += format_size;
+ if (props->sample_flags & SAMPLE_OA_REPORT) {
+ stream->sample_flags |= SAMPLE_OA_REPORT;
+ stream->sample_size += format_size;
+ }
dev_priv->perf.oa.oa_buffer.format_size = format_size;
if (WARN_ON(dev_priv->perf.oa.oa_buffer.format_size == 0))
@@ -2251,6 +2262,12 @@ static ssize_t i915_perf_read(struct file *file,
if (!stream->enabled)
return -EIO;
+ /* If the user opened the stream only to snapshot counters through
+ * MI_RECORD_PERF_COUNT, there is nothing to read from the OA buffer.
+ */
+ if (!stream->sample_flags)
+ return -EIO;
+
if (!(file->f_flags & O_NONBLOCK)) {
/* There's the small chance of false positives from
* stream->ops->wait_unlocked.
@@ -2332,6 +2349,9 @@ static __poll_t i915_perf_poll_locked(struct drm_i915_private *dev_priv,
{
__poll_t events = 0;
+ if (!stream->sample_flags)
+ return events;
+
stream->ops->poll_wait(stream, file, wait);
/* Note: we don't explicitly check whether there's something to read
--
2.16.2
More information about the Intel-gfx-trybot
mailing list