Tune the multi-context inflight parameter when in VR mode

Bug: 26541117

Change-Id: I0ac4c0e082ce0622bfe156147042219c5ed9e7d3
diff --git a/init.angler.rc b/init.angler.rc
index 71fd87b..a928ffd 100755
--- a/init.angler.rc
+++ b/init.angler.rc
@@ -135,7 +135,10 @@
     chown system system /sys/class/leds/red/rgb_start
 
     # GPU Tuning
-    chmod 0666 /sys/class/kgsl/kgsl-3d0/dispatch/inflight
+    chown root system /sys/class/kgsl/kgsl-3d0/dispatch/inflight
+    chmod 0660 /sys/class/kgsl/kgsl-3d0/dispatch/inflight
+    chown root system /sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency
+    chmod 0660 /sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency
 
     write /sys/block/mmcblk0/queue/rq_affinity 0
     write /sys/block/mmcblk0/queue/scheduler noop
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index f1f6671..9b6b15a 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -89,6 +89,7 @@
 /sys/devices/soc\.0/qpnp-smbcharger-[0-9a-f]+/power_supply/battery/capacity                                u:object_r:sysfs_batteryinfo:s0
 /sys/devices/soc\.0/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/max_gpuclk                                        u:object_r:sysfs_thermal:s0
 /sys/devices/soc\.0/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/dispatch/inflight                                 u:object_r:sysfs_gpu_tuning:s0
+/sys/devices/soc\.0/fdb00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/dispatch/inflight_low_latency                     u:object_r:sysfs_gpu_tuning:s0
 
 # Sysfs files used by fingerprintd
 /sys/devices/soc\.0/fpc1020\.[0-9]+(/.*)?                           u:object_r:sysfs_fingerprintd:s0
diff --git a/vr/vr.c b/vr/vr.c
index 0316a55..8857f9a 100644
--- a/vr/vr.c
+++ b/vr/vr.c
@@ -28,9 +28,14 @@
 #include <hardware/hardware.h>
 
 
-static const int DEFAULT_GPU_INFLIGHT = 15;
+// Angler has two inflight numbers. By default, inflight=15 and inflight_low_latency=4.
+// Inflight is only used when there is a single GL context, when there is more than one
+// context, inflight_low_latency is used. Since we are only interested in affecting
+// performance when there is context preemption, we only have to modify the low latency
+// parameter.
+static const int DEFAULT_GPU_INFLIGHT = 4;
 static const int VR_MODE_GPU_INFLIGHT = 2;
-static const char* GPU_INFLIGHT_PATH = "/sys/class/kgsl/kgsl-3d0/dispatch/inflight";
+static const char* GPU_INFLIGHT_PATH = "/sys/class/kgsl/kgsl-3d0/dispatch/inflight_low_latency";
 
 /**
  * Write 'len' characters from 'input' character array into file at path 'outFile.'