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

Commit 0cd94578 authored by Lynus Vaz's avatar Lynus Vaz Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Free A6x per-context preemption buffer at detach time



preemption_context_destroy() will try to take the iommu mutex when
unmapping the buffer. Since the context can be destroyed from atomic
context for example, fence callbacks, taking the mutex will lead to a
kernel panic. Move the function from context destroy to context
detach. Detached contexts can no longer submit cmdbatches, so the
buffer can be safely released at this point after waiting for all
context cmdbatches already in flight to retire.

Change-Id: Ic48fa4638336a93e78e037bfc331037d611b40a3
Signed-off-by: default avatarLynus Vaz <lvaz@codeaurora.org>
parent 67c0cad6
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
/* Copyright (c) 2002,2007-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2002,2007-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -472,6 +472,7 @@ void adreno_drawctxt_detach(struct kgsl_context *context)
{
	struct kgsl_device *device;
	struct adreno_device *adreno_dev;
	struct adreno_gpudev *gpudev;
	struct adreno_context *drawctxt;
	struct adreno_ringbuffer *rb;
	int ret, count, i;
@@ -482,6 +483,7 @@ void adreno_drawctxt_detach(struct kgsl_context *context)

	device = context->device;
	adreno_dev = ADRENO_DEVICE(device);
	gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	drawctxt = ADRENO_CONTEXT(context);
	rb = drawctxt->rb;

@@ -562,6 +564,9 @@ void adreno_drawctxt_detach(struct kgsl_context *context)

	mutex_unlock(&device->mutex);

	if (gpudev->preemption_context_destroy)
		gpudev->preemption_context_destroy(context);

	/* wake threads waiting to submit commands from this context */
	wake_up_all(&drawctxt->waiting);
	wake_up_all(&drawctxt->wq);
@@ -570,18 +575,10 @@ void adreno_drawctxt_detach(struct kgsl_context *context)
void adreno_drawctxt_destroy(struct kgsl_context *context)
{
	struct adreno_context *drawctxt;
	struct adreno_device *adreno_dev;
	struct adreno_gpudev *gpudev;

	if (context == NULL)
		return;

	adreno_dev = ADRENO_DEVICE(context->device);
	gpudev = ADRENO_GPU_DEVICE(adreno_dev);

	if (gpudev->preemption_context_destroy)
		gpudev->preemption_context_destroy(context);

	drawctxt = ADRENO_CONTEXT(context);
	kfree(drawctxt);
}