drm/i915: Enable userspace to opt-out of implicit fencing
Userspace is faced with a dilemma. The kernel requires implicit fencing to manage resource usage (we always must wait for the GPU to finish before releasing its PTE) and for third parties. However, userspace may wish to avoid this serialisation if it is either using explicit fencing between parties and wants more fine-grained access to buffers (e.g. it may partition the buffer between uses and track fences on ranges rather than the implicit fences tracking the whole object). It follows that userspace needs a mechanism to avoid the kernel's serialisation on its implicit fences before execbuf execution. The next question is whether this is an object, execbuf or context flag. Hybrid users (such as using explicit EGL_ANDROID_native_sync fencing on shared winsys buffers, but implicit fencing on internal surfaces) require a per-object level flag. Given that this flag need to be only set once for the lifetime of the object, this reduces the convenience of having an execbuf or context level flag (and avoids having multiple pieces of uABI controlling the same feature). Incorrect use of this flag will result in rendering corruption and GPU hangs - but will not result in use-after-free or similar resource tracking issues. Serious caveat: write ordering is not strictly correct after setting this flag on a render target on multiple engines. This affects all subsequent GEM operations (execbuf, set-domain, pread) and shared dma-buf operations. A fix is possible - but costly (both in terms of further ABI changes and runtime overhead). Testcase: igt/gem_exec_async Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Acked-by: Chad Versace <chadversary@chromium.org> Link: http://patchwork.freedesktop.org/patch/msgid/20170127094008.27489-1-chris@chris-wilson.co.uk
This commit is contained in:
Родитель
40f62bb75e
Коммит
77ae995789
|
@ -349,6 +349,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
|
||||||
case I915_PARAM_HAS_EXEC_HANDLE_LUT:
|
case I915_PARAM_HAS_EXEC_HANDLE_LUT:
|
||||||
case I915_PARAM_HAS_COHERENT_PHYS_GTT:
|
case I915_PARAM_HAS_COHERENT_PHYS_GTT:
|
||||||
case I915_PARAM_HAS_EXEC_SOFTPIN:
|
case I915_PARAM_HAS_EXEC_SOFTPIN:
|
||||||
|
case I915_PARAM_HAS_EXEC_ASYNC:
|
||||||
/* For the time being all of these are always true;
|
/* For the time being all of these are always true;
|
||||||
* if some supported hardware does not have one of these
|
* if some supported hardware does not have one of these
|
||||||
* features this value needs to be provided from
|
* features this value needs to be provided from
|
||||||
|
|
|
@ -1111,6 +1111,9 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
|
||||||
list_for_each_entry(vma, vmas, exec_list) {
|
list_for_each_entry(vma, vmas, exec_list) {
|
||||||
struct drm_i915_gem_object *obj = vma->obj;
|
struct drm_i915_gem_object *obj = vma->obj;
|
||||||
|
|
||||||
|
if (vma->exec_entry->flags & EXEC_OBJECT_ASYNC)
|
||||||
|
continue;
|
||||||
|
|
||||||
ret = i915_gem_request_await_object
|
ret = i915_gem_request_await_object
|
||||||
(req, obj, obj->base.pending_write_domain);
|
(req, obj, obj->base.pending_write_domain);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -397,6 +397,12 @@ typedef struct drm_i915_irq_wait {
|
||||||
#define I915_PARAM_HAS_SCHEDULER 41
|
#define I915_PARAM_HAS_SCHEDULER 41
|
||||||
#define I915_PARAM_HUC_STATUS 42
|
#define I915_PARAM_HUC_STATUS 42
|
||||||
|
|
||||||
|
/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
|
||||||
|
* synchronisation with implicit fencing on individual objects.
|
||||||
|
* See EXEC_OBJECT_ASYNC.
|
||||||
|
*/
|
||||||
|
#define I915_PARAM_HAS_EXEC_ASYNC 43
|
||||||
|
|
||||||
typedef struct drm_i915_getparam {
|
typedef struct drm_i915_getparam {
|
||||||
__s32 param;
|
__s32 param;
|
||||||
/*
|
/*
|
||||||
|
@ -737,8 +743,29 @@ struct drm_i915_gem_exec_object2 {
|
||||||
#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
|
#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
|
||||||
#define EXEC_OBJECT_PINNED (1<<4)
|
#define EXEC_OBJECT_PINNED (1<<4)
|
||||||
#define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
|
#define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
|
||||||
|
/* The kernel implicitly tracks GPU activity on all GEM objects, and
|
||||||
|
* synchronises operations with outstanding rendering. This includes
|
||||||
|
* rendering on other devices if exported via dma-buf. However, sometimes
|
||||||
|
* this tracking is too coarse and the user knows better. For example,
|
||||||
|
* if the object is split into non-overlapping ranges shared between different
|
||||||
|
* clients or engines (i.e. suballocating objects), the implicit tracking
|
||||||
|
* by kernel assumes that each operation affects the whole object rather
|
||||||
|
* than an individual range, causing needless synchronisation between clients.
|
||||||
|
* The kernel will also forgo any CPU cache flushes prior to rendering from
|
||||||
|
* the object as the client is expected to be also handling such domain
|
||||||
|
* tracking.
|
||||||
|
*
|
||||||
|
* The kernel maintains the implicit tracking in order to manage resources
|
||||||
|
* used by the GPU - this flag only disables the synchronisation prior to
|
||||||
|
* rendering with this object in this execbuf.
|
||||||
|
*
|
||||||
|
* Opting out of implicit synhronisation requires the user to do its own
|
||||||
|
* explicit tracking to avoid rendering corruption. See, for example,
|
||||||
|
* I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
|
||||||
|
*/
|
||||||
|
#define EXEC_OBJECT_ASYNC (1<<6)
|
||||||
/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
|
/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
|
||||||
#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_PAD_TO_SIZE<<1)
|
#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_ASYNC<<1)
|
||||||
__u64 flags;
|
__u64 flags;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче