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

Commit 3fa1f137 authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Don't block on detach if the context is invalid



An invalidated context means that something pretty nasty happened and
likely there was an unrecovered GPU fault along the way. If this is
the case then the GPU is likely not processing commands for the context
anymore. Don't block for the last retired global if the context was
invalidated.

Change-Id: Ic0dedbad22a22b704baf14557d7e18cc4cf1044a
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 4cf7c581
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -159,15 +159,13 @@ static void global_wait_callback(struct kgsl_device *device, void *priv, u32 id,
}

static int _check_global_timestamp(struct kgsl_device *device,
		unsigned int timestamp)
		struct adreno_context *drawctxt, unsigned int timestamp)
{
	int ret;

	mutex_lock(&device->mutex);
	ret = kgsl_check_timestamp(device, NULL, timestamp);
	mutex_unlock(&device->mutex);
	/* Stop waiting if the context is invalidated */
	if (drawctxt->state == ADRENO_CONTEXT_STATE_INVALID)
		return 1;

	return ret;
	return kgsl_check_timestamp(device, NULL, timestamp);
}

static int adreno_drawctxt_wait_global(struct adreno_device *adreno_dev,
@@ -176,7 +174,7 @@ static int adreno_drawctxt_wait_global(struct adreno_device *adreno_dev,
{
	struct kgsl_device *device = &adreno_dev->dev;
	struct adreno_context *drawctxt = ADRENO_CONTEXT(context);
	int ret;
	int ret = 0;

	/* Needs to hold the device mutex */
	BUG_ON(!mutex_is_locked(&device->mutex));
@@ -186,6 +184,15 @@ static int adreno_drawctxt_wait_global(struct adreno_device *adreno_dev,
		goto done;
	}

	/*
	 * If the context is invalid then return immediately - we may end up
	 * waiting for a timestamp that will never come
	 */
	if (drawctxt->state == ADRENO_CONTEXT_STATE_INVALID) {
		kgsl_context_put(context);
		goto done;
	}

	trace_adreno_drawctxt_wait_start(KGSL_MEMSTORE_GLOBAL, timestamp);

	ret = kgsl_add_event(device, KGSL_MEMSTORE_GLOBAL, timestamp,
@@ -199,7 +206,7 @@ static int adreno_drawctxt_wait_global(struct adreno_device *adreno_dev,

	if (timeout) {
		ret = (int) wait_event_timeout(drawctxt->waiting,
			_check_global_timestamp(device, timestamp),
			_check_global_timestamp(device, drawctxt, timestamp),
			msecs_to_jiffies(timeout));

		if (ret == 0)
@@ -208,7 +215,7 @@ static int adreno_drawctxt_wait_global(struct adreno_device *adreno_dev,
			ret = 0;
	} else {
		wait_event(drawctxt->waiting,
			_check_global_timestamp(device, timestamp));
			_check_global_timestamp(device, drawctxt, timestamp));
	}

	mutex_lock(&device->mutex);