drmtest changes for running tests on multi-gpu
v8 cover drmtest changes for running tests on multi-gpu
Allow to open other cards out of order with __drm_open_driver_another() There is still a problem left when there is non-matched first device and no filters are used, it will not work with legacy opening but I will leave that for later. With filters it now works on four GPUs board, when first card is non-Intel one with no render device:
sudo IGT_DEVICE=pci:vendor=Intel,device=discrete,card=all build/tests/xe_create --r multigpu-create-massive-size
Opened device: /dev/dri/card1
Starting subtest: multigpu-create-massive-size <g:1> Opened device: /dev/dri/card2
<g:2> Opened device: /dev/dri/card3
Subtest multigpu-create-massive-size: SUCCESS (0.341s)
With new helper and without filters:
sudo build/tests/xe_create --r multigpu-create-massive-size
Opened device: /dev/dri/card1
Starting subtest: multigpu-create-massive-size <g:1> Opened device: /dev/dri/card2
<g:2> Opened device: /dev/dri/card3
Subtest multigpu-create-massive-size: SUCCESS (1.686s)
v2: dropped additional patch 2/3 ("lib/drmtest: add multigpu helpers")
changed 3/3 RFC patch as additional subtest
v3: fixes in test (Zbigniew)
fixes in drmlib functions (Zbigniew, Kamil)
v4: corrected test description (Kamil)
v5: restore boundary index for already opened device (Kamil)
v6: fixes in libdrm: start searching for driver from requested index,
limit checks for already opened drivers to currently opened count (Kamil)
v7: drop checks for already opened device with filters,
change a place for igt_debug message, improve debugs (Kamil)
v8: add drm helper for the case when no filters are used,
use this helper in xe_create multi-gpu subtest (Kamil)
Kamil Konieczny (6):
lib/drmtest: allow out of order device opening tests/intel/xe_create: extend massive subtest to multi-gpu lib/drmtest: drop checks for opened device for filters lib/drmtest: save skip offset for first opened device lib/drmtest: add helper for countig number of GPUs tests/intel/xe_create: use drm helper for GPUs count
lib/drmtest.c | 129 +++++++++++++++++++++++++++++++++++----- lib/drmtest.h | 2 + tests/intel/xe_create.c | 25 ++++++++ 3 files changed, 142 insertions(+), 14 deletions(-)
Signature · 1 line
2.42.0
PATCH v8 1/6 lib/drmtest: allow out of order device opening
Allow to open cards with filters out of order, not in the sequence 0...N. This will fix problem found out with test gem_exec_gttfill@multigpu-basic with three discrete GPUs:
Opened device: /dev/dri/card1
Starting subtest: multigpu-basic
<g:1> Opened device: /dev/dri/card2gem_exec_gttfill: ../lib/drmtest.c:313: _is_already_opened: Assertion `as_idx <= _opened_fds_count' failed.
Added also some debug prints for diagnosing problems with multi-GPU tests.
v2: fix setting opened count in _set_opened_fd()
v3: search all already opened fds in _is_already_opened()
v4: revert change in v3, this will cause treating zero as
special index (no checks) as some test depend on it
v5: start searching for driver from requested index,
limit checks for already opened drivers to currently opened count (Kamil)
--- lib/drmtest.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
lib/drmtest.c +23 -5
@@ -296,13 +296,18 @@ static int _opened_fds_count;static void _set_opened_fd (int idx,int fd) {assert (idx <ARRAY_SIZE (_opened_fds)); -assert (idx <= _opened_fds_count); + +if (idx >= _opened_fds_count) { +for (int i = _opened_fds_count; i < idx; ++i) + _opened_fds[i].fd =-1 ; + } _opened_fds[idx].fd = fd;assert (fstat (fd, &_opened_fds[idx].stat) ==0 ); - _opened_fds_count = idx+1 ; +if (idx >= _opened_fds_count) + _opened_fds_count = idx +1 ; }static bool _is_already_opened (const char *path,int as_idx)
@@ -310,16 +315,23 @@ static bool _is_already_opened(const char *path, int as_idx)struct stat new;assert (as_idx <ARRAY_SIZE (_opened_fds)); -assert (as_idx <= _opened_fds_count);/* * we cannot even stat the device, so it's of no use - let's claim it's * already opened */ -if (igt_debug_on (stat (path, &new) !=0 )) +if (igt_debug_on (stat (path, &new) !=0 )) { +igt_debug ("cannot stat device: %s\n" , path);return true; + } + +if (as_idx > _opened_fds_count) + as_idx = _opened_fds_count;for (int i =0 ; i < as_idx; ++i) { +if (_opened_fds[i].fd ==-1 ) +continue ; +/* did we cross filesystem boundary? */ assert (_opened_fds[i].stat.st_dev == new.st_dev);
@@ -338,6 +350,7 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,if (forced)igt_debug ("Force option used: Using driver %s\n" , forced); + offset += as_idx;for (int i =0 ; i <16 ; i++) {char name[80 ];int fd;
@@ -484,6 +497,7 @@ int __drm_open_driver_another(int idx, int chipset) {int fd =-1 ; +igt_debug ("card idx: %d chipset: %d\n" , idx, chipset);if (chipset !=DRIVER_VGEM &&igt_device_filter_count () > idx) {struct igt_device_card card;bool found;
@@ -491,6 +505,7 @@ int __drm_open_driver_another(int idx, int chipset) found =__get_card_for_nth_filter (idx, &card);if (!found) { +igt_debug ("cannot find card idx: %d, loading module\n" , idx);drm_load_module (chipset); found =__get_card_for_nth_filter (idx, &card); }
@@ -500,11 +515,14 @@ int __drm_open_driver_another(int idx, int chipset) igt_device_filter_get(idx)); else if (_is_already_opened(card.card, idx)) igt_warn("card maching filter %d is already opened\n", idx); - else + else { +igt_debug ("card idx: %d found: %s\n" , idx, card.card); fd =__open_driver_exact (card.card, chipset); + } }else {/* no filter for device idx, let's open whatever is available */ +igt_debug ("No filter for device idx: %d\n" , idx); fd =__open_driver ("/dev/dri/card" ,0 , chipset, idx); }
Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 1/6] lib/drmtest: allow out of order device opening
Quoted 31 lines · Kamil Konieczny
Allow to open cards with filters out of order, not in the sequence 0...N. This will fix problem found out with test gem_exec_gttfill@multigpu-basic with three discrete GPUs:
Opened device:
/dev/dri/card1
Starting subtest: multigpu-basic
<g:1> Opened device:/dev/dri/card2gem_exec_gttfill:../lib/drmtest.c:313:_is_already_opened: Assertion `as_idx <=_opened_fds_count' failed.Added also some debug prints for diagnosing problems with multi-GPU tests.
v2: fix setting opened count in
_set_opened_fd()
v3: search all already opened fds in_is_already_opened()
v4: revert change in v3, this will cause treating zero as
special index (no checks) as some test depend on it
v5: start searching for driver from requested index,
limit checks for already opened drivers to currently opened count (Kamil)Cc Zbigniew Kempczyński <[email protected]>Signed-off-by Kamil Konieczny <[email protected]>--- lib/drmtest.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)lib/drmtest.c +0
-0
lib/drmtest.c static int _opened_fds_count; · line 303
Quoted 9 lines
lib/drmtest.c +5
-1@@ -296,13 +296,18 @@ static int _opened_fds_count;static void _set_opened_fd (int idx,int fd) {assert (idx <ARRAY_SIZE (_opened_fds)); -assert (idx <= _opened_fds_count); + +if (idx >= _opened_fds_count) { +for (int i = _opened_fds_count; i < idx; ++i) + _opened_fds[i].fd =-1 ; + }
Do you need if conditional? I mean if idx == _opened_fds_count (let's say _opened _fds_count == 5 and idx == 5, so you're hiting next element) and for loop just won't run -> i = 5, i < 5.
lib/drmtest.c static int _opened_fds_count; · line 305
Quoted 2 lines
lib/drmtest.c +0
-0_opened_fds[idx].fd = fd;
And you're write fd at index 5.
lib/drmtest.c static int _opened_fds_count; · line 311
Quoted 7 lines
lib/drmtest.c +2
-1assert (fstat (fd, &_opened_fds[idx].stat) ==0 ); - _opened_fds_count = idx+1 ; +if (idx >= _opened_fds_count) + _opened_fds_count = idx +1 ; }
Anyway, you're allowing to selectively extend currently opened fd array keeping -1 on not occupied slots.
Rest looks good to me.
--
Zbigniew
Quoted 10 lines
lib/drmtest.c +0
-1static bool _is_already_opened (const char *path,int as_idx)@@ -310,16 +315,23 @@ static bool _is_already_opened(const char *path, int as_idx)struct stat new;assert (as_idx <ARRAY_SIZE (_opened_fds)); -assert (as_idx <= _opened_fds_count);/* * we cannot even stat the device, so it's of no use - let's claim it's
lib/drmtest.c static bool _is_already_opened(const char *path, int as_idx) · line 329
Quoted 10 lines
lib/drmtest.c +6
-1* already opened */ -if (igt_debug_on (stat (path, &new) !=0 )) +if (igt_debug_on (stat (path, &new) !=0 )) { +igt_debug ("cannot stat device: %s\n" , path);return true; + } + +if (as_idx > _opened_fds_count) + as_idx = _opened_fds_count;
Checking up to _opened_fds_count makes sense for me.
Quoted 51 lines
lib/drmtest.c +10
-1for (int i =0 ; i < as_idx; ++i) { +if (_opened_fds[i].fd ==-1 ) +continue ; +/* did we cross filesystem boundary? */ assert (_opened_fds[i].stat.st_dev == new.st_dev);@@ -338,6 +350,7 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,if (forced)igt_debug ("Force option used: Using driver %s\n" , forced); + offset += as_idx;for (int i =0 ; i <16 ; i++) {char name[80 ];int fd;@@ -484,6 +497,7 @@ int __drm_open_driver_another(int idx, int chipset) {int fd =-1 ; +igt_debug ("card idx: %d chipset: %d\n" , idx, chipset);if (chipset !=DRIVER_VGEM &&igt_device_filter_count () > idx) {struct igt_device_card card;bool found;@@ -491,6 +505,7 @@ int __drm_open_driver_another(int idx, int chipset) found =__get_card_for_nth_filter (idx, &card);if (!found) { +igt_debug ("cannot find card idx: %d, loading module\n" , idx);drm_load_module (chipset); found =__get_card_for_nth_filter (idx, &card); }@@ -500,11 +515,14 @@ int __drm_open_driver_another(int idx, int chipset) igt_device_filter_get(idx)); else if (_is_already_opened(card.card, idx)) igt_warn("card maching filter %d is already opened\n", idx); - else + else { +igt_debug ("card idx: %d found: %s\n" , idx, card.card); fd =__open_driver_exact (card.card, chipset); + } }else {/* no filter for device idx, let's open whatever is available */ +igt_debug ("No filter for device idx: %d\n" , idx); fd =__open_driver ("/dev/dri/card" ,0 , chipset, idx); }Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 1/6] lib/drmtest: allow out of order device opening
On Thu, Oct 05, 2023 at 01:44:17PM +0200, Zbigniew Kempczyński wrote:
<cut>
Quoted 35 lines
Quoted 5 lines
lib/drmtest.c +0
-0lib/drmtest.c static int _opened_fds_count; · line 303
Quoted 9 lines
lib/drmtest.c +5
-1@@ -296,13 +296,18 @@ static int _opened_fds_count;static void _set_opened_fd (int idx,int fd) {assert (idx <ARRAY_SIZE (_opened_fds)); -assert (idx <= _opened_fds_count); + +if (idx >= _opened_fds_count) { +for (int i = _opened_fds_count; i < idx; ++i) + _opened_fds[i].fd =-1 ; + }Do you need if conditional? I mean if idx ==
_opened_fds_count(let's say_opened_fds_count== 5 and idx == 5, so you're hiting next element) and for loop just won't run -> i = 5, i < 5.lib/drmtest.c static int _opened_fds_count; · line 305
Quoted 2 lines
lib/drmtest.c +0
-0_opened_fds[idx].fd = fd;And you're write fd at index 5.
lib/drmtest.c static int _opened_fds_count; · line 311
Quoted 7 lines
lib/drmtest.c +2
-1assert (fstat (fd, &_opened_fds[idx].stat) ==0 ); - _opened_fds_count = idx+1 ; +if (idx >= _opened_fds_count) + _opened_fds_count = idx +1 ; }Anyway, you're allowing to selectively extend currently opened fd array keeping -1 on not occupied slots.
Quoted 2 lines
Rest looks good to me.
I've forgotten to write about r-b - after addressing above conditional nitpick.
Quoted 3 lines
Reviewed-by Zbigniew Kempczyński <[email protected]>--
Zbigniew
--
Zbigniew
PATCH v8 2/6 tests/intel/xe_create: extend massive subtest to multi-gpu
In reply to Kamil KoniecznySample code extends existing create-massive-size subtest to run on multi-GPUs boards. This will currently work only with --drivers or IGT_DRIVERS options selecting at least two dGPU cards.
v2: Fixed bug in opening wrong multi-gpu device (Zbigniew)
v3: revert to use filter count, add require for xe, change
subtest description
v4: correct description
--- tests/intel/xe_create.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
tests/intel/xe_create.c +25 -0
@@ -12,6 +12,7 @@#include <string.h> #include "igt.h" +#include "igt_device_scan.h" #include "xe_drm.h" #include "xe/xe_ioctl.h" #include "xe/xe_query.h"
@@ -191,6 +192,13 @@ static void create_execqueues(int fd, enum exec_queue_destroy ed)* Test category: functionality test * Description: Verifies xe bo create returns expected error code on massive * buffer sizes. +* +* SUBTEST: multigpu-create-massive-size +* Functionality: ioctl +* Test category: functionality test +* Feature: multigpu +* Description: Verifies xe bo create with massive buffer sizes runs correctly +* on two or more GPUs. */ static void create_massive_size (int fd) {
@@ -228,6 +236,23 @@ igt_maincreate_massive_size (xe); } + igt_subtest("multigpu-create-massive-size") { +int gpu_filter_count =igt_device_filter_count (); + +igt_require (xe >0 ); +igt_require (gpu_filter_count >=2 ); + igt_multi_fork(child, gpu_filter_count) { +int gpu_fd; + + gpu_fd = child ?__drm_open_driver_another (child,DRIVER_XE ) :drm_reopen_driver (xe); +igt_assert_f (gpu_fd >0 ,"cannot open gpu-%d, errno=%d\n" , child, errno); + +create_massive_size (gpu_fd); +drm_close_driver (gpu_fd); + } +igt_waitchildren (); + } +igt_fixture drm_close_driver (xe ); }
Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 2/6] tests/intel/xe_create: extend massive subtest to multi-gpu
Quoted 3 lines · Kamil Konieczny
Sample code extends existing create-massive-size subtest to run on multi-GPUs boards. This will currently work only with --drivers or
IGT_DRIVERSoptions selecting at least two dGPU
s/IGT_DRIVERS/IGT_DEVICE/
Rest looks good to me.
With above fixed:
--
Zbigniew
Quoted 66 lines
cards.
v2: Fixed bug in opening wrong multi-gpu device (Zbigniew)
v3: revert to use filter count, add require for xe, change
subtest description
v4: correct descriptionCc Zbigniew Kempczyński <[email protected]>Signed-off-by Kamil Konieczny <[email protected]>--- tests/intel/xe_create.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)tests/intel/xe_create.c +25
-0@@ -12,6 +12,7 @@#include <string.h> #include "igt.h" +#include "igt_device_scan.h" #include "xe_drm.h" #include "xe/xe_ioctl.h" #include "xe/xe_query.h" @@ -191,6 +192,13 @@ static void create_execqueues(int fd, enum exec_queue_destroy ed)* Test category: functionality test * Description: Verifies xe bo create returns expected error code on massive * buffer sizes. +* +* SUBTEST: multigpu-create-massive-size +* Functionality: ioctl +* Test category: functionality test +* Feature: multigpu +* Description: Verifies xe bo create with massive buffer sizes runs correctly +* on two or more GPUs. */ static void create_massive_size (int fd) {@@ -228,6 +236,23 @@ igt_maincreate_massive_size (xe); } + igt_subtest("multigpu-create-massive-size") { +int gpu_filter_count =igt_device_filter_count (); + +igt_require (xe >0 ); +igt_require (gpu_filter_count >=2 ); + igt_multi_fork(child, gpu_filter_count) { +int gpu_fd; + + gpu_fd = child ?__drm_open_driver_another (child,DRIVER_XE ) :drm_reopen_driver (xe); +igt_assert_f (gpu_fd >0 ,"cannot open gpu-%d, errno=%d\n" , child, errno); + +create_massive_size (gpu_fd); +drm_close_driver (gpu_fd); + } +igt_waitchildren (); + } +igt_fixture drm_close_driver (xe ); }Signature · 1 line
2.42.0
PATCH v8 3/6 lib/drmtest: drop checks for opened device for filters
In reply to Kamil KoniecznyWhen using filters honor user choice and don't restrict opens to non-opened devices. This will allow a user to test some multiGPU tests with repeated filter for card zero:
--device=pci:vendor=Intel,device=discrete,card=0\;pci:vendor=Intel,device=discrete,card=0
If the user want it just allow this. Also while at this, move debug print into filter loop as there is already one for non-filter.
--- lib/drmtest.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
lib/drmtest.c +9 -11
@@ -454,8 +454,8 @@ static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)* * device scanning is executed, * * idx-th filter (starting with 0, filters are semicolon separated) is used * * if there is no idx-th filter, goto 2 -* * first device maching the filter is selected -* * if it's already opened (for indexes = 0..idx-1) we fail with -1 +* * device maching the requested filter is selected +* * if it's not matched we fail with -1 * * otherwise open the device and return the fd * * 2. compatibility mode - open the first DRM device we can find that is not
@@ -497,11 +497,11 @@ int __drm_open_driver_another(int idx, int chipset) {int fd =-1 ; -igt_debug ("card idx: %d chipset: %d\n" , idx, chipset);if (chipset !=DRIVER_VGEM &&igt_device_filter_count () > idx) {struct igt_device_card card;bool found; +igt_debug ("card idx: %d chipset: %d\n" , idx, chipset); found =__get_card_for_nth_filter (idx, &card);if (!found) {
@@ -510,16 +510,14 @@ int __drm_open_driver_another(int idx, int chipset) found =__get_card_for_nth_filter (idx, &card); } -if (!found || !strlen (card.card)) -igt_warn ("No card matches the filter! [%s]\n" , -igt_device_filter_get (idx)); -else if (_is_already_opened (card.card, idx)) -igt_warn ("card maching filter %d is already opened\n" , idx); -else { -igt_debug ("card idx: %d found: %s\n" , idx, card.card); +if (!found || !strlen (card.card)) { +igt_warn ("No card matches the filter! [%s]%s\n" , +igt_device_filter_get (idx), + found && !strlen (card.card) ?" (card empty)" :"" ); + }else { +igt_debug ("card %d found: [%s]\n" , idx, card.card); fd =__open_driver_exact (card.card, chipset); } - }else {/* no filter for device idx, let's open whatever is available */ igt_debug ("No filter for device idx: %d\n" , idx);
Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 3/6] lib/drmtest: drop checks for opened device for filters
Quoted 72 lines · Kamil Konieczny
When using filters honor user choice and don't restrict opens to non-opened devices. This will allow a user to test some multiGPU tests with repeated filter for card zero:
--device=pci:vendor=Intel,device=discrete,card=0\;pci:vendor=Intel,device=discrete,card=0
If the user want it just allow this. Also while at this, move debug print into filter loop as there is already one for non-filter.
Cc Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>Cc Arkadiusz Hiler <[email protected]>Signed-off-by Kamil Konieczny <[email protected]>--- lib/drmtest.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)lib/drmtest.c +9
-11@@ -454,8 +454,8 @@ static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)* * device scanning is executed, * * idx-th filter (starting with 0, filters are semicolon separated) is used * * if there is no idx-th filter, goto 2 -* * first device maching the filter is selected -* * if it's already opened (for indexes = 0..idx-1) we fail with -1 +* * device maching the requested filter is selected +* * if it's not matched we fail with -1 * * otherwise open the device and return the fd * * 2. compatibility mode - open the first DRM device we can find that is not @@ -497,11 +497,11 @@ int __drm_open_driver_another(int idx, int chipset) {int fd =-1 ; -igt_debug ("card idx: %d chipset: %d\n" , idx, chipset);if (chipset !=DRIVER_VGEM &&igt_device_filter_count () > idx) {struct igt_device_card card;bool found; +igt_debug ("card idx: %d chipset: %d\n" , idx, chipset); found =__get_card_for_nth_filter (idx, &card);if (!found) {@@ -510,16 +510,14 @@ int __drm_open_driver_another(int idx, int chipset) found =__get_card_for_nth_filter (idx, &card); } -if (!found || !strlen (card.card)) -igt_warn ("No card matches the filter! [%s]\n" , -igt_device_filter_get (idx)); -else if (_is_already_opened (card.card, idx)) -igt_warn ("card maching filter %d is already opened\n" , idx); -else { -igt_debug ("card idx: %d found: %s\n" , idx, card.card); +if (!found || !strlen (card.card)) { +igt_warn ("No card matches the filter! [%s]%s\n" , +igt_device_filter_get (idx), + found && !strlen (card.card) ?" (card empty)" :"" ); + }else { +igt_debug ("card %d found: [%s]\n" , idx, card.card); fd =__open_driver_exact (card.card, chipset); } - }else {/* no filter for device idx, let's open whatever is available */ igt_debug ("No filter for device idx: %d\n" , idx);Signature · 1 line
2.42.0
Great. From now on there's much easier to test multigpu on single gpu. To be honest I've no idea why we introduced this check - from my perspective I see no reason to disallow picking same card couple of times with filter selection.
For above:
--
Zbigniew
PATCH v8 4/6 lib/drmtest: save skip offset for first opened device
In reply to Kamil KoniecznyOn some boards with many discrete GPU cards it may happen that on-board one is integrated and will be skipped during opening a first device. With out-of-order try and open it may result with off-by-one error opening wrong card. Fixed this with saving skip offset for first device name.
--- lib/drmtest.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
lib/drmtest.c +15 -2
@@ -292,6 +292,8 @@ static struct { }_opened_fds[64 ];static int _opened_fds_count; +static int _opened_fds0_skip; +static int _opened_fds0_chipset;static void _set_opened_fd (int idx,int fd) {
@@ -350,7 +352,11 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,if (forced)igt_debug ("Force option used: Using driver %s\n" , forced); - offset += as_idx; +if (offset ==0 && as_idx !=0 && _opened_fds0_chipset == chipset) + offset += as_idx + _opened_fds0_skip; +else + offset += as_idx; +for (int i =0 ; i <16 ; i++) {char name[80 ];int fd;
@@ -361,8 +367,15 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,continue ; fd =open_device (name, chipset); -if (fd !=-1 ) +if (fd !=-1 ) { +if (i !=0 && offset == as_idx && as_idx ==0 + && chipset !=DRIVER_VGEM && chipset !=DRIVER_ANY ) { + _opened_fds0_skip = i; + _opened_fds0_chipset = chipset; + } +return fd; + } }return -1 ;
Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 4/6] lib/drmtest: save skip offset for first opened device
Quoted 39 lines · Kamil Konieczny
On some boards with many discrete GPU cards it may happen that on-board one is integrated and will be skipped during opening a first device. With out-of-order try and open it may result with off-by-one error opening wrong card. Fixed this with saving skip offset for first device name.
Signed-off-by Kamil Konieczny <[email protected]>--- lib/drmtest.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)lib/drmtest.c +7
-1@@ -292,6 +292,8 @@ static struct { }_opened_fds[64 ];static int _opened_fds_count; +static int _opened_fds0_skip; +static int _opened_fds0_chipset;static void _set_opened_fd (int idx,int fd) {@@ -350,7 +352,11 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,if (forced)igt_debug ("Force option used: Using driver %s\n" , forced); - offset += as_idx; +if (offset ==0 && as_idx !=0 && _opened_fds0_chipset == chipset) + offset += as_idx + _opened_fds0_skip; +else + offset += as_idx; +for (int i =0 ; i <16 ; i++) {char name[80 ];int fd;@@ -361,8 +367,15 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,continue ;
lib/drmtest.c static int __search_and_open(const char *base, int offset, unsigned int chipset, · line 376
Quoted 10 lines
lib/drmtest.c +7
-1fd =open_device (name, chipset); -if (fd !=-1 ) +if (fd !=-1 ) { +if (i !=0 && offset == as_idx && as_idx ==0 + && chipset !=DRIVER_VGEM && chipset !=DRIVER_ANY ) { + _opened_fds0_skip = i; + _opened_fds0_chipset = chipset; + } +
I wondered can we simplify above. What you really need is to open as_idx card of requested chipset. The most time consuming part is underneath open_device() function. At the moment you're already tracking is as_idx slot occupied. You can introduce additional variable counter before the loop and increment it each time you hit as_idx is occupied - if (_is_already_counted()) or when fd = open_driver() will succeed. But you need to compare as_idx with current counter. If not equal close fd and continue. This would allow you to handle out-of-order calls with not monotonic as_idx.
--
Zbigniew
Quoted 8 lines
lib/drmtest.c +1
-0return fd; + } }return -1 ;Signature · 1 line
2.42.0
Re: [igt-dev] [PATCH i-g-t v8 4/6] lib/drmtest: save skip offset for first opened device
Hi Zbigniew,
Quoted 62 lines · Zbigniew Kempczyński
Quoted 39 lines · Kamil Konieczny
On some boards with many discrete GPU cards it may happen that on-board one is integrated and will be skipped during opening a first device. With out-of-order try and open it may result with off-by-one error opening wrong card. Fixed this with saving skip offset for first device name.
Signed-off-by Kamil Konieczny <[email protected]>--- lib/drmtest.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)lib/drmtest.c +7
-1@@ -292,6 +292,8 @@ static struct { }_opened_fds[64 ];static int _opened_fds_count; +static int _opened_fds0_skip; +static int _opened_fds0_chipset;static void _set_opened_fd (int idx,int fd) {@@ -350,7 +352,11 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,if (forced)igt_debug ("Force option used: Using driver %s\n" , forced); - offset += as_idx; +if (offset ==0 && as_idx !=0 && _opened_fds0_chipset == chipset) + offset += as_idx + _opened_fds0_skip; +else + offset += as_idx; +for (int i =0 ; i <16 ; i++) {char name[80 ];int fd;@@ -361,8 +367,15 @@ static int __search_and_open(const char *base, int offset, unsigned int chipset,continue ;lib/drmtest.c static int __search_and_open(const char *base, int offset, unsigned int chipset, · line 376
Quoted 10 lines
lib/drmtest.c +7
-1fd =open_device (name, chipset); -if (fd !=-1 ) +if (fd !=-1 ) { +if (i !=0 && offset == as_idx && as_idx ==0 + && chipset !=DRIVER_VGEM && chipset !=DRIVER_ANY ) { + _opened_fds0_skip = i; + _opened_fds0_chipset = chipset; + } +I wondered can we simplify above. What you really need is to open
as_idxcard of requested chipset. The most time consuming part is underneathopen_device()function. At the moment you're already tracking isas_idxslot occupied. You can introduce additional variable counter before the loop and increment it each time you hitas_idxis occupied - if (_is_already_counted()) or when fd =open_driver()will succeed. But you need to compareas_idxwith current counter. If not equal close fd and continue. This would allow you to handle out-of-order calls with not monotonicas_idx.
Quoted 3 lines
--
Zbigniew
I agree, it is a little too much complicated, I will change this according to your suggestions.
Regards,
Kamil
Quoted 9 lines
Quoted 9 lines
lib/drmtest.c +1
-0return fd; + } }return -1 ;Signature · 1 line
2.42.0
PATCH v8 5/6 lib/drmtest: add helper for countig number of GPUs
In reply to Kamil KoniecznyAdd a function for counting number of GPUs present on system. When no filters used this will count discrete GPUs, otherwise will count them using given filters.
--- lib/drmtest.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/drmtest.h | 2 ++ 2 files changed, 74 insertions(+)
lib/drmtest.c +72 -0
@@ -806,6 +806,78 @@ int drm_reopen_driver(int fd)return fd; } +/** +* drm_open_driver_render: +* @chipset: flag for one chipset to search, eg. #DRIVER_INTEL +* +* Get number of GPUs for given chipset. If used --device option or IGT_DEVICE +* environment variable, perform countig based on supplied filters. +* +* Returns: +* Number of GPUs for given chipset or filters. +*/ +int drm_get_gpu_count (int chipset) +{ +struct igt_device_card card; +int gpu_count; +bool found; +char v[16 ]; + +if (chipset ==DRIVER_VGEM || chipset ==DRIVER_ANY ) { +igt_debug ("No multi-gpu for chipset %d\n" , chipset); +return 0 ; + } + + gpu_count =igt_device_filter_count (); +if (!gpu_count) { +char gpu_filter[256 ]; + +if (chipset ==DRIVER_INTEL || chipset ==DRIVER_XE ) +strncpy (v,"Intel" ,sizeof (v) -1 ); +else +strncpy (v,chipset_to_str (chipset),sizeof (v) -1 ); +igt_debug ("Counting GPUs for chipset: %d vendor: %s\n" , chipset, v); +for (int i =0 ; i <64 ; i++) { +igt_assert (snprintf (gpu_filter,sizeof (gpu_filter), +"pci:vendor=%s,device=discrete,card=%d" , + v, i) <sizeof (gpu_filter)); + +memset (&card,0 ,sizeof (card)); + found =igt_device_card_match (gpu_filter, &card); +if (found &&strlen (card.card)) { +igt_debug ("Found gpu %d with %s\n" , i, card.card); + ++gpu_count; + }else { +igt_debug ("Counted GPUs number: %d\n" , gpu_count); +break ; + } + } + }else { +int count =0 ; + +for (int i =0 ; i < gpu_count; i++) { +const char *filter; + + filter =igt_device_filter_get (i); +memset (&card,0 ,sizeof (card)); + found =igt_device_card_match (filter, &card); +if (found &&strlen (card.card)) { +igt_debug ("Found gpu %d with %s\n" , i, card.card); + ++count; + }else { +break ; + } + } + +if (count < gpu_count) +igt_debug ("Counted GPUs %d lower than number of filters %d\n" , count, gpu_count); + + gpu_count = count; + } + +return gpu_count; +} +void igt_require_amdgpu (int fd) {igt_require (is_amdgpu_device (fd));
lib/drmtest.h +2 -0
@@ -109,6 +109,8 @@ int drm_close_driver(int fd);int drm_reopen_driver (int fd); +int drm_get_gpu_count (int chipset); +void igt_require_amdgpu (int fd);void igt_require_intel (int fd);void igt_require_i915 (int fd);
Signature · 1 line
2.42.0
PATCH v8 6/6 tests/intel/xe_create: use drm helper for GPUs count
In reply to Kamil KoniecznyInstead of counting filter use more general method supported by new function from drmtest, drm_get_gpu_count().
--- tests/intel/xe_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/intel/xe_create.c +2 -2
@@ -237,14 +237,14 @@ igt_main } igt_subtest("multigpu-create-massive-size") { -int gpu_filter_count =igt_device_filter_count (); +int gpu_filter_count =drm_get_gpu_count (DRIVER_XE );igt_require (xe >0 );igt_require (gpu_filter_count >=2 ); igt_multi_fork(child, gpu_filter_count) {int gpu_fd; - gpu_fd = child ?__drm_open_driver_another (child,DRIVER_XE ) :drm_reopen_driver (xe); + gpu_fd =__drm_open_driver_another (child,DRIVER_XE );igt_assert_f (gpu_fd >0 ,"cannot open gpu-%d, errno=%d\n" , child, errno);create_massive_size (gpu_fd);
Signature · 1 line
2.42.0
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for drmtest changes for running tests on multi-gpu (rev7)
In reply to Kamil Konieczny== Series Details ==
== Series Details ==
Series: drmtest changes for running tests on multi-gpu (rev7)
URL : https://patchwork.freedesktop.org/series/123991/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_13712 -> IGTPW_9920
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_9920 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_9920, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/index.html
Participating hosts (40 -> 38)
------------------------------
Additional (1): fi-pnv-d510
Missing (3): fi-kbl-soraka fi-hsw-4770 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_9920:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@hangcheck:
- fi-skl-guc: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/fi-skl-guc/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/fi-skl-guc/igt@i915_selftest@[email protected]
Known issues
------------
Here are the changes found in IGTPW_9920 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s0@smem:
- bat-dg2-9: [PASS][3] -> [INCOMPLETE][4] ([i915#9275])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/bat-dg2-9/igt@gem_exec_suspend@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-dg2-9/igt@gem_exec_suspend@[email protected]
* igt@i915_selftest@live@requests:
- bat-mtlp-8: [PASS][5] -> [ABORT][6] ([i915#9414])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/bat-mtlp-8/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-mtlp-8/igt@i915_selftest@[email protected]
* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-adlp-9: NOTRUN -> [SKIP][7] ([i915#3546]) +2 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-adlp-9/igt@[email protected]
- bat-dg2-11: NOTRUN -> [SKIP][8] ([i915#1845]) +3 other tests skip
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-dg2-11/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-d-dp-5:
- bat-adlp-11: [PASS][9] -> [ABORT][10] ([i915#8668])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
* igt@kms_psr@primary_page_flip:
- fi-pnv-d510: NOTRUN -> [SKIP][11] ([fdo#109271]) +31 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/fi-pnv-d510/igt@kms_psr@primary_page_flip.html
#### Possible fixes ####
* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: [DMESG-FAIL][12] ([i915#5334]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
* igt@kms_flip@basic-flip-vs-modeset@d-dp6:
- bat-adlp-11: [DMESG-FAIL][14] ([i915#6868]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/bat-adlp-11/igt@kms_flip@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-adlp-11/igt@kms_flip@[email protected]
* igt@kms_frontbuffer_tracking@basic:
- fi-bsw-nick: [FAIL][16] ([i915#9276]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/fi-bsw-nick/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/fi-bsw-nick/igt@[email protected]
* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [FAIL][18] ([IGT#3]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/fi-kbl-guc/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/fi-kbl-guc/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-frame-sequence@pipe-c-dp-5:
- bat-adlp-11: [ABORT][20] ([i915#8668] / [i915#9451]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13712/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/bat-adlp-11/igt@kms_pipe_crc_basic@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#6868]: https://gitlab.freedesktop.org/drm/intel/issues/6868
[i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
[i915#8668]: https://gitlab.freedesktop.org/drm/intel/issues/8668
[i915#8981]: https://gitlab.freedesktop.org/drm/intel/issues/8981
[i915#9275]: https://gitlab.freedesktop.org/drm/intel/issues/9275
[i915#9276]: https://gitlab.freedesktop.org/drm/intel/issues/9276
[i915#9414]: https://gitlab.freedesktop.org/drm/intel/issues/9414
[i915#9451]: https://gitlab.freedesktop.org/drm/intel/issues/9451
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7512 -> IGTPW_9920
CI-20190529: 20190529
CI_DRM_13712: 454adf17aa8ce15c81bff39e381d93002000a28f @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9920: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/index.html
IGT_7512: 2eb58faf82d3cd5e2e74154a7319cff56eb40762 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Testlist changes
----------------
+igt@xe_create@multigpu-create-massive-size -igt@xe_evict@evict-ccs-no-overcommit-parallel-instantfree-reopen -igt@xe_evict@evict-ccs-no-overcommit-parallel-instantfree-samefd -igt@xe_evict@evict-ccs-no-overcommit-parallel-nofree-reopen -igt@xe_evict@evict-ccs-no-overcommit-parallel-nofree-samefd -igt@xe_evict@evict-ccs-no-overcommit-standalone-instantfree-reopen -igt@xe_evict@evict-ccs-no-overcommit-standalone-instantfree-samefd -igt@xe_evict@evict-ccs-no-overcommit-standalone-nofree-reopen -igt@xe_evict@evict-ccs-no-overcommit-standalone-nofree-samefd -igt@xe_evict@evict-ccs-overcommit-parallel-instantfree-reopen -igt@xe_evict@evict-ccs-overcommit-parallel-instantfree-samefd -igt@xe_evict@evict-ccs-overcommit-parallel-nofree-reopen -igt@xe_evict@evict-ccs-overcommit-parallel-nofree-samefd -igt@xe_evict@evict-ccs-overcommit-standalone-instantfree-reopen -igt@xe_evict@evict-ccs-overcommit-standalone-instantfree-samefd -igt@xe_evict@evict-ccs-overcommit-standalone-nofree-reopen -igt@xe_evict@evict-ccs-overcommit-standalone-nofree-samefd
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/index.html
Patchwork
CI[igt-dev] ✓ CI.xeBAT: success for drmtest changes for running tests on multi-gpu (rev7)
In reply to Kamil Konieczny== Series Details ==
== Series Details ==
Series: drmtest changes for running tests on multi-gpu (rev7)
URL : https://patchwork.freedesktop.org/series/123991/
State : success
== Summary ==
CI Bug Log - changes from XEIGT_7512_BAT -> XEIGTPW_9920_BAT
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Participating hosts (4 -> 3)
------------------------------
Missing (1): bat-dg2-oem2
Known issues
------------
Here are the changes found in XEIGTPW_9920_BAT that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1:
- bat-adlp-7: [PASS][1] -> [FAIL][2] ([Intel XE#480]) +3 other tests fail
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7512/bat-adlp-7/igt@kms_flip@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9920/bat-adlp-7/igt@kms_flip@[email protected]
#### Possible fixes ####
* {igt@xe_create@create-execqueues-noleak}:
- bat-adlp-7: [FAIL][3] ([Intel XE#524]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7512/bat-adlp-7/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9920/bat-adlp-7/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[Intel XE#480]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/480
[Intel XE#524]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/524
Build changes
-------------
* IGT: IGT_7512 -> IGTPW_9920
* Linux: xe-411-090c3e92db31fbbe59a47d44f8dd7e8a1ccbcb36 -> xe-413-2ffd96b933e14e09cdd5f42c7a8264b50e2dbe31
IGTPW_9920: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9920/index.html
IGT_7512: 2eb58faf82d3cd5e2e74154a7319cff56eb40762 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
xe-411-090c3e92db31fbbe59a47d44f8dd7e8a1ccbcb36: 090c3e92db31fbbe59a47d44f8dd7e8a1ccbcb36 xe-413-2ffd96b933e14e09cdd5f42c7a8264b50e2dbe31: 2ffd96b933e14e09cdd5f42c7a8264b50e2dbe31
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9920/index.html