[PATCH i-g-t v2 23/43] lib/igt_device_scan: Allow to find device by sysname
Kamil Konieczny
kamil.konieczny at linux.intel.com
Wed Jun 11 11:09:16 UTC 2025
Hi José,
On 2025-03-13 at 18:32:58 +0100, José Expósito wrote:
> 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>
Please rebase your series as few of configfs changes got merged.
Also for this change +cc Zbigniew
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski at intel.com>
Regards,
Kamil
> ---
> 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 711bedc5c..5cbd347a3 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;
> @@ -664,6 +665,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);
> @@ -2059,6 +2061,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_get_pretty_name
> * @card: pointer to igt_device_card struct
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index 92741fe3c..2a61777b0 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -92,6 +92,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);
> --
> 2.48.1
>
More information about the igt-dev
mailing list