diff options
| author | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2023-06-19 07:32:47 +0200 |
|---|---|---|
| committer | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2023-06-19 15:33:03 +0200 |
| commit | 24e570ad6635a4aafcf3be75612131348cb71285 (patch) | |
| tree | 821409e2da89f6174bc1bc21000d4082635662a6 /lib/xe/xe_ioctl.c | |
| parent | 2062f3860dbdd1062f54f925cf6b49e28561c75a (diff) | |
lib/xe_ioctl: Add xe_wait_ufence_abstime() helper
Xe user fences supports passing timeout in relative or absolute form.
Add helper for absolute one.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'lib/xe/xe_ioctl.c')
| -rw-r--r-- | lib/xe/xe_ioctl.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c index 66a8393fe..c8af747cf 100644 --- a/lib/xe/xe_ioctl.c +++ b/lib/xe/xe_ioctl.c @@ -36,6 +36,7 @@ #define major(__v__) (((__v__) >> 8) & 0xff) #define minor(__v__) ((__v__) & 0xff) #endif +#include <time.h> #include "config.h" #include "drmtest.h" @@ -418,6 +419,40 @@ void xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait), 0); } +/** + * xe_wait_ufence_abstime: + * @fd: xe device fd + * @addr: address of value to compare + * @value: expected value (equal) in @address + * @eci: engine class instance + * @timeout: absolute time when wait expire + * + * Function compares @value with memory pointed by @addr until they are equal. + * + * Returns elapsed time in nanoseconds if user fence was signalled. + */ +int64_t xe_wait_ufence_abstime(int fd, uint64_t *addr, uint64_t value, + struct drm_xe_engine_class_instance *eci, + int64_t timeout) +{ + struct drm_xe_wait_user_fence wait = { + .addr = to_user_pointer(addr), + .op = DRM_XE_UFENCE_WAIT_EQ, + .flags = !eci ? DRM_XE_UFENCE_WAIT_SOFT_OP | DRM_XE_UFENCE_WAIT_ABSTIME : 0, + .value = value, + .mask = DRM_XE_UFENCE_WAIT_U64, + .timeout = timeout, + .num_engines = eci ? 1 : 0, + .instances = eci ? to_user_pointer(eci) : 0, + }; + struct timespec ts; + + igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait), 0); + igt_assert_eq(clock_gettime(CLOCK_MONOTONIC, &ts), 0); + + return ts.tv_sec * 1e9 + ts.tv_nsec; +} + void xe_force_gt_reset(int fd, int gt) { char reset_string[128]; |
