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

Commit fef1dd5a authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Fix context refcounting for adreno debugfs



The code is currently using a device ID look up for the context ID. This
is presumably because there was a refcounting race when looking at the
the debugfs file while the context was being destroyed.  Instead of
trying to be clever, just take a reference count on the context when the
debugfs file is created and release it when the context is detached. This
may cause the context to stick around a bit longer, but it sure is cleaner.

Change-Id: Ic0dedbad3f30168e74d03eade59218f82b93bee4
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 2726e792
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -312,16 +312,14 @@ static int ctx_print(struct seq_file *s, void *unused)
static int ctx_open(struct inode *inode, struct file *file)
{
	int ret;
	unsigned int id = (unsigned int)(unsigned long)inode->i_private;
	struct kgsl_context *context;
	struct adreno_context *ctx = inode->i_private;

	context = kgsl_context_get(kgsl_get_device(KGSL_DEVICE_3D0), id);
	if (context == NULL)
	if (!_kgsl_context_get(&ctx->base))
		return -ENODEV;

	ret = single_open(file, ctx_print, context);
	ret = single_open(file, ctx_print, &ctx->base);
	if (ret)
		kgsl_context_put(context);
		kgsl_context_put(&ctx->base);
	return ret;
}

@@ -350,11 +348,16 @@ adreno_context_debugfs_init(struct adreno_device *adreno_dev,
{
	unsigned char name[16];

	/*
	 * Get the context here to make sure it still exists for the life of the
	 * file
	 */
	_kgsl_context_get(&ctx->base);

	snprintf(name, sizeof(name), "%d", ctx->base.id);

	ctx->debug_root = debugfs_create_file(name, 0444,
				adreno_dev->ctx_d_debugfs,
				(void *)(unsigned long)ctx->base.id, &ctx_fops);
				adreno_dev->ctx_d_debugfs, ctx, &ctx_fops);
}

void adreno_debugfs_init(struct adreno_device *adreno_dev)
+2 −0
Original line number Diff line number Diff line
@@ -478,6 +478,8 @@ void adreno_drawctxt_detach(struct kgsl_context *context)
	}

	debugfs_remove_recursive(drawctxt->debug_root);
	/* The debugfs file has a reference, release it */
	kgsl_context_put(context);

	/*
	 * internal_timestamp is set in adreno_ringbuffer_addcmds,