msm: kgsl: Use spinlock for A6xx perfcounter updates

Add flag ADRENO_PERFCOUNTER_GROUP_RESTORE for perfcounters that
need to be restored for IFPC and preemption.
For these perfcounters
a) get spinlock
b) update the CP powerup restore list
c) update perfcounter select register
d) release spinlock.
Spinlock prevents race condition where GPU might be restoring
these registers while CPU is updating them at the same time.

Change-Id: I3d902d5cdc8c5b69a86353a944c07c9151b42654
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
diff --git a/drivers/gpu/msm/adreno_perfcounter.h b/drivers/gpu/msm/adreno_perfcounter.h
index 8c4db38..bcbc738 100644
--- a/drivers/gpu/msm/adreno_perfcounter.h
+++ b/drivers/gpu/msm/adreno_perfcounter.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2008-2015, 2017 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -70,6 +70,13 @@
 
 #define ADRENO_PERFCOUNTER_GROUP_FIXED BIT(0)
 
+/*
+ * ADRENO_PERFCOUNTER_GROUP_RESTORE indicates CP needs to restore the select
+ * registers of this perfcounter group as part of preemption and IFPC
+ */
+#define ADRENO_PERFCOUNTER_GROUP_RESTORE BIT(1)
+
+
 /**
  * adreno_perfcounts: all available perfcounter groups
  * @groups: available groups for this device