Skip to contentSkip to conversation

drm/i915/perf: Add helper macros for comparing with whitelisted registers

PATCH Superseded Umesh Nerlige Ramappa 3 participants 9 messages Oct 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 drm/i915/perf: Add helper macros for comparing with whitelisted registers

Add helper macros for range and equality comparisons and use them to check with whitelisted registers in oa configurations.

---
 drivers/gpu/drm/i915/i915_perf.c | 54 +++++++++++++++++---------------
 1 file changed, 28 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +28 -26
index 54ec1c4190ac..91707558a0f5 100644
@@ -3514,56 +3514,58 @@ static bool gen8_is_valid_flex_addr(struct i915_perf *perf, u32 addr)
 	return false;
 }
 
+#define ADDR_IN_RANGE(addr, start, end) \
+	((addr) >= (start) && \
+	 (addr) <= (end))
+
+#define REG_IN_RANGE(addr, start, end) \
+	((addr) >= i915_mmio_reg_offset(start) && \
+	 (addr) <= i915_mmio_reg_offset(end))
+
+#define REG_EQUAL(addr, mmio) \
+	((addr) == i915_mmio_reg_offset(mmio))
+
 static bool gen7_is_valid_b_counter_addr(struct i915_perf *perf, u32 addr)
 {
-	return (addr >= i915_mmio_reg_offset(OASTARTTRIG1) &&
-		addr <= i915_mmio_reg_offset(OASTARTTRIG8)) ||
-		(addr >= i915_mmio_reg_offset(OAREPORTTRIG1) &&
-		 addr <= i915_mmio_reg_offset(OAREPORTTRIG8)) ||
-		(addr >= i915_mmio_reg_offset(OACEC0_0) &&
-		 addr <= i915_mmio_reg_offset(OACEC7_1));
+	return REG_IN_RANGE(addr, OASTARTTRIG1, OASTARTTRIG8) ||
+	       REG_IN_RANGE(addr, OAREPORTTRIG1, OAREPORTTRIG8) ||
+	       REG_IN_RANGE(addr, OACEC0_0, OACEC7_1);
 }
 
 static bool gen7_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
 {
-	return addr == i915_mmio_reg_offset(HALF_SLICE_CHICKEN2) ||
-		(addr >= i915_mmio_reg_offset(MICRO_BP0_0) &&
-		 addr <= i915_mmio_reg_offset(NOA_WRITE)) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFCNT1_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFCNT2_HI)) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFMATRIX_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFMATRIX_HI));
+	return REG_EQUAL(addr, HALF_SLICE_CHICKEN2) ||
+	       REG_IN_RANGE(addr, MICRO_BP0_0, NOA_WRITE) ||
+	       REG_IN_RANGE(addr, OA_PERFCNT1_LO, OA_PERFCNT2_HI) ||
+	       REG_IN_RANGE(addr, OA_PERFMATRIX_LO, OA_PERFMATRIX_HI);
 }
 
 static bool gen8_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
 {
 	return gen7_is_valid_mux_addr(perf, addr) ||
-		addr == i915_mmio_reg_offset(WAIT_FOR_RC6_EXIT) ||
-		(addr >= i915_mmio_reg_offset(RPM_CONFIG0) &&
-		 addr <= i915_mmio_reg_offset(NOA_CONFIG(8)));
+	       REG_EQUAL(addr, WAIT_FOR_RC6_EXIT) ||
+	       REG_IN_RANGE(addr, RPM_CONFIG0, NOA_CONFIG(8));
 }
 
 static bool gen10_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
 {
 	return gen8_is_valid_mux_addr(perf, addr) ||
-		addr == i915_mmio_reg_offset(GEN10_NOA_WRITE_HIGH) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFCNT3_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFCNT4_HI));
+	       REG_EQUAL(addr, GEN10_NOA_WRITE_HIGH) ||
+	       REG_IN_RANGE(addr, OA_PERFCNT3_LO, OA_PERFCNT4_HI);
 }
 
 static bool hsw_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
 {
 	return gen7_is_valid_mux_addr(perf, addr) ||
-		(addr >= 0x25100 && addr <= 0x2FF90) ||
-		(addr >= i915_mmio_reg_offset(HSW_MBVID2_NOA0) &&
-		 addr <= i915_mmio_reg_offset(HSW_MBVID2_NOA9)) ||
-		addr == i915_mmio_reg_offset(HSW_MBVID2_MISR0);
+	       ADDR_IN_RANGE(addr, 0x25100, 0x2FF90) ||
+	       REG_IN_RANGE(addr, HSW_MBVID2_NOA0, HSW_MBVID2_NOA9) ||
+	       REG_EQUAL(addr, HSW_MBVID2_MISR0);
 }
 
 static bool chv_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
 {
 	return gen7_is_valid_mux_addr(perf, addr) ||
-		(addr >= 0x182300 && addr <= 0x1823A4);
+	       ADDR_IN_RANGE(addr, 0x182300, 0x1823A4);
 }
 
 static u32 mask_reg_value(u32 reg, u32 val)
@@ -3572,14 +3574,14 @@ static u32 mask_reg_value(u32 reg, u32 val)
 	 * WaDisableSTUnitPowerOptimization workaround. Make sure the value
 	 * programmed by userspace doesn't change this.
 	 */
-	if (i915_mmio_reg_offset(HALF_SLICE_CHICKEN2) == reg)
+	if (REG_EQUAL(reg, HALF_SLICE_CHICKEN2))
 		val = val & ~_MASKED_BIT_ENABLE(GEN8_ST_PO_DISABLE);
 
 	/* WAIT_FOR_RC6_EXIT has only one bit fullfilling the function
 	 * indicated by its name and a bunch of selection fields used by OA
 	 * configs.
 	 */
-	if (i915_mmio_reg_offset(WAIT_FOR_RC6_EXIT) == reg)
+	if (REG_EQUAL(reg, WAIT_FOR_RC6_EXIT))
 		val = val & ~_MASKED_BIT_ENABLE(HSW_WAIT_FOR_RC6_EXIT_ENABLE);
 
 	return val;
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 2/3 drm/i915/tgl: Add perf support on TGL

From: Lionel Landwerlin <[email protected]>

The design of the OA unit has been split into several units. We now have a global unit (OAG) and a render specific unit (OAR). This leads to some changes on how we program things. Some details :

OAR:
- has its own set of counter registers, they are per-context saved/restored
- counters are not written to the circular OA buffer
- a snapshot of the counters can be acquired with MI_RECORD_PERF_COUNT, or a single counter can be read with MI_STORE_REGISTER_MEM.

OAG:
- has global counters that increment across context switches
- counters are written into the circular OA buffer (if requested)

v2: Fix checkpatch warnings on code style (Lucas)
v3: (Umesh)
- Update register from which tail, status and head are read
- Update logic to sample context reports
- Update whitelist mux and b counter regs

BSpec: 28727, 30021

---
 drivers/gpu/drm/i915/Makefile         |   3 +-
 drivers/gpu/drm/i915/i915_perf.c      | 280 +++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_reg.h       | 103 ++++++++++
 drivers/gpu/drm/i915/oa/i915_oa_tgl.c | 121 +++++++++++
 drivers/gpu/drm/i915/oa/i915_oa_tgl.h |  16 ++
 5 files changed, 492 insertions(+), 31 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/oa/i915_oa_tgl.c
 create mode 100644 drivers/gpu/drm/i915/oa/i915_oa_tgl.h
drivers/gpu/drm/i915/Makefile +2 -1
index e791d9323b51..0ec9fee58baa 100644
@@ -242,7 +242,8 @@ i915-y += \
 	oa/i915_oa_cflgt2.o \
 	oa/i915_oa_cflgt3.o \
 	oa/i915_oa_cnl.o \
-	oa/i915_oa_icl.o
+	oa/i915_oa_icl.o \
+	oa/i915_oa_tgl.o
 i915-y += i915_perf.o
 
 # Post-mortem debug and GPU hang state capture
drivers/gpu/drm/i915/i915_perf.c +250 -30

496 lines not on this page · raw message

drivers/gpu/drm/i915/i915_reg.h +103 -0

133 lines not on this page · raw message

drivers/gpu/drm/i915/oa/i915_oa_tgl.c new file +121 -0

121 lines not on this page · raw message

drivers/gpu/drm/i915/oa/i915_oa_tgl.h new file +16 -0
new file mode 100644
index 000000000000..4c25f0be825c
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Autogenerated file by GPU Top : https://github.com/rib/gputop
+ * DO NOT EDIT manually!
+ */
+
+#ifndef __I915_OA_TGL_H__
+#define __I915_OA_TGL_H__
+
+struct drm_i915_private;
+
+void i915_perf_load_test_config_tgl(struct drm_i915_private *dev_priv);
+
+#endif
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 3/3 drm/i915/perf: enable OAR context save/restore of performance counters

In reply to Umesh Nerlige Ramappa

From: Lionel Landwerlin <[email protected]>

We want this so we can preempt performance queries and keep the system responsive even when long running queries are ongoing. We avoid doing it for all contexts.

v2: use LRI to modify context control (Chris)
v3: use MASKED_FIELD to program just the masked bits (Chris)

---
 drivers/gpu/drm/i915/gt/intel_lrc.h |  1 +
 drivers/gpu/drm/i915/i915_perf.c    | 39 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/gt/intel_lrc.h +1 -0
index 99dc576a4e25..b6daac712c9e 100644
@@ -43,6 +43,7 @@ struct intel_engine_cs;
 #define	  CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT	(1 << 0)
 #define   CTX_CTRL_RS_CTX_ENABLE		(1 << 1)
 #define	  CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT	(1 << 2)
+#define	  GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE	(1 << 8)
 #define RING_CONTEXT_STATUS_PTR(base)		_MMIO((base) + 0x3a0)
 #define RING_EXECLIST_SQ_CONTENTS(base)		_MMIO((base) + 0x510)
 #define RING_EXECLIST_CONTROL(base)		_MMIO((base) + 0x550)
drivers/gpu/drm/i915/i915_perf.c +39 -0
index abc2b7a6dc92..47a8d610af6e 100644
@@ -2211,6 +2211,36 @@ static int gen8_configure_context(struct i915_gem_context *ctx,
 	return err;
 }
 
+static int gen12_emit_oar_config(struct intel_context *ce, bool enable)
+{
+	struct i915_request *rq;
+	u32 *cs;
+	int err = 0;
+
+	rq = i915_request_create(ce);
+	if (IS_ERR(rq))
+		return PTR_ERR(rq);
+
+	cs = intel_ring_begin(rq, 4);
+	if (IS_ERR(cs)) {
+		err = PTR_ERR(cs);
+		goto out;
+	}
+
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(RING_CONTEXT_CONTROL(ce->engine->mmio_base));
+	*cs++ = _MASKED_FIELD(GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE,
+			      enable ? GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE : 0);
+	*cs++ = MI_NOOP;
+
+	intel_ring_advance(rq, cs);
+
+out:
+	i915_request_add(rq);
+
+	return err;
+}
+
 /*
  * Manages updating the per-context aspects of the OA stream
  * configuration across all contexts.
@@ -2425,6 +2455,15 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
 	if (ret)
 		return ret;
 
+	/*
+	 * For Gen12, performance counters are context
+	 * saved/restored. Only enable it for the context that
+	 * requested this.
+	 */
+	ret = gen12_emit_oar_config(stream->pinned_ctx, oa_config != NULL);
+	if (ret)
+		return ret;
+
 	return emit_oa_config(stream, oa_context(stream));
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH v2 3/3] drm/i915/perf: enable OAR context save/restore of performance counters

Quoted 71 lines · Umesh Nerlige Ramappa

From: Lionel Landwerlin <[email protected]>

We want this so we can preempt performance queries and keep the system responsive even when long running queries are ongoing. We avoid doing it for all contexts.

v2: use LRI to modify context control (Chris)
v3: use MASKED_FIELD to program just the masked bits (Chris)

---
  drivers/gpu/drm/i915/gt/intel_lrc.h |  1 +
  drivers/gpu/drm/i915/i915_perf.c    | 39 +++++++++++++++++++++++++++++
  2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/gt/intel_lrc.h +1 -0
index 99dc576a4e25..b6daac712c9e 100644
@@ -43,6 +43,7 @@ struct intel_engine_cs;
  #define	  CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT	(1 << 0)
  #define   CTX_CTRL_RS_CTX_ENABLE		(1 << 1)
  #define	  CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT	(1 << 2)
+#define	  GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE	(1 << 8)
  #define RING_CONTEXT_STATUS_PTR(base)		_MMIO((base) + 0x3a0)
  #define RING_EXECLIST_SQ_CONTENTS(base)		_MMIO((base) + 0x510)
  #define RING_EXECLIST_CONTROL(base)		_MMIO((base) + 0x550)
drivers/gpu/drm/i915/i915_perf.c +30 -0
index abc2b7a6dc92..47a8d610af6e 100644
@@ -2211,6 +2211,36 @@ static int gen8_configure_context(struct i915_gem_context *ctx,
  	return err;
  }
 
+static int gen12_emit_oar_config(struct intel_context *ce, bool enable)
+{
+	struct i915_request *rq;
+	u32 *cs;
+	int err = 0;
+
+	rq = i915_request_create(ce);
+	if (IS_ERR(rq))
+		return PTR_ERR(rq);
+
+	cs = intel_ring_begin(rq, 4);
+	if (IS_ERR(cs)) {
+		err = PTR_ERR(cs);
+		goto out;
+	}
+
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(RING_CONTEXT_CONTROL(ce->engine->mmio_base));
+	*cs++ = _MASKED_FIELD(GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE,
+			      enable ? GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE : 0);
+	*cs++ = MI_NOOP;
+
+	intel_ring_advance(rq, cs);
+
+out:
+	i915_request_add(rq);
+
+	return err;
+}
+
  /*
   * Manages updating the per-context aspects of the OA stream
   * configuration across all contexts.
@@ -2425,6 +2455,15 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
  	if (ret)

drivers/gpu/drm/i915/i915_perf.c static int gen12_enable_metric_set(struct i915_perf_stream *stream) · line 2465

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +8 -0
  		return ret;
 
+	/*
+	 * For Gen12, performance counters are context
+	 * saved/restored. Only enable it for the context that
+	 * requested this.
+	 */
+	ret = gen12_emit_oar_config(stream->pinned_ctx, oa_config != NULL);
+	if (ret)
+		return ret;

You could call this from emit_oa_config().

There you have a request created already.

All you need to check is if (stream->pinned_ctx == ce).

Then gen12_emit_oar_config() won't even need to create the request.

-Lionel

drivers/gpu/drm/i915/i915_perf.c static int gen12_enable_metric_set(struct i915_perf_stream *stream) · line 2469

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +1 -0
+
  	return emit_oa_config(stream, oa_context(stream));
  }
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH v2 3/3] drm/i915/perf: enable OAR context save/restore of performance counters

In reply to Umesh Nerlige Ramappa
Quoted 1 line · Umesh Nerlige Ramappa

From: Lionel Landwerlin <[email protected]>

Also put yourself as the author ;)

And finally put that patch before the other so that we once perf support is enabled, all the features are there.

Cheers,

-Lionel

Quoted 74 lines

We want this so we can preempt performance queries and keep the system responsive even when long running queries are ongoing. We avoid doing it for all contexts.

v2: use LRI to modify context control (Chris)
v3: use MASKED_FIELD to program just the masked bits (Chris)

---
  drivers/gpu/drm/i915/gt/intel_lrc.h |  1 +
  drivers/gpu/drm/i915/i915_perf.c    | 39 +++++++++++++++++++++++++++++
  2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/gt/intel_lrc.h +1 -0
index 99dc576a4e25..b6daac712c9e 100644
@@ -43,6 +43,7 @@ struct intel_engine_cs;
  #define	  CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT	(1 << 0)
  #define   CTX_CTRL_RS_CTX_ENABLE		(1 << 1)
  #define	  CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT	(1 << 2)
+#define	  GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE	(1 << 8)
  #define RING_CONTEXT_STATUS_PTR(base)		_MMIO((base) + 0x3a0)
  #define RING_EXECLIST_SQ_CONTENTS(base)		_MMIO((base) + 0x510)
  #define RING_EXECLIST_CONTROL(base)		_MMIO((base) + 0x550)
drivers/gpu/drm/i915/i915_perf.c +32 -0
index abc2b7a6dc92..47a8d610af6e 100644
@@ -2211,6 +2211,36 @@ static int gen8_configure_context(struct i915_gem_context *ctx,
  	return err;
  }
 
+static int gen12_emit_oar_config(struct intel_context *ce, bool enable)
+{
+	struct i915_request *rq;
+	u32 *cs;
+	int err = 0;
+
+	rq = i915_request_create(ce);
+	if (IS_ERR(rq))
+		return PTR_ERR(rq);
+
+	cs = intel_ring_begin(rq, 4);
+	if (IS_ERR(cs)) {
+		err = PTR_ERR(cs);
+		goto out;
+	}
+
+	*cs++ = MI_LOAD_REGISTER_IMM(1);
+	*cs++ = i915_mmio_reg_offset(RING_CONTEXT_CONTROL(ce->engine->mmio_base));
+	*cs++ = _MASKED_FIELD(GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE,
+			      enable ? GEN12_CTX_CTRL_OAR_CONTEXT_ENABLE : 0);
+	*cs++ = MI_NOOP;
+
+	intel_ring_advance(rq, cs);
+
+out:
+	i915_request_add(rq);
+
+	return err;
+}
+
  /*
   * Manages updating the per-context aspects of the OA stream
   * configuration across all contexts.
@@ -2425,6 +2455,15 @@ static int gen12_enable_metric_set(struct i915_perf_stream *stream)
  	if (ret)
  		return ret;
 
+	/*
+	 * For Gen12, performance counters are context

drivers/gpu/drm/i915/i915_perf.c static int gen12_enable_metric_set(struct i915_perf_stream *stream) · line 2469

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +7 -0
+	 * saved/restored. Only enable it for the context that
+	 * requested this.
+	 */
+	ret = gen12_emit_oar_config(stream->pinned_ctx, oa_config != NULL);
+	if (ret)
+		return ret;
+
  	return emit_oa_config(stream, oa_context(stream));
  }
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers

In reply to Umesh Nerlige Ramappa
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers
URL : https://patchwork.freedesktop.org/series/68131/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
159038bf586d drm/i915/perf: Add helper macros for comparing with whitelisted registers
-:20: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'addr' - possible side-effects?
#20: FILE: drivers/gpu/drm/i915/i915_perf.c:3517:
+#define ADDR_IN_RANGE(addr, start, end) \
+	((addr) >= (start) && \
+	 (addr) <= (end))

-:24: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'addr' - possible side-effects? #24: FILE: drivers/gpu/drm/i915/i915_perf.c:3521:
+#define REG_IN_RANGE(addr, start, end) \
+ ((addr) >= i915_mmio_reg_offset(start) && \
+ (addr) <= i915_mmio_reg_offset(end))

total: 0 errors, 0 warnings, 2 checks, 98 lines checked
69bf7089b7e7 drm/i915/tgl: Add perf support on TGL
-:723: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #723:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 775 lines checked
b8928d18aecc drm/i915/perf: enable OAR context save/restore of performance counters -:79: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "oa_config" #79: FILE: drivers/gpu/drm/i915/i915_perf.c:2463:
+ ret = gen12_emit_oar_config(stream->pinned_ctx, oa_config != NULL);

total: 0 errors, 0 warnings, 1 checks, 58 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

✗ Fi.CI.SPARSE: warning for series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers

In reply to Umesh Nerlige Ramappa
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers
URL : https://patchwork.freedesktop.org/series/68131/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.6.0
Commit: drm/i915/perf: Add helper macros for comparing with whitelisted registers
Okay!

Commit: drm/i915/tgl: Add perf support on TGL +drivers/gpu/drm/i915/i915_perf.c:2404:85: warning: dubious: x | !y

Commit: drm/i915/perf: enable OAR context save/restore of performance counters Okay!

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v2 1/3
#7 lore raw
In reply to Umesh Nerlige Ramappa
Quoted 4 lines · Umesh Nerlige Ramappa

Add helper macros for range and equality comparisons and use them to check with whitelisted registers in oa configurations.

Looks good :

Quoted 98 lines
---
  drivers/gpu/drm/i915/i915_perf.c | 54 +++++++++++++++++---------------
  1 file changed, 28 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +27 -25
index 54ec1c4190ac..91707558a0f5 100644
@@ -3514,56 +3514,58 @@ static bool gen8_is_valid_flex_addr(struct i915_perf *perf, u32 addr)
  	return false;
  }
 
+#define ADDR_IN_RANGE(addr, start, end) \
+	((addr) >= (start) && \
+	 (addr) <= (end))
+
+#define REG_IN_RANGE(addr, start, end) \
+	((addr) >= i915_mmio_reg_offset(start) && \
+	 (addr) <= i915_mmio_reg_offset(end))
+
+#define REG_EQUAL(addr, mmio) \
+	((addr) == i915_mmio_reg_offset(mmio))
+
  static bool gen7_is_valid_b_counter_addr(struct i915_perf *perf, u32 addr)
  {
-	return (addr >= i915_mmio_reg_offset(OASTARTTRIG1) &&
-		addr <= i915_mmio_reg_offset(OASTARTTRIG8)) ||
-		(addr >= i915_mmio_reg_offset(OAREPORTTRIG1) &&
-		 addr <= i915_mmio_reg_offset(OAREPORTTRIG8)) ||
-		(addr >= i915_mmio_reg_offset(OACEC0_0) &&
-		 addr <= i915_mmio_reg_offset(OACEC7_1));
+	return REG_IN_RANGE(addr, OASTARTTRIG1, OASTARTTRIG8) ||
+	       REG_IN_RANGE(addr, OAREPORTTRIG1, OAREPORTTRIG8) ||
+	       REG_IN_RANGE(addr, OACEC0_0, OACEC7_1);
  }
 
  static bool gen7_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
  {
-	return addr == i915_mmio_reg_offset(HALF_SLICE_CHICKEN2) ||
-		(addr >= i915_mmio_reg_offset(MICRO_BP0_0) &&
-		 addr <= i915_mmio_reg_offset(NOA_WRITE)) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFCNT1_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFCNT2_HI)) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFMATRIX_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFMATRIX_HI));
+	return REG_EQUAL(addr, HALF_SLICE_CHICKEN2) ||
+	       REG_IN_RANGE(addr, MICRO_BP0_0, NOA_WRITE) ||
+	       REG_IN_RANGE(addr, OA_PERFCNT1_LO, OA_PERFCNT2_HI) ||
+	       REG_IN_RANGE(addr, OA_PERFMATRIX_LO, OA_PERFMATRIX_HI);
  }
 
  static bool gen8_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
  {
  	return gen7_is_valid_mux_addr(perf, addr) ||
-		addr == i915_mmio_reg_offset(WAIT_FOR_RC6_EXIT) ||
-		(addr >= i915_mmio_reg_offset(RPM_CONFIG0) &&
-		 addr <= i915_mmio_reg_offset(NOA_CONFIG(8)));
+	       REG_EQUAL(addr, WAIT_FOR_RC6_EXIT) ||
+	       REG_IN_RANGE(addr, RPM_CONFIG0, NOA_CONFIG(8));
  }
 
  static bool gen10_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
  {
  	return gen8_is_valid_mux_addr(perf, addr) ||
-		addr == i915_mmio_reg_offset(GEN10_NOA_WRITE_HIGH) ||
-		(addr >= i915_mmio_reg_offset(OA_PERFCNT3_LO) &&
-		 addr <= i915_mmio_reg_offset(OA_PERFCNT4_HI));
+	       REG_EQUAL(addr, GEN10_NOA_WRITE_HIGH) ||
+	       REG_IN_RANGE(addr, OA_PERFCNT3_LO, OA_PERFCNT4_HI);
  }
 
  static bool hsw_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
  {
  	return gen7_is_valid_mux_addr(perf, addr) ||
-		(addr >= 0x25100 && addr <= 0x2FF90) ||
-		(addr >= i915_mmio_reg_offset(HSW_MBVID2_NOA0) &&
-		 addr <= i915_mmio_reg_offset(HSW_MBVID2_NOA9)) ||
-		addr == i915_mmio_reg_offset(HSW_MBVID2_MISR0);
+	       ADDR_IN_RANGE(addr, 0x25100, 0x2FF90) ||
+	       REG_IN_RANGE(addr, HSW_MBVID2_NOA0, HSW_MBVID2_NOA9) ||
+	       REG_EQUAL(addr, HSW_MBVID2_MISR0);
  }
 
  static bool chv_is_valid_mux_addr(struct i915_perf *perf, u32 addr)
  {
  	return gen7_is_valid_mux_addr(perf, addr) ||
-		(addr >= 0x182300 && addr <= 0x1823A4);
+	       ADDR_IN_RANGE(addr, 0x182300, 0x1823A4);
  }
 
  static u32 mask_reg_value(u32 reg, u32 val)
@@ -3572,14 +3574,14 @@ static u32 mask_reg_value(u32 reg, u32 val)
  	 * WaDisableSTUnitPowerOptimization workaround. Make sure the value
  	 * programmed by userspace doesn't change this.
  	 */
-	if (i915_mmio_reg_offset(HALF_SLICE_CHICKEN2) == reg)
+	if (REG_EQUAL(reg, HALF_SLICE_CHICKEN2))
  		val = val & ~_MASKED_BIT_ENABLE(GEN8_ST_PO_DISABLE);

drivers/gpu/drm/i915/i915_perf.c static u32 mask_reg_value(u32 reg, u32 val) · line 3587

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +1 -1
 
  	/* WAIT_FOR_RC6_EXIT has only one bit fullfilling the function
  	 * indicated by its name and a bunch of selection fields used by OA
  	 * configs.
  	 */
-	if (i915_mmio_reg_offset(WAIT_FOR_RC6_EXIT) == reg)
+	if (REG_EQUAL(reg, WAIT_FOR_RC6_EXIT))
  		val = val & ~_MASKED_BIT_ENABLE(HSW_WAIT_FOR_RC6_EXIT_ENABLE);
 
  	return val;

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

✗ Fi.CI.BAT: failure for series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers

In reply to Umesh Nerlige Ramappa
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/3] drm/i915/perf: Add helper macros for comparing with whitelisted registers
URL : https://patchwork.freedesktop.org/series/68131/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7114 -> Patchwork_14851
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_14851 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_14851, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_14851:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live_execlists:
- fi-icl-u2: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-icl-u2/igt@i915_selftest@live_execlists.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-icl-u2/igt@i915_selftest@live_execlists.html
- fi-kbl-7500u: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-kbl-7500u/igt@i915_selftest@live_execlists.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-kbl-7500u/igt@i915_selftest@live_execlists.html
- fi-skl-6260u: [PASS][5] -> [DMESG-FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-skl-6260u/igt@i915_selftest@live_execlists.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-skl-6260u/igt@i915_selftest@live_execlists.html

* igt@i915_selftest@live_gem_contexts:
- fi-cfl-8109u: [PASS][7] -> [DMESG-FAIL][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-cfl-8109u/igt@i915_selftest@live_gem_contexts.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-cfl-8109u/igt@i915_selftest@live_gem_contexts.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@debugfs_test@read_all_entries:
- {fi-tgl-u}: [PASS][9] -> [INCOMPLETE][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-tgl-u/igt@debugfs_test@read_all_entries.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-tgl-u/igt@debugfs_test@read_all_entries.html

Known issues
------------

Here are the changes found in Patchwork_14851 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_hangcheck:
- fi-bsw-n3050: [PASS][11] -> [INCOMPLETE][12] ([fdo#105876])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-bsw-n3050/igt@i915_selftest@live_hangcheck.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-bsw-n3050/igt@i915_selftest@live_hangcheck.html

* igt@i915_selftest@live_sanitycheck:
- fi-icl-u3: [PASS][13] -> [DMESG-WARN][14] ([fdo#107724])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-icl-u3/igt@i915_selftest@live_sanitycheck.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-icl-u3/igt@i915_selftest@live_sanitycheck.html

* igt@kms_busy@basic-flip-b:
- fi-cfl-guc: [PASS][15] -> [DMESG-WARN][16] ([fdo#106107])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-cfl-guc/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-cfl-guc/igt@[email protected]

#### Possible fixes ####

* igt@gem_basic@bad-close:
- fi-icl-u3: [DMESG-WARN][17] ([fdo#107724]) -> [PASS][18] +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-icl-u3/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-icl-u3/igt@[email protected]

* igt@gem_ctx_create@basic-files:
- fi-bdw-gvtdvm: [DMESG-WARN][19] -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-bdw-gvtdvm/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-bdw-gvtdvm/igt@[email protected]

* igt@i915_selftest@live_execlists:
- fi-cfl-guc: [DMESG-FAIL][21] -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-cfl-guc/igt@i915_selftest@live_execlists.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-cfl-guc/igt@i915_selftest@live_execlists.html
- fi-cml-u: [DMESG-FAIL][23] -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-cml-u/igt@i915_selftest@live_execlists.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-cml-u/igt@i915_selftest@live_execlists.html
- fi-whl-u: [INCOMPLETE][25] -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-whl-u/igt@i915_selftest@live_execlists.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-whl-u/igt@i915_selftest@live_execlists.html

* igt@i915_selftest@live_gtt:
- {fi-icl-guc}: [INCOMPLETE][27] ([fdo#107713]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-icl-guc/igt@i915_selftest@live_gtt.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-icl-guc/igt@i915_selftest@live_gtt.html

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][29] ([fdo#111407]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7114/fi-kbl-7500u/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/fi-kbl-7500u/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102505]: https://bugs.freedesktop.org/show_bug.cgi?id=102505
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105876]: https://bugs.freedesktop.org/show_bug.cgi?id=105876
[fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
[fdo#111049]: https://bugs.freedesktop.org/show_bug.cgi?id=111049
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
[fdo#111747]: https://bugs.freedesktop.org/show_bug.cgi?id=111747

Participating hosts (52 -> 46)
------------------------------

Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-icl-y fi-byt-clapper fi-bdw-samus

Build changes
-------------

* CI: CI-20190529 -> None
* Linux: CI_DRM_7114 -> Patchwork_14851

CI-20190529: 20190529
CI_DRM_7114: d9e909272a022597067d3ac2dfcedacd63c61af9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5231: e293051f8f99c72cb01d21e4b73a5928ea351eb3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14851: b8928d18aecc4ebc1d0e48246dabfa3bc23bfd94 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

b8928d18aecc drm/i915/perf: enable OAR context save/restore of performance counters 69bf7089b7e7 drm/i915/tgl: Add perf support on TGL
159038bf586d drm/i915/perf: Add helper macros for comparing with whitelisted registers

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14851/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx