msm: kgsl: Read the queued timestamp from the device

Add KGSL_TIMESTAMP_QUEUED to the list of timestamp types that can be
queried from the device specific readtimestamp. QUEUED returns the
last timestamp ID that was initiated by issuing a command buffer to
the ringbuffer.

Change-Id: Ic0dedbad780cbc9f7d4cf5cf2ffc11a7d9d2d3e5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 83f402b..bc35b86 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -1280,12 +1280,23 @@
 	unsigned int timestamp = 0;
 	unsigned int context_id = _get_context_id(context);
 
-	if (type == KGSL_TIMESTAMP_CONSUMED)
+	switch (type) {
+	case KGSL_TIMESTAMP_QUEUED: {
+		struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+		struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer;
+
+		timestamp = rb->timestamp[context_id];
+		break;
+	}
+	case KGSL_TIMESTAMP_CONSUMED:
 		adreno_regread(device, REG_CP_TIMESTAMP, &timestamp);
-	else if (type == KGSL_TIMESTAMP_RETIRED)
+		break;
+	case KGSL_TIMESTAMP_RETIRED:
 		kgsl_sharedmem_readl(&device->memstore, &timestamp,
-				 KGSL_MEMSTORE_OFFSET(context_id,
-					 eoptimestamp));
+			KGSL_MEMSTORE_OFFSET(context_id, eoptimestamp));
+		break;
+	}
+
 	rmb();
 
 	return timestamp;