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

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

msm: kgsl: Pass event group to callback and remove wait parameter



Pass event group to the evnt callback function instead of the context.
We have ringbuffer events that do not have a context and hence it
makes more sense to pass the event group to the callback to handle
ringbuffer events which do not have a context.

Secondly, do not use a parameter when waiting for ringbuffer timestamp
since using this parameter will require synchronization between the
event and the thread waiting for the event. The parameter can only be
destroyed when the event is complete and the wait thread has
exited. This synchronization adds code complexity which can be
avoided by not using the parameter and simply checking changing the
wait condition to see if the event is present on the event list.

Change-Id: I65db1971b1c29b441003be629f89753b1d69c9d0
CRs-Fixed: 717952
Signed-off-by: default avatarShubhraprakash Das <sadas@codeaurora.org>
parent bbe9e313
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
#define KGSL_INIT_REFTIMESTAMP		0x7FFFFFFF

static void wait_callback(struct kgsl_device *device,
		struct kgsl_context *context, void *priv, int result)
		struct kgsl_event_group *group, void *priv, int result)
{
	struct adreno_context *drawctxt = priv;
	wake_up_all(&drawctxt->waiting);
@@ -322,7 +322,7 @@ void adreno_drawctxt_sched(struct kgsl_device *device,
 * Signal waiters that were waiting on the last command of this context
 */
static void adreno_drawctxt_detach_callback(struct kgsl_device *device,
			struct kgsl_context *ctx,
			struct kgsl_event_group *group,
			void *priv, int result)
{
	struct adreno_context *drawctxt = priv;
+9 −12
Original line number Diff line number Diff line
@@ -1511,7 +1511,7 @@ done:
 * @type: The event call type (RETIRED or CANCELLED)
 */
static void adreno_ringbuffer_mmu_clk_disable_event(struct kgsl_device *device,
			struct kgsl_context *context, void *data, int type)
			struct kgsl_event_group *group, void *data, int type)
{
	struct adreno_ringbuffer_mmu_disable_clk_param *param = data;
	kgsl_mmu_disable_clk(&device->mmu, param->unit);
@@ -1565,12 +1565,11 @@ adreno_ringbuffer_mmu_disable_clk_on_ts(struct kgsl_device *device,
 * @result: Result of the event trigger
 */
static void adreno_ringbuffer_wait_callback(struct kgsl_device *device,
		struct kgsl_context *context,
		struct kgsl_event_group *group,
		void *priv, int result)
{
	struct adreno_ringbuffer_wait_params *rb_wait_params = priv;
	rb_wait_params->result = result;
	wake_up_all(&(rb_wait_params->rb->ts_expire_waitq));
	struct adreno_ringbuffer *rb = group->priv;
	wake_up_all(&rb->ts_expire_waitq);
}

/**
@@ -1586,15 +1585,12 @@ int adreno_ringbuffer_waittimestamp(struct adreno_ringbuffer *rb,
	struct kgsl_device *device = rb->device;
	int ret;
	unsigned long wait_time;
	struct adreno_ringbuffer_wait_params rb_wait_params;

	/* force a timeout from caller for the wait */
	BUG_ON(0 == msecs);

	rb_wait_params.rb = rb;
	rb_wait_params.result = 0;
	ret = kgsl_add_event(device, &rb->events, timestamp,
		adreno_ringbuffer_wait_callback, (void *)&rb_wait_params);
		adreno_ringbuffer_wait_callback, NULL);
	if (ret)
		return ret;

@@ -1602,12 +1598,13 @@ int adreno_ringbuffer_waittimestamp(struct adreno_ringbuffer *rb,

	wait_time = msecs_to_jiffies(msecs);
	ret = wait_event_interruptible_timeout(rb->ts_expire_waitq,
		adreno_ringbuffer_check_wait(&rb_wait_params),
		!kgsl_event_pending(device, &rb->events, timestamp,
				adreno_ringbuffer_wait_callback, NULL),
		wait_time);
	if (0 == ret)
		ret  = -ETIMEDOUT;
	if (ret > 0)
		ret = 0;
	else if (0 == ret)
		ret  = -ETIMEDOUT;

	mutex_lock(&device->mutex);
	/*
+0 −22
Original line number Diff line number Diff line
@@ -129,18 +129,6 @@ struct adreno_ringbuffer_mmu_disable_clk_param {
	unsigned int ts;
};

/**
 * struct adreno_ringbuffer_rb_wait_params - Structure containing parameters
 * to handle the condition for a thread to wake up when it's corresponding event
 * fires.
 * @rb: The pointer to the ringbuffer on whose timestamp the thread is waiting
 * @result: The event firing result
 */
struct adreno_ringbuffer_wait_params {
	struct adreno_ringbuffer *rb;
	int result;
};

/* enable timestamp (...scratch0) memory shadowing */
#define GSL_RB_MEMPTRS_SCRATCH_MASK 0x1

@@ -227,16 +215,6 @@ static inline unsigned int adreno_ringbuffer_dec_wrapped(unsigned int val,
	return (val + size - sizeof(unsigned int)) % size;
}

/* Return true if the rb wait event has signaled */
static inline int adreno_ringbuffer_check_wait(
			struct adreno_ringbuffer_wait_params *rb_wait_params)
{
	if (KGSL_EVENT_CANCELLED == rb_wait_params->result ||
		KGSL_EVENT_RETIRED == rb_wait_params->result)
		return 1;
	return 0;
}

/* check if timestamp is greater than the current rb timestamp */
static inline int adreno_ringbuffer_check_timestamp(
			struct adreno_ringbuffer *rb,
+3 −2
Original line number Diff line number Diff line
@@ -1642,7 +1642,7 @@ static void kgsl_cmdbatch_sync_expire(struct kgsl_device *device,
 * expires
 */
static void kgsl_cmdbatch_sync_func(struct kgsl_device *device,
		struct kgsl_context *context, void *priv, int result)
		struct kgsl_event_group *group, void *priv, int result)
{
	struct kgsl_cmdbatch_sync_event *event = priv;

@@ -2387,8 +2387,9 @@ long kgsl_ioctl_cmdstream_readtimestamp_ctxtid(struct kgsl_device_private
}

static void kgsl_freemem_event_cb(struct kgsl_device *device,
		struct kgsl_context *context, void *priv, int result)
		struct kgsl_event_group *group, void *priv, int result)
{
	struct kgsl_context *context = group->context;
	struct kgsl_mem_entry *entry = priv;
	unsigned int timestamp;

+5 −1
Original line number Diff line number Diff line
@@ -194,7 +194,9 @@ struct kgsl_mem_entry {
	struct kgsl_device_private *dev_priv;
};

typedef void (*kgsl_event_func)(struct kgsl_device *, struct kgsl_context *,
struct kgsl_event_group;

typedef void (*kgsl_event_func)(struct kgsl_device *, struct kgsl_event_group *,
		void *, int);

/**
@@ -208,6 +210,7 @@ typedef void (*kgsl_event_func)(struct kgsl_device *, struct kgsl_context *,
 * @created: Jiffies when the event was created
 * @work: Work struct for dispatching the callback
 * @result: KGSL event result type to pass to the callback
 * group: The event group this event belongs to
 */
struct kgsl_event {
	struct kgsl_device *device;
@@ -219,6 +222,7 @@ struct kgsl_event {
	unsigned int created;
	struct work_struct work;
	int result;
	struct kgsl_event_group *group;
};

typedef int (*readtimestamp_func)(struct kgsl_device *, void *,
Loading