Skip to contentSkip to conversation

tests/kms_setmode: Dynamic crtc/connector combinations

PATCH In review Harry Wentland 3 participants 5 messages Jun 5, 2017 – Jun 6, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/kms_setmode: Dynamic crtc/connector combinations

Create crtc/connector combinations based on actual adapter information obtained from drmModeRes.

Also set MAX_CRTCs to 6 for AMD GPUs.

---
 tests/kms_setmode.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
tests/kms_setmode.c +18 -6
index 430568a1c24e..a7a48de44b0e 100644
@@ -31,15 +31,13 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/time.h>
-
+#include <math.h>
 #include "intel_bufmgr.h"
 
 #define MAX_CONNECTORS  10
-#define MAX_CRTCS       3
+#define MAX_CRTCS       6
 
 /* max combinations with repetitions */
-#define MAX_COMBINATION_COUNT   \
-	(MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
 #define MAX_COMBINATION_ELEMS   MAX_CRTCS
 
 static int drm_fd;
@@ -702,7 +700,8 @@ struct combination {
 
 struct combination_set {
 	int count;
-	struct combination items[MAX_COMBINATION_COUNT];
+	int capacity;
+	struct combination *items;
 };
 
 /*
@@ -716,7 +715,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions,
 	int v;
 
 	if (!k) {
-		igt_assert(set->count < ARRAY_SIZE(set->items));
+		igt_assert(set->count < set->capacity);
 		set->items[set->count++] = *comb;
 		return;
 	}
@@ -751,6 +750,16 @@ static void test_combinations(const struct test_config *tconf,
 	if (connector_count > 2 && (tconf->flags & TEST_STEALING))
 		return;
 
+	igt_assert(tconf->resources);
+
+	connector_combs.capacity = pow(tconf->resources->count_connectors,
+				       tconf->resources->count_crtcs + 1);
+	crtc_combs.capacity = pow(tconf->resources->count_crtcs,
+				  tconf->resources->count_crtcs + 1);
+
+	connector_combs.items = malloc(connector_combs.capacity * sizeof(struct combination));
+	crtc_combs.items = malloc(crtc_combs.capacity * sizeof(struct combination));
+
 	get_combinations(tconf->resources->count_connectors, connector_count,
 			 false, &connector_combs);
 	get_combinations(tconf->resources->count_crtcs, connector_count,
@@ -787,6 +796,9 @@ static void test_combinations(const struct test_config *tconf,
 free_cconfs:
 		free(cconfs);
 	}
+
+	free(connector_combs.items);
+	free(crtc_combs.items);
 }
 
 static void run_test(const struct test_config *tconf)
Signature · 6 lines
2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Harry Wentland

Create crtc/connector combinations based on actual adapter information obtained from drmModeRes.

Also set MAX_CRTCs to 6 for AMD GPUs.

The code is kind of hard to follow, but it looks good to me:

Quoted 75 lines
---
 tests/kms_setmode.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
tests/kms_setmode.c +18 -7
index 430568a1c24e..a7a48de44b0e 100644
@@ -31,15 +31,13 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/time.h>
-
+#include <math.h>
 #include "intel_bufmgr.h"
 
 #define MAX_CONNECTORS  10
-#define MAX_CRTCS       3
+#define MAX_CRTCS       6
 
 /* max combinations with repetitions */
-#define MAX_COMBINATION_COUNT   \
-       (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
 #define MAX_COMBINATION_ELEMS   MAX_CRTCS
 
 static int drm_fd;
@@ -702,7 +700,8 @@ struct combination {
 
 struct combination_set {
        int count;
-       struct combination items[MAX_COMBINATION_COUNT];
+       int capacity;
+       struct combination *items;
 };
 
 /*
@@ -716,7 +715,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions,
        int v;
 
        if (!k) {
-               igt_assert(set->count < ARRAY_SIZE(set->items));
+               igt_assert(set->count < set->capacity);
                set->items[set->count++] = *comb;
                return;
        }
@@ -751,6 +750,16 @@ static void test_combinations(const struct test_config *tconf,
        if (connector_count > 2 && (tconf->flags & TEST_STEALING))
                return;
 
+       igt_assert(tconf->resources);
+
+       connector_combs.capacity = pow(tconf->resources->count_connectors,
+                                      tconf->resources->count_crtcs + 1);
+       crtc_combs.capacity = pow(tconf->resources->count_crtcs,
+                                 tconf->resources->count_crtcs + 1);
+
+       connector_combs.items = malloc(connector_combs.capacity * sizeof(struct combination));
+       crtc_combs.items = malloc(crtc_combs.capacity * sizeof(struct combination));
+
        get_combinations(tconf->resources->count_connectors, connector_count,
                         false, &connector_combs);
        get_combinations(tconf->resources->count_crtcs, connector_count,
@@ -787,6 +796,9 @@ static void test_combinations(const struct test_config *tconf,
 free_cconfs:
                free(cconfs);
        }
+
+       free(connector_combs.items);
+       free(crtc_combs.items);
 }
 
 static void run_test(const struct test_config *tconf)
--

2.11.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_Nqf+gwiq7PiVoaSpDvYgieVepf5sM05=m1DkA1LP6nAQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#3 lore raw
Quoted 11 lines · Alex Deucher
Quoted 6 lines · Harry Wentland

Create crtc/connector combinations based on actual adapter information obtained from drmModeRes.

Also set MAX_CRTCs to 6 for AMD GPUs.

The code is kind of hard to follow, but it looks good to me:

I agree, that's why I only tried to limit the scope of this patch to the size of the combinations struct.

Thanks for the Ack. Is it okay to merge into drm/igt-gpu-tools? Do you know what the rules are on that? https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html is quite vague on IGT patches.

Harry

Quoted 71 lines
Quoted 71 lines
---
  tests/kms_setmode.c | 24 ++++++++++++++++++------
  1 file changed, 18 insertions(+), 6 deletions(-)
tests/kms_setmode.c +18 -6
index 430568a1c24e..a7a48de44b0e 100644
@@ -31,15 +31,13 @@
  #include <unistd.h>
  #include <string.h>
  #include <sys/time.h>
-
+#include <math.h>
  #include "intel_bufmgr.h"
 
  #define MAX_CONNECTORS  10
-#define MAX_CRTCS       3
+#define MAX_CRTCS       6
 
  /* max combinations with repetitions */
-#define MAX_COMBINATION_COUNT   \
-       (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)
  #define MAX_COMBINATION_ELEMS   MAX_CRTCS
 
  static int drm_fd;
@@ -702,7 +700,8 @@ struct combination {
 
  struct combination_set {
         int count;
-       struct combination items[MAX_COMBINATION_COUNT];
+       int capacity;
+       struct combination *items;
  };
 
  /*
@@ -716,7 +715,7 @@ static void iterate_combinations(int n, int k, bool allow_repetitions,
         int v;
 
         if (!k) {
-               igt_assert(set->count < ARRAY_SIZE(set->items));
+               igt_assert(set->count < set->capacity);
                 set->items[set->count++] = *comb;
                 return;
         }
@@ -751,6 +750,16 @@ static void test_combinations(const struct test_config *tconf,
         if (connector_count > 2 && (tconf->flags & TEST_STEALING))
                 return;
 
+       igt_assert(tconf->resources);
+
+       connector_combs.capacity = pow(tconf->resources->count_connectors,
+                                      tconf->resources->count_crtcs + 1);
+       crtc_combs.capacity = pow(tconf->resources->count_crtcs,
+                                 tconf->resources->count_crtcs + 1);
+
+       connector_combs.items = malloc(connector_combs.capacity * sizeof(struct combination));
+       crtc_combs.items = malloc(crtc_combs.capacity * sizeof(struct combination));
+
         get_combinations(tconf->resources->count_connectors, connector_count,
                          false, &connector_combs);
         get_combinations(tconf->resources->count_crtcs, connector_count,
@@ -787,6 +796,9 @@ static void test_combinations(const struct test_config *tconf,
  free_cconfs:
                 free(cconfs);
         }
+
+       free(connector_combs.items);
+       free(crtc_combs.items);
  }
 
Quoted 8 lines
Quoted 8 lines
tests/kms_setmode.c +0 -1
  static void run_test(const struct test_config *tconf)
--

2.11.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 13 lines · Harry Wentland
Quoted 11 lines · Alex Deucher
Quoted 6 lines · Harry Wentland

Create crtc/connector combinations based on actual adapter information obtained from drmModeRes.

Also set MAX_CRTCs to 6 for AMD GPUs.

The code is kind of hard to follow, but it looks good to me:

Quoted 8 lines

I agree, that's why I only tried to limit the scope of this patch to the size of the combinations struct.

Thanks for the Ack. Is it okay to merge into drm/igt-gpu-tools? Do you know what the rules are on that?
https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html is quite vague on IGT patches.

Thanks, pushed this.

Getting commits to IGT is described in igt/CONTRIBUTING. That page could use a short description of IGT patch flow indeed.

Signature · 5 lines
Petri Latvala
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): 20170606074315.i2z3ylwjvdvm7du7-SnVRlzm/I0T9BXuAQUXR0fooFf0ArEBIu+b9c/[email protected]

#6 lore raw
Quoted 24 lines · Petri Latvala
Quoted 13 lines · Harry Wentland
Quoted 11 lines · Alex Deucher
Quoted 6 lines · Harry Wentland

Create crtc/connector combinations based on actual adapter information obtained from drmModeRes.

Also set MAX_CRTCs to 6 for AMD GPUs.

The code is kind of hard to follow, but it looks good to me:

Quoted 8 lines

I agree, that's why I only tried to limit the scope of this patch to the size of the combinations struct.

Thanks for the Ack. Is it okay to merge into drm/igt-gpu-tools? Do you know what the rules are on that?
https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html is quite vague on IGT patches.

Quoted 5 lines

Thanks, pushed this.

Getting commits to IGT is described in igt/CONTRIBUTING. That page could use a short description of IGT patch flow indeed.

Thanks, Petri.

I believe I have push access but didn't want to push anything prematurely. In the future I'll push after a-b or r-b if there are no objections.

Thanks,
Harry

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx