* Add CHANGE_HANDLE ioctl for drm gem v2
@ 2025-07-11 14:53 David Francis
2025-07-11 14:53 ` [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle David Francis
2025-07-11 14:53 ` [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file David Francis
0 siblings, 2 replies; 8+ messages in thread
From: David Francis @ 2025-07-11 14:53 UTC (permalink / raw)
To: dri-devel
Cc: tvrtko.ursulin, Felix.Kuehling, David.YatSin, Chris.Freehill,
Christian.Koenig, dcostantino, sruffell, simona, mripard,
tzimmermann
This patch adds a new ioctl GEM_CHANGE_HANDLE which is needed by
amdgpu CRIU for dmabuf.
The ioctl allows a user to move a gem object to a new handle.
In this version, I have added kerneldoc comments for the new ioctl
in drm.h and have moved over the other drm_gem.c ioctl docs
to drm.h.
Accompanying changes:
kernel (for dmabuf CRIU support)
https://lore.kernel.org/dri-devel/20250617194536.538681-1-David.Francis@amd.com/
igt (for this ioctl)
https://gitlab.freedesktop.org/fdavid-amd/igt-gpu-tools
CRIU (for dmabuf CRIU support)
https://github.com/checkpoint-restore/criu/pull/2613
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle
2025-07-11 14:53 Add CHANGE_HANDLE ioctl for drm gem v2 David Francis
@ 2025-07-11 14:53 ` David Francis
2025-07-17 6:23 ` Zhang, Jesse(Jie)
2025-07-11 14:53 ` [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file David Francis
1 sibling, 1 reply; 8+ messages in thread
From: David Francis @ 2025-07-11 14:53 UTC (permalink / raw)
To: dri-devel
Cc: tvrtko.ursulin, Felix.Kuehling, David.YatSin, Chris.Freehill,
Christian.Koenig, dcostantino, sruffell, simona, mripard,
tzimmermann, David Francis
CRIU restore of drm buffer objects requires the ability to create
or import a buffer object with a specific gem handle.
Add new drm ioctl DRM_IOCTL_GEM_CHANGE_HANDLE, which takes
the gem handle of an object and moves that object to a
specified new gem handle.
This ioctl needs to call drm_prime_remove_buf_handle,
but that function acquires the prime lock, which the ioctl
needs to hold for other purposes.
Make drm_prime_remove_buf_handle not acquire the prime lock,
and change its other caller to reflect this.
The rest of the kernel patches required to enable CRIU can be
found at
https://lore.kernel.org/dri-devel/20250617194536.538681-1-David.Francis@amd.com/
Signed-off-by: David Francis <David.Francis@amd.com>
---
drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_internal.h | 4 +++
drivers/gpu/drm/drm_ioctl.c | 1 +
drivers/gpu/drm/drm_prime.c | 6 +---
include/uapi/drm/drm.h | 23 +++++++++++++++
5 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index c6240bab3fa5..3166230d0119 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -282,7 +282,12 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
if (obj->funcs->close)
obj->funcs->close(obj, file_priv);
+ mutex_lock(&file_priv->prime.lock);
+
drm_prime_remove_buf_handle(&file_priv->prime, id);
+
+ mutex_unlock(&file_priv->prime.lock);
+
drm_vma_node_revoke(&obj->vma_node, file_priv);
drm_gem_object_handle_put_unlocked(obj);
@@ -933,6 +938,55 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
return ret;
}
+int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_gem_change_handle *args = data;
+ struct drm_gem_object *obj;
+ int ret;
+
+ if (!drm_core_check_feature(dev, DRIVER_GEM))
+ return -EOPNOTSUPP;
+
+ obj = drm_gem_object_lookup(file_priv, args->handle);
+ if (!obj)
+ return -ENOENT;
+
+ if (args->handle == args->new_handle)
+ return 0;
+
+ mutex_lock(&file_priv->prime.lock);
+
+ spin_lock(&file_priv->table_lock);
+ ret = idr_alloc(&file_priv->object_idr, obj,
+ args->new_handle, args->new_handle + 1, GFP_NOWAIT);
+ spin_unlock(&file_priv->table_lock);
+
+ if (ret < 0)
+ goto out_unlock;
+
+ if (obj->dma_buf) {
+ ret = drm_prime_add_buf_handle(&file_priv->prime, obj->dma_buf, args->new_handle);
+ if (ret < 0) {
+ spin_lock(&file_priv->table_lock);
+ idr_remove(&file_priv->object_idr, args->new_handle);
+ spin_unlock(&file_priv->table_lock);
+ goto out_unlock;
+ }
+
+ drm_prime_remove_buf_handle(&file_priv->prime, args->handle);
+ }
+
+ spin_lock(&file_priv->table_lock);
+ idr_remove(&file_priv->object_idr, args->handle);
+ spin_unlock(&file_priv->table_lock);
+
+out_unlock:
+ mutex_unlock(&file_priv->prime.lock);
+
+ return ret;
+}
+
/**
* drm_gem_open - initializes GEM file-private structures at devnode open time
* @dev: drm_device which is being opened by userspace
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index b2b6a8e49dda..e9d5cdf7e033 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -85,6 +85,8 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
+int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
+ struct dma_buf *dma_buf, uint32_t handle);
void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
uint32_t handle);
@@ -168,6 +170,8 @@ int drm_gem_close_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
+int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index f593dc569d31..d8a24875a7ba 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -653,6 +653,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_CHANGE_HANDLE, drm_gem_change_handle_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, 0),
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index bdb51c8f262e..1f2e858e5000 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -93,7 +93,7 @@ struct drm_prime_member {
struct rb_node handle_rb;
};
-static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
+int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
struct dma_buf *dma_buf, uint32_t handle)
{
struct drm_prime_member *member;
@@ -190,8 +190,6 @@ void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
{
struct rb_node *rb;
- mutex_lock(&prime_fpriv->lock);
-
rb = prime_fpriv->handles.rb_node;
while (rb) {
struct drm_prime_member *member;
@@ -210,8 +208,6 @@ void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
rb = rb->rb_left;
}
}
-
- mutex_unlock(&prime_fpriv->lock);
}
void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv)
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 7fba37b94401..e3940b657e16 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -625,6 +625,21 @@ struct drm_gem_open {
__u64 size;
};
+/**
+ * struct drm_gem_change_handle - Argument for &DRM_IOCTL_GEM_CHANGE_HANDLE ioctl.
+ * @handle: The handle of a gem object.
+ * @new_handle: An available gem handle.
+ *
+ * This ioctl changes the handle of a GEM object to the specified one.
+ * The new handle must be unused. On success the old handle is closed
+ * and all further IOCTL should refer to the new handle only.
+ * Calls to DRM_IOCTL_PRIME_FD_TO_HANDLE will return the new handle.
+ */
+struct drm_gem_change_handle {
+ __u32 handle;
+ __u32 new_handle;
+};
+
/**
* DRM_CAP_DUMB_BUFFER
*
@@ -1305,6 +1320,14 @@ extern "C" {
*/
#define DRM_IOCTL_SET_CLIENT_NAME DRM_IOWR(0xD1, struct drm_set_client_name)
+/**
+ * DRM_IOCTL_GEM_CHANGE_HANDLE - Move an object to a different handle
+ *
+ * Some applications (notably CRIU) need objects to have specific gem handles.
+ * This ioctl changes the object at one gem handle to use a new gem handle.
+ */
+#define DRM_IOCTL_GEM_CHANGE_HANDLE DRM_IOWR(0xD2, struct drm_gem_change_handle)
+
/*
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file
2025-07-11 14:53 Add CHANGE_HANDLE ioctl for drm gem v2 David Francis
2025-07-11 14:53 ` [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle David Francis
@ 2025-07-11 14:53 ` David Francis
2025-07-11 21:55 ` Simona Vetter
1 sibling, 1 reply; 8+ messages in thread
From: David Francis @ 2025-07-11 14:53 UTC (permalink / raw)
To: dri-devel
Cc: tvrtko.ursulin, Felix.Kuehling, David.YatSin, Chris.Freehill,
Christian.Koenig, dcostantino, sruffell, simona, mripard,
tzimmermann, David Francis
The drm_gem ioctls were documented in internal file drm_gem.c
instead of uapi header drm.h. Move them there and change to
appropriate kerneldoc formatting.
Signed-off-by: David Francis <David.Francis@amd.com>
---
drivers/gpu/drm/drm_gem.c | 30 -----------------------------
include/uapi/drm/drm.h | 40 +++++++++++++++++++++++++++------------
2 files changed, 28 insertions(+), 42 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 3166230d0119..08778a15eefb 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -820,14 +820,6 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
}
EXPORT_SYMBOL(drm_gem_dma_resv_wait);
-/**
- * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
- * @dev: drm_device
- * @data: ioctl data
- * @file_priv: drm file-private structure
- *
- * Releases the handle to an mm object.
- */
int
drm_gem_close_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
@@ -843,17 +835,6 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
return ret;
}
-/**
- * drm_gem_flink_ioctl - implementation of the GEM_FLINK ioctl
- * @dev: drm_device
- * @data: ioctl data
- * @file_priv: drm file-private structure
- *
- * Create a global name for an object, returning the name.
- *
- * Note that the name does not hold a reference; when the object
- * is freed, the name goes away.
- */
int
drm_gem_flink_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
@@ -893,17 +874,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
return ret;
}
-/**
- * drm_gem_open_ioctl - implementation of the GEM_OPEN ioctl
- * @dev: drm_device
- * @data: ioctl data
- * @file_priv: drm file-private structure
- *
- * Open an object using the global name, returning a handle and the size.
- *
- * This handle (of course) holds a reference to the object, so the object
- * will not go away until the handle is deleted.
- */
int
drm_gem_open_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index e3940b657e16..e512da8f3baf 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -597,31 +597,47 @@ struct drm_set_version {
int drm_dd_minor;
};
-/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
+/**
+ * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl.
+ * @handle: Handle of the object to be closed.
+ * @pad: Padding.
+ *
+ * Releases the handle to an mm object.
+ */
struct drm_gem_close {
- /** Handle of the object to be closed. */
__u32 handle;
__u32 pad;
};
-/* DRM_IOCTL_GEM_FLINK ioctl argument type */
+/**
+ * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl.
+ * @handle: Handle for the object being named.
+ * @name: Returned global name.
+ *
+ * Create a global name for an object, returning the name.
+ *
+ * Note that the name does not hold a reference; when the object
+ * is freed, the name goes away.
+ */
struct drm_gem_flink {
- /** Handle for the object being named */
__u32 handle;
-
- /** Returned global name */
__u32 name;
};
-/* DRM_IOCTL_GEM_OPEN ioctl argument type */
+/**
+ * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl.
+ * @name: Name of object being opened.
+ * @handle: Returned handle for the object.
+ * @size: Returned size of the object
+ *
+ * Open an object using the global name, returning a handle and the size.
+ *
+ * This handle (of course) holds a reference to the object, so the object
+ * will not go away until the handle is deleted.
+ */
struct drm_gem_open {
- /** Name of object being opened */
__u32 name;
-
- /** Returned handle for the object */
__u32 handle;
-
- /** Returned size of the object */
__u64 size;
};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file
2025-07-11 14:53 ` [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file David Francis
@ 2025-07-11 21:55 ` Simona Vetter
2025-07-14 9:50 ` Christian König
0 siblings, 1 reply; 8+ messages in thread
From: Simona Vetter @ 2025-07-11 21:55 UTC (permalink / raw)
To: David Francis
Cc: dri-devel, tvrtko.ursulin, Felix.Kuehling, David.YatSin,
Chris.Freehill, Christian.Koenig, dcostantino, sruffell, simona,
mripard, tzimmermann
On Fri, Jul 11, 2025 at 10:53:42AM -0400, David Francis wrote:
> The drm_gem ioctls were documented in internal file drm_gem.c
> instead of uapi header drm.h. Move them there and change to
> appropriate kerneldoc formatting.
>
> Signed-off-by: David Francis <David.Francis@amd.com>
Thanks a lot for taking care of this!
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
I'll leave review for the first patch to folks who care about criu, but it
looked good to me too.
-Sima
> ---
> drivers/gpu/drm/drm_gem.c | 30 -----------------------------
> include/uapi/drm/drm.h | 40 +++++++++++++++++++++++++++------------
> 2 files changed, 28 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 3166230d0119..08778a15eefb 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -820,14 +820,6 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
> }
> EXPORT_SYMBOL(drm_gem_dma_resv_wait);
>
> -/**
> - * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
> - * @dev: drm_device
> - * @data: ioctl data
> - * @file_priv: drm file-private structure
> - *
> - * Releases the handle to an mm object.
> - */
> int
> drm_gem_close_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file_priv)
> @@ -843,17 +835,6 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
> return ret;
> }
>
> -/**
> - * drm_gem_flink_ioctl - implementation of the GEM_FLINK ioctl
> - * @dev: drm_device
> - * @data: ioctl data
> - * @file_priv: drm file-private structure
> - *
> - * Create a global name for an object, returning the name.
> - *
> - * Note that the name does not hold a reference; when the object
> - * is freed, the name goes away.
> - */
> int
> drm_gem_flink_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file_priv)
> @@ -893,17 +874,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
> return ret;
> }
>
> -/**
> - * drm_gem_open_ioctl - implementation of the GEM_OPEN ioctl
> - * @dev: drm_device
> - * @data: ioctl data
> - * @file_priv: drm file-private structure
> - *
> - * Open an object using the global name, returning a handle and the size.
> - *
> - * This handle (of course) holds a reference to the object, so the object
> - * will not go away until the handle is deleted.
> - */
> int
> drm_gem_open_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file_priv)
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index e3940b657e16..e512da8f3baf 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -597,31 +597,47 @@ struct drm_set_version {
> int drm_dd_minor;
> };
>
> -/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
> +/**
> + * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl.
> + * @handle: Handle of the object to be closed.
> + * @pad: Padding.
> + *
> + * Releases the handle to an mm object.
> + */
> struct drm_gem_close {
> - /** Handle of the object to be closed. */
> __u32 handle;
> __u32 pad;
> };
>
> -/* DRM_IOCTL_GEM_FLINK ioctl argument type */
> +/**
> + * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl.
> + * @handle: Handle for the object being named.
> + * @name: Returned global name.
> + *
> + * Create a global name for an object, returning the name.
> + *
> + * Note that the name does not hold a reference; when the object
> + * is freed, the name goes away.
> + */
> struct drm_gem_flink {
> - /** Handle for the object being named */
> __u32 handle;
> -
> - /** Returned global name */
> __u32 name;
> };
>
> -/* DRM_IOCTL_GEM_OPEN ioctl argument type */
> +/**
> + * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl.
> + * @name: Name of object being opened.
> + * @handle: Returned handle for the object.
> + * @size: Returned size of the object
> + *
> + * Open an object using the global name, returning a handle and the size.
> + *
> + * This handle (of course) holds a reference to the object, so the object
> + * will not go away until the handle is deleted.
> + */
> struct drm_gem_open {
> - /** Name of object being opened */
> __u32 name;
> -
> - /** Returned handle for the object */
> __u32 handle;
> -
> - /** Returned size of the object */
> __u64 size;
> };
>
> --
> 2.34.1
>
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file
2025-07-11 21:55 ` Simona Vetter
@ 2025-07-14 9:50 ` Christian König
2025-07-14 12:40 ` Simona Vetter
0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2025-07-14 9:50 UTC (permalink / raw)
To: Simona Vetter, David Francis
Cc: dri-devel, tvrtko.ursulin, Felix.Kuehling, David.YatSin,
Chris.Freehill, dcostantino, sruffell, simona, mripard,
tzimmermann
On 11.07.25 23:55, Simona Vetter wrote:
> On Fri, Jul 11, 2025 at 10:53:42AM -0400, David Francis wrote:
>> The drm_gem ioctls were documented in internal file drm_gem.c
>> instead of uapi header drm.h. Move them there and change to
>> appropriate kerneldoc formatting.
>>
>> Signed-off-by: David Francis <David.Francis@amd.com>
>
> Thanks a lot for taking care of this!
>
> Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
>
> I'll leave review for the first patch to folks who care about criu, but it
> looked good to me too.
I will take that as an Acked-by.
Are you ok that we push this into drm-misc-next by the end of the week when we have the IGT test ready?
The patches for the CRIU code are ready and IIRC there will be a merge request made, but it will take quite a while until they are actually merged I think.
Christian.
> -Sima
>
>> ---
>> drivers/gpu/drm/drm_gem.c | 30 -----------------------------
>> include/uapi/drm/drm.h | 40 +++++++++++++++++++++++++++------------
>> 2 files changed, 28 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
>> index 3166230d0119..08778a15eefb 100644
>> --- a/drivers/gpu/drm/drm_gem.c
>> +++ b/drivers/gpu/drm/drm_gem.c
>> @@ -820,14 +820,6 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
>> }
>> EXPORT_SYMBOL(drm_gem_dma_resv_wait);
>>
>> -/**
>> - * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
>> - * @dev: drm_device
>> - * @data: ioctl data
>> - * @file_priv: drm file-private structure
>> - *
>> - * Releases the handle to an mm object.
>> - */
>> int
>> drm_gem_close_ioctl(struct drm_device *dev, void *data,
>> struct drm_file *file_priv)
>> @@ -843,17 +835,6 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
>> return ret;
>> }
>>
>> -/**
>> - * drm_gem_flink_ioctl - implementation of the GEM_FLINK ioctl
>> - * @dev: drm_device
>> - * @data: ioctl data
>> - * @file_priv: drm file-private structure
>> - *
>> - * Create a global name for an object, returning the name.
>> - *
>> - * Note that the name does not hold a reference; when the object
>> - * is freed, the name goes away.
>> - */
>> int
>> drm_gem_flink_ioctl(struct drm_device *dev, void *data,
>> struct drm_file *file_priv)
>> @@ -893,17 +874,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
>> return ret;
>> }
>>
>> -/**
>> - * drm_gem_open_ioctl - implementation of the GEM_OPEN ioctl
>> - * @dev: drm_device
>> - * @data: ioctl data
>> - * @file_priv: drm file-private structure
>> - *
>> - * Open an object using the global name, returning a handle and the size.
>> - *
>> - * This handle (of course) holds a reference to the object, so the object
>> - * will not go away until the handle is deleted.
>> - */
>> int
>> drm_gem_open_ioctl(struct drm_device *dev, void *data,
>> struct drm_file *file_priv)
>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>> index e3940b657e16..e512da8f3baf 100644
>> --- a/include/uapi/drm/drm.h
>> +++ b/include/uapi/drm/drm.h
>> @@ -597,31 +597,47 @@ struct drm_set_version {
>> int drm_dd_minor;
>> };
>>
>> -/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
>> +/**
>> + * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl.
>> + * @handle: Handle of the object to be closed.
>> + * @pad: Padding.
>> + *
>> + * Releases the handle to an mm object.
>> + */
>> struct drm_gem_close {
>> - /** Handle of the object to be closed. */
>> __u32 handle;
>> __u32 pad;
>> };
>>
>> -/* DRM_IOCTL_GEM_FLINK ioctl argument type */
>> +/**
>> + * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl.
>> + * @handle: Handle for the object being named.
>> + * @name: Returned global name.
>> + *
>> + * Create a global name for an object, returning the name.
>> + *
>> + * Note that the name does not hold a reference; when the object
>> + * is freed, the name goes away.
>> + */
>> struct drm_gem_flink {
>> - /** Handle for the object being named */
>> __u32 handle;
>> -
>> - /** Returned global name */
>> __u32 name;
>> };
>>
>> -/* DRM_IOCTL_GEM_OPEN ioctl argument type */
>> +/**
>> + * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl.
>> + * @name: Name of object being opened.
>> + * @handle: Returned handle for the object.
>> + * @size: Returned size of the object
>> + *
>> + * Open an object using the global name, returning a handle and the size.
>> + *
>> + * This handle (of course) holds a reference to the object, so the object
>> + * will not go away until the handle is deleted.
>> + */
>> struct drm_gem_open {
>> - /** Name of object being opened */
>> __u32 name;
>> -
>> - /** Returned handle for the object */
>> __u32 handle;
>> -
>> - /** Returned size of the object */
>> __u64 size;
>> };
>>
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file
2025-07-14 9:50 ` Christian König
@ 2025-07-14 12:40 ` Simona Vetter
2025-07-18 7:24 ` Christian König
0 siblings, 1 reply; 8+ messages in thread
From: Simona Vetter @ 2025-07-14 12:40 UTC (permalink / raw)
To: Christian König
Cc: Simona Vetter, David Francis, dri-devel, tvrtko.ursulin,
Felix.Kuehling, David.YatSin, Chris.Freehill, dcostantino,
sruffell, simona, mripard, tzimmermann
On Mon, Jul 14, 2025 at 11:50:32AM +0200, Christian König wrote:
> On 11.07.25 23:55, Simona Vetter wrote:
> > On Fri, Jul 11, 2025 at 10:53:42AM -0400, David Francis wrote:
> >> The drm_gem ioctls were documented in internal file drm_gem.c
> >> instead of uapi header drm.h. Move them there and change to
> >> appropriate kerneldoc formatting.
> >>
> >> Signed-off-by: David Francis <David.Francis@amd.com>
> >
> > Thanks a lot for taking care of this!
> >
> > Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
> >
> > I'll leave review for the first patch to folks who care about criu, but it
> > looked good to me too.
>
> I will take that as an Acked-by.
>
> Are you ok that we push this into drm-misc-next by the end of the week when we have the IGT test ready?
Aye, sounds like a plan.
-Sima
>
> The patches for the CRIU code are ready and IIRC there will be a merge
> request made, but it will take quite a while until they are actually
> merged I think.
>
> Christian.
>
> > -Sima
> >
> >> ---
> >> drivers/gpu/drm/drm_gem.c | 30 -----------------------------
> >> include/uapi/drm/drm.h | 40 +++++++++++++++++++++++++++------------
> >> 2 files changed, 28 insertions(+), 42 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> >> index 3166230d0119..08778a15eefb 100644
> >> --- a/drivers/gpu/drm/drm_gem.c
> >> +++ b/drivers/gpu/drm/drm_gem.c
> >> @@ -820,14 +820,6 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
> >> }
> >> EXPORT_SYMBOL(drm_gem_dma_resv_wait);
> >>
> >> -/**
> >> - * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
> >> - * @dev: drm_device
> >> - * @data: ioctl data
> >> - * @file_priv: drm file-private structure
> >> - *
> >> - * Releases the handle to an mm object.
> >> - */
> >> int
> >> drm_gem_close_ioctl(struct drm_device *dev, void *data,
> >> struct drm_file *file_priv)
> >> @@ -843,17 +835,6 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
> >> return ret;
> >> }
> >>
> >> -/**
> >> - * drm_gem_flink_ioctl - implementation of the GEM_FLINK ioctl
> >> - * @dev: drm_device
> >> - * @data: ioctl data
> >> - * @file_priv: drm file-private structure
> >> - *
> >> - * Create a global name for an object, returning the name.
> >> - *
> >> - * Note that the name does not hold a reference; when the object
> >> - * is freed, the name goes away.
> >> - */
> >> int
> >> drm_gem_flink_ioctl(struct drm_device *dev, void *data,
> >> struct drm_file *file_priv)
> >> @@ -893,17 +874,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
> >> return ret;
> >> }
> >>
> >> -/**
> >> - * drm_gem_open_ioctl - implementation of the GEM_OPEN ioctl
> >> - * @dev: drm_device
> >> - * @data: ioctl data
> >> - * @file_priv: drm file-private structure
> >> - *
> >> - * Open an object using the global name, returning a handle and the size.
> >> - *
> >> - * This handle (of course) holds a reference to the object, so the object
> >> - * will not go away until the handle is deleted.
> >> - */
> >> int
> >> drm_gem_open_ioctl(struct drm_device *dev, void *data,
> >> struct drm_file *file_priv)
> >> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> >> index e3940b657e16..e512da8f3baf 100644
> >> --- a/include/uapi/drm/drm.h
> >> +++ b/include/uapi/drm/drm.h
> >> @@ -597,31 +597,47 @@ struct drm_set_version {
> >> int drm_dd_minor;
> >> };
> >>
> >> -/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
> >> +/**
> >> + * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl.
> >> + * @handle: Handle of the object to be closed.
> >> + * @pad: Padding.
> >> + *
> >> + * Releases the handle to an mm object.
> >> + */
> >> struct drm_gem_close {
> >> - /** Handle of the object to be closed. */
> >> __u32 handle;
> >> __u32 pad;
> >> };
> >>
> >> -/* DRM_IOCTL_GEM_FLINK ioctl argument type */
> >> +/**
> >> + * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl.
> >> + * @handle: Handle for the object being named.
> >> + * @name: Returned global name.
> >> + *
> >> + * Create a global name for an object, returning the name.
> >> + *
> >> + * Note that the name does not hold a reference; when the object
> >> + * is freed, the name goes away.
> >> + */
> >> struct drm_gem_flink {
> >> - /** Handle for the object being named */
> >> __u32 handle;
> >> -
> >> - /** Returned global name */
> >> __u32 name;
> >> };
> >>
> >> -/* DRM_IOCTL_GEM_OPEN ioctl argument type */
> >> +/**
> >> + * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl.
> >> + * @name: Name of object being opened.
> >> + * @handle: Returned handle for the object.
> >> + * @size: Returned size of the object
> >> + *
> >> + * Open an object using the global name, returning a handle and the size.
> >> + *
> >> + * This handle (of course) holds a reference to the object, so the object
> >> + * will not go away until the handle is deleted.
> >> + */
> >> struct drm_gem_open {
> >> - /** Name of object being opened */
> >> __u32 name;
> >> -
> >> - /** Returned handle for the object */
> >> __u32 handle;
> >> -
> >> - /** Returned size of the object */
> >> __u64 size;
> >> };
> >>
> >> --
> >> 2.34.1
> >>
> >
>
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle
2025-07-11 14:53 ` [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle David Francis
@ 2025-07-17 6:23 ` Zhang, Jesse(Jie)
0 siblings, 0 replies; 8+ messages in thread
From: Zhang, Jesse(Jie) @ 2025-07-17 6:23 UTC (permalink / raw)
To: Francis, David, dri-devel@lists.freedesktop.org
Cc: tvrtko.ursulin@igalia.com, Kuehling, Felix, Yat Sin, David,
Freehill, Chris, Koenig, Christian, dcostantino@meta.com,
sruffell@meta.com, simona@ffwll.ch, mripard@kernel.org,
tzimmermann@suse.de, Francis, David
[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of David Francis
Sent: Friday, July 11, 2025 10:54 PM
To: dri-devel@lists.freedesktop.org
Cc: tvrtko.ursulin@igalia.com; Kuehling, Felix <Felix.Kuehling@amd.com>; Yat Sin, David <David.YatSin@amd.com>; Freehill, Chris <Chris.Freehill@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; dcostantino@meta.com; sruffell@meta.com; simona@ffwll.ch; mripard@kernel.org; tzimmermann@suse.de; Francis, David <David.Francis@amd.com>
Subject: [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle
CRIU restore of drm buffer objects requires the ability to create or import a buffer object with a specific gem handle.
Add new drm ioctl DRM_IOCTL_GEM_CHANGE_HANDLE, which takes the gem handle of an object and moves that object to a specified new gem handle.
This ioctl needs to call drm_prime_remove_buf_handle, but that function acquires the prime lock, which the ioctl needs to hold for other purposes.
Make drm_prime_remove_buf_handle not acquire the prime lock, and change its other caller to reflect this.
The rest of the kernel patches required to enable CRIU can be found at https://lore.kernel.org/dri-devel/20250617194536.538681-1-David.Francis@amd.com/
Signed-off-by: David Francis <David.Francis@amd.com>
---
drivers/gpu/drm/drm_gem.c | 54 ++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_internal.h | 4 +++
drivers/gpu/drm/drm_ioctl.c | 1 +
drivers/gpu/drm/drm_prime.c | 6 +---
include/uapi/drm/drm.h | 23 +++++++++++++++
5 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index c6240bab3fa5..3166230d0119 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -282,7 +282,12 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
if (obj->funcs->close)
obj->funcs->close(obj, file_priv);
+ mutex_lock(&file_priv->prime.lock);
+
drm_prime_remove_buf_handle(&file_priv->prime, id);
+
+ mutex_unlock(&file_priv->prime.lock);
+
drm_vma_node_revoke(&obj->vma_node, file_priv);
drm_gem_object_handle_put_unlocked(obj);
@@ -933,6 +938,55 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
return ret;
}
+int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ struct drm_gem_change_handle *args = data;
+ struct drm_gem_object *obj;
+ int ret;
+
+ if (!drm_core_check_feature(dev, DRIVER_GEM))
+ return -EOPNOTSUPP;
+
+ obj = drm_gem_object_lookup(file_priv, args->handle);
+ if (!obj)
+ return -ENOENT;
+
+ if (args->handle == args->new_handle)
+ return 0;
+
+ mutex_lock(&file_priv->prime.lock);
+
+ spin_lock(&file_priv->table_lock);
+ ret = idr_alloc(&file_priv->object_idr, obj,
+ args->new_handle, args->new_handle + 1, GFP_NOWAIT);
+ spin_unlock(&file_priv->table_lock);
+
+ if (ret < 0)
+ goto out_unlock;
+
+ if (obj->dma_buf) {
+ ret = drm_prime_add_buf_handle(&file_priv->prime, obj->dma_buf, args->new_handle);
+ if (ret < 0) {
+ spin_lock(&file_priv->table_lock);
+ idr_remove(&file_priv->object_idr, args->new_handle);
+ spin_unlock(&file_priv->table_lock);
+ goto out_unlock;
+ }
+
+ drm_prime_remove_buf_handle(&file_priv->prime, args->handle);
+ }
+
Added ret = 0 before out_unlock to ensure proper return value
ret = 0;
Thanks
Jesse
+ spin_lock(&file_priv->table_lock);
+ idr_remove(&file_priv->object_idr, args->handle);
+ spin_unlock(&file_priv->table_lock);
+
+out_unlock:
+ mutex_unlock(&file_priv->prime.lock);
+
+ return ret;
+}
+
/**
* drm_gem_open - initializes GEM file-private structures at devnode open time
* @dev: drm_device which is being opened by userspace diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index b2b6a8e49dda..e9d5cdf7e033 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -85,6 +85,8 @@ int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
+int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
+ struct dma_buf *dma_buf, uint32_t handle);
void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
uint32_t handle);
@@ -168,6 +170,8 @@ int drm_gem_close_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
+int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private); diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index f593dc569d31..d8a24875a7ba 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -653,6 +653,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_CHANGE_HANDLE,
+drm_gem_change_handle_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, 0),
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index bdb51c8f262e..1f2e858e5000 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -93,7 +93,7 @@ struct drm_prime_member {
struct rb_node handle_rb;
};
-static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv,
+int drm_prime_add_buf_handle(struct drm_prime_file_private
+*prime_fpriv,
struct dma_buf *dma_buf, uint32_t handle) {
struct drm_prime_member *member;
@@ -190,8 +190,6 @@ void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv, {
struct rb_node *rb;
- mutex_lock(&prime_fpriv->lock);
-
rb = prime_fpriv->handles.rb_node;
while (rb) {
struct drm_prime_member *member;
@@ -210,8 +208,6 @@ void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
rb = rb->rb_left;
}
}
-
- mutex_unlock(&prime_fpriv->lock);
}
void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv) diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 7fba37b94401..e3940b657e16 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -625,6 +625,21 @@ struct drm_gem_open {
__u64 size;
};
+/**
+ * struct drm_gem_change_handle - Argument for &DRM_IOCTL_GEM_CHANGE_HANDLE ioctl.
+ * @handle: The handle of a gem object.
+ * @new_handle: An available gem handle.
+ *
+ * This ioctl changes the handle of a GEM object to the specified one.
+ * The new handle must be unused. On success the old handle is closed
+ * and all further IOCTL should refer to the new handle only.
+ * Calls to DRM_IOCTL_PRIME_FD_TO_HANDLE will return the new handle.
+ */
+struct drm_gem_change_handle {
+ __u32 handle;
+ __u32 new_handle;
+};
+
/**
* DRM_CAP_DUMB_BUFFER
*
@@ -1305,6 +1320,14 @@ extern "C" {
*/
#define DRM_IOCTL_SET_CLIENT_NAME DRM_IOWR(0xD1, struct drm_set_client_name)
+/**
+ * DRM_IOCTL_GEM_CHANGE_HANDLE - Move an object to a different handle
+ *
+ * Some applications (notably CRIU) need objects to have specific gem handles.
+ * This ioctl changes the object at one gem handle to use a new gem handle.
+ */
+#define DRM_IOCTL_GEM_CHANGE_HANDLE DRM_IOWR(0xD2, struct drm_gem_change_handle)
+
/*
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file
2025-07-14 12:40 ` Simona Vetter
@ 2025-07-18 7:24 ` Christian König
0 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2025-07-18 7:24 UTC (permalink / raw)
To: Simona Vetter
Cc: David Francis, dri-devel, tvrtko.ursulin, Felix.Kuehling,
David.YatSin, Chris.Freehill, dcostantino, sruffell, simona,
mripard, tzimmermann
On 14.07.25 14:40, Simona Vetter wrote:
> On Mon, Jul 14, 2025 at 11:50:32AM +0200, Christian König wrote:
>> On 11.07.25 23:55, Simona Vetter wrote:
>>> On Fri, Jul 11, 2025 at 10:53:42AM -0400, David Francis wrote:
>>>> The drm_gem ioctls were documented in internal file drm_gem.c
>>>> instead of uapi header drm.h. Move them there and change to
>>>> appropriate kerneldoc formatting.
>>>>
>>>> Signed-off-by: David Francis <David.Francis@amd.com>
>>>
>>> Thanks a lot for taking care of this!
>>>
>>> Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
>>>
>>> I'll leave review for the first patch to folks who care about criu, but it
>>> looked good to me too.
>>
>> I will take that as an Acked-by.
>>
>> Are you ok that we push this into drm-misc-next by the end of the week when we have the IGT test ready?
>
> Aye, sounds like a plan.
Added the reviews, acks and links to the cover letter to the v2 from this morning and pushed the result to drm-misc-next.
We just haven't been quick enough with the IGT test (which BTW found another bug) to push it earlier.
Fingers crossed that there will be another misc-next pull request before 6.17-rc1.
Regards,
Christian.
> -Sima
>
>>
>> The patches for the CRIU code are ready and IIRC there will be a merge
>> request made, but it will take quite a while until they are actually
>> merged I think.
>
>>
>> Christian.
>>
>>> -Sima
>>>
>>>> ---
>>>> drivers/gpu/drm/drm_gem.c | 30 -----------------------------
>>>> include/uapi/drm/drm.h | 40 +++++++++++++++++++++++++++------------
>>>> 2 files changed, 28 insertions(+), 42 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
>>>> index 3166230d0119..08778a15eefb 100644
>>>> --- a/drivers/gpu/drm/drm_gem.c
>>>> +++ b/drivers/gpu/drm/drm_gem.c
>>>> @@ -820,14 +820,6 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
>>>> }
>>>> EXPORT_SYMBOL(drm_gem_dma_resv_wait);
>>>>
>>>> -/**
>>>> - * drm_gem_close_ioctl - implementation of the GEM_CLOSE ioctl
>>>> - * @dev: drm_device
>>>> - * @data: ioctl data
>>>> - * @file_priv: drm file-private structure
>>>> - *
>>>> - * Releases the handle to an mm object.
>>>> - */
>>>> int
>>>> drm_gem_close_ioctl(struct drm_device *dev, void *data,
>>>> struct drm_file *file_priv)
>>>> @@ -843,17 +835,6 @@ drm_gem_close_ioctl(struct drm_device *dev, void *data,
>>>> return ret;
>>>> }
>>>>
>>>> -/**
>>>> - * drm_gem_flink_ioctl - implementation of the GEM_FLINK ioctl
>>>> - * @dev: drm_device
>>>> - * @data: ioctl data
>>>> - * @file_priv: drm file-private structure
>>>> - *
>>>> - * Create a global name for an object, returning the name.
>>>> - *
>>>> - * Note that the name does not hold a reference; when the object
>>>> - * is freed, the name goes away.
>>>> - */
>>>> int
>>>> drm_gem_flink_ioctl(struct drm_device *dev, void *data,
>>>> struct drm_file *file_priv)
>>>> @@ -893,17 +874,6 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
>>>> return ret;
>>>> }
>>>>
>>>> -/**
>>>> - * drm_gem_open_ioctl - implementation of the GEM_OPEN ioctl
>>>> - * @dev: drm_device
>>>> - * @data: ioctl data
>>>> - * @file_priv: drm file-private structure
>>>> - *
>>>> - * Open an object using the global name, returning a handle and the size.
>>>> - *
>>>> - * This handle (of course) holds a reference to the object, so the object
>>>> - * will not go away until the handle is deleted.
>>>> - */
>>>> int
>>>> drm_gem_open_ioctl(struct drm_device *dev, void *data,
>>>> struct drm_file *file_priv)
>>>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>>>> index e3940b657e16..e512da8f3baf 100644
>>>> --- a/include/uapi/drm/drm.h
>>>> +++ b/include/uapi/drm/drm.h
>>>> @@ -597,31 +597,47 @@ struct drm_set_version {
>>>> int drm_dd_minor;
>>>> };
>>>>
>>>> -/* DRM_IOCTL_GEM_CLOSE ioctl argument type */
>>>> +/**
>>>> + * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl.
>>>> + * @handle: Handle of the object to be closed.
>>>> + * @pad: Padding.
>>>> + *
>>>> + * Releases the handle to an mm object.
>>>> + */
>>>> struct drm_gem_close {
>>>> - /** Handle of the object to be closed. */
>>>> __u32 handle;
>>>> __u32 pad;
>>>> };
>>>>
>>>> -/* DRM_IOCTL_GEM_FLINK ioctl argument type */
>>>> +/**
>>>> + * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl.
>>>> + * @handle: Handle for the object being named.
>>>> + * @name: Returned global name.
>>>> + *
>>>> + * Create a global name for an object, returning the name.
>>>> + *
>>>> + * Note that the name does not hold a reference; when the object
>>>> + * is freed, the name goes away.
>>>> + */
>>>> struct drm_gem_flink {
>>>> - /** Handle for the object being named */
>>>> __u32 handle;
>>>> -
>>>> - /** Returned global name */
>>>> __u32 name;
>>>> };
>>>>
>>>> -/* DRM_IOCTL_GEM_OPEN ioctl argument type */
>>>> +/**
>>>> + * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl.
>>>> + * @name: Name of object being opened.
>>>> + * @handle: Returned handle for the object.
>>>> + * @size: Returned size of the object
>>>> + *
>>>> + * Open an object using the global name, returning a handle and the size.
>>>> + *
>>>> + * This handle (of course) holds a reference to the object, so the object
>>>> + * will not go away until the handle is deleted.
>>>> + */
>>>> struct drm_gem_open {
>>>> - /** Name of object being opened */
>>>> __u32 name;
>>>> -
>>>> - /** Returned handle for the object */
>>>> __u32 handle;
>>>> -
>>>> - /** Returned size of the object */
>>>> __u64 size;
>>>> };
>>>>
>>>> --
>>>> 2.34.1
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-07-18 7:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 14:53 Add CHANGE_HANDLE ioctl for drm gem v2 David Francis
2025-07-11 14:53 ` [PATCH 1/2] drm: Add DRM prime interface to reassign GEM handle David Francis
2025-07-17 6:23 ` Zhang, Jesse(Jie)
2025-07-11 14:53 ` [PATCH 2/2] drm: Move drm_gem ioctl kerneldoc to uapi file David Francis
2025-07-11 21:55 ` Simona Vetter
2025-07-14 9:50 ` Christian König
2025-07-14 12:40 ` Simona Vetter
2025-07-18 7:24 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).