[PATCH 60/60] move-aux-execbuf-data
Chris Wilson
chris at chris-wilson.co.uk
Sun Jul 1 10:21:29 UTC 2018
---
drivers/gpu/drm/i915/i915_gem_evict.c | 3 -
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 247 ++++++++++-----------
drivers/gpu/drm/i915/i915_vma.h | 11 -
3 files changed, 121 insertions(+), 140 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index fdb83336e95a..29963d8384e7 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -357,9 +357,6 @@ int i915_gem_evict_for_node(struct i915_address_space *vm,
/* Overlap of objects in the same batch? */
if (i915_vma_is_pinned(vma)) {
ret = -ENOSPC;
- if (vma->exec_flags &&
- *vma->exec_flags & EXEC_OBJECT_PINNED)
- ret = -EINVAL;
break;
}
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 6318c14d6f10..2b80e39dc196 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -226,13 +226,24 @@ enum {
* the batchbuffer in trusted mode, otherwise the ioctl is rejected.
*/
+struct eb_vma {
+ struct i915_vma *vma;
+ struct drm_i915_gem_exec_object2 *entry;
+
+ struct list_head exec_link;
+ struct list_head reloc_link;
+
+ struct hlist_node exec_node;
+ unsigned int flags;
+ u32 handle;
+};
+
struct i915_execbuffer {
struct drm_i915_private *i915; /** i915 backpointer */
struct drm_file *file; /** per-file lookup tables and limits */
struct drm_i915_gem_execbuffer2 *args; /** ioctl parameters */
struct drm_i915_gem_exec_object2 *exec; /** ioctl execobj[] */
- struct i915_vma **vma;
- unsigned int *flags;
+ struct eb_vma *vma;
struct intel_engine_cs *engine; /** engine to queue the request to */
struct i915_gem_context *ctx; /** context for building the request */
@@ -391,9 +402,10 @@ eb_vma_misplaced(const struct drm_i915_gem_exec_object2 *entry,
static inline bool
eb_pin_vma(struct i915_execbuffer *eb,
const struct drm_i915_gem_exec_object2 *entry,
- struct i915_vma *vma)
+ struct eb_vma *ev)
{
- unsigned int exec_flags = *vma->exec_flags;
+ struct i915_vma *vma = ev->vma;
+ unsigned int exec_flags = ev->flags;
u64 pin_flags;
if (vma->node.size)
@@ -419,8 +431,8 @@ eb_pin_vma(struct i915_execbuffer *eb,
exec_flags |= __EXEC_OBJECT_HAS_FENCE;
}
- *vma->exec_flags = exec_flags | __EXEC_OBJECT_HAS_PIN;
- return !eb_vma_misplaced(entry, vma, exec_flags);
+ ev->flags = exec_flags | __EXEC_OBJECT_HAS_PIN;
+ return !eb_vma_misplaced(entry, vma, ev->flags);
}
static inline void __eb_unreserve_vma(struct i915_vma *vma, unsigned int flags)
@@ -470,12 +482,6 @@ eb_validate_vma(struct i915_execbuffer *eb,
entry->pad_to_size = 0;
}
- if (unlikely(vma->exec_flags)) {
- DRM_DEBUG("Object [handle %d, index %d] appears more than once in object list\n",
- entry->handle, (int)(entry - eb->exec));
- return -EINVAL;
- }
-
/*
* From drm_mm perspective address space is continuous,
* so from this point we're always using non-canonical
@@ -504,6 +510,7 @@ eb_add_vma(struct i915_execbuffer *eb,
struct i915_vma *vma)
{
struct drm_i915_gem_exec_object2 *entry = &eb->exec[i];
+ struct eb_vma *ev = &eb->vma[i];
int err;
GEM_BUG_ON(i915_vma_is_closed(vma));
@@ -514,25 +521,25 @@ eb_add_vma(struct i915_execbuffer *eb,
return err;
}
- if (eb->lut_size > 0) {
- vma->exec_handle = entry->handle;
- hlist_add_head(&vma->exec_node,
- &eb->buckets[hash_32(entry->handle,
- eb->lut_size)]);
- }
-
- if (entry->relocation_count)
- list_add_tail(&vma->reloc_link, &eb->relocs);
-
/*
* Stash a pointer from the vma to execobj, so we can query its flags,
* size, alignment etc as provided by the user. Also we stash a pointer
* to the vma inside the execobj so that we can use a direct lookup
* to find the right target VMA when doing relocations.
*/
- eb->vma[i] = vma;
- eb->flags[i] = entry->flags;
- vma->exec_flags = &eb->flags[i];
+ ev->vma = vma;
+ ev->entry = entry;
+ ev->flags = entry->flags;
+
+ if (eb->lut_size > 0) {
+ ev->handle = entry->handle;
+ hlist_add_head(&ev->exec_node,
+ &eb->buckets[hash_32(entry->handle,
+ eb->lut_size)]);
+ }
+
+ if (entry->relocation_count)
+ list_add_tail(&ev->reloc_link, &eb->relocs);
/*
* SNA is doing fancy tricks with compressing batch buffers, which leads
@@ -545,28 +552,26 @@ eb_add_vma(struct i915_execbuffer *eb,
*/
if (i == batch_idx) {
if (entry->relocation_count &&
- !(eb->flags[i] & EXEC_OBJECT_PINNED))
- eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS;
+ !(ev->flags & EXEC_OBJECT_PINNED))
+ ev->flags |= __EXEC_OBJECT_NEEDS_BIAS;
if (eb->reloc_cache.has_fence)
- eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE;
+ ev->flags |= EXEC_OBJECT_NEEDS_FENCE;
eb->batch = vma;
}
err = 0;
- if (eb_pin_vma(eb, entry, vma)) {
+ if (eb_pin_vma(eb, entry, ev)) {
if (entry->offset != vma->node.start) {
entry->offset = vma->node.start | UPDATE;
eb->args->flags |= __EXEC_HAS_RELOC;
}
} else {
- eb_unreserve_vma(vma, vma->exec_flags);
+ eb_unreserve_vma(vma, &ev->flags);
- list_add_tail(&vma->exec_link, &eb->unbound);
+ list_add_tail(&ev->exec_link, &eb->unbound);
if (drm_mm_node_allocated(&vma->node))
err = i915_vma_unbind(vma);
- if (unlikely(err))
- vma->exec_flags = NULL;
}
return err;
}
@@ -589,10 +594,10 @@ static inline int use_cpu_reloc(const struct reloc_cache *cache,
}
static int eb_reserve_vma(const struct i915_execbuffer *eb,
- struct i915_vma *vma)
+ struct eb_vma *ev)
{
- struct drm_i915_gem_exec_object2 *entry = exec_entry(eb, vma);
- unsigned int exec_flags = *vma->exec_flags;
+ struct drm_i915_gem_exec_object2 *entry = ev->entry;
+ unsigned int exec_flags = ev->flags;
u64 pin_flags;
int err;
@@ -617,31 +622,31 @@ static int eb_reserve_vma(const struct i915_execbuffer *eb,
pin_flags |= BATCH_OFFSET_BIAS | PIN_OFFSET_BIAS;
}
- err = __i915_vma_pin(vma,
+ err = __i915_vma_pin(ev->vma,
entry->pad_to_size, entry->alignment,
pin_flags);
if (err)
return err;
- if (entry->offset != vma->node.start) {
- entry->offset = vma->node.start | UPDATE;
+ if (entry->offset != ev->vma->node.start) {
+ entry->offset = ev->vma->node.start | UPDATE;
eb->args->flags |= __EXEC_HAS_RELOC;
}
if (unlikely(exec_flags & EXEC_OBJECT_NEEDS_FENCE)) {
- err = i915_vma_reserve_fence(vma);
+ err = i915_vma_reserve_fence(ev->vma);
if (unlikely(err)) {
- __i915_vma_unpin(vma);
+ __i915_vma_unpin(ev->vma);
return err;
}
exec_flags &= ~EXEC_OBJECT_ASYNC;
- if (vma->fence)
+ if (ev->vma->fence)
exec_flags |= __EXEC_OBJECT_HAS_FENCE;
}
- *vma->exec_flags = exec_flags | __EXEC_OBJECT_HAS_PIN;
- GEM_BUG_ON(eb_vma_misplaced(entry, vma, exec_flags));
+ ev->flags = exec_flags | __EXEC_OBJECT_HAS_PIN;
+ GEM_BUG_ON(eb_vma_misplaced(entry, ev->vma, ev->flags));
return 0;
}
@@ -650,7 +655,7 @@ static int eb_reserve(struct i915_execbuffer *eb)
{
const unsigned int count = eb->buffer_count;
struct list_head last;
- struct i915_vma *vma;
+ struct eb_vma *ev;
unsigned int i, pass;
int err;
@@ -671,8 +676,8 @@ static int eb_reserve(struct i915_execbuffer *eb)
pass = 0;
err = 0;
do {
- list_for_each_entry(vma, &eb->unbound, exec_link) {
- err = eb_reserve_vma(eb, vma);
+ list_for_each_entry(ev, &eb->unbound, exec_link) {
+ err = eb_reserve_vma(eb, ev);
if (err)
break;
}
@@ -683,21 +688,21 @@ static int eb_reserve(struct i915_execbuffer *eb)
INIT_LIST_HEAD(&eb->unbound);
INIT_LIST_HEAD(&last);
for (i = 0; i < count; i++) {
- unsigned int flags = eb->flags[i];
- struct i915_vma *vma = eb->vma[i];
+ unsigned int flags = eb->vma[i].flags;
+ struct i915_vma *vma = eb->vma[i].vma;
if (flags & EXEC_OBJECT_PINNED &&
flags & __EXEC_OBJECT_HAS_PIN)
continue;
- eb_unreserve_vma(vma, &eb->flags[i]);
+ eb_unreserve_vma(vma, &eb->vma[i].flags);
if (flags & EXEC_OBJECT_PINNED)
- list_add(&vma->exec_link, &eb->unbound);
+ list_add(&ev->exec_link, &eb->unbound);
else if (flags & __EXEC_OBJECT_NEEDS_MAP)
- list_add_tail(&vma->exec_link, &eb->unbound);
+ list_add_tail(&ev->exec_link, &eb->unbound);
else
- list_add_tail(&vma->exec_link, &last);
+ list_add_tail(&ev->exec_link, &last);
}
list_splice_tail(&last, &eb->unbound);
@@ -818,10 +823,9 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
goto err_vma;
}
- GEM_BUG_ON(vma != eb->vma[i]);
- GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
+ GEM_BUG_ON(vma != eb->vma[i].vma);
GEM_BUG_ON(drm_mm_node_allocated(&vma->node) &&
- eb_vma_misplaced(&eb->exec[i], vma, eb->flags[i]));
+ eb_vma_misplaced(&eb->exec[i], vma, eb->vma[i].flags));
}
eb->args->flags |= __EXEC_VALIDATED;
@@ -833,26 +837,26 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
err_obj:
i915_gem_object_put(obj);
err_vma:
- eb->vma[i] = NULL;
+ eb->vma[i].vma = NULL;
mutex_unlock(&eb->ctx->mutex);
return err;
}
-static struct i915_vma *
+static struct eb_vma *
eb_get_vma(const struct i915_execbuffer *eb, unsigned long handle)
{
if (eb->lut_size < 0) {
if (handle >= -eb->lut_size)
return NULL;
- return eb->vma[handle];
+ return &eb->vma[handle];
} else {
struct hlist_head *head;
- struct i915_vma *vma;
+ struct eb_vma *ev;
head = &eb->buckets[hash_32(handle, eb->lut_size)];
- hlist_for_each_entry(vma, head, exec_node) {
- if (vma->exec_handle == handle)
- return vma;
+ hlist_for_each_entry(ev, head, exec_node) {
+ if (ev->handle == handle)
+ return ev;
}
return NULL;
}
@@ -865,15 +869,13 @@ static void eb_release_vmas(const struct i915_execbuffer *eb)
mutex_lock(&eb->vm->mutex);
for (i = 0; i < count; i++) {
- struct i915_vma *vma = eb->vma[i];
- unsigned int flags = eb->flags[i];
+ struct i915_vma *vma = eb->vma[i].vma;
+ unsigned int flags = eb->vma[i].flags;
if (!vma)
break;
- GEM_BUG_ON(vma->exec_flags != &eb->flags[i]);
- vma->exec_flags = NULL;
- eb->vma[i] = NULL;
+ eb->vma[i].vma = NULL;
if (unlikely(vma->vm != eb->vm))
mutex_lock_nested(&vma->vm->mutex,
@@ -1348,10 +1350,10 @@ relocate_entry(struct i915_vma *vma,
static u64
eb_relocate_entry(struct i915_execbuffer *eb,
- struct i915_vma *vma,
+ struct eb_vma *ev,
const struct drm_i915_gem_relocation_entry *reloc)
{
- struct i915_vma *target;
+ struct eb_vma *target;
int err;
/* we've already hold a reference to all valid objects */
@@ -1383,7 +1385,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,
}
if (reloc->write_domain) {
- *target->exec_flags |= EXEC_OBJECT_WRITE;
+ target->flags |= EXEC_OBJECT_WRITE;
/*
* Sandybridge PPGTT errata: We need a global gtt mapping
@@ -1393,13 +1395,16 @@ eb_relocate_entry(struct i915_execbuffer *eb,
*/
if (reloc->write_domain == I915_GEM_DOMAIN_INSTRUCTION &&
IS_GEN6(eb->i915)) {
+ struct i915_vma *tag = target->vma;
+
reloc_cache_reset(&eb->reloc_cache);
- GEM_BUG_ON(!i915_vma_is_ggtt(target));
- mutex_lock(&target->vm->mutex);
- err = i915_vma_bind(target, target->obj->cache_level,
+ GEM_BUG_ON(!i915_vma_is_ggtt(tag));
+ mutex_lock(&tag->vm->mutex);
+ err = i915_vma_bind(tag,
+ tag->obj->cache_level,
PIN_GLOBAL);
- mutex_unlock(&target->vm->mutex);
+ mutex_unlock(&tag->vm->mutex);
if (WARN_ONCE(err,
"Unexpected failure to bind target VMA!"))
@@ -1412,17 +1417,17 @@ eb_relocate_entry(struct i915_execbuffer *eb,
* more work needs to be done.
*/
if (!DBG_FORCE_RELOC &&
- gen8_canonical_addr(target->node.start) == reloc->presumed_offset)
+ gen8_canonical_addr(target->vma->node.start) == reloc->presumed_offset)
return 0;
/* Check that the relocation address is valid... */
if (unlikely(reloc->offset >
- vma->size - (eb->reloc_cache.use_64bit_reloc ? 8 : 4))) {
+ ev->vma->size - (eb->reloc_cache.use_64bit_reloc ? 8 : 4))) {
DRM_DEBUG("Relocation beyond object bounds: "
"target %d offset %d size %d.\n",
reloc->target_handle,
(int)reloc->offset,
- (int)vma->size);
+ (int)ev->vma->size);
return -EINVAL;
}
if (unlikely(reloc->offset & 3)) {
@@ -1441,18 +1446,18 @@ eb_relocate_entry(struct i915_execbuffer *eb,
* do relocations we are already stalling, disable the user's opt
* out of our synchronisation.
*/
- *vma->exec_flags &= ~EXEC_OBJECT_ASYNC;
+ ev->flags &= ~EXEC_OBJECT_ASYNC;
/* and update the user's relocation entry */
- return relocate_entry(vma, reloc, eb, target);
+ return relocate_entry(ev->vma, reloc, eb, target->vma);
}
-static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
+static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
{
#define N_RELOC(x) ((x) / sizeof(struct drm_i915_gem_relocation_entry))
struct drm_i915_gem_relocation_entry stack[N_RELOC(512)];
struct drm_i915_gem_relocation_entry __user *urelocs;
- const struct drm_i915_gem_exec_object2 *entry = exec_entry(eb, vma);
+ const struct drm_i915_gem_exec_object2 *entry = ev->entry;
unsigned int remain;
urelocs = u64_to_user_ptr(entry->relocs_ptr);
@@ -1492,7 +1497,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
remain -= count;
do {
- u64 offset = eb_relocate_entry(eb, vma, r);
+ u64 offset = eb_relocate_entry(eb, ev, r);
if (likely(offset == 0)) {
} else if ((s64)offset < 0) {
@@ -1533,16 +1538,16 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
}
static int
-eb_relocate_vma_slow(struct i915_execbuffer *eb, struct i915_vma *vma)
+eb_relocate_vma_slow(struct i915_execbuffer *eb, struct eb_vma *ev)
{
- const struct drm_i915_gem_exec_object2 *entry = exec_entry(eb, vma);
+ const struct drm_i915_gem_exec_object2 *entry = ev->entry;
struct drm_i915_gem_relocation_entry *relocs =
u64_to_ptr(typeof(*relocs), entry->relocs_ptr);
unsigned int i;
int err;
for (i = 0; i < entry->relocation_count; i++) {
- u64 offset = eb_relocate_entry(eb, vma, &relocs[i]);
+ u64 offset = eb_relocate_entry(eb, ev, &relocs[i]);
if ((s64)offset < 0) {
err = (int)offset;
@@ -1685,7 +1690,7 @@ static noinline int eb_relocate_slow(struct i915_execbuffer *eb)
{
struct drm_device *dev = &eb->i915->drm;
bool have_copy = false;
- struct i915_vma *vma;
+ struct eb_vma *ev;
int err = 0;
repeat:
@@ -1741,15 +1746,15 @@ static noinline int eb_relocate_slow(struct i915_execbuffer *eb)
GEM_BUG_ON(!eb->batch);
- list_for_each_entry(vma, &eb->relocs, reloc_link) {
+ list_for_each_entry(ev, &eb->relocs, reloc_link) {
if (!have_copy) {
pagefault_disable();
- err = eb_relocate_vma(eb, vma);
+ err = eb_relocate_vma(eb, ev);
pagefault_enable();
if (err)
goto repeat;
} else {
- err = eb_relocate_vma_slow(eb, vma);
+ err = eb_relocate_vma_slow(eb, ev);
if (err)
goto err;
}
@@ -1794,10 +1799,10 @@ static int eb_relocate(struct i915_execbuffer *eb)
/* The objects are in their final locations, apply the relocations. */
if (eb->args->flags & __EXEC_HAS_RELOC) {
- struct i915_vma *vma;
+ struct eb_vma *ev;
- list_for_each_entry(vma, &eb->relocs, reloc_link) {
- if (eb_relocate_vma(eb, vma))
+ list_for_each_entry(ev, &eb->relocs, reloc_link) {
+ if (eb_relocate_vma(eb, ev))
goto slow;
}
}
@@ -1818,9 +1823,9 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
ww_acquire_init(&acquire, &reservation_ww_class);
for (i = 0; i < count && err == 0; i++) {
- unsigned int flags = eb->flags[i];
- struct i915_vma *vma = eb->vma[i];
+ struct i915_vma *vma = eb->vma[i].vma;
struct drm_i915_gem_object *obj = vma->obj;
+ unsigned int flags;
err = ww_mutex_lock_interruptible(&vma->resv->lock,
&acquire);
@@ -1831,13 +1836,10 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
if (err == -EDEADLK) {
GEM_BUG_ON(i == 0);
do {
- ww_mutex_unlock(&eb->vma[i - 1]->resv->lock);
- swap(eb->flags[i], eb->flags[i - 1]);
+ ww_mutex_unlock(&eb->vma[i - 1].vma->resv->lock);
swap(eb->vma[i], eb->vma[i - 1]);
- eb->vma[i]->exec_flags = &eb->flags[i];
} while (--i);
- GEM_BUG_ON(vma != eb->vma[0]);
- vma->exec_flags = &eb->flags[0];
+ GEM_BUG_ON(vma != eb->vma[i].vma);
err = ww_mutex_lock_slow_interruptible(&vma->resv->lock,
&acquire);
@@ -1859,6 +1861,7 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
* but gcc's optimiser doesn't handle that as well and emits
* two jumps instead of one. Maybe one day...
*/
+ flags = eb->vma[i].flags;
if (unlikely(obj->cache_dirty & ~obj->cache_coherent)) {
if (i915_gem_clflush_object(obj, I915_CLFLUSH_LOCKED))
flags &= ~EXEC_OBJECT_ASYNC;
@@ -1879,9 +1882,9 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
ww_acquire_done(&acquire);
while (i--) {
- i915_vma_assert_held(eb->vma[i]);
+ i915_vma_assert_held(eb->vma[i].vma);
- if (eb->flags[i] & EXEC_OBJECT_CAPTURE) {
+ if (eb->vma[i].flags & EXEC_OBJECT_CAPTURE) {
struct i915_capture_list *capture;
capture = kmalloc(sizeof(*capture), GFP_KERNEL);
@@ -1889,15 +1892,15 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
err = -ENOMEM;
capture->next = eb->request->capture_list;
- capture->vma = eb->vma[i];
+ capture->vma = eb->vma[i].vma;
eb->request->capture_list = capture;
}
if (err == 0)
- err = i915_vma_move_to_active(eb->vma[i],
+ err = i915_vma_move_to_active(eb->vma[i].vma,
eb->request,
- eb->flags[i]);
- i915_vma_unlock(eb->vma[i]);
+ eb->vma[i].flags);
+ i915_vma_unlock(eb->vma[i].vma);
}
ww_acquire_fini(&acquire);
@@ -1992,10 +1995,9 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
if (IS_ERR(vma))
goto out;
- eb->vma[eb->buffer_count] = i915_vma_get(vma);
- eb->flags[eb->buffer_count] =
+ eb->vma[eb->buffer_count].vma = i915_vma_get(vma);
+ eb->vma[eb->buffer_count].flags =
__EXEC_OBJECT_HAS_PIN | __EXEC_OBJECT_HAS_REF;
- vma->exec_flags = &eb->flags[eb->buffer_count];
eb->buffer_count++;
out:
@@ -2274,9 +2276,8 @@ i915_gem_do_execbuffer(struct drm_device *dev,
args->flags |= __EXEC_HAS_RELOC;
eb.exec = exec;
- eb.vma = (struct i915_vma **)(exec + args->buffer_count + 1);
- eb.vma[0] = NULL;
- eb.flags = (unsigned int *)(eb.vma + args->buffer_count + 1);
+ eb.vma = (struct eb_vma *)(exec + args->buffer_count + 1);
+ eb.vma[0].vma = NULL;
eb.invalid_flags = __EXEC_OBJECT_UNKNOWN_FLAGS;
if (USES_FULL_PPGTT(eb.i915))
@@ -2352,10 +2353,6 @@ i915_gem_do_execbuffer(struct drm_device *dev,
*/
intel_runtime_pm_get(eb.i915);
- err = i915_mutex_lock_interruptible(dev);
- if (err)
- goto err_rpm;
-
err = eb_relocate(&eb);
if (err) {
/*
@@ -2369,11 +2366,6 @@ i915_gem_do_execbuffer(struct drm_device *dev,
goto err_vma;
}
- if (unlikely(*eb.batch->exec_flags & EXEC_OBJECT_WRITE)) {
- DRM_DEBUG("Attempting to use self-modifying batch buffer\n");
- err = -EINVAL;
- goto err_vma;
- }
if (eb.batch_start_offset > eb.batch->size ||
eb.batch_len > eb.batch->size - eb.batch_start_offset) {
DRM_DEBUG("Attempting to use out-of-bounds batch\n");
@@ -2438,11 +2430,15 @@ i915_gem_do_execbuffer(struct drm_device *dev,
/* All GPU relocation batches must be submitted prior to the user rq */
GEM_BUG_ON(eb.reloc_cache.rq);
+ err = i915_mutex_lock_interruptible(dev);
+ if (err)
+ goto err_batch_unpin;
+
/* Allocate a request for this batch buffer nice and early. */
eb.request = i915_request_alloc(eb.engine, eb.ctx, GFP_KERNEL);
if (IS_ERR(eb.request)) {
err = PTR_ERR(eb.request);
- goto err_batch_unpin;
+ goto err_unlock;
}
if (in_fence) {
@@ -2494,14 +2490,14 @@ i915_gem_do_execbuffer(struct drm_device *dev,
}
}
+err_unlock:
+ mutex_unlock(&dev->struct_mutex);
err_batch_unpin:
if (eb.batch_flags & I915_DISPATCH_SECURE)
i915_vma_unpin(eb.batch);
err_vma:
if (eb.exec)
eb_release_vmas(&eb);
- mutex_unlock(&dev->struct_mutex);
-err_rpm:
intel_runtime_pm_put(eb.i915);
err_engine:
i915_gem_context_put(eb.ctx);
@@ -2518,8 +2514,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
static size_t eb_element_size(void)
{
return (sizeof(struct drm_i915_gem_exec_object2) +
- sizeof(struct i915_vma *) +
- sizeof(unsigned int));
+ sizeof(struct eb_vma *));
}
static bool check_buffer_count(size_t count)
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index c6d4ae404eaa..9645297b7a2a 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -117,21 +117,10 @@ struct i915_vma {
struct rb_node obj_node;
struct hlist_node obj_hash;
- /** This vma's place in the execbuf reservation list */
- struct list_head exec_link;
- struct list_head reloc_link;
-
/** This vma's place in the eviction list */
struct list_head evict_link;
struct list_head closed_link;
-
- /**
- * Used for performing relocations during execbuffer insertion.
- */
- unsigned int *exec_flags;
- struct hlist_node exec_node;
- u32 exec_handle;
};
struct i915_vma *
--
2.18.0
More information about the Intel-gfx-trybot
mailing list