tests/kms_setmode: increase MAX_CRTCS to 6
PATCH 1/1 tests/kms_setmode: increase MAX_CRTCS to 6
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
tests/kms_setmode.c +15 -10
@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;
@@ -743,22 +745,25 @@ static void get_combinations(int n, int k, bool allow_repetitions,static void test_combinations (const struct test_config *tconf,int connector_count) { -struct combination_set connector_combs; -struct combination_set crtc_combs; +struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs)); +get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;
@@ -766,14 +771,14 @@ static void test_combinations(const struct test_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs);
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 35 lines · Harry Wentland
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
Signed-off-by Harry Wentland <[email protected]>--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)tests/kms_setmode.c +4
-4@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;@@ -743,22 +745,25 @@ static void get_combinations(int n, int k, bool allow_repetitions,static void test_combinations (const struct test_config *tconf,int connector_count) { -struct combination_set connector_combs; -struct combination_set crtc_combs;
tests/kms_setmode.c static void get_combinations(int n, int k, bool allow_repetitions, · line 757
Quoted 10 lines
tests/kms_setmode.c +4
-0+struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs));
Shouldn't this get freed somewhere?
Quoted 36 lines
tests/kms_setmode.c +7
-7+get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;@@ -766,14 +771,14 @@ static void test_combinations(const struct test_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs); --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
Quoted 5 lines · Harry Wentland
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
Signed-off-by Harry Wentland <[email protected]>
I think just dynamically allocating stuff directly and dropping the #define would be even neater ... GetResources can tell us how much of each exists.
-Daniel
Quoted 80 lines
--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)tests/kms_setmode.c +15
-10@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;@@ -743,22 +745,25 @@ static void get_combinations(int n, int k, bool allow_repetitions,static void test_combinations (const struct test_config *tconf,int connector_count) { -struct combination_set connector_combs; -struct combination_set crtc_combs; +struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs)); +get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;@@ -766,14 +771,14 @@ static void test_combinations(const struct test_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs);Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ 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): 20170531093737.xovr4mn24uvxuvdq-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org
Quoted 12 lines · Daniel Vetter
Quoted 5 lines · Harry Wentland
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
Signed-off-by Harry Wentland <[email protected]>I think just dynamically allocating stuff directly and dropping the #define would be even neater ... GetResources can tell us how much of each exists.
-Daniel
Agreed. I'll send out a v3 later.
Harry
Quoted 76 lines
Quoted 76 lines
--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)tests/kms_setmode.c +15
-10@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;@@ -743,22 +745,25 @@ static void get_combinations(int n, int k, bool allow_repetitions,static void test_combinations (const struct test_config *tconf,int connector_count) { -struct combination_set connector_combs; -struct combination_set crtc_combs; +struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs)); +get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;@@ -766,14 +771,14 @@ static void test_combinations(const struct test_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs);Signature · 1 line
2.11.0
Quoted 5 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 8 lines · Harry Wentland
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Harry Wentland
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
Signed-off-by Harry Wentland <[email protected]>
Quoted 8 lines
Quoted 5 lines
I think just dynamically allocating stuff directly and dropping the #define would be even neater ... GetResources can tell us how much of each exists.
-DanielAgreed. I'll send out a v3 later.
About to send v3 but this code is quite majorly wrong as-is. In particular I see these two issues:
1) In iterate_combinations we assign a stack object to our list of combinations which is then popped off the stack as soon as get_combinations returns. Later on in test_combinations we then try to access it with
connector_idxs = &connector_combs.items[i].elems[0]; ... int *crtc_idxs = &crtc_combs.items[j].elems[0];
2) This for loop in iterate_combinations will simply override comb->elems[depth] with new values:
for (v = base; v < n; v++) {
comb->elems[depth] = v;
[...]
}It looks like whoever wrote the code tried to do some k choose n algorithm to find all possible sets of crtcs and connectors but then only ended up picking one crtc and connector out of each list anyways (after the item popped from the stack).
If I find time I might rewrite the test_combinations function with a simple nested for loop that tries all crtcs with all connectors one-to-one as this seems to be currently the intention of this function.
Harry
Quoted 79 lines
Harry
Quoted 77 lines
Quoted 76 lines
--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)tests/kms_setmode.c +15
-10@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;@@ -743,22 +745,25 @@ static void get_combinations(int n, int k, bool allow_repetitions, static void test_combinations(const struct test_config *tconf,int connector_count) { -struct combination_set connector_combs; -struct combination_set crtc_combs; +struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs)); +get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;@@ -766,14 +771,14 @@ static void test_combinations(const structtest_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs);Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-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): 030650e0-7a22-8811-e4eb-fea07ff44210-5C7GfCeVMHo@public.gmane.org
Please ignore what I wrote. Looks like I was a bit hasty in my judgement. The code just doesn't read easily but seems correct, other than the array size.
Harry
Quoted 121 lines · Harry Wentland
Quoted 8 lines · Harry Wentland
Quoted 7 lines · Daniel Vetter
Quoted 5 lines · Harry Wentland
AMD GPUs can have 6 CRTCs.
This requires us to allocate the combinations on the heap.
Signed-off-by Harry Wentland <[email protected]>Quoted 8 lines
Quoted 5 lines
I think just dynamically allocating stuff directly and dropping the #define would be even neater ... GetResources can tell us how much of each exists.
-DanielAgreed. I'll send out a v3 later.
About to send v3 but this code is quite majorly wrong as-is. In particular I see these two issues:
1) In
iterate_combinationswe assign a stack object to our list of combinations which is then popped off the stack as soon asget_combinationsreturns. Later on intest_combinationswe then try to access it with
connector_idxs= &connector_combs.items[i].elems[0];
...
int*crtc_idxs= &crtc_combs.items[j].elems[0];2) This for loop in
iterate_combinationswill simply overridecomb->elems[depth] with new values: for (v = base; v < n; v++) { comb->elems[depth] = v; [...] }It looks like whoever wrote the code tried to do some k choose n algorithm to find all possible sets of crtcs and connectors but then only ended up picking one crtc and connector out of each list anyways (after the item popped from the stack).
If I find time I might rewrite the
test_combinationsfunction with a simple nested for loop that tries all crtcs with all connectors one-to-one as this seems to be currently the intention of this function.Harry
Quoted 79 lines
Harry
Quoted 77 lines
Quoted 76 lines
--- tests/kms_setmode.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)tests/kms_setmode.c +15
-10@@ -35,11 +35,13 @@#include "intel_bufmgr.h" #define MAX_CONNECTORS 10 -#define MAX_CRTCS 3 +#define MAX_CRTCS 6/* max combinations with repetitions */ +/* MAX_CONNECTORS ^ MAX_CRTCS */ +/* TODO should really be MAX_CONNECTORS ^ MAX_CONNECTORS ??? */ #define MAX_COMBINATION_COUNT \ - (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS) + (MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS * MAX_CONNECTORS)#define MAX_COMBINATION_ELEMS MAX_CRTCSstatic int drm_fd;@@ -743,22 +745,25 @@ static void get_combinations(int n, int k,bool allow_repetitions, static void test_combinations(const struct test_config *tconf, int connector_count) { - struct combination_set connector_combs; -struct combination_set crtc_combs; + struct combination_set *connector_combs; +struct combination_set *crtc_combs;struct connector_config *cconfs;int i;if (connector_count >2 && (tconf->flags &TEST_STEALING ))return ; + connector_combs =malloc (sizeof (*connector_combs)); + crtc_combs =malloc (sizeof (*crtc_combs)); +get_combinations (tconf->resources->count_connectors, connector_count, - false, &connector_combs); + false, connector_combs);get_combinations (tconf->resources->count_crtcs, connector_count, - true, &crtc_combs); + true, crtc_combs);igt_info ("Testing: %s %d connector combinations\n" , tconf->name, connector_count); -for (i =0 ; i < connector_combs.count; i++) { +for (i =0 ; i < connector_combs->count; i++) {int *connector_idxs;int ret;int j;@@ -766,14 +771,14 @@ static void test_combinations(const structtest_config *tconf, cconfs =malloc (sizeof (*cconfs) * connector_count);igt_assert (cconfs); - connector_idxs = &connector_combs.items[i].elems[0 ]; + connector_idxs = &connector_combs->items[i].elems[0 ]; ret =get_connectors (tconf->resources, connector_idxs, connector_count, cconfs);if (ret <0 ) goto free_cconfs; -for (j =0 ; j < crtc_combs.count; j++) { -int *crtc_idxs = &crtc_combs.items[j].elems[0 ]; +for (j =0 ; j < crtc_combs->count; j++) { +int *crtc_idxs = &crtc_combs->items[j].elems[0 ]; ret =assign_crtc_to_connectors (tconf, crtc_idxs, connector_count, cconfs);Signature · 6 lines
2.11.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines
_______________________________________________
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