Path: blob/21.2-virgl/src/intel/common/intel_gem.c
4547 views
/*1* Copyright © 2020 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included11* in all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER19* DEALINGS IN THE SOFTWARE.20*/2122#include "intel_gem.h"23#include "drm-uapi/i915_drm.h"2425bool26intel_gem_supports_syncobj_wait(int fd)27{28int ret;2930struct drm_syncobj_create create = {31.flags = 0,32};33ret = intel_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);34if (ret)35return false;3637uint32_t syncobj = create.handle;3839struct drm_syncobj_wait wait = {40.handles = (uint64_t)(uintptr_t)&create,41.count_handles = 1,42.timeout_nsec = 0,43.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,44};45ret = intel_ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);4647struct drm_syncobj_destroy destroy = {48.handle = syncobj,49};50intel_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);5152/* If it timed out, then we have the ioctl and it supports the53* DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT flag.54*/55return ret == -1 && errno == ETIME;56}575859