[PATCH i-g-t v2] lib/drmtest: drop legacy path from filtered opens

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Feb 15 14:29:08 UTC 2024


Hi,
On 2024-02-14 at 14:16:10 +0100, Kamil Konieczny wrote:
> For some multi-GPU tests user can check them on single-GPU board
> with the help of repeating same card in --device option or
> environment var IGT_DEVICE:
> 
> sudo IGT_DEVICE=pci:vendor=Intel,card=0\;pci:vendor=Intel,card=0 \
> 	build/tests/gem_basic --r multigpu-create-close
> 
> but is unable to use it due to current implementation of device
> opening in function __drm_open_driver_another(). It will also
> prevent restricting multiGPU test to only two cards on three or
> four card board.
> 
> To allow this separate legacy opening path from filtered one and
> do not fallback into legacy path when index for card exceeds
> number of filtered devices. Use local opened fds table only for
> legacy opens so that path is not affected.
> When filters are used for multi-GPU tests user should provide all
> of them needed for testing, this could be done with the help of
> incrementing filters or with "card=all":
> 
> sudo IGT_DEVICE=pci:vendor=Intel,card=all \
> 	build/tests/gem_basic --r multigpu-create-close
> 
> v2: improving description, using filtered_count var (Janusz)
>   changing drmtest: to lib/drmtest: (Kamil)
>   adding Lukasz Laguna to Cc: (Kamil)
> 
> Cc: Arkadiusz Hiler <arek at hiler.eu>
> Cc: Chris Wilson <chris.p.wilson at linux.intel.com>
> Cc: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
> Cc: Lukasz Laguna <lukasz.laguna at intel.com>
> Cc: Petri Latvala <adrinael at adrinael.net>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> ---
>  lib/drmtest.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 52b5a2020..e718d6291 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -481,13 +481,12 @@ static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)
>   *
>   * This function opens device in the following order:
>   *
> - * 1. when --device arguments are present:
> + * 1. when --device arguments are present or IGT_DEVICE env var is used:
>   *   * 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
> + *   * if there is no idx-th filter fail with -1
>   *   * first device maching the filter is selected
> - *   * if it's already opened (for indexes = 0..idx-1) we fail with -1
> - *   * otherwise open the device and return the fd
> + *   * open the device and return the fd
>   *
>   * 2. compatibility mode - open the first DRM device we can find that is not
>   *    already opened for indexes 0..idx-1, searching up to 16 device nodes
> @@ -526,12 +525,19 @@ static bool __get_card_for_nth_filter(int idx, struct igt_device_card *card)
>   */
>  int __drm_open_driver_another(int idx, int chipset)
>  {
> +	int filter_count = igt_device_filter_count();
>  	int fd = -1;
>  
> -	if (chipset != DRIVER_VGEM && igt_device_filter_count() > idx) {
> +	if (chipset != DRIVER_VGEM && filter_count) {
>  		struct igt_device_card card;
>  		bool found;
>  
> +		if (idx < 0 || idx >= filter_count) {
> +			igt_warn("Cannot open, index out of bounds: %d, filter_count=%d\n",

This warn is causing fails in igt at kms_prime@basic-crc-vgem on DG2
instead of skip, I will turn it into igt_debug and send v3.

Regards,
Kamil

> +				 idx, filter_count);
> +			return -1;
> +		}
> +
>  		found = __get_card_for_nth_filter(idx, &card);
>  
>  		if (!found) {
> @@ -542,19 +548,17 @@ int __drm_open_driver_another(int idx, int chipset)
>  		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
>  			fd = __open_driver_exact(card.card, chipset);
>  
>  	} else {
>  		/* no filter for device idx, let's open whatever is available */
>  		fd = __open_driver("/dev/dri/card", 0, chipset, idx);
> +		if (fd >= 0)
> +			_set_opened_fd(idx, fd);
>  	}
>  
>  	if (fd >= 0) {
> -		_set_opened_fd(idx, fd);
> -
>  		/* Cache xe_device struct. */
>  		if (is_xe_device(fd))
>  			xe_device_get(fd);
> -- 
> 2.42.0
> 


More information about the igt-dev mailing list