mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ketil Johnsen <ketil.johnsen@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
	Steven Price <steven.price@arm.com>,
	Liviu Dudau <liviu.dudau@arm.com>,
	Akash Goel <akash.goel@arm.com>,
	Karunika Choo <karunika.choo@arm.com>,
	Lukas Zapolskas <lukas.zapolskas@arm.com>,
	Chris Diamand <chris.diamand@arm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Alice Ryhl <aliceryhl@google.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org,
	Ketil Johnsen <ketil.johnsen@arm.com>
Subject: [PATCH v5 12/13] drm/panthor: Protm support for groups
Date: Mon, 16 Nov 2026 12:26:00 +0100	[thread overview]
Message-ID: <20261116112601.3483649-13-ketil.johnsen@arm.com> (raw)
In-Reply-To: <20261116112601.3483649-1-ketil.johnsen@arm.com>

From: Boris Brezillon <boris.brezillon@collabora.com>

Extends struct drm_panthor_group_create to allow user provided protm
suspend buffer. This is needed for protm execution with this group.

Make use of the user supplied suspend buffer (import).

Allow PROT_REGION instruction for groups which provided protm
suspend buffer.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Co-developed-by: Ketil Johnsen <ketil.johnsen@arm.com>
Signed-off-by: Ketil Johnsen <ketil.johnsen@arm.com>

---

v5:
- Removed unused #define
- Minor formating changes
- Moved caching of suspend buf sizes to a separate patch

v4:
- First version of this change as a separate commit
---
 drivers/gpu/drm/panthor/panthor_sched.c | 50 +++++++++++++++++++++----
 include/uapi/drm/panthor_drm.h          | 10 ++++-
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index 9c78f04d4f30a..02726cbcce3ca 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -1456,10 +1456,15 @@ cs_slot_process_protm_pending_event_locked(struct panthor_device *ptdev,
 	if (!group)
 		return;
 
-	/* Do not allow user space work to switch into protected mode, as we
-	 * do not fully support this quite yet.
+	/* Do not allow user space work to switch into protected mode if we
+	 * do not support protected mode on this device.
+	 * User space should query (and init) this support before attempting
+	 * to use such GPU instructions.
 	 */
-	atomic_or(BIT(cs_id), &group->fatal_queues);
+	if (group->protm_suspend_buf)
+		atomic_or(BIT(cs_id), &group->protm_pending_queues);
+	else
+		atomic_or(BIT(cs_id), &group->fatal_queues);
 
 	sched_queue_delayed_work(sched, tick, 0);
 }
@@ -4056,14 +4061,10 @@ int panthor_group_create(struct drm_file *file,
 	struct panthor_device *ptdev = pfile->ptdev;
 	struct panthor_group_pool *gpool = pfile->groups;
 	struct panthor_scheduler *sched = ptdev->scheduler;
-	struct panthor_fw_csg_iface *csg_iface = panthor_fw_get_csg_iface(ptdev, 0);
 	struct panthor_group *group = NULL;
 	u32 gid, i;
 	int ret;
 
-	if (group_args->pad)
-		return -EINVAL;
-
 	if (group_args->priority >= PANTHOR_CSG_PRIORITY_COUNT)
 		return -EINVAL;
 
@@ -4117,6 +4118,41 @@ int panthor_group_create(struct drm_file *file,
 		goto err_put_group;
 	}
 
+	if (group_args->protected_suspend_bo_handle) {
+		struct drm_gem_object *obj;
+
+		/* Read a correct snapshot of the state */
+		if (!panthor_fw_protm_is_inited(ptdev)) {
+			ret = -EINVAL;
+			goto err_put_group;
+		}
+
+		obj = drm_gem_object_lookup(file, group_args->protected_suspend_bo_handle);
+		if (!obj) {
+			ret = -ENOENT;
+			goto err_put_group;
+		}
+
+		if (obj->size < panthor_fw_protm_suspend_size(ptdev)) {
+			drm_gem_object_put(obj);
+			ret = -EINVAL;
+			goto err_put_group;
+		}
+
+		group->protm_suspend_buf =
+			panthor_kernel_bo_create_from_gem(ptdev, panthor_fw_vm(ptdev),
+							  to_panthor_bo(obj),
+							  DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC,
+							  PANTHOR_VM_KERNEL_AUTO_VA,
+							  panthor_fw_protm_suspend_size(ptdev));
+		drm_gem_object_put(obj);
+		if (IS_ERR(group->protm_suspend_buf)) {
+			ret = PTR_ERR(group->protm_suspend_buf);
+			group->protm_suspend_buf = NULL;
+			goto err_put_group;
+		}
+	}
+
 	group->syncobjs = panthor_kernel_bo_create(ptdev, group->vm,
 						   group_args->queues.count *
 						   sizeof(struct panthor_syncobj_64b),
diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h
index d2d21e3e6bb39..a0ed16041e178 100644
--- a/include/uapi/drm/panthor_drm.h
+++ b/include/uapi/drm/panthor_drm.h
@@ -956,8 +956,14 @@ struct drm_panthor_group_create {
 	/** @priority: Group priority (see enum drm_panthor_group_priority). */
 	__u8 priority;
 
-	/** @pad: Padding field, MBZ. */
-	__u32 pad;
+	/**
+	 * @protected_suspend_bo_handle: BO to use as a protected suspend buffer.
+	 *
+	 * This BO must have been allocated from a protected DMA-BUF heap and
+	 * imported in panthor. It's size must be at least
+	 * drm_panthor_protm_info::group_protected_suspend_buf_size.
+	 */
+	__u32 protected_suspend_bo_handle;
 
 	/**
 	 * @compute_core_mask: Mask encoding cores that can be used for compute jobs.
-- 
2.43.0


  parent reply	other threads:[~2026-11-16 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:25 [PATCH v5 00/13] drm/panthor: Protected mode support for Mali CSF GPUs Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 01/13] drm/panthor: De-duplicate FW memory section sync Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 02/13] drm/panthor: Minor scheduler refactoring Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 03/13] drm/panthor: Pass drm_file instead of panthor_file Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 04/13] drm/panthor: Don't allocate protm_suspend_buf Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 05/13] drm/panthor: Add support for entering and exiting protected mode Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 06/13] drm/panthor: New function for FW section map flags Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 07/13] drm/panthor: Keep size and VA in FW section obj Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 08/13] drm/panthor: Refactor GEM usage flags assignment Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 09/13] drm/panthor: Create kernel BO from existing GEM Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 10/13] drm/panthor: Use a copy of suspend buffer sizes Ketil Johnsen
2026-11-16 11:25 ` [PATCH v5 11/13] drm/panthor: Support FW init of protm Ketil Johnsen
2026-11-16 11:26 ` Ketil Johnsen [this message]
2026-11-16 11:26 ` [PATCH v5 13/13] drm/panthor: Bump version to expose protm feature Ketil Johnsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116112601.3483649-13-ketil.johnsen@arm.com \
    --to=ketil.johnsen@arm.com \
    --cc=airlied@gmail.com \
    --cc=akash.goel@arm.com \
    --cc=aliceryhl@google.com \
    --cc=boris.brezillon@collabora.com \
    --cc=chris.diamand@arm.com \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karunika.choo@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lukas.zapolskas@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=steven.price@arm.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®