Skip to contentSkip to conversation

Enable i915 perf stream for Haswell OA unit

PATCH In review Robert Bragg 5 participants 32 messages Nov 7, 2016 – Nov 22, 2016

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

v9 cover Enable i915 perf stream for Haswell OA unit

Rebased and updated with more feedback from Sourab and Matt.

In particular the patch that added the oa_min_timer_exponent sysctl parameter has now been replaced with one adding an oa_max_sample_rate parameter in Hz.

This way userspace policy won't need to be tailored to different systems when gen9 OA is enabled where the exponents don't represent the same periods as for Haswell.

- Robert

Robert Bragg (11):
drm/i915: Add i915 perf infrastructure
drm/i915: rename OACONTROL GEN7_OACONTROL drm/i915: return EACCES for check_cmd() failures drm/i915: don't whitelist oacontrol in cmd parser drm/i915: Add 'render basic' Haswell OA unit config drm/i915: Enable i915 perf stream for Haswell OA unit drm/i915: advertise available metrics via sysfs drm/i915: Add dev.i915.perf_stream_paranoid sysctl option drm/i915: add dev.i915.oa_max_sample_rate sysctl drm/i915: Add more Haswell OA metric sets drm/i915: Add a kerneldoc summary for i915_perf.c

 drivers/gpu/drm/i915/Makefile          |    4 +
 drivers/gpu/drm/i915/gvt/handlers.c    |    2 +-
 drivers/gpu/drm/i915/i915_cmd_parser.c |   45 +-
 drivers/gpu/drm/i915/i915_drv.c        |    9 +
 drivers/gpu/drm/i915/i915_drv.h        |  156 +++
 drivers/gpu/drm/i915/i915_oa_hsw.c     |  752 ++++++++++++++
 drivers/gpu/drm/i915/i915_oa_hsw.h     |   38 +
 drivers/gpu/drm/i915/i915_perf.c       | 1753 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h        |  340 ++++++-
 include/uapi/drm/i915_drm.h            |  134 +++
 10 files changed, 3193 insertions(+), 40 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_oa_hsw.c
 create mode 100644 drivers/gpu/drm/i915/i915_oa_hsw.h
 create mode 100644 drivers/gpu/drm/i915/i915_perf.c
Signature · 6 lines
2.10.1

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

PATCH v9 1/11 drm/i915: Add i915 perf infrastructure

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of uint64 properties to configure a stream of metrics and returns a new fd usable with standard VFS system calls including read() to read typed and sized records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,

};
int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris Wilson fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

---
 drivers/gpu/drm/i915/Makefile    |   3 +
 drivers/gpu/drm/i915/i915_drv.c  |   4 +
 drivers/gpu/drm/i915/i915_drv.h  |  91 ++++++++
 drivers/gpu/drm/i915/i915_perf.c | 449 +++++++++++++++++++++++++++++++++++++++
 include/uapi/drm/i915_drm.h      |  67 ++++++
 5 files changed, 614 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/i915_perf.c
drivers/gpu/drm/i915/Makefile +3 -0
index 0857e50..08b43af 100644
@@ -116,6 +116,9 @@ i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
 # virtual gpu code
 i915-y += i915_vgpu.o
 
+# perf code
+i915-y += i915_perf.o
+
 ifeq ($(CONFIG_DRM_I915_GVT),y)
 i915-y += intel_gvt.o
 include $(src)/gvt/Makefile
drivers/gpu/drm/i915/i915_drv.c +4 -0
index 0213a30..22b4166 100644
@@ -844,6 +844,8 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
 
 	intel_detect_preproduction_hw(dev_priv);
 
+	i915_perf_init(dev_priv);
+
 	return 0;
 
 err_gvt:
@@ -859,6 +861,7 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
  */
 static void i915_driver_cleanup_early(struct drm_i915_private *dev_priv)
 {
+	i915_perf_fini(dev_priv);
 	i915_gem_load_cleanup(&dev_priv->drm);
 	i915_workqueues_cleanup(dev_priv);
 }
@@ -2561,6 +2564,7 @@ static const struct drm_ioctl_desc i915_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_GETPARAM, i915_gem_context_getparam_ioctl, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_SETPARAM, i915_gem_context_setparam_ioctl, DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(I915_PERF_OPEN, i915_perf_open_ioctl, DRM_RENDER_ALLOW),
 };
 
 static struct drm_driver driver = {
drivers/gpu/drm/i915/i915_drv.h +91 -0

115 lines not on this page · raw message

drivers/gpu/drm/i915/i915_perf.c new file +449 -0

449 lines not on this page · raw message

include/uapi/drm/i915_drm.h +67 -0

85 lines not on this page · raw message

Signature · 6 lines
2.10.1

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

Re: [PATCH v9 01/11] drm/i915: Add i915 perf infrastructure

Quoted 48 lines · Robert Bragg

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of uint64 properties to configure a stream of metrics and returns a new fd usable with standard VFS system calls including read() to read typed and sized records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,
   };
   int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris Wilson fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

Quoted 3 lines

Minor nit, there are a fair few DRM_ERROR's missing a new line.
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [Intel-gfx] [PATCH v9 01/11] drm/i915: Add i915 perf infrastructure

Quoted 49 lines · Matthew Auld
Quoted 48 lines · Robert Bragg

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of uint64 properties to configure a stream of metrics and returns a new fd usable with standard VFS system calls including read() to read typed and sized records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,
   };
   int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris Wilson fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

Quoted 4 lines
Quoted 3 lines

Minor nit, there are a fair few DRM_ERROR's missing a new line.

Also, DRM_ERROR for userspace-triggerable failures is no good. igt testcase are supposed to exercise all the invalid stuff, and would then fail if you spam dmesg. Why was this not caught?

Fixup patch totally fine, but if this wasn't caught due to missing igt that needs to be fixed, too.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH v9 01/11] drm/i915: Add i915 perf infrastructure

Quoted 53 lines · Daniel Vetter
Quoted 52 lines · Matthew Auld
Quoted 51 lines · Robert Bragg

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of uint64 properties to configure a stream of metrics and returns a new fd usable with standard VFS system calls including read() to read typed and sized records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,
   };
   int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris Wilson fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

Quoted 8 lines
Quoted 1 line

Minor nit, there are a fair few DRM_ERROR's missing a new line.

Also, DRM_ERROR for userspace-triggerable failures is no good. igt testcase are supposed to exercise all the invalid stuff, and would then fail if you spam dmesg. Why was this not caught?

Fixup patch totally fine, but if this wasn't caught due to missing igt that needs to be fixed, too.

Another nitpick for the future: Enabling new features first and then fixing up the fallout is the wrong way round, if someone bisects over this range mesa might blow up in really bad ways.

Oh well, this has been out there for way too long, so meh. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [Intel-gfx] [PATCH v9 01/11] drm/i915: Add i915 perf infrastructure

Quoted 65 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter
Quoted 1 line · Matthew Auld

On 7 November 2016 at 19:49, Robert Bragg <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of

uint64

Quoted 1 line
Quoted 1 line
Quoted 1 line

properties to configure a stream of metrics and returns a new fd

usable

Quoted 1 line
Quoted 1 line
Quoted 1 line

with standard VFS system calls including read() to read typed and

sized

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,
   };
   int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris

Wilson

Quoted 13 lines
Quoted 8 lines
Quoted 7 lines

fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

Minor nit, there are a fair few DRM_ERROR's missing a new line.

Also, DRM_ERROR for userspace-triggerable failures is no good. igt testcase are supposed to exercise all the invalid stuff, and would then fail if you spam dmesg. Why was this not caught?

Quoted 9 lines
Quoted 2 lines

Fixup patch totally fine, but if this wasn't caught due to missing igt that needs to be fixed, too.

Another nitpick for the future: Enabling new features first and then fixing up the fallout is the wrong way round, if someone bisects over this range mesa might blow up in really bad ways.

Oh well, this has been out there for way too long, so meh.

Fwiw I'm aware of this, and think I've ordered the patches correctly to avoid bisect problems in Mesa / userspace. This infrastructure patch should have no fallout to fix for userspace. The command parser changes that affect userspace were done before adding oacontrol usage to i915-perf and the cmd parser's EINVAL reporting for access failures was changed *before* removing oacontrol from the whitelist.

Did I overlook something in particular?

- Robert

Quoted 6 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v9 01/11] drm/i915: Add i915 perf infrastructure

Quoted 77 lines · Robert Bragg
Quoted 65 lines · Daniel Vetter
Quoted 2 lines · Daniel Vetter
Quoted 1 line · Matthew Auld

On 7 November 2016 at 19:49, Robert Bragg <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines

Adds base i915 perf infrastructure for Gen performance metrics.

This adds a DRM_IOCTL_I915_PERF_OPEN ioctl that takes an array of

uint64

Quoted 1 line
Quoted 1 line
Quoted 1 line

properties to configure a stream of metrics and returns a new fd

usable

Quoted 1 line
Quoted 1 line
Quoted 1 line

with standard VFS system calls including read() to read typed and

sized

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

records; ioctl() to enable or disable capture and poll() to wait for data.

A stream is opened something like:

  uint64_t properties[] = {
      /* Single context sampling */
      DRM_I915_PERF_PROP_CTX_HANDLE,        ctx_handle,
      /* Include OA reports in samples */
      DRM_I915_PERF_PROP_SAMPLE_OA,         true,

      /* OA unit configuration */
      DRM_I915_PERF_PROP_OA_METRICS_SET,    metrics_set_id,
      DRM_I915_PERF_PROP_OA_FORMAT,         report_format,
      DRM_I915_PERF_PROP_OA_EXPONENT,       period_exponent,
   };
   struct drm_i915_perf_open_param parm = {
      .flags = I915_PERF_FLAG_FD_CLOEXEC |
               I915_PERF_FLAG_FD_NONBLOCK |
               I915_PERF_FLAG_DISABLED,
      .properties_ptr = (uint64_t)properties,
      .num_properties = sizeof(properties) / 16,
   };
   int fd = drmIoctl(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param);

Records read all start with a common { type, size } header with DRM_I915_PERF_RECORD_SAMPLE being of most interest. Sample records contain an extensible number of fields and it's the DRM_I915_PERF_PROP_SAMPLE_xyz properties given when opening that determine what's included in every sample.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

No specific streams are supported yet so any attempt to open a stream will return an error.

v2:
use i915_gem_context_get() - Chris Wilson
v3:
update read() interface to avoid passing state struct - Chris

Wilson

Quoted 13 lines
Quoted 8 lines
Quoted 7 lines

fix some rebase fallout, with i915-perf init/deinit
v4:
s/DRM_IORW/DRM_IOW/ - Emil Velikov

Minor nit, there are a fair few DRM_ERROR's missing a new line.

Also, DRM_ERROR for userspace-triggerable failures is no good. igt testcase are supposed to exercise all the invalid stuff, and would then fail if you spam dmesg. Why was this not caught?

Quoted 9 lines
Quoted 2 lines

Fixup patch totally fine, but if this wasn't caught due to missing igt that needs to be fixed, too.

Another nitpick for the future: Enabling new features first and then fixing up the fallout is the wrong way round, if someone bisects over this range mesa might blow up in really bad ways.

Oh well, this has been out there for way too long, so meh.

Quoted 8 lines

Fwiw I'm aware of this, and think I've ordered the patches correctly to avoid bisect problems in Mesa / userspace. This infrastructure patch should have no fallout to fix for userspace. The command parser changes that affect userspace were done before adding oacontrol usage to i915-perf and the cmd parser's EINVAL reporting for access failures was changed *before* removing oacontrol from the whitelist.

Did I overlook something in particular?

Ah, if you key the userspace side off the cmd parser change then I think it should be all fine. I only looked at this ioctl here, and that alone looked like it was unsafe. Ordering of the patches later on seemed correct indeed.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH v9 2/11 drm/i915: rename OACONTROL GEN7_OACONTROL

In reply to Robert Bragg

OACONTROL changes quite a bit for gen8, with some bits split out into a per-context OACTXCONTROL register. Rename now before adding more gen7 OA registers

---
 drivers/gpu/drm/i915/gvt/handlers.c    | 2 +-
 drivers/gpu/drm/i915/i915_cmd_parser.c | 4 ++--
 drivers/gpu/drm/i915/i915_reg.h        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gvt/handlers.c +1 -1
index 9ab1f95..4527cb7 100644
@@ -2177,7 +2177,7 @@ static int init_generic_mmio_info(struct intel_gvt *gvt)
 	MMIO_DFH(0x1217c, D_ALL, F_CMD_ACCESS, NULL, NULL);
 
 	MMIO_F(0x2290, 8, 0, 0, 0, D_HSW_PLUS, NULL, NULL);
-	MMIO_D(OACONTROL, D_HSW);
+	MMIO_D(GEN7_OACONTROL, D_HSW);
 	MMIO_D(0x2b00, D_BDW_PLUS);
 	MMIO_D(0x2360, D_BDW_PLUS);
 	MMIO_F(0x5200, 32, 0, 0, 0, D_ALL, NULL, NULL);
drivers/gpu/drm/i915/i915_cmd_parser.c +2 -2
index f5039f4..7719aed 100644
@@ -450,7 +450,7 @@ static const struct drm_i915_reg_descriptor gen7_render_regs[] = {
 	REG64(PS_INVOCATION_COUNT),
 	REG64(PS_DEPTH_COUNT),
 	REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-	REG32(OACONTROL), /* Only allowed for LRI and SRM. See below. */
+	REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below. */
 	REG64(MI_PREDICATE_SRC0),
 	REG64(MI_PREDICATE_SRC1),
 	REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1108,7 +1108,7 @@ static bool check_cmd(const struct intel_engine_cs *engine,
 			 * to the register. Hence, limit OACONTROL writes to
 			 * only MI_LOAD_REGISTER_IMM commands.
 			 */
-			if (reg_addr == i915_mmio_reg_offset(OACONTROL)) {
+			if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL)) {
 				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
 					DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");
 					return false;
drivers/gpu/drm/i915/i915_reg.h +1 -1
index 3361d7f..4623dbb 100644
@@ -615,7 +615,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define HSW_CS_GPR(n)                   _MMIO(0x2600 + (n) * 8)
 #define HSW_CS_GPR_UDW(n)               _MMIO(0x2600 + (n) * 8 + 4)
 
-#define OACONTROL _MMIO(0x2360)
+#define GEN7_OACONTROL _MMIO(0x2360)
 
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
Signature · 6 lines
2.10.1

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

PATCH v9 3/11 drm/i915: return EACCES for check_cmd() failures

In reply to Robert Bragg

check_cmd() is checking whether a command adheres to certain restrictions that ensure it's safe to execute within a privileged batch buffer. Returning false implies a privilege problem, not that the command is invalid.

The distinction makes the difference between allowing the buffer to be executed as an unprivileged batch buffer or returning an EINVAL error to userspace without executing anything.

In a case where userspace may want to test whether it can successfully write to a register that needs privileges the distinction may be important and an EINVAL error may be considered fatal.

In particular this is currently true for Mesa, which includes a test for whether OACONTROL can be written too, but Mesa treats any error when flushing a batch buffer as fatal, calling exit(1).

As it is currently Mesa can gracefully handle a failure to write to OACONTROL if the command parser is disabled, but if we were to remove OACONTROL from the parser's whitelist then the returned EINVAL would break Mesa applications as they attempt an OACONTROL write.

This bumps the command parser version from 7 to 8, as the change is visible to userspace.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +5 -2
index 7719aed..c9d2ecd 100644
@@ -1272,7 +1272,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 
 		if (!check_cmd(engine, desc, cmd, length, is_master,
 			       &oacontrol_set)) {
-			ret = -EINVAL;
+			ret = -EACCES;
 			break;
 		}
 
@@ -1333,6 +1333,9 @@ int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv)
 	 * 5. GPGPU dispatch compute indirect registers.
 	 * 6. TIMESTAMP register and Haswell CS GPR registers
 	 * 7. Allow MI_LOAD_REGISTER_REG between whitelisted registers.
+	 * 8. Don't report cmd_check() failures as EINVAL errors to userspace;
+	 *    rely on the HW to NOOP disallowed commands as it would without
+	 *    the parser enabled.
 	 */
-	return 7;
+	return 8;
 }
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH v9 4/11 drm/i915: don't whitelist oacontrol in cmd parser

In reply to Robert Bragg

Being able to program OACONTROL from a non-privileged batch buffer is not sufficient to be able to configure the OA unit. This was originally allowed to help enable Mesa to expose OA counters via the INTEL_performance_query extension, but the current implementation based on programming OACONTROL via a batch buffer isn't able to report useable data without a more complete OA unit configuration. Mesa handles the possibility that writes to OACONTROL may not be allowed and so only advertises the extension after explicitly testing that a write to OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist should be ok for userspace.

Removing this simplifies adding a new kernel api for configuring the OA unit without needing to consider the possibility that userspace might trample on OACONTROL state which we'd like to start managing within the kernel instead. In particular running any Mesa based GL application currently results in clearing OACONTROL when initializing which would disable the capturing of metrics.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 38 ++--------------------------------
 1 file changed, 2 insertions(+), 36 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +2 -36
index c9d2ecd..f3453dc 100644
@@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor gen7_render_regs[] = {
 	REG64(PS_INVOCATION_COUNT),
 	REG64(PS_DEPTH_COUNT),
 	REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-	REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below. */
 	REG64(MI_PREDICATE_SRC0),
 	REG64(MI_PREDICATE_SRC1),
 	REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine)
 static bool check_cmd(const struct intel_engine_cs *engine,
 		      const struct drm_i915_cmd_descriptor *desc,
 		      const u32 *cmd, u32 length,
-		      const bool is_master,
-		      bool *oacontrol_set)
+		      const bool is_master)
 {
 	if (desc->flags & CMD_DESC_SKIP)
 		return true;
@@ -1099,31 +1097,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
 			}
 
 			/*
-			 * OACONTROL requires some special handling for
-			 * writes. We want to make sure that any batch which
-			 * enables OA also disables it before the end of the
-			 * batch. The goal is to prevent one process from
-			 * snooping on the perf data from another process. To do
-			 * that, we need to check the value that will be written
-			 * to the register. Hence, limit OACONTROL writes to
-			 * only MI_LOAD_REGISTER_IMM commands.
-			 */
-			if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL)) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRR to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1))
-					*oacontrol_set = (cmd[offset + 1] != 0);
-			}
-
-			/*
 			 * Check the value written to the register against the
 			 * allowed mask/value pair given in the whitelist entry.
 			 */
@@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 	u32 *cmd, *batch_end;
 	struct drm_i915_cmd_descriptor default_desc = noop_desc;
 	const struct drm_i915_cmd_descriptor *desc = &default_desc;
-	bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd() */
 	bool needs_clflush_after = false;
 	int ret = 0;
 
@@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 			break;
 		}
 
-		if (!check_cmd(engine, desc, cmd, length, is_master,
-			       &oacontrol_set)) {
+		if (!check_cmd(engine, desc, cmd, length, is_master)) {
 			ret = -EACCES;
 			break;
 		}
@@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 		cmd += length;
 	}
 
-	if (oacontrol_set) {
-		DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n");
-		ret = -EINVAL;
-	}
-
 	if (cmd >= batch_end) {
 		DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a BBE cmd!\n");
 		ret = -EINVAL;
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH v2 1/1 drm/i915: don't whitelist oacontrol in cmd parser

This v2 patch bumps the command parser version so it can be referenced in corresponding i-g-t gem_exec_parse changes.

--- >8 ---

Being able to program OACONTROL from a non-privileged batch buffer is not sufficient to be able to configure the OA unit. This was originally allowed to help enable Mesa to expose OA counters via the INTEL_performance_query extension, but the current implementation based on programming OACONTROL via a batch buffer isn't able to report useable data without a more complete OA unit configuration. Mesa handles the possibility that writes to OACONTROL may not be allowed and so only advertises the extension after explicitly testing that a write to OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist should be ok for userspace.

Removing this simplifies adding a new kernel api for configuring the OA unit without needing to consider the possibility that userspace might trample on OACONTROL state which we'd like to start managing within the kernel instead. In particular running any Mesa based GL application currently results in clearing OACONTROL when initializing which would disable the capturing of metrics.

v2:
This bumps the command parser version from 8 to 9, as the change is visible to userspace.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 42 ++++------------------------------
 1 file changed, 5 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +5 -37
index c9d2ecd..f5762cd 100644
@@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor gen7_render_regs[] = {
 	REG64(PS_INVOCATION_COUNT),
 	REG64(PS_DEPTH_COUNT),
 	REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-	REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below. */
 	REG64(MI_PREDICATE_SRC0),
 	REG64(MI_PREDICATE_SRC1),
 	REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine)
 static bool check_cmd(const struct intel_engine_cs *engine,
 		      const struct drm_i915_cmd_descriptor *desc,
 		      const u32 *cmd, u32 length,
-		      const bool is_master,
-		      bool *oacontrol_set)
+		      const bool is_master)
 {
 	if (desc->flags & CMD_DESC_SKIP)
 		return true;
@@ -1099,31 +1097,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
 			}
 
 			/*
-			 * OACONTROL requires some special handling for
-			 * writes. We want to make sure that any batch which
-			 * enables OA also disables it before the end of the
-			 * batch. The goal is to prevent one process from
-			 * snooping on the perf data from another process. To do
-			 * that, we need to check the value that will be written
-			 * to the register. Hence, limit OACONTROL writes to
-			 * only MI_LOAD_REGISTER_IMM commands.
-			 */
-			if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL)) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRR to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1))
-					*oacontrol_set = (cmd[offset + 1] != 0);
-			}
-
-			/*
 			 * Check the value written to the register against the
 			 * allowed mask/value pair given in the whitelist entry.
 			 */
@@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 	u32 *cmd, *batch_end;
 	struct drm_i915_cmd_descriptor default_desc = noop_desc;
 	const struct drm_i915_cmd_descriptor *desc = &default_desc;
-	bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd() */
 	bool needs_clflush_after = false;
 	int ret = 0;
 
@@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 			break;
 		}
 
-		if (!check_cmd(engine, desc, cmd, length, is_master,
-			       &oacontrol_set)) {
+		if (!check_cmd(engine, desc, cmd, length, is_master)) {
 			ret = -EACCES;
 			break;
 		}
@@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 		cmd += length;
 	}
 
-	if (oacontrol_set) {
-		DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n");
-		ret = -EINVAL;
-	}
-
 	if (cmd >= batch_end) {
 		DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a BBE cmd!\n");
 		ret = -EINVAL;
@@ -1336,6 +1302,8 @@ int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv)
 	 * 8. Don't report cmd_check() failures as EINVAL errors to userspace;
 	 *    rely on the HW to NOOP disallowed commands as it would without
 	 *    the parser enabled.
+	 * 9. Don't whitelist or handle oacontrol specially, as ownership
+	 *    for oacontrol state is moving to i915-perf.
 	 */
-	return 8;
+	return 9;
 }
Signature · 6 lines
2.10.1

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

Re: [Intel-gfx] [PATCH v2] drm/i915: don't whitelist oacontrol in cmd parser

Quoted 4 lines · Robert Bragg

This v2 patch bumps the command parser version so it can be referenced in corresponding i-g-t gem_exec_parse changes.

--- >8 ---

Scissors cut everything below, not everything above, hence next time around pls switch around your comment and the commit message, as-is not much left ;-)

Fixed up while applying.
-Daniel

Quoted 131 lines

Being able to program OACONTROL from a non-privileged batch buffer is not sufficient to be able to configure the OA unit. This was originally allowed to help enable Mesa to expose OA counters via the INTEL_performance_query extension, but the current implementation based on programming OACONTROL via a batch buffer isn't able to report useable data without a more complete OA unit configuration. Mesa handles the possibility that writes to OACONTROL may not be allowed and so only advertises the extension after explicitly testing that a write to OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist should be ok for userspace.

Removing this simplifies adding a new kernel api for configuring the OA unit without needing to consider the possibility that userspace might trample on OACONTROL state which we'd like to start managing within the kernel instead. In particular running any Mesa based GL application currently results in clearing OACONTROL when initializing which would disable the capturing of metrics.

v2:
This bumps the command parser version from 8 to 9, as the change is visible to userspace.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 42 ++++------------------------------
 1 file changed, 5 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +5 -37
index c9d2ecd..f5762cd 100644
@@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor gen7_render_regs[] = {
 	REG64(PS_INVOCATION_COUNT),
 	REG64(PS_DEPTH_COUNT),
 	REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-	REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below. */
 	REG64(MI_PREDICATE_SRC0),
 	REG64(MI_PREDICATE_SRC1),
 	REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine)
 static bool check_cmd(const struct intel_engine_cs *engine,
 		      const struct drm_i915_cmd_descriptor *desc,
 		      const u32 *cmd, u32 length,
-		      const bool is_master,
-		      bool *oacontrol_set)
+		      const bool is_master)
 {
 	if (desc->flags & CMD_DESC_SKIP)
 		return true;
@@ -1099,31 +1097,6 @@ static bool check_cmd(const struct intel_engine_cs *engine,
 			}
 
 			/*
-			 * OACONTROL requires some special handling for
-			 * writes. We want to make sure that any batch which
-			 * enables OA also disables it before the end of the
-			 * batch. The goal is to prevent one process from
-			 * snooping on the perf data from another process. To do
-			 * that, we need to check the value that will be written
-			 * to the register. Hence, limit OACONTROL writes to
-			 * only MI_LOAD_REGISTER_IMM commands.
-			 */
-			if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL)) {
-				if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRM to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
-					DRM_DEBUG_DRIVER("CMD: Rejected LRR to OACONTROL\n");
-					return false;
-				}
-
-				if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1))
-					*oacontrol_set = (cmd[offset + 1] != 0);
-			}
-
-			/*
 			 * Check the value written to the register against the
 			 * allowed mask/value pair given in the whitelist entry.
 			 */
@@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 	u32 *cmd, *batch_end;
 	struct drm_i915_cmd_descriptor default_desc = noop_desc;
 	const struct drm_i915_cmd_descriptor *desc = &default_desc;
-	bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd() */
 	bool needs_clflush_after = false;
 	int ret = 0;
 
@@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 			break;
 		}
 
-		if (!check_cmd(engine, desc, cmd, length, is_master,
-			       &oacontrol_set)) {
+		if (!check_cmd(engine, desc, cmd, length, is_master)) {
 			ret = -EACCES;
 			break;
 		}
@@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 		cmd += length;
 	}
 
-	if (oacontrol_set) {
-		DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not clear it\n");
-		ret = -EINVAL;
-	}
-
 	if (cmd >= batch_end) {
 		DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a BBE cmd!\n");
 		ret = -EINVAL;
@@ -1336,6 +1302,8 @@ int i915_cmd_parser_get_version(struct drm_i915_private *dev_priv)
 	 * 8. Don't report cmd_check() failures as EINVAL errors to userspace;
 	 *    rely on the HW to NOOP disallowed commands as it would without
 	 *    the parser enabled.
+	 * 9. Don't whitelist or handle oacontrol specially, as ownership
+	 *    for oacontrol state is moving to i915-perf.
 	 */
-	return 8;
+	return 9;
 }
Signature · 6 lines
2.10.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

Re: [PATCH v2] drm/i915: don't whitelist oacontrol in cmd parser

Quoted 10 lines · Daniel Vetter
Quoted 4 lines · Robert Bragg

This v2 patch bumps the command parser version so it can be referenced in corresponding i-g-t gem_exec_parse changes.

--- >8 ---

Scissors cut everything below, not everything above, hence next time around pls switch around your comment and the commit message, as-is not much left ;-)

Hmm, they cut away what's above and keep what's below in my experience - what command are you seeing the opposite with?

I just double checked this with git am --scissors

- Robert

Quoted 165 lines

Fixed up while applying.
-Daniel

Quoted 23 lines

Being able to program OACONTROL from a non-privileged batch buffer is not sufficient to be able to configure the OA unit. This was originally allowed to help enable Mesa to expose OA counters via the INTEL_performance_query extension, but the current implementation based on programming OACONTROL via a batch buffer isn't able to report useable data without a more complete OA unit configuration. Mesa handles the possibility that writes to OACONTROL may not be allowed and so only advertises the extension after explicitly testing that a write to OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist should be ok for userspace.

Removing this simplifies adding a new kernel api for configuring the OA unit without needing to consider the possibility that userspace might trample on OACONTROL state which we'd like to start managing within the kernel instead. In particular running any Mesa based GL application currently results in clearing OACONTROL when initializing which would disable the capturing of metrics.

v2:
This bumps the command parser version from 8 to 9, as the change is visible to userspace.

Quoted 5 lines
---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 42

++++------------------------------

Review

Quoted 3 lines
 1 file changed, 5 insertions(+), 37 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_cmd_parser.c

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_reg_descriptor

Quoted 4 lines

index c9d2ecd..f5762cd 100644

drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
@@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor

gen7_render_regs[] = {

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_reg_descriptor gen7_render_regs[] = {

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
      REG64(PS_INVOCATION_COUNT),
      REG64(PS_DEPTH_COUNT),
      REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-     REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below.

*/

drivers/gpu/drm/i915/i915_cmd_parser.c bool intel_engine_needs_cmd_parser(struct

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
      REG64(MI_PREDICATE_SRC0),
      REG64(MI_PREDICATE_SRC1),
      REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(struct

intel_engine_cs *engine)

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -2
 static bool check_cmd(const struct intel_engine_cs *engine,
                    const struct drm_i915_cmd_descriptor *desc,
                    const u32 *cmd, u32 length,
-                   const bool is_master,
-                   bool *oacontrol_set)
+                   const bool is_master)
 {
      if (desc->flags & CMD_DESC_SKIP)
              return true;
@@ -1099,31 +1097,6 @@ static bool check_cmd(const struct

intel_engine_cs *engine,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
                      }
 
                      /*
-                      * OACONTROL requires some special handling for
-                      * writes. We want to make sure that any batch

which

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1104

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * enables OA also disables it before the end of

the

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1106

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
-                      * batch. The goal is to prevent one process from
-                      * snooping on the perf data from another process.

To do

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1107

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * that, we need to check the value that will be

written

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1108

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * to the register. Hence, limit OACONTROL writes

to

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 3 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-                      * only MI_LOAD_REGISTER_IMM commands.
-                      */
-                     if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL))

{

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1112

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_MEM) {

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1113

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     DRM_DEBUG_DRIVER("CMD: Rejected

LRM to OACONTROL\n");

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -4
-                                     return false;
-                             }
-
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_REG) {

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1118

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     DRM_DEBUG_DRIVER("CMD: Rejected

LRR to OACONTROL\n");

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -4
-                                     return false;
-                             }
-
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_IMM(1))

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1123

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     *oacontrol_set = (cmd[offset + 1]

!= 0);

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-                     }
-
-                     /*
                       * Check the value written to the register against

the

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1101

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
                       * allowed mask/value pair given in the whitelist

entry.

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
                       */
@@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs

*engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
      u32 *cmd, *batch_end;
      struct drm_i915_cmd_descriptor default_desc = noop_desc;
      const struct drm_i915_cmd_descriptor *desc = &default_desc;
-     bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd()

*/

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
      bool needs_clflush_after = false;
      int ret = 0;
 
@@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs

*engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -2
                      break;
              }
 
-             if (!check_cmd(engine, desc, cmd, length, is_master,
-                            &oacontrol_set)) {
+             if (!check_cmd(engine, desc, cmd, length, is_master)) {
                      ret = -EACCES;
                      break;
              }
@@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct

intel_engine_cs *engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
              cmd += length;
      }
 
-     if (oacontrol_set) {
-             DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not

clear it\n");

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-             ret = -EINVAL;
-     }
-
      if (cmd >= batch_end) {
              DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a

BBE cmd!\n");

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
              ret = -EINVAL;
@@ -1336,6 +1302,8 @@ int i915_cmd_parser_get_version(struct

drm_i915_private *dev_priv)

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct · line 1302

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
       * 8. Don't report cmd_check() failures as EINVAL errors to

userspace;

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct · line 1303

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
       *    rely on the HW to NOOP disallowed commands as it would

without

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +3 -2
       *    the parser enabled.
+      * 9. Don't whitelist or handle oacontrol specially, as ownership
+      *    for oacontrol state is moving to i915-perf.
       */
-     return 8;
+     return 9;
 }
--

2.10.1

Quoted 4 lines

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

Quoted 5 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

#13 lore raw

Re: [PATCH v2] drm/i915: don't whitelist oacontrol in cmd parser

Quoted 13 lines · Robert Bragg
Quoted 10 lines · Daniel Vetter
Quoted 4 lines · Robert Bragg

This v2 patch bumps the command parser version so it can be referenced in corresponding i-g-t gem_exec_parse changes.

--- >8 ---

Scissors cut everything below, not everything above, hence next time around pls switch around your comment and the commit message, as-is not much left ;-)

Quoted 4 lines

Hmm, they cut away what's above and keep what's below in my experience - what command are you seeing the opposite with?

I just double checked this with git am --scissors

Plain git am works the other way round, that's why I never noticed there's a special option. TIL ;-)
-Daniel

Quoted 175 lines

- Robert

Quoted 170 lines

Fixed up while applying.
-Daniel

Quoted 23 lines

Being able to program OACONTROL from a non-privileged batch buffer is not sufficient to be able to configure the OA unit. This was originally allowed to help enable Mesa to expose OA counters via the INTEL_performance_query extension, but the current implementation based on programming OACONTROL via a batch buffer isn't able to report useable data without a more complete OA unit configuration. Mesa handles the possibility that writes to OACONTROL may not be allowed and so only advertises the extension after explicitly testing that a write to OACONTROL succeeds. Based on this; removing OACONTROL from the whitelist should be ok for userspace.

Removing this simplifies adding a new kernel api for configuring the OA unit without needing to consider the possibility that userspace might trample on OACONTROL state which we'd like to start managing within the kernel instead. In particular running any Mesa based GL application currently results in clearing OACONTROL when initializing which would disable the capturing of metrics.

v2:
This bumps the command parser version from 8 to 9, as the change is visible to userspace.

Quoted 5 lines
---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 42

++++------------------------------

Review

Quoted 3 lines
 1 file changed, 5 insertions(+), 37 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_cmd_parser.c

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_reg_descriptor

Quoted 4 lines

index c9d2ecd..f5762cd 100644

drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
@@ -450,7 +450,6 @@ static const struct drm_i915_reg_descriptor

gen7_render_regs[] = {

drivers/gpu/drm/i915/i915_cmd_parser.c static const struct drm_i915_reg_descriptor gen7_render_regs[] = {

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
      REG64(PS_INVOCATION_COUNT),
      REG64(PS_DEPTH_COUNT),
      REG64_IDX(RING_TIMESTAMP, RENDER_RING_BASE),
-     REG32(GEN7_OACONTROL), /* Only allowed for LRI and SRM. See below.

*/

drivers/gpu/drm/i915/i915_cmd_parser.c bool intel_engine_needs_cmd_parser(struct

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
      REG64(MI_PREDICATE_SRC0),
      REG64(MI_PREDICATE_SRC1),
      REG32(GEN7_3DPRIM_END_OFFSET),
@@ -1060,8 +1059,7 @@ bool intel_engine_needs_cmd_parser(struct

intel_engine_cs *engine)

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -2
 static bool check_cmd(const struct intel_engine_cs *engine,
                    const struct drm_i915_cmd_descriptor *desc,
                    const u32 *cmd, u32 length,
-                   const bool is_master,
-                   bool *oacontrol_set)
+                   const bool is_master)
 {
      if (desc->flags & CMD_DESC_SKIP)
              return true;
@@ -1099,31 +1097,6 @@ static bool check_cmd(const struct

intel_engine_cs *engine,

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
                      }
 
                      /*
-                      * OACONTROL requires some special handling for
-                      * writes. We want to make sure that any batch

which

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1104

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * enables OA also disables it before the end of

the

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1106

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
-                      * batch. The goal is to prevent one process from
-                      * snooping on the perf data from another process.

To do

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1107

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * that, we need to check the value that will be

written

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1108

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                      * to the register. Hence, limit OACONTROL writes

to

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 3 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-                      * only MI_LOAD_REGISTER_IMM commands.
-                      */
-                     if (reg_addr == i915_mmio_reg_offset(GEN7_OACONTROL))

{

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1112

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_MEM) {

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1113

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     DRM_DEBUG_DRIVER("CMD: Rejected

LRM to OACONTROL\n");

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -4
-                                     return false;
-                             }
-
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_REG) {

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1118

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     DRM_DEBUG_DRIVER("CMD: Rejected

LRR to OACONTROL\n");

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -4
-                                     return false;
-                             }
-
-                             if (desc->cmd.value ==

MI_LOAD_REGISTER_IMM(1))

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1123

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
-                                     *oacontrol_set = (cmd[offset + 1]

!= 0);

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-                     }
-
-                     /*
                       * Check the value written to the register against

the

drivers/gpu/drm/i915/i915_cmd_parser.c static bool check_cmd(const struct · line 1101

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
                       * allowed mask/value pair given in the whitelist

entry.

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
                       */
@@ -1214,7 +1187,6 @@ int intel_engine_cmd_parser(struct intel_engine_cs

*engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -1
      u32 *cmd, *batch_end;
      struct drm_i915_cmd_descriptor default_desc = noop_desc;
      const struct drm_i915_cmd_descriptor *desc = &default_desc;
-     bool oacontrol_set = false; /* OACONTROL tracking. See check_cmd()

*/

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
      bool needs_clflush_after = false;
      int ret = 0;
 
@@ -1270,8 +1242,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs

*engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -2
                      break;
              }
 
-             if (!check_cmd(engine, desc, cmd, length, is_master,
-                            &oacontrol_set)) {
+             if (!check_cmd(engine, desc, cmd, length, is_master)) {
                      ret = -EACCES;
                      break;
              }
@@ -1279,11 +1250,6 @@ int intel_engine_cmd_parser(struct

intel_engine_cs *engine,

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -2
              cmd += length;
      }
 
-     if (oacontrol_set) {
-             DRM_DEBUG_DRIVER("CMD: batch set OACONTROL but did not

clear it\n");

drivers/gpu/drm/i915/i915_cmd_parser.c int intel_engine_cmd_parser(struct intel_engine_cs *engine,

Quoted 5 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -3
-             ret = -EINVAL;
-     }
-
      if (cmd >= batch_end) {
              DRM_DEBUG_DRIVER("CMD: Got to the end of the buffer w/o a

BBE cmd!\n");

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct

Quoted 2 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
              ret = -EINVAL;
@@ -1336,6 +1302,8 @@ int i915_cmd_parser_get_version(struct

drm_i915_private *dev_priv)

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct · line 1302

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
       * 8. Don't report cmd_check() failures as EINVAL errors to

userspace;

drivers/gpu/drm/i915/i915_cmd_parser.c int i915_cmd_parser_get_version(struct · line 1303

Quoted 1 line
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
       *    rely on the HW to NOOP disallowed commands as it would

without

Quoted 10 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +3 -2
       *    the parser enabled.
+      * 9. Don't whitelist or handle oacontrol specially, as ownership
+      *    for oacontrol state is moving to i915-perf.
       */
-     return 8;
+     return 9;
 }
--

2.10.1

Quoted 4 lines

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

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

PATCH v9 5/11 drm/i915: Add 'render basic' Haswell OA unit config

In reply to Robert Bragg

Adds a static OA unit, MUX + B Counter configuration for basic render metrics on Haswell. This is auto generated from an XML description of metric sets, currently maintained in gputop, ref:

https://github.com/rib/gputop

Quoted 2 lines

gputop-data/oa-*.xml
scripts/i915-perf-kernelgen.py

  $ make -C gputop-data -f Makefile.xml SYSFS=0 WHITELIST=RenderBasic
---
 drivers/gpu/drm/i915/Makefile      |   3 +-
 drivers/gpu/drm/i915/i915_drv.h    |  14 ++++
 drivers/gpu/drm/i915/i915_oa_hsw.c | 144 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_oa_hsw.h |  34 +++++++++
 4 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/i915/i915_oa_hsw.c
 create mode 100644 drivers/gpu/drm/i915/i915_oa_hsw.h
drivers/gpu/drm/i915/Makefile +2 -1
index 08b43af..7e9e6d0 100644
@@ -117,7 +117,8 @@ i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
 i915-y += i915_vgpu.o
 
 # perf code
-i915-y += i915_perf.o
+i915-y += i915_perf.o \
+	  i915_oa_hsw.o
 
 ifeq ($(CONFIG_DRM_I915_GVT),y)
 i915-y += intel_gvt.o
drivers/gpu/drm/i915/i915_drv.h +14 -0
index e4cd322..bdebb66 100644
@@ -1785,6 +1785,11 @@ struct intel_wm_config {
 	bool sprites_scaled;
 };
 
+struct i915_oa_reg {
+	i915_reg_t addr;
+	u32 value;
+};
+
 struct i915_perf_stream;
 
 struct i915_perf_stream_ops {
@@ -2168,6 +2173,15 @@ struct drm_i915_private {
 		bool initialized;
 		struct mutex lock;
 		struct list_head streams;
+
+		struct {
+			u32 metrics_set;
+
+			const struct i915_oa_reg *mux_regs;
+			int mux_regs_len;
+			const struct i915_oa_reg *b_counter_regs;
+			int b_counter_regs_len;
+		} oa;
 	} perf;
 
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
drivers/gpu/drm/i915/i915_oa_hsw.c new file +144 -0

144 lines not on this page · raw message

drivers/gpu/drm/i915/i915_oa_hsw.h new file +34 -0
new file mode 100644
index 0000000..b618a1f
@@ -0,0 +1,34 @@
+/*
+ * Autogenerated file, DO NOT EDIT manually!
+ *
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __I915_OA_HSW_H__
+#define __I915_OA_HSW_H__
+
+extern int i915_oa_n_builtin_metric_sets_hsw;
+
+extern int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv);
+
+#endif
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v9 5/11
#15 lore raw

Re: [PATCH v9 05/11] drm/i915: Add 'render basic' Haswell OA unit config

Quoted 5 lines · Robert Bragg

Adds a static OA unit, MUX + B Counter configuration for basic render metrics on Haswell. This is auto generated from an XML description of metric sets, currently maintained in gputop, ref:

https://github.com/rib/gputop

Quoted 8 lines
Quoted 2 lines

gputop-data/oa-*.xml
scripts/i915-perf-kernelgen.py

  $ make -C gputop-data -f Makefile.xml SYSFS=0 WHITELIST=RenderBasic

---

Looks good.

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

#16 lore raw

PATCH v9 6/11 drm/i915: Enable i915 perf stream for Haswell OA unit

In reply to Robert Bragg

Gen graphics hardware can be set up to periodically write snapshots of performance counters into a circular buffer via its Observation Architecture and this patch exposes that capability to userspace via the i915 perf interface.

v2:
Make sure to initialize ->specific_ctx_id when opening, without relying on _pin_notify hook, in case ctx already pinned.
v3:
Revert back to pinning ctx upfront when opening stream, removing need to hook in to pinning and to update OACONTROL on the fly.

---
 drivers/gpu/drm/i915/i915_drv.h  |   66 ++-
 drivers/gpu/drm/i915/i915_perf.c | 1036 +++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_reg.h  |  338 +++++++++++++
 include/uapi/drm/i915_drm.h      |   71 ++-
 4 files changed, 1482 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +56 -10
index bdebb66..8003120 100644
@@ -1785,6 +1785,11 @@ struct intel_wm_config {
 	bool sprites_scaled;
 };
 
+struct i915_oa_format {
+	u32 format;
+	int size;
+};
+
 struct i915_oa_reg {
 	i915_reg_t addr;
 	u32 value;
@@ -1805,11 +1810,6 @@ struct i915_perf_stream_ops {
 	 */
 	void (*disable)(struct i915_perf_stream *stream);
 
-	/* Return: true if any i915 perf records are ready to read()
-	 * for this stream.
-	 */
-	bool (*can_read)(struct i915_perf_stream *stream);
-
 	/* Call poll_wait, passing a wait queue that will be woken
 	 * once there is something ready to read() for the stream
 	 */
@@ -1819,9 +1819,7 @@ struct i915_perf_stream_ops {
 
 	/* For handling a blocking read, wait until there is something
 	 * to ready to read() for the stream. E.g. wait on the same
-	 * wait queue that would be passed to poll_wait() until
-	 * ->can_read() returns true (if its safe to call ->can_read()
-	 * without the i915 perf lock held).
+	 * wait queue that would be passed to poll_wait().
 	 */
 	int (*wait_unlocked)(struct i915_perf_stream *stream);
 
@@ -1861,11 +1859,28 @@ struct i915_perf_stream {
 	struct list_head link;
 
 	u32 sample_flags;
+	int sample_size;
 
 	struct i915_gem_context *ctx;
 	bool enabled;
 
-	struct i915_perf_stream_ops *ops;
+	const struct i915_perf_stream_ops *ops;
+};
+
+struct i915_oa_ops {
+	void (*init_oa_buffer)(struct drm_i915_private *dev_priv);
+	int (*enable_metric_set)(struct drm_i915_private *dev_priv);
+	void (*disable_metric_set)(struct drm_i915_private *dev_priv);
+	void (*oa_enable)(struct drm_i915_private *dev_priv);
+	void (*oa_disable)(struct drm_i915_private *dev_priv);
+	void (*update_oacontrol)(struct drm_i915_private *dev_priv);
+	void (*update_hw_ctx_id_locked)(struct drm_i915_private *dev_priv,
+					u32 ctx_id);
+	int (*read)(struct i915_perf_stream *stream,
+		    char __user *buf,
+		    size_t count,
+		    size_t *offset);
+	bool (*oa_buffer_is_empty)(struct drm_i915_private *dev_priv);
 };
 
 struct drm_i915_private {
@@ -2171,16 +2186,47 @@ struct drm_i915_private {
 
 	struct {
 		bool initialized;
+
 		struct mutex lock;
 		struct list_head streams;
 
+		spinlock_t hook_lock;
+
 		struct {
-			u32 metrics_set;
+			struct i915_perf_stream *exclusive_stream;
+
+			u32 specific_ctx_id;
+			struct i915_vma *pinned_rcs_vma;
+
+			struct hrtimer poll_check_timer;
+			wait_queue_head_t poll_wq;
+			bool pollin;
+
+			bool periodic;
+			int period_exponent;
+			int timestamp_frequency;
+
+			int tail_margin;
+
+			int metrics_set;
 
 			const struct i915_oa_reg *mux_regs;
 			int mux_regs_len;
 			const struct i915_oa_reg *b_counter_regs;
 			int b_counter_regs_len;
+
+			struct {
+				struct i915_vma *vma;
+				u8 *vaddr;
+				int format;
+				int format_size;
+			} oa_buffer;
+
+			u32 gen7_latched_oastatus1;
+
+			struct i915_oa_ops ops;
+			const struct i915_oa_format *oa_formats;
+			int n_builtin_sets;
 		} oa;
 	} perf;
 
drivers/gpu/drm/i915/i915_perf.c +1019 -17

1,110 lines not on this page · raw message

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

350 lines not on this page · raw message

include/uapi/drm/i915_drm.h +69 -2

105 lines not on this page · raw message

Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v9 6/11
#17 lore raw

Re: [PATCH v9 06/11] drm/i915: Enable i915 perf stream for Haswell OA unit

Quoted 13 lines · Robert Bragg

Gen graphics hardware can be set up to periodically write snapshots of performance counters into a circular buffer via its Observation Architecture and this patch exposes that capability to userspace via the
i915 perf interface.

v2:
Make sure to initialize ->specific_ctx_id when opening, without relying on _pin_notify hook, in case ctx already pinned.
v3:
Revert back to pinning ctx upfront when opening stream, removing need to hook in to pinning and to update OACONTROL on the fly.

Quoted 4 lines

Have been working for quite some time on extending the interfaces per the usecase of multiple concurrent streams (on different engines), and infrastructure fits quite well for these usecases. With Chris' comments addressed, the patch can have my r-b.

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

#18 lore raw

PATCH v9 7/11 drm/i915: advertise available metrics via sysfs

In reply to Robert Bragg

Each metric set is given a sysfs entry like:

/sys/class/drm/card0/metrics/<guid>/id

This allows userspace to enumerate the specific sets that are available for the current system. The 'id' file contains an unsigned integer that can be used to open the associated metric set via DRM_IOCTL_I915_PERF_OPEN. The <guid> is a globally unique ID for a specific OA unit register configuration that can be reliably used by userspace as a key to lookup corresponding counter meta data and normalization equations.

The guid registry is currently maintained as part of gputop along with the XML metric set descriptions and code generation scripts, ref:

https://github.com/rib/gputop

Quoted 4 lines

gputop-data/guids.xml
scripts/update-guids.py
gputop-data/oa-*.xml
scripts/i915-perf-kernelgen.py

 $ make -C gputop-data -f Makefile.xml SYSFS=1 WHITELIST=RenderBasic
---
 drivers/gpu/drm/i915/i915_drv.c    |  5 ++++
 drivers/gpu/drm/i915/i915_drv.h    |  4 +++
 drivers/gpu/drm/i915/i915_oa_hsw.c | 51 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_oa_hsw.h |  4 +++
 drivers/gpu/drm/i915/i915_perf.c   | 52 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 116 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +5 -0
index 22b4166..4fd8650 100644
@@ -1125,6 +1125,9 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 		i915_debugfs_register(dev_priv);
 		i915_guc_register(dev_priv);
 		i915_setup_sysfs(dev_priv);
+
+		/* Depends on sysfs having been initialized */
+		i915_perf_register(dev_priv);
 	} else
 		DRM_ERROR("Failed to register driver for userspace access!\n");
 
@@ -1161,6 +1164,8 @@ static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 	acpi_video_unregister();
 	intel_opregion_unregister(dev_priv);
 
+	i915_perf_unregister(dev_priv);
+
 	i915_teardown_sysfs(dev_priv);
 	i915_guc_unregister(dev_priv);
 	i915_debugfs_unregister(dev_priv);
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 8003120..15fba6b 100644
@@ -2187,6 +2187,8 @@ struct drm_i915_private {
 	struct {
 		bool initialized;
 
+		struct kobject *metrics_kobj;
+
 		struct mutex lock;
 		struct list_head streams;
 
@@ -3884,6 +3886,8 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
 /* i915_perf.c */
 extern void i915_perf_init(struct drm_i915_private *dev_priv);
 extern void i915_perf_fini(struct drm_i915_private *dev_priv);
+extern void i915_perf_register(struct drm_i915_private *dev_priv);
+extern void i915_perf_unregister(struct drm_i915_private *dev_priv);
 
 /* i915_suspend.c */
 extern int i915_save_state(struct drm_device *dev);
drivers/gpu/drm/i915/i915_oa_hsw.c +51 -0

60 lines not on this page · raw message

drivers/gpu/drm/i915/i915_oa_hsw.h +4 -0
index b618a1f..429a229 100644
@@ -31,4 +31,8 @@ extern int i915_oa_n_builtin_metric_sets_hsw;
 
 extern int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv);
 
+extern int i915_perf_register_sysfs_hsw(struct drm_i915_private *dev_priv);
+
+extern void i915_perf_unregister_sysfs_hsw(struct drm_i915_private *dev_priv);
+
 #endif
drivers/gpu/drm/i915/i915_perf.c +52 -0

64 lines not on this page · raw message

Signature · 6 lines
2.10.1

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

PATCH v9 8/11 drm/i915: Add dev.i915.perf_stream_paranoid sysctl option

In reply to Robert Bragg

Consistent with the kernel.perf_event_paranoid sysctl option that can allow non-root users to access system wide cpu metrics, this can optionally allow non-root users to access system wide OA counter metrics from Gen graphics hardware.

---
 drivers/gpu/drm/i915/i915_drv.h  |  1 +
 drivers/gpu/drm/i915/i915_perf.c | 50 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 15fba6b..8962bfd 100644
@@ -2188,6 +2188,7 @@ struct drm_i915_private {
 		bool initialized;
 
 		struct kobject *metrics_kobj;
+		struct ctl_table_header *sysctl_header;
 
 		struct mutex lock;
 		struct list_head streams;
drivers/gpu/drm/i915/i915_perf.c +49 -1

80 lines not on this page · raw message

Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#20 lore raw

PATCH v9 9/11 drm/i915: add dev.i915.oa_max_sample_rate sysctl

In reply to Robert Bragg

The maximum OA sampling frequency is now configurable via a dev.i915.oa_max_sample_rate sysctl parameter.

Following the precedent set by perf's similar kernel.perf_event_max_sample_rate the default maximum rate is 100000Hz

---
 drivers/gpu/drm/i915/i915_perf.c | 61 ++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +50 -11
index e51c1d8..1a87fe9 100644
@@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid = true;
 #define INVALID_CTX_ID 0xffffffff
 
 
+/* 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.
+ */
+static int oa_sample_rate_hard_limit = 6250000;
+
+/* Theoretically we can program the OA unit to sample every 160ns but don't
+ * allow that by default unless root...
+ *
+ * The default threshold of 100000Hz is based on perf's similar
+ * kernel.perf_event_max_sample_rate sysctl parameter.
+ */
+static u32 i915_oa_max_sample_rate = 100000;
+
 /* XXX: beware if future OA HW adds new report formats that the current
  * code assumes all reports have a power-of-two size and ~(size - 1) can
  * be used as a mask to align the OA tail pointer.
@@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 	}
 
 	for (i = 0; i < n_props; i++) {
+		u64 oa_period, oa_freq_hz;
 		u64 id, value;
 		int ret;
 
@@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 				return -EINVAL;
 			}
 
-			/* NB: The exponent represents a period as follows:
-			 *
-			 *   80ns * 2^(period_exponent + 1)
-			 *
-			 * Theoretically we can program the OA unit to sample
+			/* Theoretically we can program the OA unit to sample
 			 * every 160ns but don't allow that by default unless
 			 * root.
 			 *
-			 * Referring to perf's
-			 * kernel.perf_event_max_sample_rate for a precedent
-			 * (100000 by default); with an OA exponent of 6 we get
-			 * a period of 10.240 microseconds -just under 100000Hz
+			 * 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);
+
+			/* This check is primarily to ensure that oa_period <=
+			 * UINT32_MAX (before passing to do_div which only
+			 * accepts a u32 denominator), but we can also skip
+			 * checking anything < 1Hz which implicitly can't be
+			 * limited via an integer oa_max_sample_rate.
 			 */
-			if (value < 6 && !capable(CAP_SYS_ADMIN)) {
-				DRM_ERROR("Minimum OA sampling exponent is 6 without root privileges\n");
+			if (oa_period <= NSEC_PER_SEC) {
+				u64 tmp = NSEC_PER_SEC;
+				do_div(tmp, oa_period);
+				oa_freq_hz = tmp;
+			} else
+				oa_freq_hz = 0;
+
+			if (oa_freq_hz > i915_oa_max_sample_rate &&
+			    !capable(CAP_SYS_ADMIN)) {
+				DRM_ERROR("OA exponent would exceed the max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",
+					  i915_oa_max_sample_rate);
 				return -EACCES;
 			}
 
@@ -1481,6 +1511,15 @@ static struct ctl_table oa_table[] = {
 	 .extra1 = &zero,
 	 .extra2 = &one,
 	 },
+	{
+	 .procname = "oa_max_sample_rate",
+	 .data = &i915_oa_max_sample_rate,
+	 .maxlen = sizeof(i915_oa_max_sample_rate),
+	 .mode = 0644,
+	 .proc_handler = proc_dointvec_minmax,
+	 .extra1 = &zero,
+	 .extra2 = &oa_sample_rate_hard_limit,
+	 },
 	{}
 };
 
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#21 lore raw

Re: [PATCH v9 09/11] drm/i915: add dev.i915.oa_max_sample_rate sysctl

Quoted 16 lines · Robert Bragg

The maximum OA sampling frequency is now configurable via a dev.i915.oa_max_sample_rate sysctl parameter.

Following the precedent set by perf's similar kernel.perf_event_max_sample_rate the default maximum rate is 100000Hz

---
 drivers/gpu/drm/i915/i915_perf.c | 61 ++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +0 -0
index e51c1d8..1a87fe9 100644

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true; · line 90

Quoted 9 lines
drivers/gpu/drm/i915/i915_perf.c +6 -0
@@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid = true;
 #define INVALID_CTX_ID 0xffffffff
 
 
+/* 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.
+ */
+static int oa_sample_rate_hard_limit = 6250000;

There's no check for 'oa_sample_rate_hard_limit' anywhere below.

Quoted 34 lines
drivers/gpu/drm/i915/i915_perf.c +11 -6
+
+/* Theoretically we can program the OA unit to sample every 160ns but don't
+ * allow that by default unless root...
+ *
+ * The default threshold of 100000Hz is based on perf's similar
+ * kernel.perf_event_max_sample_rate sysctl parameter.
+ */
+static u32 i915_oa_max_sample_rate = 100000;
+
 /* XXX: beware if future OA HW adds new report formats that the current
  * code assumes all reports have a power-of-two size and ~(size - 1) can
  * be used as a mask to align the OA tail pointer.
@@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 	}
 
 	for (i = 0; i < n_props; i++) {
+		u64 oa_period, oa_freq_hz;
 		u64 id, value;
 		int ret;
 
@@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
 				return -EINVAL;
 			}
 
-			/* NB: The exponent represents a period as follows:
-			 *
-			 *   80ns * 2^(period_exponent + 1)
-			 *
-			 * Theoretically we can program the OA unit to sample
+			/* Theoretically we can program the OA unit to sample
 			 * every 160ns but don't allow that by default unless
 			 * root.
 			 *
-			 * Referring to perf's

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv, · line 1388

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +7 -3
-			 * kernel.perf_event_max_sample_rate for a precedent
-			 * (100000 by default); with an OA exponent of 6 we get
-			 * a period of 10.240 microseconds -just under 100000Hz
+			 * 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);

I assume now that there'll be a platform specific check for 80ull, while programming oa_period, for subquent Gen8+ platforms, which should be fine.

Quoted 29 lines
drivers/gpu/drm/i915/i915_perf.c +19 -2
+
+			/* This check is primarily to ensure that oa_period <=
+			 * UINT32_MAX (before passing to do_div which only
+			 * accepts a u32 denominator), but we can also skip
+			 * checking anything < 1Hz which implicitly can't be
+			 * limited via an integer oa_max_sample_rate.
 			 */
-			if (value < 6 && !capable(CAP_SYS_ADMIN)) {
-				DRM_ERROR("Minimum OA sampling exponent is 6 without root privileges\n");
+			if (oa_period <= NSEC_PER_SEC) {
+				u64 tmp = NSEC_PER_SEC;
+				do_div(tmp, oa_period);
+				oa_freq_hz = tmp;
+			} else
+				oa_freq_hz = 0;
+
+			if (oa_freq_hz > i915_oa_max_sample_rate &&
+			    !capable(CAP_SYS_ADMIN)) {
+				DRM_ERROR("OA exponent would exceed the max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",
+					  i915_oa_max_sample_rate);
 				return -EACCES;
 			}
 
@@ -1481,6 +1511,15 @@ static struct ctl_table oa_table[] = {
 	 .extra1 = &zero,
 	 .extra2 = &one,
 	 },
+	{
+	 .procname = "oa_max_sample_rate",

drivers/gpu/drm/i915/i915_perf.c static struct ctl_table oa_table[] = { · line 1525

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +7 -0
+	 .data = &i915_oa_max_sample_rate,
+	 .maxlen = sizeof(i915_oa_max_sample_rate),
+	 .mode = 0644,
+	 .proc_handler = proc_dointvec_minmax,
+	 .extra1 = &zero,
+	 .extra2 = &oa_sample_rate_hard_limit,
+	 },
 	{}
 };
 

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

#22 lore raw

Re: [PATCH v9 09/11] drm/i915: add dev.i915.oa_max_sample_rate sysctl

Quoted 22 lines · sourab gupta
Quoted 9 lines · Robert Bragg

The maximum OA sampling frequency is now configurable via a dev.i915.oa_max_sample_rate sysctl parameter.

Following the precedent set by perf's similar kernel.perf_event_max_sample_rate the default maximum rate is 100000Hz

---
 drivers/gpu/drm/i915/i915_perf.c | 61 ++++++++++++++++++++++++++++++

++--------

Review

Quoted 3 lines
 1 file changed, 50 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_perf.c

Quoted 7 lines

index e51c1d8..1a87fe9 100644

drivers/gpu/drm/i915/i915_perf.c +0 -0
@@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid = true;
 #define INVALID_CTX_ID 0xffffffff
 
 
Quoted 9 lines

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true;

Quoted 3 lines
drivers/gpu/drm/i915/i915_perf.c +3 -0
+/* For sysctl proc_dointvec_minmax of i915_oa_max_sample_rate
+ *
+ * 160ns is the smallest sampling period we can theoretically program

the OA

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true; · line 90

Quoted 3 lines
drivers/gpu/drm/i915/i915_perf.c +3 -0
+ * unit with on Haswell, corresponding to 6.25MHz.
+ */
+static int oa_sample_rate_hard_limit = 6250000;

There's no check for 'oa_sample_rate_hard_limit' anywhere below.

It's in the struct ctl_table oa_table[] declaration of the "oa_max_sample_rate" paramater, assigned to .extra2 which is referenced by the proc_dointvec_minmax validation handler for the parameter.

Quoted 55 lines

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true; · line 92

Quoted 3 lines
drivers/gpu/drm/i915/i915_perf.c +2 -0
+
+/* Theoretically we can program the OA unit to sample every 160ns but

don't

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct

Quoted 11 lines
drivers/gpu/drm/i915/i915_perf.c +7 -0
+ * allow that by default unless root...
+ *
+ * The default threshold of 100000Hz is based on perf's similar
+ * kernel.perf_event_max_sample_rate sysctl parameter.
+ */
+static u32 i915_oa_max_sample_rate = 100000;
+
 /* XXX: beware if future OA HW adds new report formats that the current
  * code assumes all reports have a power-of-two size and ~(size - 1) can
  * be used as a mask to align the OA tail pointer.
@@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct

drm_i915_private *dev_priv,

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +1 -0
      }
 
      for (i = 0; i < n_props; i++) {
+             u64 oa_period, oa_freq_hz;
              u64 id, value;
              int ret;
 
@@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct

drm_i915_private *dev_priv,

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +0 -5
                              return -EINVAL;
                      }
 
-                     /* NB: The exponent represents a period as follows:
-                      *
-                      *   80ns * 2^(period_exponent + 1)
-                      *
-                      * Theoretically we can program the OA unit to

sample

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1378

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                     /* Theoretically we can program the OA unit to

sample

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1379

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -0
                       * every 160ns but don't allow that by default

unless

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +0 -2
                       * root.
                       *
-                      * Referring to perf's
-                      * kernel.perf_event_max_sample_rate for a

precedent

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1372

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -1
-                      * (100000 by default); with an OA exponent of 6

we get

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1373

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -1
-                      * a period of 10.240 microseconds -just under

100000Hz

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1382

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                      * On Haswell the period is derived from the

exponent

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv, · line 1388

Quoted 6 lines
drivers/gpu/drm/i915/i915_perf.c +6 -0
+                      * as:
+                      *
+                      *   period = 80ns * 2^(exponent + 1)
+                      */
+                     BUILD_BUG_ON(sizeof(oa_period) != 8);
+                     oa_period = 80ull * (2ull << value);
Quoted 4 lines

I assume now that there'll be a platform specific check for 80ull, while programming oa_period, for subquent Gen8+ platforms, which should be fine.

Yeah, this code will need adapting for gen9+. I guess we'll change it to work in terms of ((2<<exp) * NSEC_PER_SEC) / timestamp_frequency.

Quoted 29 lines

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1390

Quoted 3 lines
drivers/gpu/drm/i915/i915_perf.c +2 -0
+
+                     /* This check is primarily to ensure that

oa_period <=

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 3 lines
drivers/gpu/drm/i915/i915_perf.c +3 -0
+                      * UINT32_MAX (before passing to do_div which only
+                      * accepts a u32 denominator), but we can also skip
+                      * checking anything < 1Hz which implicitly can't

be

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +1 -2
+                      * limited via an integer oa_max_sample_rate.
                       */
-                     if (value < 6 && !capable(CAP_SYS_ADMIN)) {
-                             DRM_ERROR("Minimum OA sampling exponent is

6 without root privileges\n");

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +10 -0
+                     if (oa_period <= NSEC_PER_SEC) {
+                             u64 tmp = NSEC_PER_SEC;
+                             do_div(tmp, oa_period);
+                             oa_freq_hz = tmp;
+                     } else
+                             oa_freq_hz = 0;
+
+                     if (oa_freq_hz > i915_oa_max_sample_rate &&
+                         !capable(CAP_SYS_ADMIN)) {
+                             DRM_ERROR("OA exponent would exceed the

max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                                       i915_oa_max_sample_rate);
                              return -EACCES;
                      }
 
Quoted 19 lines
Quoted 6 lines
drivers/gpu/drm/i915/i915_perf.c +2 -0
@@ -1481,6 +1511,15 @@ static struct ctl_table oa_table[] = {
       .extra1 = &zero,
       .extra2 = &one,
       },
+     {
+      .procname = "oa_max_sample_rate",

drivers/gpu/drm/i915/i915_perf.c static struct ctl_table oa_table[] = { · line 1525

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +7 -0
+      .data = &i915_oa_max_sample_rate,
+      .maxlen = sizeof(i915_oa_max_sample_rate),
+      .mode = 0644,
+      .proc_handler = proc_dointvec_minmax,
+      .extra1 = &zero,
+      .extra2 = &oa_sample_rate_hard_limit,
+      },
      {}
 };
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by
#23 lore raw

Re: [PATCH v9 09/11] drm/i915: add dev.i915.oa_max_sample_rate sysctl

Quoted 40 lines · Robert Bragg

On Tue, Nov 8, 2016 at 6:19 AM, sourab gupta <[email protected]> wrote:

        On Mon, 2016-11-07 at 11:49 -0800, Robert Bragg wrote:
        > The maximum OA sampling frequency is now configurable via a
        > dev.i915.oa_max_sample_rate sysctl parameter.
        >
        > Following the precedent set by perf's similar
        > kernel.perf_event_max_sample_rate the default maximum rate
        is 100000Hz
        >
        > Signed-off-by: Robert Bragg <[email protected]>
        > ---
        >  drivers/gpu/drm/i915/i915_perf.c | 61
        ++++++++++++++++++++++++++++++++--------
        >  1 file changed, 50 insertions(+), 11 deletions(-)
        >
        > diff --git a/drivers/gpu/drm/i915/i915_perf.c
        b/drivers/gpu/drm/i915/i915_perf.c
        > index e51c1d8..1a87fe9 100644
        > --- a/drivers/gpu/drm/i915/i915_perf.c
        > +++ b/drivers/gpu/drm/i915/i915_perf.c
        > @@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid =
        true;
        >  #define INVALID_CTX_ID 0xffffffff
        >
        >
        > +/* 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.
        > + */
        > +static int oa_sample_rate_hard_limit = 6250000;
        There's no check for 'oa_sample_rate_hard_limit' anywhere
        below.
Quoted 5 lines

It's in the struct ctl_table oa_table[] declaration of the "oa_max_sample_rate" paramater, assigned to .extra2 which is referenced by the proc_dointvec_minmax validation handler for the parameter.

Ok. Seems fine then.

Quoted 68 lines

> +
> +/* Theoretically we can program the OA unit to sample every 160ns but don't
> + * allow that by default unless root...
> + *
> + * The default threshold of 100000Hz is based on perf's similar
> + * kernel.perf_event_max_sample_rate sysctl parameter. > + */
> +static u32 i915_oa_max_sample_rate = 100000;
> +
> /* XXX: beware if future OA HW adds new report formats that the current
> * code assumes all reports have a power-of-two size and
~(size - 1) can
> * be used as a mask to align the OA tail pointer.
> @@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
> }
>
> for (i = 0; i < n_props; i++) {
> + u64 oa_period, oa_freq_hz;
> u64 id, value;
> int ret;
>
> @@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
> return -EINVAL;
> }
>
> - /* NB: The exponent represents a
period as follows:
> - *
> - * 80ns * 2^(period_exponent + 1)
> - *
> - * Theoretically we can program the OA
unit to sample
> + /* Theoretically we can program the OA
unit to sample
> * every 160ns but don't allow that by
default unless
> * root.
> *
> - * Referring to perf's
> - * kernel.perf_event_max_sample_rate
for a precedent
> - * (100000 by default); with an OA
exponent of 6 we get
> - * a period of 10.240 microseconds
-just under 100000Hz
> + * 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);

I assume now that there'll be a platform specific check for 80ull, while
programming oa_period, for subquent Gen8+ platforms, which should be
fine.

Quoted 3 lines

Yeah, this code will need adapting for gen9+. I guess we'll change it to work in terms of ((2<<exp) * NSEC_PER_SEC) / timestamp_frequency.

Seems reasonable.

Quoted 45 lines
 
        
        > +
        > +                     /* This check is primarily to ensure
        that oa_period <=
        > +                      * UINT32_MAX (before passing to
        do_div which only
        > +                      * accepts a u32 denominator), but we
        can also skip
        > +                      * checking anything < 1Hz which
        implicitly can't be
        > +                      * limited via an integer
        oa_max_sample_rate.
        >                        */
        > -                     if (value < 6 && !
        capable(CAP_SYS_ADMIN)) {
        > -                             DRM_ERROR("Minimum OA sampling
        exponent is 6 without root privileges\n");
        > +                     if (oa_period <= NSEC_PER_SEC) {
        > +                             u64 tmp = NSEC_PER_SEC;
        > +                             do_div(tmp, oa_period);
        > +                             oa_freq_hz = tmp;
        > +                     } else
        > +                             oa_freq_hz = 0;
        > +
        > +                     if (oa_freq_hz >
        i915_oa_max_sample_rate &&
        > +                         !capable(CAP_SYS_ADMIN)) {
        > +                             DRM_ERROR("OA exponent would
        exceed the max sampling frequency (sysctl
        dev.i915.oa_max_sample_rate) %uHz without root privileges\n",
        > +
         i915_oa_max_sample_rate);
        >                               return -EACCES;
        >                       }
        >
        > @@ -1481,6 +1511,15 @@ static struct ctl_table oa_table[] =
        {
        >        .extra1 = &zero,
        >        .extra2 = &one,
        >        },
        > +     {
        > +      .procname = "oa_max_sample_rate",
        > +      .data = &i915_oa_max_sample_rate,
        > +      .maxlen = sizeof(i915_oa_max_sample_rate),
Quoted 9 lines
        > +      .mode = 0644,
        > +      .proc_handler = proc_dointvec_minmax,
        > +      .extra1 = &zero,
        > +      .extra2 = &oa_sample_rate_hard_limit,
        > +      },
        >       {}
        >  };
        >

The patch looks good to me.

Quoted 4 lines

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

Reviewed-by on v9 9/11
#24 lore raw

Re: [PATCH v9 09/11] drm/i915: add dev.i915.oa_max_sample_rate sysctl

In reply to Robert Bragg
Quoted 78 lines · Robert Bragg

The maximum OA sampling frequency is now configurable via a dev.i915.oa_max_sample_rate sysctl parameter.

Following the precedent set by perf's similar kernel.perf_event_max_sample_rate the default maximum rate is 100000Hz

---
 drivers/gpu/drm/i915/i915_perf.c | 61 ++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +30 -11
index e51c1d8..1a87fe9 100644
@@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid = true;
 #define INVALID_CTX_ID 0xffffffff
 
 
+/* 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.
+ */
+static int oa_sample_rate_hard_limit = 6250000;
+
+/* Theoretically we can program the OA unit to sample every 160ns but don't
+ * allow that by default unless root...
+ *
+ * The default threshold of 100000Hz is based on perf's similar
+ * kernel.perf_event_max_sample_rate sysctl parameter.
+ */
+static u32 i915_oa_max_sample_rate = 100000;
+
 /* XXX: beware if future OA HW adds new report formats that the current
  * code assumes all reports have a power-of-two size and ~(size - 1) can
  * be used as a mask to align the OA tail pointer.
@@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
        }
 
        for (i = 0; i < n_props; i++) {
+               u64 oa_period, oa_freq_hz;
                u64 id, value;
                int ret;
 
@@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv,
                                return -EINVAL;
                        }
 
-                       /* NB: The exponent represents a period as follows:
-                        *
-                        *   80ns * 2^(period_exponent + 1)
-                        *
-                        * Theoretically we can program the OA unit to sample
+                       /* Theoretically we can program the OA unit to sample
                         * every 160ns but don't allow that by default unless
                         * root.
                         *
-                        * Referring to perf's
-                        * kernel.perf_event_max_sample_rate for a precedent
-                        * (100000 by default); with an OA exponent of 6 we get
-                        * a period of 10.240 microseconds -just under 100000Hz
+                        * 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);
+
+                       /* This check is primarily to ensure that oa_period <=
+                        * UINT32_MAX (before passing to do_div which only
+                        * accepts a u32 denominator), but we can also skip
+                        * checking anything < 1Hz which implicitly can't be
+                        * limited via an integer oa_max_sample_rate.
                         */
-                       if (value < 6 && !capable(CAP_SYS_ADMIN)) {
-                               DRM_ERROR("Minimum OA sampling exponent is 6 without root privileges\n");

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv, · line 1405

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +10 -0
+                       if (oa_period <= NSEC_PER_SEC) {
+                               u64 tmp = NSEC_PER_SEC;
+                               do_div(tmp, oa_period);
+                               oa_freq_hz = tmp;
+                       } else
+                               oa_freq_hz = 0;
+
+                       if (oa_freq_hz > i915_oa_max_sample_rate &&
+                           !capable(CAP_SYS_ADMIN)) {
+                               DRM_ERROR("OA exponent would exceed the max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",

This line is getting a little too long.

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

#25 lore raw

Re: [PATCH v9 09/11] drm/i915: add dev.i915.oa_max_sample_rate sysctl

On Wed, Nov 9, 2016 at 7:52 PM, Matthew Auld <[email protected]

Quoted 110 lines

wrote:

Quoted 9 lines · Robert Bragg

The maximum OA sampling frequency is now configurable via a dev.i915.oa_max_sample_rate sysctl parameter.

Following the precedent set by perf's similar kernel.perf_event_max_sample_rate the default maximum rate is 100000Hz

---
 drivers/gpu/drm/i915/i915_perf.c | 61 ++++++++++++++++++++++++++++++

++--------

Review

Quoted 3 lines
 1 file changed, 50 insertions(+), 11 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_perf.c

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true; · line 87

Quoted 10 lines

index e51c1d8..1a87fe9 100644

drivers/gpu/drm/i915/i915_perf.c +3 -0
@@ -82,6 +82,21 @@ static u32 i915_perf_stream_paranoid = true;
 #define INVALID_CTX_ID 0xffffffff
 
 
+/* For sysctl proc_dointvec_minmax of i915_oa_max_sample_rate
+ *
+ * 160ns is the smallest sampling period we can theoretically program

the OA

drivers/gpu/drm/i915/i915_perf.c static u32 i915_perf_stream_paranoid = true;

Quoted 5 lines
drivers/gpu/drm/i915/i915_perf.c +5 -0
+ * unit with on Haswell, corresponding to 6.25MHz.
+ */
+static int oa_sample_rate_hard_limit = 6250000;
+
+/* Theoretically we can program the OA unit to sample every 160ns but

don't

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct

Quoted 11 lines
drivers/gpu/drm/i915/i915_perf.c +7 -0
+ * allow that by default unless root...
+ *
+ * The default threshold of 100000Hz is based on perf's similar
+ * kernel.perf_event_max_sample_rate sysctl parameter.
+ */
+static u32 i915_oa_max_sample_rate = 100000;
+
 /* XXX: beware if future OA HW adds new report formats that the current
  * code assumes all reports have a power-of-two size and ~(size - 1) can
  * be used as a mask to align the OA tail pointer.
@@ -1314,6 +1329,7 @@ static int read_properties_unlocked(struct

drm_i915_private *dev_priv,

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +1 -0
        }
 
        for (i = 0; i < n_props; i++) {
+               u64 oa_period, oa_freq_hz;
                u64 id, value;
                int ret;
 
@@ -1359,21 +1375,35 @@ static int read_properties_unlocked(struct

drm_i915_private *dev_priv,

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +0 -1
                                return -EINVAL;
                        }
 
-                       /* NB: The exponent represents a period as

follows:

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +0 -4
-                        *
-                        *   80ns * 2^(period_exponent + 1)
-                        *
-                        * Theoretically we can program the OA unit to

sample

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1378

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                       /* Theoretically we can program the OA unit to

sample

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1379

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -0
                         * every 160ns but don't allow that by default

unless

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +0 -2
                         * root.
                         *
-                        * Referring to perf's
-                        * kernel.perf_event_max_sample_rate for a

precedent

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1372

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -1
-                        * (100000 by default); with an OA exponent of 6

we get

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1373

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +0 -1
-                        * a period of 10.240 microseconds -just under

100000Hz

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1382

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                        * On Haswell the period is derived from the

exponent

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +8 -0
+                        * as:
+                        *
+                        *   period = 80ns * 2^(exponent + 1)
+                        */
+                       BUILD_BUG_ON(sizeof(oa_period) != 8);
+                       oa_period = 80ull * (2ull << value);
+
+                       /* This check is primarily to ensure that

oa_period <=

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct · line 1391

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                        * UINT32_MAX (before passing to do_div which

only

Quoted 1 line
drivers/gpu/drm/i915/i915_perf.c +1 -0
+                        * accepts a u32 denominator), but we can also

skip

Quoted 1 line

+ * checking anything < 1Hz which implicitly

can't be

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 4 lines
drivers/gpu/drm/i915/i915_perf.c +1 -2
+                        * limited via an integer oa_max_sample_rate.
                         */
-                       if (value < 6 && !capable(CAP_SYS_ADMIN)) {
-                               DRM_ERROR("Minimum OA sampling exponent

is 6 without root privileges\n");

drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct drm_i915_private *dev_priv,

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +10 -0
+                       if (oa_period <= NSEC_PER_SEC) {
+                               u64 tmp = NSEC_PER_SEC;
+                               do_div(tmp, oa_period);
+                               oa_freq_hz = tmp;
+                       } else
+                               oa_freq_hz = 0;
+
+                       if (oa_freq_hz > i915_oa_max_sample_rate &&
+                           !capable(CAP_SYS_ADMIN)) {
+                               DRM_ERROR("OA exponent would exceed the
Quoted 4 lines

max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz without root privileges\n",
This line is getting a little too long.

yeah, though the coding style has the exception for string constants so they remain grepable which can be useful too. Could maybe remove the bracketed naming of the corresponding sysctl parameter, though it does seem like pertinent/useful info if someone were to hit this limit.

Quoted 3 lines

thanks

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

#26 lore raw

PATCH v9 10/11 drm/i915: Add more Haswell OA metric sets

In reply to Robert Bragg

This adds 'compute', 'compute extended', 'memory reads', 'memory writes' and 'sampler balance' metric sets for Haswell.

The code is auto generated from an XML description of metric sets, currently maintained in gputop, ref:

https://github.com/rib/gputop

Quoted 2 lines

gputop-data/oa-*.xml
scripts/i915-perf-kernelgen.py

 $ make -C gputop-data -f Makefile.xml
---
 drivers/gpu/drm/i915/i915_oa_hsw.c | 559 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 558 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_oa_hsw.c +558 -1
index 6af25cf..4ddf756 100644
@@ -31,9 +31,14 @@
 
 enum metric_set_id {
 	METRIC_SET_ID_RENDER_BASIC = 1,
+	METRIC_SET_ID_COMPUTE_BASIC,
+	METRIC_SET_ID_COMPUTE_EXTENDED,
+	METRIC_SET_ID_MEMORY_READS,
+	METRIC_SET_ID_MEMORY_WRITES,
+	METRIC_SET_ID_SAMPLER_BALANCE,
 };
 
-int i915_oa_n_builtin_metric_sets_hsw = 1;
+int i915_oa_n_builtin_metric_sets_hsw = 6;
 
 static const struct i915_oa_reg b_counter_config_render_basic[] = {
 	{ _MMIO(0x2724), 0x00800000 },
@@ -112,6 +117,298 @@ get_render_basic_mux_config(struct drm_i915_private *dev_priv,
 	return mux_config_render_basic;
 }
 
+static const struct i915_oa_reg b_counter_config_compute_basic[] = {
+	{ _MMIO(0x2710), 0x00000000 },
+	{ _MMIO(0x2714), 0x00800000 },
+	{ _MMIO(0x2718), 0xaaaaaaaa },
+	{ _MMIO(0x271c), 0xaaaaaaaa },
+	{ _MMIO(0x2720), 0x00000000 },
+	{ _MMIO(0x2724), 0x00800000 },
+	{ _MMIO(0x2728), 0xaaaaaaaa },
+	{ _MMIO(0x272c), 0xaaaaaaaa },
+	{ _MMIO(0x2740), 0x00000000 },
+	{ _MMIO(0x2744), 0x00000000 },
+	{ _MMIO(0x2748), 0x00000000 },
+	{ _MMIO(0x274c), 0x00000000 },
+	{ _MMIO(0x2750), 0x00000000 },
+	{ _MMIO(0x2754), 0x00000000 },
+	{ _MMIO(0x2758), 0x00000000 },
+	{ _MMIO(0x275c), 0x00000000 },
+	{ _MMIO(0x236c), 0x00000000 },
+};
+
+static const struct i915_oa_reg mux_config_compute_basic[] = {
+	{ _MMIO(0x253a4), 0x00000000 },
+	{ _MMIO(0x2681c), 0x01f00800 },
+	{ _MMIO(0x26820), 0x00001000 },
+	{ _MMIO(0x2781c), 0x01f00800 },
+	{ _MMIO(0x26520), 0x00000007 },
+	{ _MMIO(0x265a0), 0x00000007 },
+	{ _MMIO(0x25380), 0x00000010 },
+	{ _MMIO(0x2538c), 0x00300000 },
+	{ _MMIO(0x25384), 0xaa8aaaaa },
+	{ _MMIO(0x25404), 0xffffffff },
+	{ _MMIO(0x26800), 0x00004202 },
+	{ _MMIO(0x26808), 0x00605817 },
+	{ _MMIO(0x2680c), 0x10001005 },
+	{ _MMIO(0x26804), 0x00000000 },
+	{ _MMIO(0x27800), 0x00000102 },
+	{ _MMIO(0x27808), 0x0c0701e0 },
+	{ _MMIO(0x2780c), 0x000200a0 },
+	{ _MMIO(0x27804), 0x00000000 },
+	{ _MMIO(0x26484), 0x44000000 },
+	{ _MMIO(0x26704), 0x44000000 },
+	{ _MMIO(0x26500), 0x00000006 },
+	{ _MMIO(0x26510), 0x00000001 },
+	{ _MMIO(0x26504), 0x88000000 },
+	{ _MMIO(0x26580), 0x00000006 },
+	{ _MMIO(0x26590), 0x00000020 },
+	{ _MMIO(0x26584), 0x00000000 },
+	{ _MMIO(0x26104), 0x55822222 },
+	{ _MMIO(0x26184), 0xaa866666 },
+	{ _MMIO(0x25420), 0x08320c83 },
+	{ _MMIO(0x25424), 0x06820c83 },
+	{ _MMIO(0x2541c), 0x00000000 },
+	{ _MMIO(0x25428), 0x00000c03 },
+};
+
+static const struct i915_oa_reg *
+get_compute_basic_mux_config(struct drm_i915_private *dev_priv,
+			     int *len)
+{
+	*len = ARRAY_SIZE(mux_config_compute_basic);
+	return mux_config_compute_basic;
+}
+
+static const struct i915_oa_reg b_counter_config_compute_extended[] = {
+	{ _MMIO(0x2724), 0xf0800000 },
+	{ _MMIO(0x2720), 0x00000000 },
+	{ _MMIO(0x2714), 0xf0800000 },
+	{ _MMIO(0x2710), 0x00000000 },
+	{ _MMIO(0x2770), 0x0007fe2a },
+	{ _MMIO(0x2774), 0x0000ff00 },
+	{ _MMIO(0x2778), 0x0007fe6a },
+	{ _MMIO(0x277c), 0x0000ff00 },
+	{ _MMIO(0x2780), 0x0007fe92 },
+	{ _MMIO(0x2784), 0x0000ff00 },
+	{ _MMIO(0x2788), 0x0007fea2 },
+	{ _MMIO(0x278c), 0x0000ff00 },
+	{ _MMIO(0x2790), 0x0007fe32 },
+	{ _MMIO(0x2794), 0x0000ff00 },
+	{ _MMIO(0x2798), 0x0007fe9a },
+	{ _MMIO(0x279c), 0x0000ff00 },
+	{ _MMIO(0x27a0), 0x0007ff23 },
+	{ _MMIO(0x27a4), 0x0000ff00 },
+	{ _MMIO(0x27a8), 0x0007fff3 },
+	{ _MMIO(0x27ac), 0x0000fffe },
+};
+
+static const struct i915_oa_reg mux_config_compute_extended[] = {
+	{ _MMIO(0x2681c), 0x3eb00800 },
+	{ _MMIO(0x26820), 0x00900000 },
+	{ _MMIO(0x25384), 0x02aaaaaa },
+	{ _MMIO(0x25404), 0x03ffffff },
+	{ _MMIO(0x26800), 0x00142284 },
+	{ _MMIO(0x26808), 0x0e629062 },
+	{ _MMIO(0x2680c), 0x3f6f55cb },
+	{ _MMIO(0x26810), 0x00000014 },
+	{ _MMIO(0x26804), 0x00000000 },
+	{ _MMIO(0x26104), 0x02aaaaaa },
+	{ _MMIO(0x26184), 0x02aaaaaa },
+	{ _MMIO(0x25420), 0x00000000 },
+	{ _MMIO(0x25424), 0x00000000 },
+	{ _MMIO(0x2541c), 0x00000000 },
+	{ _MMIO(0x25428), 0x00000000 },
+};
+
+static const struct i915_oa_reg *
+get_compute_extended_mux_config(struct drm_i915_private *dev_priv,
+				int *len)
+{
+	*len = ARRAY_SIZE(mux_config_compute_extended);
+	return mux_config_compute_extended;
+}
+
+static const struct i915_oa_reg b_counter_config_memory_reads[] = {
+	{ _MMIO(0x2724), 0xf0800000 },
+	{ _MMIO(0x2720), 0x00000000 },
+	{ _MMIO(0x2714), 0xf0800000 },
+	{ _MMIO(0x2710), 0x00000000 },
+	{ _MMIO(0x274c), 0x76543298 },
+	{ _MMIO(0x2748), 0x98989898 },
+	{ _MMIO(0x2744), 0x000000e4 },
+	{ _MMIO(0x2740), 0x00000000 },
+	{ _MMIO(0x275c), 0x98a98a98 },
+	{ _MMIO(0x2758), 0x88888888 },
+	{ _MMIO(0x2754), 0x000c5500 },
+	{ _MMIO(0x2750), 0x00000000 },
+	{ _MMIO(0x2770), 0x0007f81a },
+	{ _MMIO(0x2774), 0x0000fc00 },
+	{ _MMIO(0x2778), 0x0007f82a },
+	{ _MMIO(0x277c), 0x0000fc00 },
+	{ _MMIO(0x2780), 0x0007f872 },
+	{ _MMIO(0x2784), 0x0000fc00 },
+	{ _MMIO(0x2788), 0x0007f8ba },
+	{ _MMIO(0x278c), 0x0000fc00 },
+	{ _MMIO(0x2790), 0x0007f87a },
+	{ _MMIO(0x2794), 0x0000fc00 },
+	{ _MMIO(0x2798), 0x0007f8ea },
+	{ _MMIO(0x279c), 0x0000fc00 },
+	{ _MMIO(0x27a0), 0x0007f8e2 },
+	{ _MMIO(0x27a4), 0x0000fc00 },
+	{ _MMIO(0x27a8), 0x0007f8f2 },
+	{ _MMIO(0x27ac), 0x0000fc00 },
+};
+
+static const struct i915_oa_reg mux_config_memory_reads[] = {
+	{ _MMIO(0x253a4), 0x34300000 },
+	{ _MMIO(0x25440), 0x2d800000 },
+	{ _MMIO(0x25444), 0x00000008 },
+	{ _MMIO(0x25128), 0x0e600000 },
+	{ _MMIO(0x25380), 0x00000450 },
+	{ _MMIO(0x25390), 0x00052c43 },
+	{ _MMIO(0x25384), 0x00000000 },
+	{ _MMIO(0x25400), 0x00006144 },
+	{ _MMIO(0x25408), 0x0a418820 },
+	{ _MMIO(0x2540c), 0x000820e6 },
+	{ _MMIO(0x25404), 0xff500000 },
+	{ _MMIO(0x25100), 0x000005d6 },
+	{ _MMIO(0x2510c), 0x0ef00000 },
+	{ _MMIO(0x25104), 0x00000000 },
+	{ _MMIO(0x25420), 0x02108421 },
+	{ _MMIO(0x25424), 0x00008421 },
+	{ _MMIO(0x2541c), 0x00000000 },
+	{ _MMIO(0x25428), 0x00000000 },
+};
+
+static const struct i915_oa_reg *
+get_memory_reads_mux_config(struct drm_i915_private *dev_priv,
+			    int *len)
+{
+	*len = ARRAY_SIZE(mux_config_memory_reads);
+	return mux_config_memory_reads;
+}
+
+static const struct i915_oa_reg b_counter_config_memory_writes[] = {
+	{ _MMIO(0x2724), 0xf0800000 },
+	{ _MMIO(0x2720), 0x00000000 },
+	{ _MMIO(0x2714), 0xf0800000 },
+	{ _MMIO(0x2710), 0x00000000 },
+	{ _MMIO(0x274c), 0x76543298 },
+	{ _MMIO(0x2748), 0x98989898 },
+	{ _MMIO(0x2744), 0x000000e4 },
+	{ _MMIO(0x2740), 0x00000000 },
+	{ _MMIO(0x275c), 0xbabababa },
+	{ _MMIO(0x2758), 0x88888888 },
+	{ _MMIO(0x2754), 0x000c5500 },
+	{ _MMIO(0x2750), 0x00000000 },
+	{ _MMIO(0x2770), 0x0007f81a },
+	{ _MMIO(0x2774), 0x0000fc00 },
+	{ _MMIO(0x2778), 0x0007f82a },
+	{ _MMIO(0x277c), 0x0000fc00 },
+	{ _MMIO(0x2780), 0x0007f822 },
+	{ _MMIO(0x2784), 0x0000fc00 },
+	{ _MMIO(0x2788), 0x0007f8ba },
+	{ _MMIO(0x278c), 0x0000fc00 },
+	{ _MMIO(0x2790), 0x0007f87a },
+	{ _MMIO(0x2794), 0x0000fc00 },
+	{ _MMIO(0x2798), 0x0007f8ea },
+	{ _MMIO(0x279c), 0x0000fc00 },
+	{ _MMIO(0x27a0), 0x0007f8e2 },
+	{ _MMIO(0x27a4), 0x0000fc00 },
+	{ _MMIO(0x27a8), 0x0007f8f2 },
+	{ _MMIO(0x27ac), 0x0000fc00 },
+};
+
+static const struct i915_oa_reg mux_config_memory_writes[] = {
+	{ _MMIO(0x253a4), 0x34300000 },
+	{ _MMIO(0x25440), 0x01500000 },
+	{ _MMIO(0x25444), 0x00000120 },
+	{ _MMIO(0x25128), 0x0c200000 },
+	{ _MMIO(0x25380), 0x00000450 },
+	{ _MMIO(0x25390), 0x00052c43 },
+	{ _MMIO(0x25384), 0x00000000 },
+	{ _MMIO(0x25400), 0x00007184 },
+	{ _MMIO(0x25408), 0x0a418820 },
+	{ _MMIO(0x2540c), 0x000820e6 },
+	{ _MMIO(0x25404), 0xff500000 },
+	{ _MMIO(0x25100), 0x000005d6 },
+	{ _MMIO(0x2510c), 0x1e700000 },
+	{ _MMIO(0x25104), 0x00000000 },
+	{ _MMIO(0x25420), 0x02108421 },
+	{ _MMIO(0x25424), 0x00008421 },
+	{ _MMIO(0x2541c), 0x00000000 },
+	{ _MMIO(0x25428), 0x00000000 },
+};
+
+static const struct i915_oa_reg *
+get_memory_writes_mux_config(struct drm_i915_private *dev_priv,
+			     int *len)
+{
+	*len = ARRAY_SIZE(mux_config_memory_writes);
+	return mux_config_memory_writes;
+}
+
+static const struct i915_oa_reg b_counter_config_sampler_balance[] = {
+	{ _MMIO(0x2740), 0x00000000 },
+	{ _MMIO(0x2744), 0x00800000 },
+	{ _MMIO(0x2710), 0x00000000 },
+	{ _MMIO(0x2714), 0x00800000 },
+	{ _MMIO(0x2720), 0x00000000 },
+	{ _MMIO(0x2724), 0x00800000 },
+};
+
+static const struct i915_oa_reg mux_config_sampler_balance[] = {
+	{ _MMIO(0x2eb9c), 0x01906400 },
+	{ _MMIO(0x2fb9c), 0x01906400 },
+	{ _MMIO(0x253a4), 0x00000000 },
+	{ _MMIO(0x26b9c), 0x01906400 },
+	{ _MMIO(0x27b9c), 0x01906400 },
+	{ _MMIO(0x27104), 0x00a00000 },
+	{ _MMIO(0x27184), 0x00a50000 },
+	{ _MMIO(0x2e804), 0x00500000 },
+	{ _MMIO(0x2e984), 0x00500000 },
+	{ _MMIO(0x2eb04), 0x00500000 },
+	{ _MMIO(0x2eb80), 0x00000084 },
+	{ _MMIO(0x2eb8c), 0x14200000 },
+	{ _MMIO(0x2eb84), 0x00000000 },
+	{ _MMIO(0x2f804), 0x00050000 },
+	{ _MMIO(0x2f984), 0x00050000 },
+	{ _MMIO(0x2fb04), 0x00050000 },
+	{ _MMIO(0x2fb80), 0x00000084 },
+	{ _MMIO(0x2fb8c), 0x00050800 },
+	{ _MMIO(0x2fb84), 0x00000000 },
+	{ _MMIO(0x25380), 0x00000010 },
+	{ _MMIO(0x2538c), 0x000000c0 },
+	{ _MMIO(0x25384), 0xaa550000 },
+	{ _MMIO(0x25404), 0xffffc000 },
+	{ _MMIO(0x26804), 0x50000000 },
+	{ _MMIO(0x26984), 0x50000000 },
+	{ _MMIO(0x26b04), 0x50000000 },
+	{ _MMIO(0x26b80), 0x00000084 },
+	{ _MMIO(0x26b90), 0x00050800 },
+	{ _MMIO(0x26b84), 0x00000000 },
+	{ _MMIO(0x27804), 0x05000000 },
+	{ _MMIO(0x27984), 0x05000000 },
+	{ _MMIO(0x27b04), 0x05000000 },
+	{ _MMIO(0x27b80), 0x00000084 },
+	{ _MMIO(0x27b90), 0x00000142 },
+	{ _MMIO(0x27b84), 0x00000000 },
+	{ _MMIO(0x26104), 0xa0000000 },
+	{ _MMIO(0x26184), 0xa5000000 },
+	{ _MMIO(0x25424), 0x00008620 },
+	{ _MMIO(0x2541c), 0x00000000 },
+	{ _MMIO(0x25428), 0x0004a54a },
+};
+
+static const struct i915_oa_reg *
+get_sampler_balance_mux_config(struct drm_i915_private *dev_priv,
+			       int *len)
+{
+	*len = ARRAY_SIZE(mux_config_sampler_balance);
+	return mux_config_sampler_balance;
+}
+
 int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv)
 {
 	dev_priv->perf.oa.mux_regs = NULL;
@@ -140,6 +437,106 @@ int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv)
 			ARRAY_SIZE(b_counter_config_render_basic);
 
 		return 0;
+	case METRIC_SET_ID_COMPUTE_BASIC:
+		dev_priv->perf.oa.mux_regs =
+			get_compute_basic_mux_config(dev_priv,
+						     &dev_priv->perf.oa.mux_regs_len);
+		if (!dev_priv->perf.oa.mux_regs) {
+			DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_BASIC\" metric set");
+
+			/* EINVAL because *_register_sysfs already checked this
+			 * and so it wouldn't have been advertised so userspace and
+			 * so shouldn't have been requested
+			 */
+			return -EINVAL;
+		}
+
+		dev_priv->perf.oa.b_counter_regs =
+			b_counter_config_compute_basic;
+		dev_priv->perf.oa.b_counter_regs_len =
+			ARRAY_SIZE(b_counter_config_compute_basic);
+
+		return 0;
+	case METRIC_SET_ID_COMPUTE_EXTENDED:
+		dev_priv->perf.oa.mux_regs =
+			get_compute_extended_mux_config(dev_priv,
+							&dev_priv->perf.oa.mux_regs_len);
+		if (!dev_priv->perf.oa.mux_regs) {
+			DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_EXTENDED\" metric set");
+
+			/* EINVAL because *_register_sysfs already checked this
+			 * and so it wouldn't have been advertised so userspace and
+			 * so shouldn't have been requested
+			 */
+			return -EINVAL;
+		}
+
+		dev_priv->perf.oa.b_counter_regs =
+			b_counter_config_compute_extended;
+		dev_priv->perf.oa.b_counter_regs_len =
+			ARRAY_SIZE(b_counter_config_compute_extended);
+
+		return 0;
+	case METRIC_SET_ID_MEMORY_READS:
+		dev_priv->perf.oa.mux_regs =
+			get_memory_reads_mux_config(dev_priv,
+						    &dev_priv->perf.oa.mux_regs_len);
+		if (!dev_priv->perf.oa.mux_regs) {
+			DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_READS\" metric set");
+
+			/* EINVAL because *_register_sysfs already checked this
+			 * and so it wouldn't have been advertised so userspace and
+			 * so shouldn't have been requested
+			 */
+			return -EINVAL;
+		}
+
+		dev_priv->perf.oa.b_counter_regs =
+			b_counter_config_memory_reads;
+		dev_priv->perf.oa.b_counter_regs_len =
+			ARRAY_SIZE(b_counter_config_memory_reads);
+
+		return 0;
+	case METRIC_SET_ID_MEMORY_WRITES:
+		dev_priv->perf.oa.mux_regs =
+			get_memory_writes_mux_config(dev_priv,
+						     &dev_priv->perf.oa.mux_regs_len);
+		if (!dev_priv->perf.oa.mux_regs) {
+			DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_WRITES\" metric set");
+
+			/* EINVAL because *_register_sysfs already checked this
+			 * and so it wouldn't have been advertised so userspace and
+			 * so shouldn't have been requested
+			 */
+			return -EINVAL;
+		}
+
+		dev_priv->perf.oa.b_counter_regs =
+			b_counter_config_memory_writes;
+		dev_priv->perf.oa.b_counter_regs_len =
+			ARRAY_SIZE(b_counter_config_memory_writes);
+
+		return 0;
+	case METRIC_SET_ID_SAMPLER_BALANCE:
+		dev_priv->perf.oa.mux_regs =
+			get_sampler_balance_mux_config(dev_priv,
+						       &dev_priv->perf.oa.mux_regs_len);
+		if (!dev_priv->perf.oa.mux_regs) {
+			DRM_DEBUG_DRIVER("No suitable MUX config for \"SAMPLER_BALANCE\" metric set");
+
+			/* EINVAL because *_register_sysfs already checked this
+			 * and so it wouldn't have been advertised so userspace and
+			 * so shouldn't have been requested
+			 */
+			return -EINVAL;
+		}
+
+		dev_priv->perf.oa.b_counter_regs =
+			b_counter_config_sampler_balance;
+		dev_priv->perf.oa.b_counter_regs_len =
+			ARRAY_SIZE(b_counter_config_sampler_balance);
+
+		return 0;
 	default:
 		return -ENODEV;
 	}
@@ -167,6 +564,116 @@ static struct attribute_group group_render_basic = {
 	.attrs =  attrs_render_basic,
 };
 
+static ssize_t
+show_compute_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_BASIC);
+}
+
+static struct device_attribute dev_attr_compute_basic_id = {
+	.attr = { .name = "id", .mode = 0444 },
+	.show = show_compute_basic_id,
+	.store = NULL,
+};
+
+static struct attribute *attrs_compute_basic[] = {
+	&dev_attr_compute_basic_id.attr,
+	NULL,
+};
+
+static struct attribute_group group_compute_basic = {
+	.name = "39ad14bc-2380-45c4-91eb-fbcb3aa7ae7b",
+	.attrs =  attrs_compute_basic,
+};
+
+static ssize_t
+show_compute_extended_id(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_EXTENDED);
+}
+
+static struct device_attribute dev_attr_compute_extended_id = {
+	.attr = { .name = "id", .mode = 0444 },
+	.show = show_compute_extended_id,
+	.store = NULL,
+};
+
+static struct attribute *attrs_compute_extended[] = {
+	&dev_attr_compute_extended_id.attr,
+	NULL,
+};
+
+static struct attribute_group group_compute_extended = {
+	.name = "3865be28-6982-49fe-9494-e4d1b4795413",
+	.attrs =  attrs_compute_extended,
+};
+
+static ssize_t
+show_memory_reads_id(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_READS);
+}
+
+static struct device_attribute dev_attr_memory_reads_id = {
+	.attr = { .name = "id", .mode = 0444 },
+	.show = show_memory_reads_id,
+	.store = NULL,
+};
+
+static struct attribute *attrs_memory_reads[] = {
+	&dev_attr_memory_reads_id.attr,
+	NULL,
+};
+
+static struct attribute_group group_memory_reads = {
+	.name = "bb5ed49b-2497-4095-94f6-26ba294db88a",
+	.attrs =  attrs_memory_reads,
+};
+
+static ssize_t
+show_memory_writes_id(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_WRITES);
+}
+
+static struct device_attribute dev_attr_memory_writes_id = {
+	.attr = { .name = "id", .mode = 0444 },
+	.show = show_memory_writes_id,
+	.store = NULL,
+};
+
+static struct attribute *attrs_memory_writes[] = {
+	&dev_attr_memory_writes_id.attr,
+	NULL,
+};
+
+static struct attribute_group group_memory_writes = {
+	.name = "3358d639-9b5f-45ab-976d-9b08cbfc6240",
+	.attrs =  attrs_memory_writes,
+};
+
+static ssize_t
+show_sampler_balance_id(struct device *kdev, struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%d\n", METRIC_SET_ID_SAMPLER_BALANCE);
+}
+
+static struct device_attribute dev_attr_sampler_balance_id = {
+	.attr = { .name = "id", .mode = 0444 },
+	.show = show_sampler_balance_id,
+	.store = NULL,
+};
+
+static struct attribute *attrs_sampler_balance[] = {
+	&dev_attr_sampler_balance_id.attr,
+	NULL,
+};
+
+static struct attribute_group group_sampler_balance = {
+	.name = "bc274488-b4b6-40c7-90da-b77d7ad16189",
+	.attrs =  attrs_sampler_balance,
+};
+
 int
 i915_perf_register_sysfs_hsw(struct drm_i915_private *dev_priv)
 {
@@ -178,9 +685,49 @@ i915_perf_register_sysfs_hsw(struct drm_i915_private *dev_priv)
 		if (ret)
 			goto error_render_basic;
 	}
+	if (get_compute_basic_mux_config(dev_priv, &mux_len)) {
+		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
+		if (ret)
+			goto error_compute_basic;
+	}
+	if (get_compute_extended_mux_config(dev_priv, &mux_len)) {
+		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
+		if (ret)
+			goto error_compute_extended;
+	}
+	if (get_memory_reads_mux_config(dev_priv, &mux_len)) {
+		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
+		if (ret)
+			goto error_memory_reads;
+	}
+	if (get_memory_writes_mux_config(dev_priv, &mux_len)) {
+		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
+		if (ret)
+			goto error_memory_writes;
+	}
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len)) {
+		ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
+		if (ret)
+			goto error_sampler_balance;
+	}
 
 	return 0;
 
+error_sampler_balance:
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
+error_memory_writes:
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
+error_memory_reads:
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
+error_compute_extended:
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
+error_compute_basic:
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
 error_render_basic:
 	return ret;
 }
@@ -192,4 +739,14 @@ i915_perf_unregister_sysfs_hsw(struct drm_i915_private *dev_priv)
 
 	if (get_render_basic_mux_config(dev_priv, &mux_len))
 		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
+	if (get_compute_basic_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
+	if (get_compute_extended_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
+	if (get_memory_reads_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
+	if (get_memory_writes_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
+	if (get_sampler_balance_mux_config(dev_priv, &mux_len))
+		sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
 }
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

PATCH v9 11/11 drm/i915: Add a kerneldoc summary for i915_perf.c

In reply to Robert Bragg

In particular this tries to capture for posterity some of the early challenges we had with using the core perf infrastructure in case we ever want to revisit adapting perf for device metrics.

---
 drivers/gpu/drm/i915/i915_perf.c | 163 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 163 insertions(+)
drivers/gpu/drm/i915/i915_perf.c +163 -0
index 1a87fe9..9551282 100644
@@ -24,6 +24,169 @@
  *   Robert Bragg <[email protected]>
  */
 
+
+/**
+ * DOC: i915 Perf, streaming API for GPU metrics
+ *
+ * Gen graphics supports a large number of performance counters that can help
+ * driver and application developers understand and optimize their use of the
+ * GPU.
+ *
+ * This i915 perf interface enables userspace to configure and open a file
+ * descriptor representing a stream of GPU metrics which can then be read() as
+ * a stream of sample records.
+ *
+ * The interface is particularly suited to exposing buffered metrics that are
+ * captured by DMA from the GPU, unsynchronized with and unrelated to the CPU.
+ *
+ * Streams representing a single context are accessible to applications with a
+ * corresponding drm file descriptor, such that OpenGL can use the interface
+ * without special privileges. Access to system-wide metrics requires root
+ * privileges by default, unless changed via the dev.i915.perf_event_paranoid
+ * sysctl option.
+ *
+ *
+ * The interface was initially inspired by the core Perf infrastructure but
+ * some notable differences are:
+ *
+ * i915 perf file descriptors represent a "stream" instead of an "event"; where
+ * a perf event primarily corresponds to a single 64bit value, while a stream
+ * might sample sets of tightly-coupled counters, depending on the
+ * configuration.  For example the Gen OA unit isn't designed to support
+ * orthogonal configurations of individual counters; it's configured for a set
+ * of related counters. Samples for an i915 perf stream capturing OA metrics
+ * will include a set of counter values packed in a compact HW specific format.
+ * The OA unit supports a number of different packing formats which can be
+ * selected by the user opening the stream. Perf has support for grouping
+ * events, but each event in the group is configured, validated and
+ * authenticated individually with separate system calls.
+ *
+ * i915 perf stream configurations are provided as an array of u64 (key,value)
+ * pairs, instead of a fixed struct with multiple miscellaneous config members,
+ * interleaved with event-type specific members.
+ *
+ * i915 perf doesn't support exposing metrics via an mmap'd circular buffer.
+ * The supported metrics are being written to memory by the GPU unsynchronized
+ * with the CPU, using HW specific packing formats for counter sets. Sometimes
+ * the constraints on HW configuration require reports to be filtered before it
+ * would be acceptable to expose them to unprivileged applications - to hide
+ * the metrics of other processes/contexts. For these use cases a read() based
+ * interface is a good fit, and provides an opportunity to filter data as it
+ * gets copied from the GPU mapped buffers to userspace buffers.
+ *
+ *
+ * Some notes regarding Linux Perf:
+ * --------------------------------
+ *
+ * The first prototype of this driver was based on the core perf
+ * infrastructure, and while we did make that mostly work, with some changes to
+ * perf, we found we were breaking or working around too many assumptions baked
+ * into perf's currently cpu centric design.
+ *
+ * In the end we didn't see a clear benefit to making perf's implementation and
+ * interface more complex by changing design assumptions while we knew we still
+ * wouldn't be able to use any existing perf based userspace tools.
+ *
+ * Also considering the Gen specific nature of the Observability hardware and
+ * how userspace will sometimes need to combine i915 perf OA metrics with
+ * side-band OA data captured via MI_REPORT_PERF_COUNT commands; we're
+ * expecting the interface to be used by a platform specific userspace such as
+ * OpenGL or tools. This is to say; we aren't inherently missing out on having
+ * a standard vendor/architecture agnostic interface by not using perf.
+ *
+ *
+ * For posterity, in case we might re-visit trying to adapt core perf to be
+ * better suited to exposing i915 metrics these were the main pain points we
+ * hit:
+ *
+ * - The perf based OA PMU driver broke some significant design assumptions:
+ *
+ *   Existing perf pmus are used for profiling work on a cpu and we were
+ *   introducing the idea of _IS_DEVICE pmus with different security
+ *   implications, the need to fake cpu-related data (such as user/kernel
+ *   registers) to fit with perf's current design, and adding _DEVICE records
+ *   as a way to forward device-specific status records.
+ *
+ *   The OA unit writes reports of counters into a circular buffer, without
+ *   involvement from the CPU, making our PMU driver the first of a kind.
+ *
+ *   Given the way we were periodically forward data from the GPU-mapped, OA
+ *   buffer to perf's buffer, those bursts of sample writes looked to perf like
+ *   we were sampling too fast and so we had to subvert its throttling checks.
+ *
+ *   Perf supports groups of counters and allows those to be read via
+ *   transactions internally but transactions currently seem designed to be
+ *   explicitly initiated from the cpu (say in response to a userspace read())
+ *   and while we could pull a report out of the OA buffer we can't
+ *   trigger a report from the cpu on demand.
+ *
+ *   Related to being report based; the OA counters are configured in HW as a
+ *   set while perf generally expects counter configurations to be orthogonal.
+ *   Although counters can be associated with a group leader as they are
+ *   opened, there's no clear precedent for being able to provide group-wide
+ *   configuration attributes (for example we want to let userspace choose the
+ *   OA unit report format used to capture all counters in a set, or specify a
+ *   GPU context to filter metrics on). We avoided using perf's grouping
+ *   feature and forwarded OA reports to userspace via perf's 'raw' sample
+ *   field. This suited our userspace well considering how coupled the counters
+ *   are when dealing with normalizing. It would be inconvenient to split
+ *   counters up into separate events, only to require userspace to recombine
+ *   them. For Mesa it's also convenient to be forwarded raw, periodic reports
+ *   for combining with the side-band raw reports it captures using
+ *   MI_REPORT_PERF_COUNT commands.
+ *
+ *   _ As a side note on perf's grouping feature; there was also some concern
+ *     that using PERF_FORMAT_GROUP as a way to pack together counter values
+ *     would quite drastically inflate our sample sizes, which would likely
+ *     lower the effective sampling resolutions we could use when the available
+ *     memory bandwidth is limited.
+ *
+ *     With the OA unit's report formats, counters are packed together as 32
+ *     or 40bit values, with the largest report size being 256 bytes.
+ *
+ *     PERF_FORMAT_GROUP values are 64bit, but there doesn't appear to be a
+ *     documented ordering to the values, implying PERF_FORMAT_ID must also be
+ *     used to add a 64bit ID before each value; giving 16 bytes per counter.
+ *
+ *   Related to counter orthogonality; we can't time share the OA unit, while
+ *   event scheduling is a central design idea within perf for allowing
+ *   userspace to open + enable more events than can be configured in HW at any
+ *   one time.  The OA unit is not designed to allow re-configuration while in
+ *   use. We can't reconfigure the OA unit without losing internal OA unit
+ *   state which we can't access explicitly to save and restore. Reconfiguring
+ *   the OA unit is also relatively slow, involving ~100 register writes. From
+ *   userspace Mesa also depends on a stable OA configuration when emitting
+ *   MI_REPORT_PERF_COUNT commands and importantly the OA unit can't be
+ *   disabled while there are outstanding MI_RPC commands lest we hang the
+ *   command streamer.
+ *
+ *   The contents of sample records aren't extensible by device drivers (i.e.
+ *   the sample_type bits). As an example; Sourab Gupta had been looking to
+ *   attach GPU timestamps to our OA samples. We were shoehorning OA reports
+ *   into sample records by using the 'raw' field, but it's tricky to pack more
+ *   than one thing into this field because events/core.c currently only lets a
+ *   pmu give a single raw data pointer plus len which will be copied into the
+ *   ring buffer. To include more than the OA report we'd have to copy the
+ *   report into an intermediate larger buffer. I'd been considering allowing a
+ *   vector of data+len values to be specified for copying the raw data, but
+ *   it felt like a kludge to being using the raw field for this purpose.
+ *
+ * - It felt like our perf based PMU was making some technical compromises
+ *   just for the sake of using perf:
+ *
+ *   perf_event_open() requires events to either relate to a pid or a specific
+ *   cpu core, while our device pmu related to neither.  Events opened with a
+ *   pid will be automatically enabled/disabled according to the scheduling of
+ *   that process - so not appropriate for us. When an event is related to a
+ *   cpu id, perf ensures pmu methods will be invoked via an inter process
+ *   interrupt on that core. To avoid invasive changes our userspace opened OA
+ *   perf events for a specific cpu. This was workable but it meant the
+ *   majority of the OA driver ran in atomic context, including all OA report
+ *   forwarding, which wasn't really necessary in our case and seems to make
+ *   our locking requirements somewhat complex as we handled the interaction
+ *   with the rest of the i915 driver.
+ */
+
 #include <linux/anon_inodes.h>
 #include <linux/sizes.h>
 
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v9 11/11
#28 lore raw

Re: [PATCH v9 11/11] drm/i915: Add a kerneldoc summary for i915_perf.c

Quoted 8 lines · Robert Bragg

In particular this tries to capture for posterity some of the early challenges we had with using the core perf infrastructure in case we ever want to revisit adapting perf for device metrics.

---

Good summary of early challenges faced while adapting core perf.

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

#29 lore raw

Re: [PATCH v9 11/11] drm/i915: Add a kerneldoc summary for i915_perf.c

In reply to Robert Bragg
Quoted 9 lines · Robert Bragg

In particular this tries to capture for posterity some of the early challenges we had with using the core perf infrastructure in case we ever want to revisit adapting perf for device metrics.

---
 drivers/gpu/drm/i915/i915_perf.c | 163 +++++++++++++++++++++++++++++++++++++++

Missing the include stanza in Documentation/gpu/i915.rst, which means this won't show up in the docs build. Also function/struct docs are not included either it seems.

Please check out Documentation/kernel-documentation.rst and build it all with

$ make DOCBOOKS="" htmldocs

Again fixup patch is fine.
-Daniel

Quoted 183 lines
 1 file changed, 163 insertions(+)
drivers/gpu/drm/i915/i915_perf.c +163 -0
index 1a87fe9..9551282 100644
@@ -24,6 +24,169 @@
  *   Robert Bragg <[email protected]>
  */
 
+
+/**
+ * DOC: i915 Perf, streaming API for GPU metrics
+ *
+ * Gen graphics supports a large number of performance counters that can help
+ * driver and application developers understand and optimize their use of the
+ * GPU.
+ *
+ * This i915 perf interface enables userspace to configure and open a file
+ * descriptor representing a stream of GPU metrics which can then be read() as
+ * a stream of sample records.
+ *
+ * The interface is particularly suited to exposing buffered metrics that are
+ * captured by DMA from the GPU, unsynchronized with and unrelated to the CPU.
+ *
+ * Streams representing a single context are accessible to applications with a
+ * corresponding drm file descriptor, such that OpenGL can use the interface
+ * without special privileges. Access to system-wide metrics requires root
+ * privileges by default, unless changed via the dev.i915.perf_event_paranoid
+ * sysctl option.
+ *
+ *
+ * The interface was initially inspired by the core Perf infrastructure but
+ * some notable differences are:
+ *
+ * i915 perf file descriptors represent a "stream" instead of an "event"; where
+ * a perf event primarily corresponds to a single 64bit value, while a stream
+ * might sample sets of tightly-coupled counters, depending on the
+ * configuration.  For example the Gen OA unit isn't designed to support
+ * orthogonal configurations of individual counters; it's configured for a set
+ * of related counters. Samples for an i915 perf stream capturing OA metrics
+ * will include a set of counter values packed in a compact HW specific format.
+ * The OA unit supports a number of different packing formats which can be
+ * selected by the user opening the stream. Perf has support for grouping
+ * events, but each event in the group is configured, validated and
+ * authenticated individually with separate system calls.
+ *
+ * i915 perf stream configurations are provided as an array of u64 (key,value)
+ * pairs, instead of a fixed struct with multiple miscellaneous config members,
+ * interleaved with event-type specific members.
+ *
+ * i915 perf doesn't support exposing metrics via an mmap'd circular buffer.
+ * The supported metrics are being written to memory by the GPU unsynchronized
+ * with the CPU, using HW specific packing formats for counter sets. Sometimes
+ * the constraints on HW configuration require reports to be filtered before it
+ * would be acceptable to expose them to unprivileged applications - to hide
+ * the metrics of other processes/contexts. For these use cases a read() based
+ * interface is a good fit, and provides an opportunity to filter data as it
+ * gets copied from the GPU mapped buffers to userspace buffers.
+ *
+ *
+ * Some notes regarding Linux Perf:
+ * --------------------------------
+ *
+ * The first prototype of this driver was based on the core perf
+ * infrastructure, and while we did make that mostly work, with some changes to
+ * perf, we found we were breaking or working around too many assumptions baked
+ * into perf's currently cpu centric design.
+ *
+ * In the end we didn't see a clear benefit to making perf's implementation and
+ * interface more complex by changing design assumptions while we knew we still
+ * wouldn't be able to use any existing perf based userspace tools.
+ *
+ * Also considering the Gen specific nature of the Observability hardware and
+ * how userspace will sometimes need to combine i915 perf OA metrics with
+ * side-band OA data captured via MI_REPORT_PERF_COUNT commands; we're
+ * expecting the interface to be used by a platform specific userspace such as
+ * OpenGL or tools. This is to say; we aren't inherently missing out on having
+ * a standard vendor/architecture agnostic interface by not using perf.
+ *
+ *
+ * For posterity, in case we might re-visit trying to adapt core perf to be
+ * better suited to exposing i915 metrics these were the main pain points we
+ * hit:
+ *
+ * - The perf based OA PMU driver broke some significant design assumptions:
+ *
+ *   Existing perf pmus are used for profiling work on a cpu and we were
+ *   introducing the idea of _IS_DEVICE pmus with different security
+ *   implications, the need to fake cpu-related data (such as user/kernel
+ *   registers) to fit with perf's current design, and adding _DEVICE records
+ *   as a way to forward device-specific status records.
+ *
+ *   The OA unit writes reports of counters into a circular buffer, without
+ *   involvement from the CPU, making our PMU driver the first of a kind.
+ *
+ *   Given the way we were periodically forward data from the GPU-mapped, OA
+ *   buffer to perf's buffer, those bursts of sample writes looked to perf like
+ *   we were sampling too fast and so we had to subvert its throttling checks.
+ *
+ *   Perf supports groups of counters and allows those to be read via
+ *   transactions internally but transactions currently seem designed to be
+ *   explicitly initiated from the cpu (say in response to a userspace read())
+ *   and while we could pull a report out of the OA buffer we can't
+ *   trigger a report from the cpu on demand.
+ *
+ *   Related to being report based; the OA counters are configured in HW as a
+ *   set while perf generally expects counter configurations to be orthogonal.
+ *   Although counters can be associated with a group leader as they are
+ *   opened, there's no clear precedent for being able to provide group-wide
+ *   configuration attributes (for example we want to let userspace choose the
+ *   OA unit report format used to capture all counters in a set, or specify a
+ *   GPU context to filter metrics on). We avoided using perf's grouping
+ *   feature and forwarded OA reports to userspace via perf's 'raw' sample
+ *   field. This suited our userspace well considering how coupled the counters
+ *   are when dealing with normalizing. It would be inconvenient to split
+ *   counters up into separate events, only to require userspace to recombine
+ *   them. For Mesa it's also convenient to be forwarded raw, periodic reports
+ *   for combining with the side-band raw reports it captures using
+ *   MI_REPORT_PERF_COUNT commands.
+ *
+ *   _ As a side note on perf's grouping feature; there was also some concern
+ *     that using PERF_FORMAT_GROUP as a way to pack together counter values
+ *     would quite drastically inflate our sample sizes, which would likely
+ *     lower the effective sampling resolutions we could use when the available
+ *     memory bandwidth is limited.
+ *
+ *     With the OA unit's report formats, counters are packed together as 32
+ *     or 40bit values, with the largest report size being 256 bytes.
+ *
+ *     PERF_FORMAT_GROUP values are 64bit, but there doesn't appear to be a
+ *     documented ordering to the values, implying PERF_FORMAT_ID must also be
+ *     used to add a 64bit ID before each value; giving 16 bytes per counter.
+ *
+ *   Related to counter orthogonality; we can't time share the OA unit, while
+ *   event scheduling is a central design idea within perf for allowing
+ *   userspace to open + enable more events than can be configured in HW at any
+ *   one time.  The OA unit is not designed to allow re-configuration while in
+ *   use. We can't reconfigure the OA unit without losing internal OA unit
+ *   state which we can't access explicitly to save and restore. Reconfiguring
+ *   the OA unit is also relatively slow, involving ~100 register writes. From
+ *   userspace Mesa also depends on a stable OA configuration when emitting
+ *   MI_REPORT_PERF_COUNT commands and importantly the OA unit can't be
+ *   disabled while there are outstanding MI_RPC commands lest we hang the
+ *   command streamer.
+ *
+ *   The contents of sample records aren't extensible by device drivers (i.e.
+ *   the sample_type bits). As an example; Sourab Gupta had been looking to
+ *   attach GPU timestamps to our OA samples. We were shoehorning OA reports
+ *   into sample records by using the 'raw' field, but it's tricky to pack more
+ *   than one thing into this field because events/core.c currently only lets a
+ *   pmu give a single raw data pointer plus len which will be copied into the
+ *   ring buffer. To include more than the OA report we'd have to copy the
+ *   report into an intermediate larger buffer. I'd been considering allowing a
+ *   vector of data+len values to be specified for copying the raw data, but
+ *   it felt like a kludge to being using the raw field for this purpose.
+ *
+ * - It felt like our perf based PMU was making some technical compromises
+ *   just for the sake of using perf:
+ *
+ *   perf_event_open() requires events to either relate to a pid or a specific
+ *   cpu core, while our device pmu related to neither.  Events opened with a
+ *   pid will be automatically enabled/disabled according to the scheduling of
+ *   that process - so not appropriate for us. When an event is related to a
+ *   cpu id, perf ensures pmu methods will be invoked via an inter process
+ *   interrupt on that core. To avoid invasive changes our userspace opened OA
+ *   perf events for a specific cpu. This was workable but it meant the
+ *   majority of the OA driver ran in atomic context, including all OA report
+ *   forwarding, which wasn't really necessary in our case and seems to make
+ *   our locking requirements somewhat complex as we handled the interaction
+ *   with the rest of the i915 driver.
+ */
+
 #include <linux/anon_inodes.h>
 #include <linux/sizes.h>
 
Signature · 6 lines
2.10.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw

✗ Fi.CI.BAT: failure for Enable i915 perf stream for Haswell OA unit

In reply to Robert Bragg
== Series Details ==

== Series Details ==

Series: Enable i915 perf stream for Haswell OA unit
URL : https://patchwork.freedesktop.org/series/14935/
State : failure

== Summary ==

Series 14935v1 Enable i915 perf stream for Haswell OA unit
https://patchwork.freedesktop.org/api/1.0/series/14935/revisions/1/mbox/

Test gem_exec_parse:

        Subgroup basic-rejected:
                pass       -> FAIL       (fi-hsw-4770r)
                pass       -> FAIL       (fi-byt-n2820)
                pass       -> FAIL       (fi-hsw-4770)
                pass       -> FAIL       (fi-ivb-3520m)
                pass       -> FAIL       (fi-ivb-3770)
                pass       -> FAIL       (fi-byt-j1900)
fi-bdw-5557u     total:241  pass:226  dwarn:0   dfail:0   fail:0   skip:15 
fi-bxt-t5700     total:241  pass:213  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-j1900     total:241  pass:212  dwarn:0   dfail:0   fail:1   skip:28 
fi-byt-n2820     total:241  pass:208  dwarn:0   dfail:0   fail:1   skip:32 
fi-hsw-4770      total:241  pass:220  dwarn:0   dfail:0   fail:1   skip:20 
fi-hsw-4770r     total:241  pass:220  dwarn:0   dfail:0   fail:1   skip:20 
fi-ilk-650       total:241  pass:188  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m     total:241  pass:218  dwarn:0   dfail:0   fail:1   skip:22 
fi-ivb-3770      total:241  pass:218  dwarn:0   dfail:0   fail:1   skip:22 
fi-skl-6260u     total:241  pass:227  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:241  pass:220  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k     total:241  pass:219  dwarn:1   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:241  pass:227  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m     total:241  pass:209  dwarn:0   dfail:0   fail:0   skip:32 
fi-snb-2600      total:241  pass:208  dwarn:0   dfail:0   fail:0   skip:33 

fb7fc6fcfc660044f50b98e63ab608afdf4eb1ef drm-intel-nightly: 2016y-11m-07d-17h-05m-46s UTC integration manifest 9fb1bf7 drm/i915: Add a kerneldoc summary for i915_perf.c
78a09b4 drm/i915: Add more Haswell OA metric sets
1167139 drm/i915: add dev.i915.oa_max_sample_rate sysctl
2046027 drm/i915: Add dev.i915.perf_stream_paranoid sysctl option
c3f7e74 drm/i915: advertise available metrics via sysfs
8a66445 drm/i915: Enable i915 perf stream for Haswell OA unit
64a5c5e drm/i915: Add 'render basic' Haswell OA unit config
2f6d0a1 drm/i915: don't whitelist oacontrol in cmd parser
735a8a5 drm/i915: return EACCES for check_cmd() failures
5d5a243 drm/i915: rename OACONTROL GEN7_OACONTROL
19883ca0 drm/i915: Add i915 perf infrastructure

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2925/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#31 lore raw

✗ Fi.CI.BAT: failure for Enable i915 perf stream for Haswell OA unit (rev2)

In reply to Robert Bragg
== Series Details ==

== Series Details ==

Series: Enable i915 perf stream for Haswell OA unit (rev2)
URL : https://patchwork.freedesktop.org/series/14935/
State : failure

== Summary ==

Series 14935v2 Enable i915 perf stream for Haswell OA unit
https://patchwork.freedesktop.org/api/1.0/series/14935/revisions/2/mbox/

Test gem_exec_parse:

        Subgroup basic-rejected:
                pass       -> FAIL       (fi-ivb-3520m)
                pass       -> FAIL       (fi-byt-j1900)
                pass       -> FAIL       (fi-ivb-3770)
                pass       -> FAIL       (fi-byt-n2820)
                pass       -> FAIL       (fi-hsw-4770r)
                pass       -> FAIL       (fi-hsw-4770)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-skl-6770hq)
fi-bdw-5557u     total:244  pass:229  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:244  pass:204  dwarn:0   dfail:0   fail:0   skip:40 
fi-bxt-t5700     total:244  pass:216  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-j1900     total:244  pass:215  dwarn:0   dfail:0   fail:1   skip:28 
fi-byt-n2820     total:244  pass:211  dwarn:0   dfail:0   fail:1   skip:32 
fi-hsw-4770      total:244  pass:223  dwarn:0   dfail:0   fail:1   skip:20 
fi-hsw-4770r     total:244  pass:223  dwarn:0   dfail:0   fail:1   skip:20 
fi-ilk-650       total:244  pass:191  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m     total:244  pass:221  dwarn:0   dfail:0   fail:1   skip:22 
fi-ivb-3770      total:244  pass:221  dwarn:0   dfail:0   fail:1   skip:22 
fi-kbl-7200u     total:244  pass:222  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u     total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:244  pass:223  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k     total:244  pass:222  dwarn:1   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:244  pass:230  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m     total:244  pass:212  dwarn:0   dfail:0   fail:0   skip:32 
fi-snb-2600      total:244  pass:211  dwarn:0   dfail:0   fail:0   skip:33 

aa74f4d7a58d239a7ff25c02eebf00c9ceb42c95 drm-intel-nightly: 2016y-11m-08d-11h-05m-41s UTC integration manifest 6bbae39 drm/i915: Add a kerneldoc summary for i915_perf.c
8b05137 drm/i915: Add more Haswell OA metric sets
f4c6eec drm/i915: add dev.i915.oa_max_sample_rate sysctl
9f486e7 drm/i915: Add dev.i915.perf_stream_paranoid sysctl option
576e12b drm/i915: advertise available metrics via sysfs
2fe39d2 drm/i915: Enable i915 perf stream for Haswell OA unit
b478f8e drm/i915: Add 'render basic' Haswell OA unit config
bcf0893 drm/i915: don't whitelist oacontrol in cmd parser
cf8aecb drm/i915: return EACCES for check_cmd() failures
676b8a2 drm/i915: rename OACONTROL GEN7_OACONTROL
289c71d drm/i915: Add i915 perf infrastructure

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2930/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx