From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D61C6CE7AB4 for ; Fri, 6 Sep 2024 06:12:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 043F510E17B; Fri, 6 Sep 2024 06:12:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="PeBgyloQ"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FF6110E17B for ; Fri, 6 Sep 2024 06:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1725603153; bh=UO6g/Ji12/elGfRu9ibvIc94caMDiFjVz4JJvAVD5ww=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PeBgyloQf+iOZduma14RhPQXlURwqT5Ja6ymAKQnuUDH8ts92Fio0hw3LM+hnZT9h gF2sAcX4kCqe/2D1UcmZroZva5wESi4Vrmai/51/3z/ugCYMXPFWxfzbvvmEJVPLHb IjH+OCmMKJ3AeN+MAlvGaqX+Ey+Y/eTDY3BIv4pDm/WbVEAngWyyO1IzGrNQDz3a52 HQ5SMzBD/zwbxIvK6qZntwjEukKMMQQjmIVXpKO1jUn1vfx+sTxpnrvU+lxe/GbNIg IxkKOIhZcSTDG+bB2LLujdMDO49sSgSe6D5UlwN2/VSxmWDE/wja/dPg6HHIt69XMF 1pN7MSVc9ZeAA== Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 6D7AA17E0F87; Fri, 6 Sep 2024 08:12:33 +0200 (CEST) Date: Fri, 6 Sep 2024 08:12:29 +0200 From: Boris Brezillon To: Mary Guillemard Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Christopher Healy , kernel@collabora.com, Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: Re: [PATCH v2 2/2] drm/panthor: Add DEV_QUERY_GROUP_PRIORITIES_INFO dev query Message-ID: <20240906081229.776899b7@collabora.com> In-Reply-To: <20240905173222.252641-4-mary.guillemard@collabora.com> References: <20240905173222.252641-2-mary.guillemard@collabora.com> <20240905173222.252641-4-mary.guillemard@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, 5 Sep 2024 19:32:23 +0200 Mary Guillemard 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 > --- > 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