Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5236978 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Start returning an error from i915_vma_move_to_active()



Handling such a late error in request construction is tricky, but to
accommodate future patches which may allocate here, we potentially could
err. To handle the error after already adjusting global state to track
the new request, we must finish and submit the request. But we don't
want to use the request as not everything is being tracked by it, so we
opt to cancel the commands inside the request.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180706103947.15919-3-chris@chris-wilson.co.uk
parent 6dd7526f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -476,7 +476,11 @@ static int prepare_shadow_batch_buffer(struct intel_vgpu_workload *workload)
			i915_gem_obj_finish_shmem_access(bb->obj);
			bb->accessing = false;

			i915_vma_move_to_active(bb->vma, workload->req, 0);
			ret = i915_vma_move_to_active(bb->vma,
						      workload->req,
						      0);
			if (ret)
				goto err;
		}
	}
	return 0;
+3 −3
Original line number Diff line number Diff line
@@ -3090,7 +3090,7 @@ i915_gem_obj_finish_shmem_access(struct drm_i915_gem_object *obj)
}

int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
void i915_vma_move_to_active(struct i915_vma *vma,
int __must_check i915_vma_move_to_active(struct i915_vma *vma,
					 struct i915_request *rq,
					 unsigned int flags);
int i915_gem_dumb_create(struct drm_file *file_priv,
+18 −7
Original line number Diff line number Diff line
@@ -1165,12 +1165,16 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
		goto err_request;

	GEM_BUG_ON(!reservation_object_test_signaled_rcu(batch->resv, true));
	i915_vma_move_to_active(batch, rq, 0);
	i915_vma_unpin(batch);
	err = i915_vma_move_to_active(batch, rq, 0);
	if (err)
		goto skip_request;

	i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
	err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
	if (err)
		goto skip_request;

	rq->batch = batch;
	i915_vma_unpin(batch);

	cache->rq = rq;
	cache->rq_cmd = cmd;
@@ -1179,6 +1183,8 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
	/* Return with batch mapping (cmd) still pinned */
	return 0;

skip_request:
	i915_request_skip(rq, err);
err_request:
	i915_request_add(rq);
err_unpin:
@@ -1818,7 +1824,11 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
		unsigned int flags = eb->flags[i];
		struct i915_vma *vma = eb->vma[i];

		i915_vma_move_to_active(vma, eb->request, flags);
		err = i915_vma_move_to_active(vma, eb->request, flags);
		if (unlikely(err)) {
			i915_request_skip(eb->request, err);
			return err;
		}

		__eb_unreserve_vma(vma, flags);
		vma->exec_flags = NULL;
@@ -1877,7 +1887,7 @@ static void export_fence(struct i915_vma *vma,
	reservation_object_unlock(resv);
}

void i915_vma_move_to_active(struct i915_vma *vma,
int i915_vma_move_to_active(struct i915_vma *vma,
			    struct i915_request *rq,
			    unsigned int flags)
{
@@ -1916,6 +1926,7 @@ void i915_vma_move_to_active(struct i915_vma *vma,
		i915_gem_active_set(&vma->last_fence, rq);

	export_fence(vma, rq, flags);
	return 0;
}

static int i915_reset_gen7_sol_offsets(struct i915_request *rq)
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ int i915_gem_render_state_emit(struct i915_request *rq)
			goto err_unpin;
	}

	i915_vma_move_to_active(so.vma, rq, 0);
	err = i915_vma_move_to_active(so.vma, rq, 0);
err_unpin:
	i915_vma_unpin(so.vma);
err_vma:
+7 −2
Original line number Diff line number Diff line
@@ -985,7 +985,10 @@ static int gpu_write(struct i915_vma *vma,
		goto err_request;
	}

	i915_vma_move_to_active(batch, rq, 0);
	err = i915_vma_move_to_active(batch, rq, 0);
	if (err)
		goto err_request;

	i915_gem_object_set_active_reference(batch->obj);
	i915_vma_unpin(batch);
	i915_vma_close(batch);
@@ -996,7 +999,9 @@ static int gpu_write(struct i915_vma *vma,
	if (err)
		goto err_request;

	i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
	err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
	if (err)
		i915_request_skip(rq, err);

err_request:
	i915_request_add(rq);
Loading