[Intel-gfx] [PATCH i-g-t] Idleness DRRS:

2017-11-10 Thread Lohith BS
By default the DRRS state will be at DRRS_HIGH_RR. When a Display
content is Idle for more than 1Sec Idleness will be declared and
DRRS_LOW_RR will be invoked, changing the refresh rate to the
lower most refresh rate supported by the panel. As soon as there
is a display content change there will be a DRRS state transition
as DRRS_LOW_RR--> DRRS_HIGH_RR, changing the refresh rate to the
highest refresh rate supported by the panel.

To test this, Idleness DRRS IGT will probe the DRRS state at below
instances and compare with the expected state.

InstanceExpected State
1. Immediately after rendering the still image  DRRS_HIGH_RR
2. After a delay of 1.2Sec  DRRS_LOW_RR
3. After changing the frame buffer  DRRS_HIGH_RR
4. After a delay of 1.2Sec  DRRS_LOW_RR
5. After changing the frame buffer  DRRS_HIGH_RR
6. After a delay of 1.2Sec  DRRS_LOW_RR

The test checks the driver DRRS state from the debugfs entry. To check the
actual refresh-rate, the number of vblanks received per sec.
The refresh-rate calculated is checked against the expected refresh-rate
with a tolerance value of 2.

This patch is a continuation of the earlier work
https://patchwork.freedesktop.org/patch/45472/ towards igt for idleness

DRRS. The code is tested on Broxton BXT_T platform.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence, provided by
drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the kms_frontbuffer_tracking 
IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable the DRRS
   feature dynamically(as in case of PSR). Hence if the panel supports
   DRRS it will be enabled by default.

This is in continuation of last patch 
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS 
through debugfs entry
"i915_drrs_ctl".

Signed-off-by: Lohith BS 
Signed-off-by: Ramalingam C 
Signed-off-by: Vandana Kannan 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 166 +++
 1 file changed, 151 insertions(+), 15 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index a068c8a..b06d304 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+   "its related features: FBC, DRRS and PSR");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 6,
+   FEATURE_DEFAULT = 6,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -178,10 +180,8 @@ struct {
 
 struct {
bool can_test;
-} psr = {
-   .can_test = false,
-};
-
+} psr = { .can_test = false,},
+drrs = { .can_test = false,};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -775,8 +775,8 @@ static bool set_mode_for_params(struct modeset_params 
*params)
int rc;
 
rc = drmModeSetCrtc(drm.fd, params->crtc_id, params->fb.fb->fb_id,
-   params->fb.x, params->fb.y,
-   ¶ms->connector_id, 1, params->mode);
+   params->

[Intel-gfx] [PATCH i-g-t v11] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2018-01-03 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

v10: Corrected DRRS state expectation in suspend related subtests.

v11: Removing the global flag is_psr_drrs_combo [Rodrigo].

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 184 +--
 1 file changed, 175 insertions(+), 9 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1601cab..7876a12 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -182,6 +184,13 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+} drrs = {
+   .can_test = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -825,6 +834,64 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   igt_assert_eq(write(drm.drrs_debugfs_fd,
+ buf, strlen(buf)), strlen(buf));
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+
+   if (strstr(buf, "No active crtc found"))
+ 

[Intel-gfx] [PATCH i-g-t v12] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2018-01-05 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

v10: Corrected DRRS state expectation in suspend related subtests.

v11: Removing the global flag is_psr_drrs_combo [Rodrigo].

v12: Rewriting the DRRS inactive deduction [Rodrigo].

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 178 +--
 1 file changed, 170 insertions(+), 8 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1601cab..4b87273 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -182,6 +184,13 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+} drrs = {
+   .can_test = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -825,6 +834,60 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   igt_assert_eq(write(drm.drrs_debugfs_fd,
+ buf, strlen(buf)), strlen(buf));
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+
+   if (strstr(

[Intel-gfx] [PATCH i-g-t v13] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2018-01-10 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

v10: Corrected DRRS state expectation in suspend related subtests.

v11: Removing the global flag is_psr_drrs_combo [Rodrigo].

v12: Rewriting the DRRS inactive deduction [Rodrigo].

v13: En/Dis-able DRRS only when DRRS is capable on the setup.

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 172 +--
 1 file changed, 164 insertions(+), 8 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1601cab..6b2299b 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -182,6 +183,13 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+} drrs = {
+   .can_test = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -790,7 +798,14 @@ static void __debugfs_read(const char *param, char *buf, 
int len)
buf[len] = '\0';
 }
 
+static void __debugfs_write(const char *param, char *buf, int len)
+{
+   igt_assert_eq(igt_sysfs_write(drm.debugfs, param, buf, len - 1),
+ len - 1);
+}
+
 #define debugfs_read(p, arr) __debugfs_read(p, arr, sizeof(arr))
+#define debugfs_write(p, arr) __debugfs_write(p, arr, sizeof(arr))
 
 static bool fbc_is_enabled(void)
 {
@@ -825,6 +840,62 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+
+   if (!drrs.can_test)
+   return;
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   debugfs_write("i915_drrs_ctl", buf);
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+  

[Intel-gfx] [PATCH i-g-t v14] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2018-01-30 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

v10: Corrected DRRS state expectation in suspend related subtests.

v11: Removing the global flag is_psr_drrs_combo [Rodrigo].

v12: Rewriting the DRRS inactive deduction [Rodrigo].

v13: En/Dis-able DRRS only when DRRS is capable on the setup.

v14: Handle the error states of drrs_enable only [Rodrigo].

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 177 +--
 1 file changed, 169 insertions(+), 8 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1601cab..046f16a 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -182,6 +183,13 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+} drrs = {
+   .can_test = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -790,7 +798,13 @@ static void __debugfs_read(const char *param, char *buf, 
int len)
buf[len] = '\0';
 }
 
+static int __debugfs_write(const char *param, char *buf, int len)
+{
+   return igt_sysfs_write(drm.debugfs, param, buf, len - 1);
+}
+
 #define debugfs_read(p, arr) __debugfs_read(p, arr, sizeof(arr))
+#define debugfs_write(p, arr) __debugfs_write(p, arr, sizeof(arr))
 
 static bool fbc_is_enabled(void)
 {
@@ -825,6 +839,68 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+   int ret;
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   ret = debugfs_write("i915_drrs_ctl", buf);
+
+   /*
+* drrs_enable() is called on DRRS capable platform only,
+* whereas drrs_disable() is called on all platforms.
+* So handle the failure of debugfs_write only for drrs_enable().
+*/
+   if (val)
+   igt_assert_f(ret == (sizeof(buf) - 1), "debugfs_write failed");
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read(&quo

[Intel-gfx] [PATCH i-g-t v8] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2017-12-06 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 166 +++
 1 file changed, 151 insertions(+), 15 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index a068c8a..b06d304 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+   "its related features: FBC, DRRS and PSR");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 6,
+   FEATURE_DEFAULT = 6,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -178,10 +180,8 @@ struct {
 
 struct {
bool can_test;
-} psr = {
-   .can_test = false,
-};
-
+} psr = { .can_test = false,},
+drrs = { .can_test = false,};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -775,8 +775,8 @@ static bool set_mode_for_params(struct modeset_params 
*params)
int rc;
 
rc = drmModeSetCrtc(drm.fd, params->crtc_id, params->fb.fb->fb_id,
-   params->fb.x, params->fb.y,
-   ¶ms->connector_id, 1, params->mode);
+   params->fb.x, params->fb.y,
+   ¶ms->connector_id, 1, params->mode);
return (rc == 0);
 }
 
@@ -822,6 +822,63 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[16];
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   igt_assert_eq(write(drm.drrs_debugfs_fd, buf, strlen(buf)), 
strlen(buf));
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(v

[Intel-gfx] [PATCH i-g-t v9] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2017-12-11 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 183 +--
 1 file changed, 176 insertions(+), 7 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index a068c8a..19e38cb 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -182,6 +184,15 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+   bool is_psr_drrs_combo;
+} drrs = {
+   .can_test = false,
+   .is_psr_drrs_combo = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -822,6 +833,64 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   igt_assert_eq(write(drm.drrs_debugfs_fd,
+ buf, strlen(buf)), strlen(buf));
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+
+   if (strstr(buf, "No active crtc found"))
+   return true;
+   if (strstr(buf, "Idleness DRRS:

[Intel-gfx] [PATCH i-g-t v10] tests/kms_frontbuffer_tracking: Including DRRS test coverage

2018-01-01 Thread Lohith BS
Dynamic Refresh Rate Switch(DRRS) is used to switch the panel's
refresh rate to the lowest vrefresh supported by panel, when frame is
not flipped for more than a Sec.

In kernel, DRRS uses the front buffer tracking infrastructure.
Hence DRRS test coverage is added along with other frontbuffer tracking
based features such as FBC and PSR tests.

Here, we are testing DRRS with other features in all possible
combinations, in all required test cases, to capture any possible
regression.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence,
provided by drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the
kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable
   the DRRS feature dynamically(as in case of PSR). Hence if the
   panel supports DRRS it will be enabled by default.

This is in continuation of last patch
"https://patchwork.freedesktop.org/patch/162726/";

v6: This patch adds runtime enable and disable feature for testing DRRS

v7: This patch adds runtime enable and disable feature for testing DRRS
through debugfs entry "i915_drrs_ctl".

v8: Commit message is updated to reflect current implementation.

v9: Addressed Paulo Zanoni comments.
Check for DRRS_LOW at tests with OFFSCREEN + FBS_INDIVIDUAL.

v10: Corrected DRRS state expectation in suspend related subtests.

Signed-off-by: Lohith BS 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 188 +--
 1 file changed, 179 insertions(+), 9 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 1601cab..1039c9e 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC, PSR and DRRS");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 8,
+   FEATURE_DEFAULT = 8,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -156,6 +157,7 @@ struct rect {
 struct {
int fd;
int debugfs;
+   int drrs_debugfs_fd;
drmModeResPtr res;
drmModeConnectorPtr connectors[MAX_CONNECTORS];
drmModeEncoderPtr encoders[MAX_ENCODERS];
@@ -182,6 +184,15 @@ struct {
.can_test = false,
 };
 
+#define MAX_DRRS_STATUS_BUF_LEN 256
+
+struct {
+   bool can_test;
+   bool is_psr_drrs_combo;
+} drrs = {
+   .can_test = false,
+   .is_psr_drrs_combo = false,
+};
 
 #define SINK_CRC_SIZE 12
 typedef struct {
@@ -825,6 +836,64 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+void drrs_set(unsigned int val)
+{
+   char buf[2];
+
+   igt_debug("Manually %sabling DRRS. %llu\n", val ? "en" : "dis", val);
+   snprintf(buf, sizeof(buf), "%d", val);
+   igt_assert_eq(write(drm.drrs_debugfs_fd,
+ buf, strlen(buf)), strlen(buf));
+}
+
+static bool is_drrs_high(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_supported(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(void)
+{
+   char buf[MAX_DRRS_STATUS_BUF_LEN];
+
+   debugfs_read("i915_drrs_status", buf);
+
+   if (strstr(buf, "No active crtc foun

[Intel-gfx] [PATCH] edp-DRRS test

2017-06-21 Thread Lohith BS
Idleness DRRS:
By default the DRRS state will be at DRRS_HIGH_RR. When a Display
content is Idle for more than 1Sec Idleness will be declared and
DRRS_LOW_RR will be invoked, changing the refresh rate to the
lower most refresh rate supported by the panel. As soon as there
is a display content change there will be a DRRS state transition
as DRRS_LOW_RR--> DRRS_HIGH_RR, changing the refresh rate to the
highest refresh rate supported by the panel.

To test this, Idleness DRRS IGT will probe the DRRS state at below
instances and compare with the expected state.

InstanceExpected State
1. Immediately after rendering the still image  DRRS_HIGH_RR
2. After a delay of 1.2Sec  DRRS_LOW_RR
3. After changing the frame buffer  DRRS_HIGH_RR
4. After a delay of 1.2Sec  DRRS_LOW_RR
5. After changing the frame buffer  DRRS_HIGH_RR
6. After a delay of 1.2Sec  DRRS_LOW_RR

The test checks the driver DRRS state from the debugfs entry. To check the
actual refresh-rate, the number of vblanks received per sec.
The refresh-rate calculated is checked against the expected refresh-rate
with a tolerance value of 2.

This patch is a continuation of the earlier work
https://patchwork.freedesktop.org/patch/45472/ towards igt for idleness

DRRS. The code is tested on Broxton BXT_T platform.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence, provided by
drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

This is in continuation of last patch 
"https://patchwork.freedesktop.org/patch/117149/";

Signed-off-by: Lohith BS 
Signed-off-by: Ramalingam C 
Signed-off-by: Vandana Kannan 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 453 ++-
 1 file changed, 452 insertions(+), 1 deletion(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index c24e4a8..4d46e1e 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -32,9 +32,18 @@
 #include 
 #include 
 
+#include "drmtest.h"
+#include "igt_debugfs.h"
+#include "igt_kms.h"
+#include "intel_chipset.h"
+#include "intel_batchbuffer.h"
+#include "ioctl_wrappers.h"
+#include 
+#include 
+#include 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: DRRS, FBC and PSR");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -327,6 +336,41 @@ drmModeModeInfo std_1024_mode = {
.name = "Custom 1024x768",
 };
 
+#define DRRS_TOLERANCE_THRESHOLD 2
+#define DRRS_POLL_TIMEOUT_PERIOD_MS 5000
+#define DRRS_STATUS_BYTES_CNT 1000
+#define DRRS_MAX_ITERATION 3
+
+/*
+ * Struct to hold drrs test related data
+ */
+typedef struct {
+   uint32_t devid;
+   uint32_t handle[2];
+   igt_display_t display;
+   igt_output_t *output;
+   enum pipe pipe;
+   igt_plane_t *primary;
+   struct igt_fb fb[2];
+   uint32_t fb_id[2];
+} drrs_data_t;
+
+/*
+ * Structure to count vblank and note the starting time of the counter
+ */
+typedef struct {
+   unsigned int vbl_count;
+   struct timeval start;
+} vbl_info;
+
+/*
+ * Structure for refresh rate type
+ */
+typedef struct{
+   int rate;
+   const char *name;
+} refresh_rate_t;
+
 static drmModeModeInfoPtr get_connector_smallest_mode(drmModeConnectorPtr c)
 {
int i;
@@ -3415,6 +3459,410 @@ static const char *flip_str(enum flip_type flip)
 
 #define TEST_MODE_ITER_END } } } } } }
 
+static inline uint32_t pipe_select(int pipe)
+{
+   if (pipe > 1)
+   return pipe << DRM_VBLANK_HIGH_CRTC_SHIFT;
+   else if (pipe > 0)
+   return DRM_VBLANK_SECONDARY;
+   else
+   return DRM_VBLANK_ABSOLUTE;
+}
+
+/*
+ * Calculates the total no. of millisec elapsed since timeval start
+ */
+static double igt_millisec_elapsed(const struct timeval *start)
+{
+   struct timeval curr;
+
+   gettimeofday(&curr, NULL);
+   return (1e3*(curr.tv_sec - start->tv_sec) +
+

[Intel-gfx] [PATCH] Idleness DRRS:

2017-09-18 Thread Lohith BS
By default the DRRS state will be at DRRS_HIGH_RR. When a Display
content is Idle for more than 1Sec Idleness will be declared and
DRRS_LOW_RR will be invoked, changing the refresh rate to the
lower most refresh rate supported by the panel. As soon as there
is a display content change there will be a DRRS state transition
as DRRS_LOW_RR--> DRRS_HIGH_RR, changing the refresh rate to the
highest refresh rate supported by the panel.

To test this, Idleness DRRS IGT will probe the DRRS state at below
instances and compare with the expected state.

InstanceExpected State
1. Immediately after rendering the still image  DRRS_HIGH_RR
2. After a delay of 1.2Sec  DRRS_LOW_RR
3. After changing the frame buffer  DRRS_HIGH_RR
4. After a delay of 1.2Sec  DRRS_LOW_RR
5. After changing the frame buffer  DRRS_HIGH_RR
6. After a delay of 1.2Sec  DRRS_LOW_RR

The test checks the driver DRRS state from the debugfs entry. To check the
actual refresh-rate, the number of vblanks received per sec.
The refresh-rate calculated is checked against the expected refresh-rate
with a tolerance value of 2.

This patch is a continuation of the earlier work
https://patchwork.freedesktop.org/patch/45472/ towards igt for idleness

DRRS. The code is tested on Broxton BXT_T platform.

v2: Addressed the comments and suggestions from Vlad, Marius.
The signoff details from the earlier work are also included.

v3: Modified vblank rate calculation by using reply-sequence, provided by
drmWaitVBlank, as suggested by Chris Wilson.

v4: As suggested from Chris Wilson and Daniel Vetter
1) Avoided using pthread for calculating vblank refresh rate,
   instead used drmWaitVBlank reply sequence.
2) Avoided using kernel-specific info like transitional delays,
   instead polling mechanism with timeout is used.
3) Included edp-DRRS as a subtest in kms_frontbuffer_tracking.c,
   instead of having a separate test.

v5: This patch adds DRRS as a new feature in the kms_frontbuffer_tracking IGT.
DRRS switch to lower vrefresh rate is tested at slow-draw subtest.

Note:
1) Currently kernel doesn't have support to enable and disable the DRRS
   feature dynamically(as in case of PSR). Hence if the panel supports
   DRRS it will be enabled by default.

This is in continuation of last patch 
"https://patchwork.freedesktop.org/patch/162726/";

Signed-off-by: Lohith BS 
Signed-off-by: Ramalingam C 
Signed-off-by: Vandana Kannan 
Signed-off-by: aknautiy 
---
 tests/kms_frontbuffer_tracking.c | 161 ---
 1 file changed, 152 insertions(+), 9 deletions(-)

diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index a068c8a..4f44109 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -34,7 +34,7 @@
 
 
 IGT_TEST_DESCRIPTION("Test the Kernel's frontbuffer tracking mechanism and "
-"its related features: FBC and PSR");
+"its related features: FBC DRRS and PSR");
 
 /*
  * One of the aspects of this test is that, for every subtest, we try different
@@ -105,8 +105,9 @@ struct test_mode {
FEATURE_NONE  = 0,
FEATURE_FBC   = 1,
FEATURE_PSR   = 2,
-   FEATURE_COUNT = 4,
-   FEATURE_DEFAULT = 4,
+   FEATURE_DRRS  = 4,
+   FEATURE_COUNT = 6,
+   FEATURE_DEFAULT = 6,
} feature;
 
/* Possible pixel formats. We just use FORMAT_DEFAULT for most tests and
@@ -180,6 +181,9 @@ struct {
bool can_test;
 } psr = {
.can_test = false,
+},
+drrs  = {
+   .can_test = false,
 };
 
 
@@ -822,6 +826,52 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
 }
 
+static bool is_drrs_high(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_HIGH_RR");
+}
+
+static bool is_drrs_low(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS_LOW_RR");
+}
+
+static bool is_drrs_enabled(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "DRRS Supported: Yes");
+}
+
+static bool is_drrs_inactive(void)
+{
+   char buf[256];
+
+   debugfs_read("i915_drrs_status", buf);
+   return strstr(buf, "No active crtc found");
+}
+
+static void drrs_print_status(void)
+{
+   char buf[256];
+
+   if (is_drrs_high())
+   igt_info("DRRS STATUS : DRRS HIG