History

drm/xe/uapi: Introduce API for EU stall sampling

A new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs. Use an existing IOCTL - DRM_IOCTL_XE_OBSERVATION as the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a struct drm_xe_observation_param in which observation_type should be set to DRM_XE_OBSERVATION_TYPE_EU_STALL, observation_op should be DRM_XE_OBSERVATION_OP_STREAM_OPEN and param should point to a chain of drm_xe_ext_set_property structures in which each structure has a pair of property and value. The EU stall sampling input properties are defined in drm_xe_eu_stall_property_id enum. With the file descriptor obtained from DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs: DRM_XE_OBSERVATION_IOCTL_ENABLE and DRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also call poll() to check for availability of data in the buffer. The data can be read with read(). Finally, the file descriptor can be closed with close(). v11: Changed a couple of variables in struct eu_stall_open_properties from unsigned int to int. v10: Use extension number while parsing chain of extensions. Remove function description for static functions. Move code around as per review feedback. v9: Changed some u32 to unsigned int. Moved some code around as per review feedback from v8. v8: Used div_u64 instead of / to fix 32-bit build issue. Changed copyright year in xe_eu_stall.c/h to 2025. v7: Renamed input property DRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT to DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS to be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback. v6: Change the input sampling rate to GPU cycles instead of GPU cycles multiplier.

Harish Chegondi committed 1 year ago

Commit 1537ec81 parent a2d6f865 files · +285 −0Browse files

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

Unified · Split

include/uapi/drm/xe_drm.h+38−0
@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence { · 1495 unmodified lines
14961496 enum drm_xe_observation_type {
14971497 /** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */
14981498 DRM_XE_OBSERVATION_TYPE_OA,
1499+ /** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */
1500+ DRM_XE_OBSERVATION_TYPE_EU_STALL,
14991501 };
15001502
15011503 /**
@@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type { · 346 unmodified lines
18481850 /* ID of the protected content session managed by Xe when PXP is active */
18491851 #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf
18501852
1853+/**
1854+ * enum drm_xe_eu_stall_property_id - EU stall sampling input property ids.
1855+ *
1856+ * These properties are passed to the driver at open as a chain of
1857+ * @drm_xe_ext_set_property structures with @property set to these
1858+ * properties' enums and @value set to the corresponding values of these
1859+ * properties. @drm_xe_user_extension base.name should be set to
1860+ * @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY.
1861+ *
1862+ * With the file descriptor obtained from open, user space must enable
1863+ * the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before
1864+ * calling read(). EIO errno from read() indicates HW dropped data
1865+ * due to full buffer.
1866+ */
1867+enum drm_xe_eu_stall_property_id {
1868+#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0
1869+ /**
1870+ * @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which
1871+ * EU stall data will be captured.
1872+ */
1873+ DRM_XE_EU_STALL_PROP_GT_ID = 1,
1874+
1875+ /**
1876+ * @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate
1877+ * in GPU cycles.
1878+ */
1879+ DRM_XE_EU_STALL_PROP_SAMPLE_RATE,
1880+
1881+ /**
1882+ * @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of
1883+ * EU stall data reports to be present in the kernel buffer
1884+ * before unblocking a blocked poll or read.
1885+ */
1886+ DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS,
1887+};
1888+
18511889 #if defined(__cplusplus)
18521890 }
18531891 #endif

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