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

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

msm: kgsl: Remove the CPU pagetable path



It turns out that we have been forcing GPU side pagetable switches for
some time. Remove the now unused CPU path which nobody liked anyway.

Change-Id: Ic0dedbadd39d9403d860ae16ce401bc94e14ddc5
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 5dfd6bc8
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-License-Identifier: GPL-2.0-only
/*
/*
 * Copyright (c) 2002,2007-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2002,2007-2019, The Linux Foundation. All rights reserved.
 */
 */


#include <linux/slab.h>
#include <linux/slab.h>
@@ -589,15 +589,13 @@ static void _drawctxt_switch_wait_callback(struct kgsl_device *device,
 * @adreno_dev - The 3D device that owns the context
 * @adreno_dev - The 3D device that owns the context
 * @rb: The ringubffer pointer on which the current context is being changed
 * @rb: The ringubffer pointer on which the current context is being changed
 * @drawctxt - the 3D context to switch to
 * @drawctxt - the 3D context to switch to
 * @flags: Control flags for the switch
 *
 *
 * Switch the current draw context in given RB
 * Switch the current draw context in given RB
 */
 */


int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
				struct adreno_ringbuffer *rb,
				struct adreno_ringbuffer *rb,
				struct adreno_context *drawctxt,
				struct adreno_context *drawctxt)
				unsigned int flags)
{
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_pagetable *new_pt;
	struct kgsl_pagetable *new_pt;
@@ -632,7 +630,8 @@ int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
		 /* No context - set the default pagetable and thats it. */
		 /* No context - set the default pagetable and thats it. */
		new_pt = device->mmu.defaultpagetable;
		new_pt = device->mmu.defaultpagetable;
	}
	}
	ret = adreno_ringbuffer_set_pt_ctx(rb, new_pt, drawctxt, flags);

	ret = adreno_iommu_set_pt_ctx(rb, new_pt, drawctxt);
	if (ret)
	if (ret)
		return ret;
		return ret;


+2 −6
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* SPDX-License-Identifier: GPL-2.0 */
/*
/*
 * Copyright (c) 2002,2007-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2002,2007-2019, The Linux Foundation. All rights reserved.
 */
 */
#ifndef __ADRENO_DRAWCTXT_H
#ifndef __ADRENO_DRAWCTXT_H
#define __ADRENO_DRAWCTXT_H
#define __ADRENO_DRAWCTXT_H
@@ -101,9 +101,6 @@ enum adreno_context_priv {
	ADRENO_CONTEXT_FENCE_LOG,
	ADRENO_CONTEXT_FENCE_LOG,
};
};


/* Flags for adreno_drawctxt_switch() */
#define ADRENO_CONTEXT_SWITCH_FORCE_GPU BIT(0)

struct kgsl_context *adreno_drawctxt_create(
struct kgsl_context *adreno_drawctxt_create(
			struct kgsl_device_private *dev_priv,
			struct kgsl_device_private *dev_priv,
			uint32_t *flags);
			uint32_t *flags);
@@ -118,8 +115,7 @@ void adreno_drawctxt_sched(struct kgsl_device *device,
struct adreno_ringbuffer;
struct adreno_ringbuffer;
int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
int adreno_drawctxt_switch(struct adreno_device *adreno_dev,
				struct adreno_ringbuffer *rb,
				struct adreno_ringbuffer *rb,
				struct adreno_context *drawctxt,
				struct adreno_context *drawctxt);
				unsigned int flags);


int adreno_drawctxt_wait(struct adreno_device *adreno_dev,
int adreno_drawctxt_wait(struct adreno_device *adreno_dev,
		struct kgsl_context *context,
		struct kgsl_context *context,
+11 −142
Original line number Original line Diff line number Diff line
@@ -43,9 +43,6 @@ static unsigned int _wait_reg(struct adreno_device *adreno_dev,
	return cmds - start;
	return cmds - start;
}
}


#define KGSL_MMU(_dev) \
	((struct kgsl_mmu *) (&(KGSL_DEVICE((_dev))->mmu)))

static unsigned int _vbif_lock(struct adreno_device *adreno_dev,
static unsigned int _vbif_lock(struct adreno_device *adreno_dev,
			unsigned int *cmds)
			unsigned int *cmds)
{
{
@@ -148,60 +145,6 @@ static inline int _adreno_iommu_add_idle_cmds(struct adreno_device *adreno_dev,
	return cmds - start;
	return cmds - start;
}
}


/*
 * _invalidate_uche_cpu() - Invalidate UCHE using CPU
 * @adreno_dev: the device
 */
static void _invalidate_uche_cpu(struct adreno_device *adreno_dev)
{
	/* Invalidate UCHE using CPU */
	if (adreno_is_a5xx(adreno_dev))
		adreno_writereg(adreno_dev,
			ADRENO_REG_UCHE_INVALIDATE0, 0x12);
	else if (adreno_is_a3xx(adreno_dev)) {
		adreno_writereg(adreno_dev,
			ADRENO_REG_UCHE_INVALIDATE0, 0);
		adreno_writereg(adreno_dev,
			ADRENO_REG_UCHE_INVALIDATE1,
			0x90000000);
	} else {
		WARN_ONCE(1, "GPU UCHE invalidate sequence not defined\n");
	}
}

/*
 * _ctx_switch_use_cpu_path() - Decide whether to use cpu path
 * @adreno_dev: the device
 * @new_pt: pagetable to switch
 * @rb: ringbuffer for ctx switch
 *
 * If we are idle and switching to default pagetable it is
 * preferable to poke the iommu directly rather than using the
 * GPU command stream.
 */
static bool _ctx_switch_use_cpu_path(
				struct adreno_device *adreno_dev,
				struct kgsl_pagetable *new_pt,
				struct adreno_ringbuffer *rb)
{
	struct kgsl_mmu *mmu = KGSL_MMU(adreno_dev);

	/*
	 * If rb is current, we can use cpu path when GPU is
	 * idle and we are switching to default pt.
	 * If rb is not current, we can use cpu path when rb has no
	 * pending commands (rptr = wptr) and we are switching to default pt.
	 */
	if (adreno_dev->cur_rb == rb)
		return adreno_isidle(KGSL_DEVICE(adreno_dev)) &&
			(new_pt == mmu->defaultpagetable);
	else if (adreno_rb_empty(rb) &&
			(new_pt == mmu->defaultpagetable))
		return true;

	return false;
}

/**
/**
 * adreno_iommu_set_apriv() - Generate commands to set/reset the APRIV
 * adreno_iommu_set_apriv() - Generate commands to set/reset the APRIV
 * @adreno_dev: Device on which the commands will execute
 * @adreno_dev: Device on which the commands will execute
@@ -443,31 +386,6 @@ static unsigned int __add_curr_ctxt_cmds(struct adreno_ringbuffer *rb,
	return cmds - cmds_orig;
	return cmds - cmds_orig;
}
}


/*
 * _set_ctxt_cpu() - Set the current context in memstore
 * @rb: The ringbuffer memstore to set curr context
 * @drawctxt: The context whose id is being set in memstore
 */
static void _set_ctxt_cpu(struct adreno_ringbuffer *rb,
			struct adreno_context *drawctxt)
{
	struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);

	if (rb == adreno_dev->cur_rb) {
		_invalidate_uche_cpu(adreno_dev);
		/* Update global memstore with current context */
		kgsl_sharedmem_writel(device, &device->memstore,
			KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
						current_context),
			drawctxt ? drawctxt->base.id : 0);
	}
	/* Update rb memstore with current context */
	kgsl_sharedmem_writel(device, &device->memstore,
		MEMSTORE_RB_OFFSET(rb, current_context),
		drawctxt ? drawctxt->base.id : 0);
}

/**
/**
 * _set_ctxt_gpu() - Add commands to set the current context in memstore
 * _set_ctxt_gpu() - Add commands to set the current context in memstore
 * @rb: The ringbuffer in which commands to set memstore are added
 * @rb: The ringbuffer in which commands to set memstore are added
@@ -486,33 +404,6 @@ static int _set_ctxt_gpu(struct adreno_ringbuffer *rb,
	return result;
	return result;
}
}


/**
 * _set_pagetable_cpu() - Use CPU to switch the pagetable
 * @rb: The rb for which pagetable needs to be switched
 * @new_pt: The pagetable to switch to
 */
static int _set_pagetable_cpu(struct adreno_ringbuffer *rb,
			struct kgsl_pagetable *new_pt)
{
	struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int result;

	/* update TTBR0 only if we are updating current RB */
	if (adreno_dev->cur_rb == rb) {
		result = kgsl_mmu_set_pt(&device->mmu, new_pt);
		if (result)
			return result;
		/* write the new pt set to memory var */
		adreno_ringbuffer_set_global(adreno_dev, new_pt->name);
	}

	/* Update the RB pagetable info here */
	adreno_ringbuffer_set_pagetable(rb, new_pt);

	return 0;
}

/**
/**
 * _set_pagetable_gpu() - Use GPU to switch the pagetable
 * _set_pagetable_gpu() - Use GPU to switch the pagetable
 * @rb: The rb in which commands to switch pagetable are to be
 * @rb: The rb in which commands to switch pagetable are to be
@@ -590,48 +481,26 @@ void adreno_iommu_init(struct adreno_device *adreno_dev)
 */
 */
int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
			struct kgsl_pagetable *new_pt,
			struct kgsl_pagetable *new_pt,
			struct adreno_context *drawctxt,
			struct adreno_context *drawctxt)
			unsigned long flags)
{
{
	struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
	struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct kgsl_pagetable *cur_pt = device->mmu.defaultpagetable;
	struct kgsl_pagetable *cur_pt = device->mmu.defaultpagetable;
	int result = 0;
	int result = 0;
	int cpu_path = 0;

	/* Just do the context switch incase of NOMMU */
	if (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_NONE) {
		if ((!(flags & ADRENO_CONTEXT_SWITCH_FORCE_GPU)) &&
			adreno_isidle(device) && !adreno_is_a6xx(adreno_dev))
			_set_ctxt_cpu(rb, drawctxt);
		else
			result = _set_ctxt_gpu(rb, drawctxt);

		return result;
	}


	/* Switch the page table if a MMU is attached */
	if (kgsl_mmu_get_mmutype(device) != KGSL_MMU_TYPE_NONE) {
		if (rb->drawctxt_active)
		if (rb->drawctxt_active)
			cur_pt = rb->drawctxt_active->base.proc_priv->pagetable;
			cur_pt = rb->drawctxt_active->base.proc_priv->pagetable;


	cpu_path = !(flags & ADRENO_CONTEXT_SWITCH_FORCE_GPU) &&
		_ctx_switch_use_cpu_path(adreno_dev, new_pt, rb);

		/* Pagetable switch */
		/* Pagetable switch */
	if (new_pt != cur_pt) {
		if (new_pt != cur_pt)
		if (cpu_path)
			result = _set_pagetable_cpu(rb, new_pt);
		else
			result = _set_pagetable_gpu(rb, new_pt);
			result = _set_pagetable_gpu(rb, new_pt);
	}


		if (result)
		if (result)
			return result;
			return result;
	}


	/* Context switch */
	/* Context switch */
	if (cpu_path && !adreno_is_a6xx(adreno_dev))
	return _set_ctxt_gpu(rb, drawctxt);
		_set_ctxt_cpu(rb, drawctxt);
	else
		result = _set_ctxt_gpu(rb, drawctxt);

	return result;
}
}
+2 −4
Original line number Original line Diff line number Diff line
@@ -9,8 +9,7 @@
#ifdef CONFIG_QCOM_KGSL_IOMMU
#ifdef CONFIG_QCOM_KGSL_IOMMU
int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
			struct kgsl_pagetable *new_pt,
			struct kgsl_pagetable *new_pt,
			struct adreno_context *drawctxt,
			struct adreno_context *drawctxt);
			unsigned long flags);


void adreno_iommu_init(struct adreno_device *adreno_dev);
void adreno_iommu_init(struct adreno_device *adreno_dev);


@@ -23,8 +22,7 @@ static inline void adreno_iommu_init(struct adreno_device *adreno_dev) { }


static inline int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
static inline int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
			struct kgsl_pagetable *new_pt,
			struct kgsl_pagetable *new_pt,
			struct adreno_context *drawctxt,
			struct adreno_context *drawctxt)
			unsigned long flags)
{
{
	return 0;
	return 0;
}
}
+1 −2
Original line number Original line Diff line number Diff line
@@ -1019,8 +1019,7 @@ int adreno_ringbuffer_submitcmd(struct adreno_device *adreno_dev,
	cmds += cp_identifier(adreno_dev, cmds, END_IB_IDENTIFIER);
	cmds += cp_identifier(adreno_dev, cmds, END_IB_IDENTIFIER);


	/* Context switches commands should *always* be on the GPU */
	/* Context switches commands should *always* be on the GPU */
	ret = adreno_drawctxt_switch(adreno_dev, rb, drawctxt,
	ret = adreno_drawctxt_switch(adreno_dev, rb, drawctxt);
		ADRENO_CONTEXT_SWITCH_FORCE_GPU);


	/*
	/*
	 * In the unlikely event of an error in the drawctxt switch,
	 * In the unlikely event of an error in the drawctxt switch,
Loading