WIP: freedreno/drm: Import new UABI for PERFCNTR_CONFIG

This commit is contained in:
Rob Clark 2026-04-15 08:29:23 -07:00
parent 38b029cb7d
commit 3358e40fed

View file

@ -117,6 +117,7 @@ struct drm_msm_timespec {
* ioctl will throw -EPIPE.
*/
#define MSM_PARAM_EN_VM_BIND 0x16 /* WO, once */
#define MSM_PARAM_AQE 0x17 /* RO */
/* For backwards compat. The original support for preemption was based on
* a single ring per priority level so # of priority levels equals the #
@ -490,6 +491,52 @@ struct drm_msm_submitqueue_query {
__u32 pad;
};
#define MSM_PERFCNTR_STREAM 0x00000001
#define MSM_PERFCNTR_UPDATE 0x00000002
#define MSM_PERFCNTR_FLAGS ( \
MSM_PERFCNTR_STREAM | \
MSM_PERFCNTR_UPDATE | \
0)
struct drm_msm_perfcntr_group {
char group_name[16];
__u32 nr_countables;
__u32 pad;
__u64 countables; /* pointer to an array of nr_countables u32 */
};
/*
* Note, for MSM_PERFCNTR_STREAM, the ioctl returns an fd to read recorded
* counters. This only works because the ioctl is DRM_IOW(), if we returned
* a out param in the ioctl struct the copy_to_user() (in drm_ioctl())
* could fault, causing us to leak the fd.
*
* If the ioctl returns with error E2BIG, that means more counters/countables
* are requested than are currently available. If MSM_PERFCNTR_UPDATE flag
* is set, drm_msm_perfcntr_group::nr_countables will be updated to return
* the actual # of counters available.
*
* The data read from the has the following format for each sampling period:
*
* uint64_t timestamp; // CP_ALWAYS_ON_COUNTER captured at sample time
* uint32_t seqno; // increments by 1 each period, reset to 0 on discontinuity
* uint32_t mbz; // pad out counters to 64b
* struct {
* uint64_t counter[nr_countables];
* } groups[nr_groups];
*
* The ordering of groups and counters matches the order in PERFCNTR_CONFIG
* ioctl.
*/
struct drm_msm_perfcntr_config {
__u32 flags; /* bitmask of MSM_PERFCNTR_x */
__u32 nr_groups; /* # of entries in groups array */
__u64 groups; /* pointer to array of drm_msm_perfcntr_group */
__u64 period; /* sampling period in ns */
__u32 bufsz_shift; /* sample buffer size in bytes is 1<<bufsz_shift */
__u32 group_stride; /* sizeof(struct drm_msm_perfcntr_group) */
};
#define DRM_MSM_GET_PARAM 0x00
#define DRM_MSM_SET_PARAM 0x01
#define DRM_MSM_GEM_NEW 0x02
@ -506,6 +553,7 @@ struct drm_msm_submitqueue_query {
#define DRM_MSM_SUBMITQUEUE_CLOSE 0x0B
#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
#define DRM_MSM_VM_BIND 0x0D
#define DRM_MSM_PERFCNTR_CONFIG 0x0E
#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
#define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
@ -520,6 +568,7 @@ struct drm_msm_submitqueue_query {
#define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
#define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
#define DRM_IOCTL_MSM_VM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_VM_BIND, struct drm_msm_vm_bind)
#define DRM_IOCTL_MSM_PERFCNTR_CONFIG DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_PERFCNTR_CONFIG, struct drm_msm_perfcntr_config)
#if defined(__cplusplus)
}