All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] headers: add i915-perf interface to i915_drm.h
@ 2016-11-10 13:42 Robert Bragg
  2016-11-10 15:45 ` Emil Velikov
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Bragg @ 2016-11-10 13:42 UTC (permalink / raw)
  To: dri-devel

This interface gives access to Gen graphics Observability counters

Signed-off-by: Robert Bragg <robert@sixbynine.org>
---
 include/drm/i915_drm.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)

diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index eb611a7..9eb2b7b 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -230,6 +230,7 @@ typedef struct _drm_i915_sarea {
 #define DRM_I915_GEM_USERPTR		0x33
 #define DRM_I915_GEM_CONTEXT_GETPARAM	0x34
 #define DRM_I915_GEM_CONTEXT_SETPARAM	0x35
+#define DRM_I915_PERF_OPEN		0x36
 
 #define DRM_IOCTL_I915_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
 #define DRM_IOCTL_I915_FLUSH		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -283,6 +284,7 @@ typedef struct _drm_i915_sarea {
 #define DRM_IOCTL_I915_GEM_USERPTR			DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
 #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
 #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
+#define DRM_IOCTL_I915_PERF_OPEN	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
 
 /* Allow drivers to submit batchbuffers directly to hardware, relying
  * on the security mechanisms provided by hardware.
@@ -1172,4 +1174,136 @@ struct drm_i915_gem_context_param {
 	__u64 value;
 };
 
+enum drm_i915_oa_format {
+	I915_OA_FORMAT_A13 = 1,
+	I915_OA_FORMAT_A29,
+	I915_OA_FORMAT_A13_B8_C8,
+	I915_OA_FORMAT_B4_C8,
+	I915_OA_FORMAT_A45_B8_C8,
+	I915_OA_FORMAT_B4_C8_A16,
+	I915_OA_FORMAT_C4_B8,
+
+	I915_OA_FORMAT_MAX	    /* non-ABI */
+};
+
+enum drm_i915_perf_property_id {
+	/**
+	 * Open the stream for a specific context handle (as used with
+	 * execbuffer2). A stream opened for a specific context this way
+	 * won't typically require root privileges.
+	 */
+	DRM_I915_PERF_PROP_CTX_HANDLE = 1,
+
+	/**
+	 * A value of 1 requests the inclusion of raw OA unit reports as
+	 * part of stream samples.
+	 */
+	DRM_I915_PERF_PROP_SAMPLE_OA,
+
+	/**
+	 * The value specifies which set of OA unit metrics should be
+	 * be configured, defining the contents of any OA unit reports.
+	 */
+	DRM_I915_PERF_PROP_OA_METRICS_SET,
+
+	/**
+	 * The value specifies the size and layout of OA unit reports.
+	 */
+	DRM_I915_PERF_PROP_OA_FORMAT,
+
+	/**
+	 * Specifying this property implicitly requests periodic OA unit
+	 * sampling and (at least on Haswell) the sampling frequency is derived
+	 * from this exponent as follows:
+	 *
+	 *   80ns * 2^(period_exponent + 1)
+	 */
+	DRM_I915_PERF_PROP_OA_EXPONENT,
+
+	DRM_I915_PERF_PROP_MAX /* non-ABI */
+};
+
+struct drm_i915_perf_open_param {
+	__u32 flags;
+#define I915_PERF_FLAG_FD_CLOEXEC	(1<<0)
+#define I915_PERF_FLAG_FD_NONBLOCK	(1<<1)
+#define I915_PERF_FLAG_DISABLED		(1<<2)
+
+	/** The number of u64 (id, value) pairs */
+	__u32 num_properties;
+
+	/**
+	 * Pointer to array of u64 (id, value) pairs configuring the stream
+	 * to open.
+	 */
+	__u64 properties_ptr;
+};
+
+/**
+ * Enable data capture for a stream that was either opened in a disabled state
+ * via I915_PERF_FLAG_DISABLED or was later disabled via
+ * I915_PERF_IOCTL_DISABLE.
+ *
+ * It is intended to be cheaper to disable and enable a stream than it may be
+ * to close and re-open a stream with the same configuration.
+ *
+ * It's undefined whether any pending data for the stream will be lost.
+ */
+#define I915_PERF_IOCTL_ENABLE	_IO('i', 0x0)
+
+/**
+ * Disable data capture for a stream.
+ *
+ * It is an error to try and read a stream that is disabled.
+ */
+#define I915_PERF_IOCTL_DISABLE	_IO('i', 0x1)
+
+/**
+ * Common to all i915 perf records
+ */
+struct drm_i915_perf_record_header {
+	__u32 type;
+	__u16 pad;
+	__u16 size;
+};
+
+enum drm_i915_perf_record_type {
+
+	/**
+	 * Samples are the work horse record type whose contents are extensible
+	 * and defined when opening an i915 perf stream based on the given
+	 * properties.
+	 *
+	 * Boolean properties following the naming convention
+	 * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
+	 * every sample.
+	 *
+	 * The order of these sample properties given by userspace has no
+	 * affect on the ordering of data within a sample. The order is
+	 * documented here.
+	 *
+	 * struct {
+	 *     struct drm_i915_perf_record_header header;
+	 *
+	 *     { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
+	 * };
+	 */
+	DRM_I915_PERF_RECORD_SAMPLE = 1,
+
+	/*
+	 * Indicates that one or more OA reports were not written by the
+	 * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
+	 * command collides with periodic sampling - which would be more likely
+	 * at higher sampling frequencies.
+	 */
+	DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
+
+	/**
+	 * An error occurred that resulted in all pending OA reports being lost.
+	 */
+	DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
+
+	DRM_I915_PERF_RECORD_MAX /* non-ABI */
+};
+
 #endif /* _I915_DRM_H_ */
-- 
2.10.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] headers: add i915-perf interface to i915_drm.h
  2016-11-10 13:42 [PATCH] headers: add i915-perf interface to i915_drm.h Robert Bragg
@ 2016-11-10 15:45 ` Emil Velikov
  2016-11-10 16:55   ` Robert Bragg
  0 siblings, 1 reply; 3+ messages in thread
From: Emil Velikov @ 2016-11-10 15:45 UTC (permalink / raw)
  To: Robert Bragg; +Cc: ML dri-devel

Hi Robert

Just a couple of trivial suggestions:
 - git config --local format.subjectPrefix "PATCH libdrm"
 - make sure that the headers are generated via `make headers_install'
and state the tree/sha that you've used.
See 9af2ccdef cc9a53f07 or 89cdda3d5.

Thanks
Emil
P.S. /me goes to add a README with the above instructions
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] headers: add i915-perf interface to i915_drm.h
  2016-11-10 15:45 ` Emil Velikov
@ 2016-11-10 16:55   ` Robert Bragg
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Bragg @ 2016-11-10 16:55 UTC (permalink / raw)
  To: Emil Velikov; +Cc: ML dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1424 bytes --]

Ah, yup, I missed the [PATH libdrm] convention sorry.

I noticed some other updates based on make headers_install, though I also
saw a bunch of unrelated noise with e.g. mocs and C++ guard changes so
figured I'd avoid those for now, while I was pretty much expecting I'd need
to re-send this later. I just wanted to get a patch out in case it could be
convenient for folks looking to run my i915-perf igt tests.

I don't have a meaningful tree/sha to reference while it's chicken/egg atm
the order of landing i915-perf changes.

tbh I didn't read the README before sending and not sure I'd expect to find
this kind of info there. Maybe if there were a CONTRIBUTING doc or
something along those lines a note could go there. I probably should have
just thought to check for a format-patch infix since libdrm isn't the only
fd.o project with this, it was probably a bit of laziness on my part so
sorry about that.

thanks for the note though, I've updated my git [format] config now.

- Robert


On Thu, Nov 10, 2016 at 3:45 PM, Emil Velikov <emil.l.velikov@gmail.com>
wrote:

> Hi Robert
>
> Just a couple of trivial suggestions:
>  - git config --local format.subjectPrefix "PATCH libdrm"
>  - make sure that the headers are generated via `make headers_install'
> and state the tree/sha that you've used.
> See 9af2ccdef cc9a53f07 or 89cdda3d5.
>
> Thanks
> Emil
> P.S. /me goes to add a README with the above instructions
>

[-- Attachment #1.2: Type: text/html, Size: 2058 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-10 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 13:42 [PATCH] headers: add i915-perf interface to i915_drm.h Robert Bragg
2016-11-10 15:45 ` Emil Velikov
2016-11-10 16:55   ` Robert Bragg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.