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

Commit 10ae2ed6 authored by Harshdeep Dhatt's avatar Harshdeep Dhatt
Browse files

msm: kgsl: Fix drawqueue timer race condition



Update the drawqueue timer while holding the device mutex
to make sure we don't trigger the timeout incorrectly.

Change-Id: I19fbe7847b7e69c12ea903b4d3ee18b9438ccb6d
Signed-off-by: default avatarHarshdeep Dhatt <hdhatt@codeaurora.org>
parent 6cae47e2
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/wait.h>
@@ -632,6 +632,17 @@ static int sendcmd(struct adreno_device *adreno_dev,
	secs = time.ktime;
	nsecs = do_div(secs, 1000000000);

	/*
	 * For the first submission in any given command queue update the
	 * expected expire time - this won't actually be used / updated until
	 * the command queue in question goes current, but universally setting
	 * it here avoids the possibilty of some race conditions with preempt
	 */

	if (dispatch_q->inflight == 1)
		dispatch_q->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	trace_adreno_cmdbatch_submitted(drawobj, (int) dispatcher->inflight,
		time.ticks, (unsigned long) secs, nsecs / 1000, drawctxt->rb,
		adreno_get_rptr(drawctxt->rb));
@@ -644,17 +655,6 @@ static int sendcmd(struct adreno_device *adreno_dev,
	dispatch_q->tail = (dispatch_q->tail + 1) %
		ADRENO_DISPATCH_DRAWQUEUE_SIZE;

	/*
	 * For the first submission in any given command queue update the
	 * expected expire time - this won't actually be used / updated until
	 * the command queue in question goes current, but universally setting
	 * it here avoids the possibilty of some race conditions with preempt
	 */

	if (dispatch_q->inflight == 1)
		dispatch_q->expires = jiffies +
			msecs_to_jiffies(adreno_drawobj_timeout);

	/*
	 * If we believe ourselves to be current and preemption isn't a thing,
	 * then set up the timer.  If this misses, then preemption is indeed a