From nobody Sat Nov 30 16:44:36 2024 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E59AC1AD3ED for ; Mon, 9 Sep 2024 06:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725864548; cv=pass; b=k2sosZbLYaAtA6SEI91qOktZR8dXaZKr4+NYu6ovaiRn/1G9ZsuJ0JbRT9WQQmcxBzWHq6WBZX2NYLnAbtbpe5s9zGZg9bZhpnrMERKagu/fSRimvMpaYRJC4UbEySjeKh6OnTcAy74QWSvIOIWVknYjTgqT2ByYy+goWiOCjPk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725864548; c=relaxed/simple; bh=QN35AwxHJDfDfqmcuZOypZos+zKgHENbFCUpnfBMbUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aYxS8OC/ZVMuj7YTc3JbptYTQwz3r7IK3huSzG9bpUQrkYyty6VxMoExoFayB8cf48FgZDnYmpZ+jKwrg6+7XYIbx03Z1F/YBnSUFWuQZndxRKpnmNegC8PoYgF6VY2rtiwFEucY1X0E0tT8loctPuc7f7HQk6sYGT22xwSDzCs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b=QJ21+Lcm; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="QJ21+Lcm" ARC-Seal: i=1; a=rsa-sha256; t=1725864531; cv=none; d=zohomail.com; s=zohoarc; b=ccaF5xNFq3yzQvtqy11NItJYhAp7Q/LtkhVYn6o15VSgVdK5PN1m7f54IGEvQvp1d02f7pZt4jdt62Jb0cxy5i+aVa8SqcKv6rvgYKbl8GTS9mm2hNMdEJQ03RaWdOlpkG9n4cgLpo+Sx6JMjHfYH6saWJ62MmiZSp5OOTFFpa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725864531; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=OfU+ay/I9Q7xGwL1E4eRj11ki8z/LY8nnyoSSRBFRc8=; b=iy3FDsE9oDNcVn+U9PL7y4eXF3VO5Dq5OfcRLZJYfT+3SsW5kYlzUMO1VaMTOxy+4tygtCLTOsW6L7UtbCXht1VO34vAoPl4eGjaQe/oATR5hOkHm2n/9+sPR8/Dr6/o9xDzuDiK/EoLNRLsp8A5yFRo+s2HxTHTkNw+9vCYhG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=mary.guillemard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725864531; s=zohomail; d=collabora.com; i=mary.guillemard@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=OfU+ay/I9Q7xGwL1E4eRj11ki8z/LY8nnyoSSRBFRc8=; b=QJ21+Lcmm3VfGrrd9lgf8stTv6Nj+vmGZ+IdX7a9nZs6ysej+sJL23nxtS+Jb8o9 lP8Ccnsu9QZ+QZRWdoXvDEE9EHygObXWcM/ykwn2M7WJM48bFR3WdJMBKVa7VvXa/AF j800TvvIw9TgI8pfcELspdrk8IdtFKBoV0g+zwRE= Received: by mx.zohomail.com with SMTPS id 1725864529300427.77978146133546; Sun, 8 Sep 2024 23:48:49 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Boris Brezillon , Christopher Healy , kernel@collabora.com, Mary Guillemard , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH v3 1/2] drm/panthor: Add PANTHOR_GROUP_PRIORITY_REALTIME group priority Date: Mon, 9 Sep 2024 08:48:20 +0200 Message-ID: <20240909064820.34982-3-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240909064820.34982-2-mary.guillemard@collabora.com> References: <20240909064820.34982-2-mary.guillemard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" This adds a new value to drm_panthor_group_priority exposing the realtime priority to userspace. This is required to implement NV_context_priority_realtime in Mesa. v2: - Add Steven Price r-b v3: - Add Boris Brezillon r-b Signed-off-by: Mary Guillemard Reviewed-by: Steven Price Reviewed-by: Boris Brezillon --- drivers/gpu/drm/panthor/panthor_drv.c | 2 +- drivers/gpu/drm/panthor/panthor_sched.c | 2 -- include/uapi/drm/panthor_drm.h | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index 0caf9e9a8c45..7b1db2adcb4c 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1041,7 +1041,7 @@ static int group_priority_permit(struct drm_file *fil= e, u8 priority) { /* Ensure that priority is valid */ - if (priority > PANTHOR_GROUP_PRIORITY_HIGH) + if (priority > PANTHOR_GROUP_PRIORITY_REALTIME) return -EINVAL; =20 /* Medium priority and below are always allowed */ diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index 91a31b70c037..86908ada7335 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -137,8 +137,6 @@ enum panthor_csg_priority { * non-real-time groups. When such a group becomes executable, * it will evict the group with the lowest non-rt priority if * there's no free group slot available. - * - * Currently not exposed to userspace. */ PANTHOR_CSG_PRIORITY_RT, =20 diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 1fd8473548ac..011a555e4674 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -720,6 +720,13 @@ enum drm_panthor_group_priority { * Requires CAP_SYS_NICE or DRM_MASTER. */ PANTHOR_GROUP_PRIORITY_HIGH, + + /** + * @PANTHOR_GROUP_PRIORITY_REALTIME: Realtime priority group. + * + * Requires CAP_SYS_NICE or DRM_MASTER. + */ + PANTHOR_GROUP_PRIORITY_REALTIME, }; =20 /** --=20 2.46.0 From nobody Sat Nov 30 16:44:36 2024 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 999FE1AE022 for ; Mon, 9 Sep 2024 06:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725864549; cv=pass; b=Lnie4n95uT8FOumZucAPEN35AgDzrz1HgGiwgq63/9w1/pCUdlPTV3ixUfyNrb/KV1lugNedxNUqDY/0hO86vcFAHIE+UY1uIFGHF001hrycfJR6BkhOiLMlAhCYM9SbbMAZXTFNMyTCz0bLD+Se9HZLHNo0f4e0phpisku8Bpc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725864549; c=relaxed/simple; bh=/C0vS5pR1D77oh+yk1Wziv9+Qp9fDRH/K5uBtUK3vN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YsYKmq4IJSX8k8xPeMlGMoDCi0xDHwmK2oxr4AmTO3G7LmjYOfjr5gAu7YLDBx1s1DamKvpGKLCi/S03RYKFUcSMZavebrLmFPuJszkuwjiAYgmtNC8yV9FozOf+4NUcRu7WQAdDrfDdF2FSwrpZHqRbkQM1Q647/zaSBdKeDc0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b=R04FXvxd; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=mary.guillemard@collabora.com header.b="R04FXvxd" ARC-Seal: i=1; a=rsa-sha256; t=1725864533; cv=none; d=zohomail.com; s=zohoarc; b=KDv3TGOOMlHAoFFRw2lgcKsMgU1s5CQciN6S3aWQIml9j041/LYA7sso4IO9z8D7Jlk4nGnwJ1mRyaozgcctr7NYbWD5KOkC0VwhbVDr4+3sdH/yr4hzlaRL0iNT3N9FdxUBmzu/YrxcSNlpw024POr/IDAo7rCH8ckdQK9q+p0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725864533; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=URFnd2Z77POtYk8MmvC3Vl5tyHzCCAlEp2xTpMqHwVQ=; b=SUVFS/M97CeUNDsPQAd4nOejlMtb/IkBH9b/sYqhlIEUNdbBKHXce5S9n2pxrS5TnhNDvnK4iCqNq7THGHdJ34d6qibbKBy+Kr/wXpUvWqkhnRsH9tdfUHXkzc08+DgjkPmwVlWjB9j3Grxi8FNT3KI5b3L+2Od72G7LpO/FG4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=mary.guillemard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1725864533; s=zohomail; d=collabora.com; i=mary.guillemard@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=URFnd2Z77POtYk8MmvC3Vl5tyHzCCAlEp2xTpMqHwVQ=; b=R04FXvxd2ftbXhUwDGLUf5VqSsBvv6kzxFPDsMRC4+rGnR5K9kTmyWbARB/fAjjJ 8argKeQVexvfyrFjzXc8urz0Fp4XmcDTlZ+EY31MngDxLex+IGvJsDZaaQ9H0szfCoB 6Lm6i5+zd8V1yDp+sOZAvVWdbOTYvcwyKKYNDkIY= Received: by mx.zohomail.com with SMTPS id 172586453261846.07654823838766; Sun, 8 Sep 2024 23:48:52 -0700 (PDT) From: Mary Guillemard To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Boris Brezillon , Christopher Healy , kernel@collabora.com, Mary Guillemard , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH v3 2/2] drm/panthor: Add DEV_QUERY_GROUP_PRIORITIES_INFO dev query Date: Mon, 9 Sep 2024 08:48:21 +0200 Message-ID: <20240909064820.34982-4-mary.guillemard@collabora.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240909064820.34982-2-mary.guillemard@collabora.com> References: <20240909064820.34982-2-mary.guillemard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" 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 v3: - Use BIT macro in panthor_query_group_priorities_info - Add r-b from Steven Price and Boris Brezillon Signed-off-by: Mary Guillemard Reviewed-by: Steven Price Reviewed-by: Boris Brezillon --- 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/pantho= r/panthor_drv.c index 7b1db2adcb4c..0d825d63d712 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_arr= ay *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 pantho= r_device *ptdev, return 0; } =20 +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 <=3D 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 =3D PANTHOR_GROUP_PRIORITY_REALTIME; prio >=3D 0; prio--) { + if (!group_priority_permit(file, prio)) + arg->allowed_mask |=3D BIT(prio); + } +} + static int panthor_ioctl_dev_query(struct drm_device *ddev, void *data, st= ruct drm_file *file) { struct panthor_device *ptdev =3D container_of(ddev, struct panthor_device= , base); struct drm_panthor_dev_query *args =3D data; struct drm_panthor_timestamp_info timestamp_info; + struct drm_panthor_group_priorities_info priorities_info; int ret; =20 if (!args->pointer) { @@ -798,6 +829,10 @@ static int panthor_ioctl_dev_query(struct drm_device *= ddev, void *data, struct d args->size =3D sizeof(timestamp_info); return 0; =20 + case DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO: + args->size =3D sizeof(priorities_info); + return 0; + default: return -EINVAL; } @@ -818,6 +853,10 @@ static int panthor_ioctl_dev_query(struct drm_device *= ddev, void *data, struct d =20 return PANTHOR_UOBJ_SET(args->pointer, args->size, timestamp_info); =20 + case DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO: + panthor_query_group_priorities_info(file, &priorities_info); + return PANTHOR_UOBJ_SET(args->pointer, args->size, priorities_info); + default: return -EINVAL; } @@ -1037,24 +1076,6 @@ static int panthor_ioctl_group_destroy(struct drm_de= vice *ddev, void *data, return panthor_group_destroy(pfile, args->group_handle); } =20 -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 <=3D 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 int panthor_ioctl_group_create(struct drm_device *ddev, void *data, struct drm_file *file) { @@ -1436,6 +1457,8 @@ static void panthor_debugfs_init(struct drm_minor *mi= nor) * PanCSF driver version: * - 1.0 - initial interface * - 1.1 - adds DEV_QUERY_TIMESTAMP_INFO query + * - 1.2 - adds DEV_QUERY_GROUP_PRIORITIES_INFO query + * - adds PANTHOR_GROUP_PRIORITY_REALTIME priority */ static const struct drm_driver panthor_drm_driver =3D { .driver_features =3D DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ | @@ -1449,7 +1472,7 @@ static const struct drm_driver panthor_drm_driver =3D= { .desc =3D "Panthor DRM driver", .date =3D "20230801", .major =3D 1, - .minor =3D 1, + .minor =3D 2, =20 .gem_create_object =3D panthor_gem_create_object, .gem_prime_import_sg_table =3D drm_gem_shmem_prime_import_sg_table, diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 011a555e4674..87c9cb555dd1 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -263,6 +263,11 @@ enum drm_panthor_dev_query_type { =20 /** @DRM_PANTHOR_DEV_QUERY_TIMESTAMP_INFO: Query timestamp information. */ DRM_PANTHOR_DEV_QUERY_TIMESTAMP_INFO, + + /** + * @DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO: Query allowed group prio= rities information. + */ + DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO, }; =20 /** @@ -399,6 +404,23 @@ struct drm_panthor_timestamp_info { __u64 timestamp_offset; }; =20 +/** + * struct drm_panthor_group_priorities_info - Group priorities information + * + * Structure grouping all queryable information relating to the allowed gr= oup priorities. + */ +struct drm_panthor_group_priorities_info { + /** + * @allowed_mask: Bitmask of the allowed group priorities. + * + * Each bit represents a variant of the enum drm_panthor_group_priority. + */ + __u8 allowed_mask; + + /** @pad: Padding fields, MBZ. */ + __u8 pad[3]; +}; + /** * struct drm_panthor_dev_query - Arguments passed to DRM_PANTHOR_IOCTL_DE= V_QUERY */ --=20 2.46.0