From: "Christian König" <christian.koenig@amd.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>,
Rob Clark <robdclark@gmail.com>,
dri-devel@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
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>,
Sumit Semwal <sumit.semwal@linaro.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:DMA BUFFER SHARING
FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b"
<linux-media@vger.kernel.org>,
"moderated list:DMA BUFFER SHARING
FRAMEWORK:Keyword:bdma_(?:buf|fence|resv)b"
<linaro-mm-sig@lists.linaro.org>
Subject: Re: [PATCH v6] drm/syncobj: Extend EXPORT_SYNC_FILE for timeline syncobjs
Date: Wed, 2 Apr 2025 08:55:15 +0200 [thread overview]
Message-ID: <b636faa5-ab31-41d6-b957-4dfe89a2b47d@amd.com> (raw)
In-Reply-To: <ff614cb7-94ca-4d74-9bbb-f97c95893113@collabora.com>
Am 01.04.25 um 22:46 schrieb Dmitry Osipenko:
> On 4/1/25 23:40, Rob Clark wrote:
>> On Tue, Apr 1, 2025 at 8:58 AM Rob Clark <robdclark@gmail.com> wrote:
>>> From: Rob Clark <robdclark@chromium.org>
>>>
>>> Add support for exporting a dma_fence fd for a specific point on a
>>> timeline. This is needed for vtest/vpipe[1][2] to implement timeline
>>> syncobj support, as it needs a way to turn a point on a timeline back
>>> into a dma_fence fd. It also closes an odd omission from the syncobj
>>> UAPI.
>>>
>>> [1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33433
>>> [2] https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/805
>>>
>>> v2: Add DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_TIMELINE
>>> v3: Add unstaged uabi header hunk
>>> v4: Also handle IMPORT_SYNC_FILE case
>>> v5: Address comments from Dmitry
>>> v6: checkpatch.pl nits
>>>
>>> Signed-off-by: Rob Clark <robdclark@chromium.org>
>>> Reviewed-by: Christian König <christian.koenig@amd.com>
>>> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>>> ---
>>> drivers/gpu/drm/drm_syncobj.c | 47 +++++++++++++++++++++++++++--------
>>> include/uapi/drm/drm.h | 4 +++
>>> 2 files changed, 41 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
>>> index 4f2ab8a7b50f..636cd83ca29e 100644
>>> --- a/drivers/gpu/drm/drm_syncobj.c
>>> +++ b/drivers/gpu/drm/drm_syncobj.c
>>> @@ -741,7 +741,7 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private,
>>> }
>>>
>>> static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
>>> - int fd, int handle)
>>> + int fd, int handle, u64 point)
>>> {
>>> struct dma_fence *fence = sync_file_get_fence(fd);
>>> struct drm_syncobj *syncobj;
>>> @@ -755,14 +755,24 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
>>> return -ENOENT;
>>> }
>>>
>>> - drm_syncobj_replace_fence(syncobj, fence);
>>> + if (point) {
>>> + struct dma_fence_chain *chain = dma_fence_chain_alloc();
>>> +
>>> + if (!chain)
>>> + return -ENOMEM;
>>> +
>>> + drm_syncobj_add_point(syncobj, chain, fence, point);
>>> + } else {
>>> + drm_syncobj_replace_fence(syncobj, fence);
>>> + }
>>> +
>>> dma_fence_put(fence);
>>> drm_syncobj_put(syncobj);
>>> return 0;
>>> }
>>>
>>> static int drm_syncobj_export_sync_file(struct drm_file *file_private,
>>> - int handle, int *p_fd)
>>> + int handle, u64 point, int *p_fd)
>>> {
>>> int ret;
>>> struct dma_fence *fence;
>>> @@ -772,7 +782,7 @@ static int drm_syncobj_export_sync_file(struct drm_file *file_private,
>>> if (fd < 0)
>>> return fd;
>>>
>>> - ret = drm_syncobj_find_fence(file_private, handle, 0, 0, &fence);
>>> + ret = drm_syncobj_find_fence(file_private, handle, point, 0, &fence);
>>> if (ret)
>>> goto err_put_fd;
>>>
>>> @@ -869,6 +879,9 @@ drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
>>> struct drm_file *file_private)
>>> {
>>> struct drm_syncobj_handle *args = data;
>>> + unsigned int valid_flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_TIMELINE |
>>> + DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
>>> + u64 point = 0;
>>>
>>> if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
>>> return -EOPNOTSUPP;
>>> @@ -876,13 +889,18 @@ drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
>>> if (args->pad)
>>> return -EINVAL;
>>>
>>> - if (args->flags != 0 &&
>>> - args->flags != DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
>>> + if (args->flags & ~valid_flags)
>>> return -EINVAL;
>>>
>>> + if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_TIMELINE)
>>> + point = args->point;
>>> +
>>> if (args->flags & DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE)
>>> return drm_syncobj_export_sync_file(file_private, args->handle,
>>> - &args->fd);
>>> + point, &args->fd);
>>> +
>>> + if (args->point)
>>> + return -EINVAL;
>>>
>>> return drm_syncobj_handle_to_fd(file_private, args->handle,
>>> &args->fd);
>>> @@ -893,6 +911,9 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
>>> struct drm_file *file_private)
>>> {
>>> struct drm_syncobj_handle *args = data;
>>> + unsigned int valid_flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_TIMELINE |
>>> + DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
>>> + u64 point = 0;
>>>
>>> if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
>>> return -EOPNOTSUPP;
>> oh, I suppose I should add a check for DRIVER_SYNCOBJ_TIMELINE? I'll
>> send a v7 a bit later
> Christian already applied to misc-test, please rebase and make it as a
> new patch
Yeah, sorry I was a bit to quick obviously.
On the other hand I don't see an immediate need for a check for DRIVER_SYNCOBJ_TIMELINE here.
The functions should work even when the driver doesn't handle timeline syncobj on it's own.
Regards,
Christian.
next prev parent reply other threads:[~2025-04-02 6:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 15:57 [PATCH v6] drm/syncobj: Extend EXPORT_SYNC_FILE for timeline syncobjs Rob Clark
2025-04-01 20:40 ` Rob Clark
2025-04-01 20:46 ` Dmitry Osipenko
2025-04-02 6:55 ` Christian König [this message]
2025-04-02 16:11 ` Rob Clark
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=b636faa5-ab31-41d6-b957-4dfe89a2b47d@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.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