From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org,
"Daniel Vetter" <daniel@ffwll.ch>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
"Michel Dänzer" <michel@daenzer.net>,
"Tvrtko Ursulin" <tvrtko.ursulin@intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Pekka Paalanen" <ppaalanen@gmail.com>,
"Simon Ser" <contact@emersion.fr>,
"Rob Clark" <robdclark@chromium.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Gustavo Padovan" <gustavo@padovan.org>,
"Christian König" <christian.koenig@amd.com>,
linux-media@vger.kernel.org (open list:SYNC FILE FRAMEWORK),
linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER
SHARING FRAMEWORK), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v4 05/14] dma-buf/sync_file: Add SET_DEADLINE ioctl
Date: Sat, 18 Feb 2023 13:15:48 -0800 [thread overview]
Message-ID: <20230218211608.1630586-6-robdclark@gmail.com> (raw)
In-Reply-To: <20230218211608.1630586-1-robdclark@gmail.com>
From: Rob Clark <robdclark@chromium.org>
The initial purpose is for igt tests, but this would also be useful for
compositors that wait until close to vblank deadline to make decisions
about which frame to show.
The igt tests can be found at:
https://gitlab.freedesktop.org/robclark/igt-gpu-tools/-/commits/fence-deadline
v2: Clarify the timebase, add link to igt tests
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
drivers/dma-buf/sync_file.c | 19 +++++++++++++++++++
include/uapi/linux/sync_file.h | 22 ++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index af57799c86ce..fb6ca1032885 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -350,6 +350,22 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
return ret;
}
+static int sync_file_ioctl_set_deadline(struct sync_file *sync_file,
+ unsigned long arg)
+{
+ struct sync_set_deadline ts;
+
+ if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
+ return -EFAULT;
+
+ if (ts.pad)
+ return -EINVAL;
+
+ dma_fence_set_deadline(sync_file->fence, ktime_set(ts.tv_sec, ts.tv_nsec));
+
+ return 0;
+}
+
static long sync_file_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -362,6 +378,9 @@ static long sync_file_ioctl(struct file *file, unsigned int cmd,
case SYNC_IOC_FILE_INFO:
return sync_file_ioctl_fence_info(sync_file, arg);
+ case SYNC_IOC_SET_DEADLINE:
+ return sync_file_ioctl_set_deadline(sync_file, arg);
+
default:
return -ENOTTY;
}
diff --git a/include/uapi/linux/sync_file.h b/include/uapi/linux/sync_file.h
index ee2dcfb3d660..c8666580816f 100644
--- a/include/uapi/linux/sync_file.h
+++ b/include/uapi/linux/sync_file.h
@@ -67,6 +67,20 @@ struct sync_file_info {
__u64 sync_fence_info;
};
+/**
+ * struct sync_set_deadline - set a deadline on a fence
+ * @tv_sec: seconds elapsed since epoch
+ * @tv_nsec: nanoseconds elapsed since the time given by the tv_sec
+ * @pad: must be zero
+ *
+ * The timebase for the deadline is CLOCK_MONOTONIC (same as vblank)
+ */
+struct sync_set_deadline {
+ __s64 tv_sec;
+ __s32 tv_nsec;
+ __u32 pad;
+};
+
#define SYNC_IOC_MAGIC '>'
/**
@@ -95,4 +109,12 @@ struct sync_file_info {
*/
#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info)
+
+/**
+ * DOC: SYNC_IOC_SET_DEADLINE - set a deadline on a fence
+ *
+ * Allows userspace to set a deadline on a fence, see dma_fence_set_deadline()
+ */
+#define SYNC_IOC_SET_DEADLINE _IOW(SYNC_IOC_MAGIC, 5, struct sync_set_deadline)
+
#endif /* _UAPI_LINUX_SYNC_H */
--
2.39.1
next prev parent reply other threads:[~2023-02-18 21:16 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 21:15 [PATCH v4 00/14] dma-fence: Deadline awareness Rob Clark
2023-02-18 21:15 ` [PATCH v4 01/14] dma-buf/dma-fence: Add deadline awareness Rob Clark
2023-02-22 10:23 ` Tvrtko Ursulin
2023-02-22 15:28 ` Christian König
2023-02-22 17:04 ` Tvrtko Ursulin
2023-02-22 17:16 ` Rob Clark
2023-02-22 17:33 ` Tvrtko Ursulin
2023-02-22 18:57 ` Rob Clark
2023-02-22 11:01 ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 02/14] dma-buf/fence-array: Add fence deadline support Rob Clark
2023-02-18 21:15 ` [PATCH v4 03/14] dma-buf/fence-chain: " Rob Clark
2023-02-22 10:27 ` Tvrtko Ursulin
2023-02-22 15:55 ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 04/14] dma-buf/dma-resv: Add a way to set fence deadline Rob Clark
2023-02-20 8:16 ` Christian König
2023-02-18 21:15 ` Rob Clark [this message]
2023-02-20 8:27 ` [PATCH v4 05/14] dma-buf/sync_file: Add SET_DEADLINE ioctl Christian König
2023-02-20 16:09 ` Rob Clark
2023-02-21 8:41 ` Pekka Paalanen
2023-02-23 9:19 ` Christian König
2023-02-20 8:48 ` Pekka Paalanen
2023-02-18 21:15 ` [PATCH v4 06/14] dma-buf/sync_file: Support (E)POLLPRI Rob Clark
2023-02-20 8:31 ` Christian König
2023-02-21 8:38 ` Pekka Paalanen
2023-02-20 8:53 ` Pekka Paalanen
2023-02-20 16:14 ` Rob Clark
2023-02-21 8:37 ` Pekka Paalanen
2023-02-21 16:01 ` Sebastian Wick
2023-02-21 17:55 ` Rob Clark
2023-02-21 16:48 ` Luben Tuikov
2023-02-21 17:53 ` Rob Clark
2023-02-22 9:49 ` Pekka Paalanen
2023-02-22 10:26 ` Luben Tuikov
2023-02-22 15:37 ` Rob Clark
2023-02-23 9:38 ` Pekka Paalanen
2023-02-23 18:51 ` Rob Clark
2023-02-24 9:26 ` Pekka Paalanen
2023-02-24 9:41 ` Tvrtko Ursulin
2023-02-24 10:24 ` Pekka Paalanen
2023-02-24 10:50 ` Tvrtko Ursulin
2023-02-24 11:00 ` Pekka Paalanen
2023-02-24 11:37 ` Tvrtko Ursulin
2023-02-24 15:26 ` Luben Tuikov
2023-02-24 17:59 ` Rob Clark
2023-02-27 21:35 ` Rodrigo Vivi
2023-02-27 22:20 ` Rob Clark
2023-02-27 22:44 ` Sebastian Wick
2023-02-27 23:48 ` Rob Clark
2023-02-28 14:30 ` Sebastian Wick
2023-02-28 22:52 ` Rob Clark
2023-03-01 15:31 ` Sebastian Wick
2023-03-01 16:02 ` Rob Clark
2023-03-01 15:45 ` Rodrigo Vivi
2023-02-24 16:59 ` Rob Clark
2023-02-24 19:44 ` Rob Clark
2023-02-27 9:34 ` Pekka Paalanen
2023-02-27 18:43 ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 07/14] dma-buf/sw_sync: Add fence deadline support Rob Clark
2023-02-20 8:29 ` Christian König
2023-02-18 21:15 ` [PATCH v4 08/14] drm/scheduler: " Rob Clark
2023-02-21 19:40 ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 12/14] drm/msm: Add deadline based boost support Rob Clark
2023-02-18 21:15 ` [PATCH v4 14/14] drm/i915: " Rob Clark
2023-02-20 15:46 ` Tvrtko Ursulin
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=20230218211608.1630586-6-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=michel@daenzer.net \
--cc=ppaalanen@gmail.com \
--cc=robdclark@chromium.org \
--cc=rodrigo.vivi@intel.com \
--cc=sumit.semwal@linaro.org \
--cc=tvrtko.ursulin@intel.com \
/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