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

Commit 59210237 authored by Shubhraprakash Das's avatar Shubhraprakash Das
Browse files

msm: kgsl: When switching pagetable use current context ID



When we switch pagetables then the pagetable switch commands
should be executed on behalf of the current active context and
not the context to which we are switching. This is because
until the pagetable switch occurs the GPU will be using the
pagetable of the active context.

CRs-fixed: 574989
Change-Id: I9ca65ea399e39a158dc72adc2c7b661f62f18c93
Signed-off-by: default avatarShubhraprakash Das <sadas@codeaurora.org>
parent c7f4e912
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -1114,11 +1114,10 @@ static int adreno_iommu_setstate(struct kgsl_device *device,
	num_iommu_units = kgsl_mmu_get_num_iommu_units(&device->mmu);

	context = kgsl_context_get(device, context_id);
	if (context == NULL) {
		kgsl_mmu_device_setstate(&device->mmu, KGSL_CONTEXT_INVALID);
		return -EINVAL;
	if (!context) {
		kgsl_mmu_device_setstate(&device->mmu, flags);
		return 0;
	}

	adreno_ctx = ADRENO_CONTEXT(context);

	result = kgsl_mmu_enable_clk(&device->mmu, KGSL_IOMMU_CONTEXT_USER);
+12 −17
Original line number Diff line number Diff line
@@ -467,7 +467,6 @@ void adreno_drawctxt_destroy(struct kgsl_context *context)
static int adreno_context_restore(struct adreno_device *adreno_dev,
				  struct adreno_context *context)
{
	int ret;
	struct kgsl_device *device;
	unsigned int cmds[5];

@@ -475,6 +474,7 @@ static int adreno_context_restore(struct adreno_device *adreno_dev,
		return -EINVAL;

	device = &adreno_dev->dev;

	/* write the context identifier to the ringbuffer */
	cmds[0] = cp_nop_packet(1);
	cmds[1] = KGSL_CONTEXT_TO_MEM_IDENTIFIER;
@@ -482,14 +482,8 @@ static int adreno_context_restore(struct adreno_device *adreno_dev,
	cmds[3] = device->memstore.gpuaddr +
		KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL, current_context);
	cmds[4] = context->base.id;
	ret = adreno_ringbuffer_issuecmds(device, context, KGSL_CMD_FLAGS_NONE,
					cmds, 5);
	if (ret)
		return ret;

	return kgsl_mmu_setstate(&device->mmu,
			context->base.proc_priv->pagetable,
			context->base.id);
	return adreno_ringbuffer_issuecmds(device, context,
				KGSL_CMD_FLAGS_NONE, cmds, 5);
}

/**
@@ -515,17 +509,16 @@ int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
	trace_adreno_drawctxt_switch(adreno_dev->drawctxt_active,
		drawctxt, flags);

	if (adreno_dev->drawctxt_active) {
		/* Put the old instance of the active drawctxt */
		kgsl_context_put(&adreno_dev->drawctxt_active->base);
		adreno_dev->drawctxt_active = NULL;
	}

	/* Get a refcount to the new instance */
	if (drawctxt) {
		if (!_kgsl_context_get(&drawctxt->base))
			return -EINVAL;

		ret = kgsl_mmu_setstate(&device->mmu,
			drawctxt->base.proc_priv->pagetable,
			adreno_dev->drawctxt_active ?
			adreno_dev->drawctxt_active->base.id :
			KGSL_CONTEXT_INVALID);
		/* Set the new context */
		ret = adreno_context_restore(adreno_dev, drawctxt);
		if (ret) {
@@ -543,9 +536,11 @@ int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
		 */
		ret = kgsl_mmu_setstate(&device->mmu,
					 device->mmu.defaultpagetable,
					 KGSL_CONTEXT_INVALID);
					adreno_dev->drawctxt_active->base.id);
	}

	/* Put the old instance of the active drawctxt */
	if (adreno_dev->drawctxt_active)
		kgsl_context_put(&adreno_dev->drawctxt_active->base);
	adreno_dev->drawctxt_active = drawctxt;
	return 0;
}