[PATCH i-g-t v3 21/41] lib/igt_device_scan: Allow to find device by sysname
Louis Chauvet
louis.chauvet at bootlin.com
Wed Jul 16 09:51:31 UTC 2025
Le 15/07/2025 à 12:24, José Expósito a écrit :
> The VKMS driver allows to create multiple devices handled by the same
> driver but with a different sysname.
>
> In order to differentiate between them, allow to find devices by
> sysname.
>
> Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
> lib/igt_device_scan.c | 22 ++++++++++++++++++++++
> lib/igt_device_scan.h | 2 ++
> 2 files changed, 24 insertions(+)
>
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index 0ab7b7a0a..abd8ca209 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -231,6 +231,7 @@ struct igt_device {
> char *subsystem;
> char *syspath;
> char *devnode;
> + char *sysname;
>
> /* /dev/dri/... paths */
> char *drm_card;
> @@ -680,6 +681,7 @@ static struct igt_device *igt_device_new_from_udev(struct udev_device *dev,
> idev->syspath = strdup_nullsafe(udev_device_get_syspath(dev));
> idev->subsystem = strdup_nullsafe(udev_device_get_subsystem(dev));
> idev->devnode = strdup_nullsafe(udev_device_get_devnode(dev));
> + idev->sysname = strdup_nullsafe(udev_device_get_sysname(dev));
>
> if (idev->devnode && strstr(idev->devnode, "/dev/dri/card"))
> idev->drm_card = strdup(idev->devnode);
> @@ -2145,6 +2147,26 @@ bool igt_device_card_match_pci(const char *filter,
> return __igt_device_card_match(filter, card, true);
> }
>
> +bool igt_device_find_card_by_sysname(const char *sysname,
> + struct igt_device_card *card)
> +{
> + struct igt_device *dev;
> +
> + igt_assert(card);
> + igt_assert(sysname);
> +
> + memset(card, 0, sizeof(*card));
> +
> + igt_list_for_each_entry(dev, &igt_devs.all, link) {
> + if (strcmp(dev->sysname, sysname) == 0) {
> + __copy_dev_to_card(dev, card);
> + return true;
> + }
> + }
> +
> + return false;
> +}
> +
> /**
> * igt_device_card_match_all
> * @filter: filter string.
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index e6e31e799..f24a193cd 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -94,6 +94,8 @@ bool igt_device_find_first_i915_discrete_card(struct igt_device_card *card);
> bool igt_device_find_integrated_card(struct igt_device_card *card);
> bool igt_device_find_first_xe_discrete_card(struct igt_device_card *card);
> bool igt_device_find_xe_integrated_card(struct igt_device_card *card);
> +bool igt_device_find_card_by_sysname(const char *sysname,
> + struct igt_device_card *card);
> char *igt_device_get_pretty_name(struct igt_device_card *card, bool numeric);
> int igt_open_card(struct igt_device_card *card);
> int igt_open_render(struct igt_device_card *card);
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the igt-dev
mailing list