mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sarah Walker <sarah.walker@imgtec.com>
To: <dri-devel@lists.freedesktop.org>
Cc: <frank.binns@imgtec.com>, <donald.robson@imgtec.com>,
	<boris.brezillon@collabora.com>, <faith.ekstrand@collabora.com>,
	<airlied@gmail.com>, <daniel@ffwll.ch>,
	<maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
	<tzimmermann@suse.de>, <afd@ti.com>, <hns@goldelico.com>,
	<matthew.brost@intel.com>, <christian.koenig@amd.com>,
	<luben.tuikov@amd.com>, <dakr@redhat.com>,
	<linux-kernel@vger.kernel.org>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
	<devicetree@vger.kernel.org>, <corbet@lwn.net>,
	<linux-doc@vger.kernel.org>
Subject: [PATCH v8 02/20] drm/gpuvm: Helper to get range of unmap from a remap op.
Date: Tue, 31 Oct 2023 15:12:39 +0000	[thread overview]
Message-ID: <20231031151257.90350-3-sarah.walker@imgtec.com> (raw)
In-Reply-To: <20231031151257.90350-1-sarah.walker@imgtec.com>

From: Donald Robson <donald.robson@imgtec.com>

Determining the start and range of the unmap stage of a remap op is a
common piece of code currently implemented by multiple drivers. Add a
helper for this.

Changes since v7:
- Renamed helper to drm_gpuva_op_remap_to_unmap_range()
- Improved documentation

Changes since v6:
- Remove use of __always_inline

Signed-off-by: Donald Robson <donald.robson@imgtec.com>
Signed-off-by: Sarah Walker <sarah.walker@imgtec.com>
---
 include/drm/drm_gpuvm.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h
index c7ed6bf441d4..c64585dc4e8e 100644
--- a/include/drm/drm_gpuvm.h
+++ b/include/drm/drm_gpuvm.h
@@ -702,4 +702,32 @@ void drm_gpuva_remap(struct drm_gpuva *prev,
 
 void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op);
 
+/**
+ * drm_gpuva_op_remap_to_unmap_range() - Helper to get the start and range of
+ * the unmap stage of a remap op.
+ * @op: Remap op.
+ * @start_addr: Output pointer for the start of the required unmap.
+ * @range: Output pointer for the length of the required unmap.
+ *
+ * The given start address and range will be set such that they represent the
+ * range of the address space that was previously covered by the mapping being
+ * re-mapped, but is now empty.
+ */
+static inline void
+drm_gpuva_op_remap_to_unmap_range(const struct drm_gpuva_op_remap *op,
+				  u64 *start_addr, u64 *range)
+{
+	const u64 va_start = op->prev ?
+			     op->prev->va.addr + op->prev->va.range :
+			     op->unmap->va->va.addr;
+	const u64 va_end = op->next ?
+			   op->next->va.addr :
+			   op->unmap->va->va.addr + op->unmap->va->va.range;
+
+	if (start_addr)
+		*start_addr = va_start;
+	if (range)
+		*range = va_end - va_start;
+}
+
 #endif /* __DRM_GPUVM_H__ */
-- 
2.42.0


  parent reply	other threads:[~2023-10-31 15:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 15:12 [PATCH v8 00/20] Imagination Technologies PowerVR DRM driver Sarah Walker
2023-10-31 15:12 ` [PATCH v8 01/20] sizes.h: Add entries between SZ_32G and SZ_64T Sarah Walker
2023-10-31 15:12 ` Sarah Walker [this message]
2023-11-14 16:42   ` [PATCH v8 02/20] drm/gpuvm: Helper to get range of unmap from a remap op Danilo Krummrich
2023-11-20 11:07     ` [EXTERNAL] " Donald Robson
2023-10-31 15:12 ` [PATCH v8 03/20] dt-bindings: gpu: Add Imagination Technologies PowerVR/IMG GPU Sarah Walker
2023-10-31 15:12 ` [PATCH v8 04/20] drm/imagination/uapi: Add PowerVR driver UAPI Sarah Walker
2023-11-06 14:51   ` Faith Ekstrand
2023-10-31 15:12 ` [PATCH v8 05/20] drm/imagination: Add skeleton PowerVR driver Sarah Walker
2023-10-31 15:12 ` [PATCH v8 06/20] drm/imagination: Get GPU resources Sarah Walker
2023-10-31 15:12 ` [PATCH v8 07/20] drm/imagination: Add GPU register headers Sarah Walker
2023-10-31 15:12 ` [PATCH v8 08/20] drm/imagination: Add firmware and MMU related headers Sarah Walker
2023-10-31 15:12 ` [PATCH v8 09/20] drm/imagination: Add FWIF headers Sarah Walker
2023-10-31 15:12 ` [PATCH v8 10/20] drm/imagination: Add GPU ID parsing and firmware loading Sarah Walker
2023-10-31 15:12 ` [PATCH v8 11/20] drm/imagination: Add GEM and VM related code Sarah Walker
2023-10-31 15:12 ` [PATCH v8 12/20] drm/imagination: Implement power management Sarah Walker
2023-10-31 15:12 ` [PATCH v8 13/20] drm/imagination: Implement firmware infrastructure and META FW support Sarah Walker
2023-10-31 15:12 ` [PATCH v8 14/20] drm/imagination: Implement MIPS firmware processor and MMU support Sarah Walker
2023-10-31 15:12 ` [PATCH v8 15/20] drm/imagination: Implement free list and HWRT create and destroy ioctls Sarah Walker
2023-10-31 15:12 ` [PATCH v8 16/20] drm/imagination: Implement context creation/destruction ioctls Sarah Walker
2023-10-31 15:12 ` [PATCH v8 17/20] drm/imagination: Implement job submission and scheduling Sarah Walker
2023-10-31 15:12 ` [PATCH v8 18/20] drm/imagination: Add firmware trace header Sarah Walker
2023-10-31 15:12 ` [PATCH v8 19/20] drm/imagination: Add firmware trace to debugfs Sarah Walker
2023-10-31 15:12 ` [PATCH v8 20/20] drm/imagination: Add driver documentation Sarah Walker
2023-10-31 16:31 ` [PATCH v8 00/20] Imagination Technologies PowerVR DRM driver Maxime Ripard
2023-11-01 10:15   ` Frank Binns
2023-11-06  9:43     ` mripard

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=20231031151257.90350-3-sarah.walker@imgtec.com \
    --to=sarah.walker@imgtec.com \
    --cc=afd@ti.com \
    --cc=airlied@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=christian.koenig@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=dakr@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=donald.robson@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=faith.ekstrand@collabora.com \
    --cc=frank.binns@imgtec.com \
    --cc=hns@goldelico.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luben.tuikov@amd.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mripard@kernel.org \
    --cc=robh+dt@kernel.org \
    --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®