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

Commit 7d4549f6 authored by Carter Cooper's avatar Carter Cooper
Browse files

msm: kgsl: Allow users to set context priority at creation



Allow context priority to be passed in as a flag when creating
contexts. Priority is set only at context creation and cannot be
changed. Priority is used as a hint to the dispatcher when sending
commands to the GPU hardware.

Priorities are only hints. If the driver wishes, it can reject the
priority passed in. If the driver rejects the priority (if there
are too many high priorities for example), then the new context will
be created at the default priority level.

Change-Id: I12253275b7045048d59d326fbecc6446714f33a9
Signed-off-by: default avatarCarter Cooper <ccooper@codeaurora.org>
parent 537388fc
Loading
Loading
Loading
Loading
+28 −5
Original line number Original line Diff line number Diff line
@@ -278,6 +278,27 @@ void adreno_drawctxt_invalidate(struct kgsl_device *device,
	wake_up_interruptible_all(&drawctxt->wq);
	wake_up_interruptible_all(&drawctxt->wq);
}
}


/*
 * Set the priority of the context based on the flags passed into context
 * create.  If the priority is not set in the flags, then the kernel can
 * assign any priority it desires for the context.
 */
#define KGSL_CONTEXT_PRIORITY_MED	0x8

static inline void _set_context_priority(struct adreno_context *drawctxt)
{
	/* If the priority is not set by user, set it for them */
	if ((drawctxt->base.flags & KGSL_CONTEXT_PRIORITY_MASK) ==
			KGSL_CONTEXT_PRIORITY_UNDEF)
		drawctxt->base.flags |= (KGSL_CONTEXT_PRIORITY_MED <<
				KGSL_CONTEXT_PRIORITY_SHIFT);

	/* Store the context priority */
	drawctxt->base.priority =
		(drawctxt->base.flags & KGSL_CONTEXT_PRIORITY_MASK) >>
		KGSL_CONTEXT_PRIORITY_SHIFT;
}

/**
/**
 * adreno_drawctxt_create - create a new adreno draw context
 * adreno_drawctxt_create - create a new adreno draw context
 * @dev_priv: the owner of the context
 * @dev_priv: the owner of the context
@@ -313,6 +334,7 @@ adreno_drawctxt_create(struct kgsl_device_private *dev_priv,
		KGSL_CONTEXT_USER_GENERATED_TS |
		KGSL_CONTEXT_USER_GENERATED_TS |
		KGSL_CONTEXT_NO_FAULT_TOLERANCE |
		KGSL_CONTEXT_NO_FAULT_TOLERANCE |
		KGSL_CONTEXT_CTX_SWITCH |
		KGSL_CONTEXT_CTX_SWITCH |
		KGSL_CONTEXT_PRIORITY_MASK |
		KGSL_CONTEXT_TYPE_MASK);
		KGSL_CONTEXT_TYPE_MASK);


	/* Always enable per-context timestamps */
	/* Always enable per-context timestamps */
@@ -322,13 +344,14 @@ adreno_drawctxt_create(struct kgsl_device_private *dev_priv,
	init_waitqueue_head(&drawctxt->wq);
	init_waitqueue_head(&drawctxt->wq);
	init_waitqueue_head(&drawctxt->waiting);
	init_waitqueue_head(&drawctxt->waiting);


	/* Set the context priority */
	_set_context_priority(drawctxt);

	/*
	/*
	 * Set up the plist node for the dispatcher.  For now all contexts have
	 * Set up the plist node for the dispatcher.  Insert the node into the
	 * the same priority, but later the priority will be set at create time
	 * drawctxt pending list based on priority.
	 * by the user
	 */
	 */

	plist_node_init(&drawctxt->pending, drawctxt->base.priority);
	plist_node_init(&drawctxt->pending, ADRENO_CONTEXT_DEFAULT_PRIORITY);


	if (adreno_dev->gpudev->ctxt_create) {
	if (adreno_dev->gpudev->ctxt_create) {
		ret = adreno_dev->gpudev->ctxt_create(adreno_dev, drawctxt);
		ret = adreno_dev->gpudev->ctxt_create(adreno_dev, drawctxt);
+0 −2
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@ struct adreno_context_type {


#define ADRENO_CONTEXT_CMDQUEUE_SIZE 128
#define ADRENO_CONTEXT_CMDQUEUE_SIZE 128


#define ADRENO_CONTEXT_DEFAULT_PRIORITY 1

#define ADRENO_CONTEXT_STATE_ACTIVE 0
#define ADRENO_CONTEXT_STATE_ACTIVE 0
#define ADRENO_CONTEXT_STATE_INVALID 1
#define ADRENO_CONTEXT_STATE_INVALID 1


+3 −1
Original line number Original line Diff line number Diff line
@@ -146,11 +146,13 @@ DECLARE_EVENT_CLASS(adreno_drawctxt_template,
	TP_ARGS(drawctxt),
	TP_ARGS(drawctxt),
	TP_STRUCT__entry(
	TP_STRUCT__entry(
		__field(unsigned int, id)
		__field(unsigned int, id)
		__field(unsigned int, priority)
	),
	),
	TP_fast_assign(
	TP_fast_assign(
		__entry->id = drawctxt->base.id;
		__entry->id = drawctxt->base.id;
		__entry->priority = drawctxt->base.priority;
	),
	),
	TP_printk("ctx=%u", __entry->id)
	TP_printk("ctx=%u priority=%u", __entry->id, __entry->priority)
);
);


DEFINE_EVENT(adreno_drawctxt_template, adreno_drawctxt_sleep,
DEFINE_EVENT(adreno_drawctxt_template, adreno_drawctxt_sleep,
+1 −0
Original line number Original line Diff line number Diff line
@@ -382,6 +382,7 @@ struct kgsl_process_private;
struct kgsl_context {
struct kgsl_context {
	struct kref refcount;
	struct kref refcount;
	uint32_t id;
	uint32_t id;
	uint32_t priority;
	pid_t pid;
	pid_t pid;
	pid_t tid;
	pid_t tid;
	struct kgsl_device_private *dev_priv;
	struct kgsl_device_private *dev_priv;
+5 −2
Original line number Original line Diff line number Diff line
@@ -646,14 +646,17 @@ TRACE_EVENT(kgsl_context_create,
	),
	),


	TP_printk(
	TP_printk(
		"d_name=%s ctx=%u flags=0x%x %s",
		"d_name=%s ctx=%u flags=0x%x %s priority=%u",
		__get_str(device_name), __entry->id, __entry->flags,
		__get_str(device_name), __entry->id, __entry->flags,
		__entry->flags ? __print_flags(__entry->flags, "|",
		__entry->flags ? __print_flags(__entry->flags, "|",
			{ KGSL_CONTEXT_NO_GMEM_ALLOC , "NO_GMEM_ALLOC" },
			{ KGSL_CONTEXT_NO_GMEM_ALLOC , "NO_GMEM_ALLOC" },
			{ KGSL_CONTEXT_PREAMBLE, "PREAMBLE" },
			{ KGSL_CONTEXT_PREAMBLE, "PREAMBLE" },
			{ KGSL_CONTEXT_TRASH_STATE, "TRASH_STATE" },
			{ KGSL_CONTEXT_TRASH_STATE, "TRASH_STATE" },
			{ KGSL_CONTEXT_PER_CONTEXT_TS, "PER_CONTEXT_TS" })
			{ KGSL_CONTEXT_PER_CONTEXT_TS, "PER_CONTEXT_TS" })
			: "None"
			: "None",
		(__entry->flags & KGSL_CONTEXT_PRIORITY_MASK) >
			KGSL_CONTEXT_PRIORITY_SHIFT

	)
	)
);
);


Loading