History

drm/i915: Enable i915 perf stream for Haswell OA unit

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.

Robert Bragg committed 10 years ago

Commit d7965151 parent 8a3003d4 files · +1482 −29Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/drm/i915_drm.h+69−2
@@ -1230,6 +1230,18 @@ struct drm_i915_gem_context_param { · 1229 unmodified lines
12301230 __u64 value;
12311231 };
12321232
1233+enum drm_i915_oa_format {
1234+ I915_OA_FORMAT_A13 = 1,
1235+ I915_OA_FORMAT_A29,
1236+ I915_OA_FORMAT_A13_B8_C8,
1237+ I915_OA_FORMAT_B4_C8,
1238+ I915_OA_FORMAT_A45_B8_C8,
1239+ I915_OA_FORMAT_B4_C8_A16,
1240+ I915_OA_FORMAT_C4_B8,
1241+
1242+ I915_OA_FORMAT_MAX /* non-ABI */
1243+};
1244+
12331245 enum drm_i915_perf_property_id {
12341246 /**
12351247 * Open the stream for a specific context handle (as used with
@@ -1238,6 +1250,32 @@ enum drm_i915_perf_property_id { · 2 unmodified lines
12381250 */
12391251 DRM_I915_PERF_PROP_CTX_HANDLE = 1,
12401252
1253+ /**
1254+ * A value of 1 requests the inclusion of raw OA unit reports as
1255+ * part of stream samples.
1256+ */
1257+ DRM_I915_PERF_PROP_SAMPLE_OA,
1258+
1259+ /**
1260+ * The value specifies which set of OA unit metrics should be
1261+ * be configured, defining the contents of any OA unit reports.
1262+ */
1263+ DRM_I915_PERF_PROP_OA_METRICS_SET,
1264+
1265+ /**
1266+ * The value specifies the size and layout of OA unit reports.
1267+ */
1268+ DRM_I915_PERF_PROP_OA_FORMAT,
1269+
1270+ /**
1271+ * Specifying this property implicitly requests periodic OA unit
1272+ * sampling and (at least on Haswell) the sampling frequency is derived
1273+ * from this exponent as follows:
1274+ *
1275+ * 80ns * 2^(period_exponent + 1)
1276+ */
1277+ DRM_I915_PERF_PROP_OA_EXPONENT,
1278+
12411279 DRM_I915_PERF_PROP_MAX /* non-ABI */
12421280 };
12431281
@@ -1257,7 +1295,23 @@ struct drm_i915_perf_open_param { · 13 unmodified lines
12571295 __u64 __user properties_ptr;
12581296 };
12591297
1298+/**
1299+ * Enable data capture for a stream that was either opened in a disabled state
1300+ * via I915_PERF_FLAG_DISABLED or was later disabled via
1301+ * I915_PERF_IOCTL_DISABLE.
1302+ *
1303+ * It is intended to be cheaper to disable and enable a stream than it may be
1304+ * to close and re-open a stream with the same configuration.
1305+ *
1306+ * It's undefined whether any pending data for the stream will be lost.
1307+ */
12601308 #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)
1309+
1310+/**
1311+ * Disable data capture for a stream.
1312+ *
1313+ * It is an error to try and read a stream that is disabled.
1314+ */
12611315 #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
12621316
12631317 /**
@@ -1281,17 +1335,30 @@ enum drm_i915_perf_record_type { · 17 unmodified lines
12811335 * every sample.
12821336 *
12831337 * The order of these sample properties given by userspace has no
1284− * affect on the ordering of data within a sample. The order will be
1338+ * affect on the ordering of data within a sample. The order is
12851339 * documented here.
12861340 *
12871341 * struct {
12881342 * struct drm_i915_perf_record_header header;
12891343 *
1290− * TODO: itemize extensible sample data here
1344+ * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
12911345 * };
12921346 */
12931347 DRM_I915_PERF_RECORD_SAMPLE = 1,
12941348
1349+ /*
1350+ * Indicates that one or more OA reports were not written by the
1351+ * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
1352+ * command collides with periodic sampling - which would be more likely
1353+ * at higher sampling frequencies.
1354+ */
1355+ DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
1356+
1357+ /**
1358+ * An error occurred that resulted in all pending OA reports being lost.
1359+ */
1360+ DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
1361+
12951362 DRM_I915_PERF_RECORD_MAX /* non-ABI */
12961363 };
12971364

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t