From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73B4010E95C for ; Fri, 1 Dec 2023 21:00:23 +0000 (UTC) From: Brian Welty To: igt-dev@lists.freedesktop.org Date: Fri, 1 Dec 2023 13:00:12 -0800 Message-Id: <20231201210013.16147-2-brian.welty@intel.com> In-Reply-To: <20231201210013.16147-1-brian.welty@intel.com> References: <20231201210013.16147-1-brian.welty@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t 1/2] lib/xe_ioctl: Add _xe_wait_ufence() List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: xe_wait_ufence is expected to fail if GPU hangs or is reset. We need a version of calling XE_WAIT_USER_FENCE without the assertion that it won't expire (timeout), for use with IGTs that intentionally cause hangs or reset. Signed-off-by: Brian Welty --- lib/xe/xe_ioctl.c | 22 ++++++++++++++++------ lib/xe/xe_ioctl.h | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c index a5fe7dd792..b9828fc49f 100644 --- a/lib/xe/xe_ioctl.c +++ b/lib/xe/xe_ioctl.c @@ -446,9 +446,9 @@ void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr) syncobj_destroy(fd, sync.handle); } -int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, - struct drm_xe_engine_class_instance *eci, - int64_t timeout) +int _xe_wait_ufence(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), @@ -456,14 +456,24 @@ int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, .flags = !eci ? DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP : 0, .value = value, .mask = DRM_XE_UFENCE_WAIT_MASK_U64, - .timeout = timeout, + .timeout = *timeout, .num_engines = eci ? 1 :0, .instances = eci ? to_user_pointer(eci) : 0, }; - igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait), 0); + if (igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait)) + return -errno; - return wait.timeout; + *timeout = wait.timeout; + return 0; +} + +int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, + struct drm_xe_engine_class_instance *eci, + int64_t timeout) +{ + igt_assert_eq(_xe_wait_ufence(fd, addr, value, eci, &timeout), 0); + return timeout; } /** diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h index 6d91d3e8e6..7476a62c81 100644 --- a/lib/xe/xe_ioctl.h +++ b/lib/xe/xe_ioctl.h @@ -88,6 +88,9 @@ void xe_exec(int fd, struct drm_xe_exec *exec); void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr, struct drm_xe_sync *sync, uint32_t num_syncs); void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr); +int _xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, + struct drm_xe_engine_class_instance *eci, + int64_t *timeout); int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value, struct drm_xe_engine_class_instance *eci, int64_t timeout); -- 2.38.0