mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-11 16:32:58 +00:00
lib: Move gem_wait() to ioctl-wrappers
We intend to use gem_wait() in more tests than gem_wait.c, so move the simple ioctl wrapper into the core. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
+36
-12
@@ -369,6 +369,36 @@ void gem_set_domain(int fd, uint32_t handle,
|
||||
do_ioctl(fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &set_domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* __gem_wait:
|
||||
* @fd: open i915 drm file descriptor
|
||||
* @handle: gem buffer object handle
|
||||
* @timeout_ns: [in] time to wait, [out] remaining time (in nanoseconds)
|
||||
*
|
||||
* This functions waits for outstanding rendering to complete, upto
|
||||
* the timeout_ns. If no timeout_ns is provided, the wait is indefinite and
|
||||
* only returns upon an error or when the rendering is complete.
|
||||
*/
|
||||
int gem_wait(int fd, uint32_t handle, int64_t *timeout_ns)
|
||||
{
|
||||
struct drm_i915_gem_wait wait;
|
||||
int ret;
|
||||
|
||||
memset(&wait, 0, sizeof(wait));
|
||||
wait.bo_handle = handle;
|
||||
wait.timeout_ns = timeout_ns ? *timeout_ns : -1;
|
||||
wait.flags = 0;
|
||||
|
||||
ret = 0;
|
||||
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait))
|
||||
ret = -errno;
|
||||
|
||||
if (timeout_ns)
|
||||
*timeout_ns = wait.timeout_ns;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gem_sync:
|
||||
* @fd: open i915 drm file descriptor
|
||||
@@ -378,20 +408,14 @@ void gem_set_domain(int fd, uint32_t handle,
|
||||
*/
|
||||
void gem_sync(int fd, uint32_t handle)
|
||||
{
|
||||
struct drm_i915_gem_wait wait;
|
||||
|
||||
memset(&wait, 0, sizeof(wait));
|
||||
wait.bo_handle = handle;
|
||||
wait.timeout_ns =-1;
|
||||
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_WAIT, &wait) == 0) {
|
||||
errno = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
gem_set_domain(fd, handle,
|
||||
I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
|
||||
if (gem_wait(fd, handle, NULL))
|
||||
gem_set_domain(fd, handle,
|
||||
I915_GEM_DOMAIN_GTT,
|
||||
I915_GEM_DOMAIN_GTT);
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
|
||||
bool gem_create__has_stolen_support(int fd)
|
||||
{
|
||||
static int has_stolen_support = -1;
|
||||
|
||||
@@ -55,6 +55,7 @@ void gem_write(int fd, uint32_t handle, uint64_t offset, const void *buf, uint6
|
||||
void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t length);
|
||||
void gem_set_domain(int fd, uint32_t handle,
|
||||
uint32_t read_domains, uint32_t write_domain);
|
||||
int gem_wait(int fd, uint32_t handle, int64_t *timeout_ns);
|
||||
void gem_sync(int fd, uint32_t handle);
|
||||
bool gem_create__has_stolen_support(int fd);
|
||||
uint32_t __gem_create_stolen(int fd, uint64_t size);
|
||||
|
||||
Reference in New Issue
Block a user