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

Commit 29c611cc authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Add kgsl_flush_event_group()



Add kgsl_flush_event_group() to deal with all the pending events in a
context.  Events with a retired timestamp are retired and still
pending events are canceled. This is intended for situations when
the context or event group is going away or will otherwise be
inoperable.

Change-Id: Ic0dedbadb308f95e4bf9097e8553e30d3ec2bdd4
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent d52c796d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -264,8 +264,8 @@ void adreno_drawctxt_invalidate(struct kgsl_device *device,

	spin_unlock(&drawctxt->lock);

	/* Make sure all "retired" events are processed */
	kgsl_process_event_group(device, &context->events);
	/* Make sure all pending events are processed or cancelled */
	kgsl_flush_event_group(device, &context->events);

	/* Give the bad news to everybody waiting around */
	wake_up_all(&drawctxt->waiting);
+2 −1
Original line number Diff line number Diff line
@@ -703,7 +703,8 @@ int kgsl_add_event(struct kgsl_device *device, struct kgsl_event_group *group,
		unsigned int timestamp, kgsl_event_func func, void *priv);
void kgsl_process_event_group(struct kgsl_device *device,
	struct kgsl_event_group *group);

void kgsl_flush_event_group(struct kgsl_device *device,
		struct kgsl_event_group *group);
void kgsl_process_events(struct work_struct *work);

void kgsl_context_destroy(struct kref *kref);
+32 −9
Original line number Diff line number Diff line
@@ -56,13 +56,8 @@ static void _kgsl_event_worker(struct work_struct *work)
	kmem_cache_free(events_cache, event);
}

/**
 * retire_events() - Handle all the retired events in a group
 * @device: Pointer to a KGSL device
 * @group: Pointer to a GPU events group to process
 */
void kgsl_process_event_group(struct kgsl_device *device,
		struct kgsl_event_group *group)
static void _process_event_group(struct kgsl_device *device,
		struct kgsl_event_group *group, bool flush)
{
	struct kgsl_event *event, *tmp;
	unsigned int timestamp;
@@ -84,12 +79,15 @@ void kgsl_process_event_group(struct kgsl_device *device,
	 * If no timestamps have been retired since the last time we were here
	 * then we can avoid going through this loop
	 */
	if (timestamp_cmp(timestamp, group->processed) <= 0)
	if (!flush && timestamp_cmp(timestamp, group->processed) <= 0)
		goto out;

	list_for_each_entry_safe(event, tmp, &group->events, node) {
		if (timestamp_cmp(event->timestamp, timestamp) <= 0)
			signal_event(device, event, KGSL_EVENT_RETIRED);
		else if (flush)
			signal_event(device, event, KGSL_EVENT_CANCELLED);

	}

	group->processed = timestamp;
@@ -98,8 +96,33 @@ out:
	spin_unlock(&group->lock);
	kgsl_context_put(context);
}

/**
 * kgsl_process_event_group() - Handle all the retired events in a group
 * @device: Pointer to a KGSL device
 * @group: Pointer to a GPU events group to process
 */

void kgsl_process_event_group(struct kgsl_device *device,
		struct kgsl_event_group *group)
{
	_process_event_group(device, group, false);
}
EXPORT_SYMBOL(kgsl_process_event_group);

/**
 * kgsl_flush_event_group() - flush all the events in a group by retiring the
 * ones can be retired and cancelling the ones that are pending
 * @device: Pointer to a KGSL device
 * @group: Pointer to a GPU events group to process
 */
void kgsl_flush_event_group(struct kgsl_device *device,
		struct kgsl_event_group *group)
{
	_process_event_group(device, group, true);
}
EXPORT_SYMBOL(kgsl_flush_event_group);

/**
 * kgsl_cancel_events_timestamp() - Cancel pending events for a given timestamp
 * @device: Pointer to a KGSL device
@@ -282,7 +305,7 @@ void kgsl_process_events(struct work_struct *work)

	read_lock(&group_lock);
	list_for_each_entry(group, &group_list, group)
		kgsl_process_event_group(device, group);
		_process_event_group(device, group, false);
	read_unlock(&group_lock);
}
EXPORT_SYMBOL(kgsl_process_events);