[PATCH i-g-t v14 1/5] lib/igt_device_scan: Introduce filtering out non-PCI devices

Janusz Krzysztofik janusz.krzysztofik at linux.intel.com
Wed Mar 20 19:47:52 UTC 2024


On Wednesday, 20 March 2024 16:56:55 CET Kamil Konieczny wrote:
> From: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> 
> Introduced igt_device_filter_pci function that filters out non-PCI
> devices from IGT devices. This will help with checking multi-GPU
> tests after they skip due to detected only one GPU, in that case
> one can verify it after printing what GPUs are really on PCI bus.
> Such errors can happen when using wrong env IGT_DEVICE filter.
> 
> v6: extending description
> v9: fix memory leak in loop (Zbigniew)
> 
> Cc: Chris Wilson <chris.p.wilson at linux.intel.com>
> Cc: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
> Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski 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/igt_device_scan.c | 23 +++++++++++++++++++++++
>  lib/igt_device_scan.h |  2 ++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index fbf3fa482..9a2da3d62 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -1908,6 +1908,29 @@ const char *igt_device_filter_get(int num)
>  	return NULL;
>  }
>  
> +/**
> + * igt_device_filter_pci
> + *
> + * Filter devices to PCI only.
> + *
> + * Returns PCI devices count.
> + */
> +int igt_device_filter_pci(void)
> +{
> +	int count = 0;
> +	struct igt_device *dev, *tmp;

NIT: Code style: Taking into account the general IGT rule of following kernel 
rules where applicable, don't we want to use reverse Christmas tree ordering 
of local variable declarations, which is recognized as making the code easier 
to read, if there are no reasons to order them in a different way?

Anyway,
Reviewed-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>

> +
> +	igt_list_for_each_entry_safe(dev, tmp, &igt_devs.filtered, link)
> +		if (strcmp(dev->subsystem, "pci") != 0) {
> +			igt_list_del(&dev->link);
> +			free(dev);
> +		} else {
> +			count++;
> +		}
> +
> +	return count;
> +}
> +
>  static bool igt_device_filter_apply(const char *fstr)
>  {
>  	struct igt_device *dev, *tmp;
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index 48690e236..908733745 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -81,6 +81,8 @@ int igt_device_filter_add(const char *filter);
>  void igt_device_filter_free_all(void);
>  const char *igt_device_filter_get(int num);
>  
> +int igt_device_filter_pci(void);
> +
>  /* Use filter to match the device and fill card structure */
>  bool igt_device_card_match(const char *filter, struct igt_device_card *card);
>  bool igt_device_card_match_pci(const char *filter,
> 






More information about the igt-dev mailing list