[PATCH v2 2/2] drm/panthor: Add DEV_QUERY_GROUP_PRIORITIES_INFO dev query
Boris Brezillon
boris.brezillon at collabora.com
Fri Sep 6 06:12:29 UTC 2024
On Thu, 5 Sep 2024 19:32:23 +0200
Mary Guillemard <mary.guillemard at collabora.com> wrote:
> Expose allowed group priorities with a new device query.
>
> This new uAPI will be used in Mesa to properly report what priorities a
> user can use for EGL_IMG_context_priority.
>
> Since this extends the uAPI and because userland needs a way to
> advertise priorities accordingly, this also bumps the driver minor
> version.
>
> v2:
> - Remove drm_panthor_group_allow_priority_flags definition
> - Document that allowed_mask is a bitmask of drm_panthor_group_priority
>
> Signed-off-by: Mary Guillemard <mary.guillemard at collabora.com>
> ---
> drivers/gpu/drm/panthor/panthor_drv.c | 61 ++++++++++++++++++---------
> include/uapi/drm/panthor_drm.h | 22 ++++++++++
> 2 files changed, 64 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index 7b1db2adcb4c..f85aa2d99f09 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
> @@ -170,6 +170,7 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride,
> PANTHOR_UOBJ_DECL(struct drm_panthor_gpu_info, tiler_present), \
> PANTHOR_UOBJ_DECL(struct drm_panthor_csif_info, pad), \
> PANTHOR_UOBJ_DECL(struct drm_panthor_timestamp_info, current_timestamp), \
> + PANTHOR_UOBJ_DECL(struct drm_panthor_group_priorities_info, pad), \
> PANTHOR_UOBJ_DECL(struct drm_panthor_sync_op, timeline_value), \
> PANTHOR_UOBJ_DECL(struct drm_panthor_queue_submit, syncs), \
> PANTHOR_UOBJ_DECL(struct drm_panthor_queue_create, ringbuf_size), \
> @@ -777,11 +778,41 @@ static int panthor_query_timestamp_info(struct panthor_device *ptdev,
> return 0;
> }
>
> +static int group_priority_permit(struct drm_file *file,
> + u8 priority)
> +{
> + /* Ensure that priority is valid */
> + if (priority > PANTHOR_GROUP_PRIORITY_REALTIME)
> + return -EINVAL;
> +
> + /* Medium priority and below are always allowed */
> + if (priority <= PANTHOR_GROUP_PRIORITY_MEDIUM)
> + return 0;
> +
> + /* Higher priorities require CAP_SYS_NICE or DRM_MASTER */
> + if (capable(CAP_SYS_NICE) || drm_is_current_master(file))
> + return 0;
> +
> + return -EACCES;
> +}
> +
> +static void panthor_query_group_priorities_info(struct drm_file *file,
> + struct drm_panthor_group_priorities_info *arg)
> +{
> + int prio;
> +
> + for (prio = PANTHOR_GROUP_PRIORITY_REALTIME; prio >= 0; prio--) {
> + if (!group_priority_permit(file, prio))
> + arg->allowed_mask |= 1 << prio;
nit: we have a BIT() macro for that ;-). Other than that, it looks good
to me.
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
More information about the dri-devel
mailing list