From: "Krzysztofik, Janusz" <janusz.krzysztofik@intel.com>
To: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"Laguna, Lukasz" <lukasz.laguna@intel.com>
Cc: "Bernatowicz, Marcin" <marcin.bernatowicz@intel.com>
Subject: Re: [PATCH 1/2] lib/igt_device: Extract helper setting device filter from fd
Date: Thu, 23 Jul 2026 11:21:03 +0000 [thread overview]
Message-ID: <67a441c7b0cc018b5c5e3905586501d6b22ebe86.camel@intel.com> (raw)
In-Reply-To: <20260723095701.528790-1-lukasz.laguna@intel.com>
Hi Łukasz,
On Thu, 2026-07-23 at 11:57 +0200, Lukasz Laguna wrote:
> Helper sets device filter to the device corresponding to DRM device file
> descriptor. Move the implementation from core_hotunplug test into the
> library, so it can be reused in other tests.
>
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
> ---
> lib/igt_device.c | 22 ++++++++++++++++++++++
> lib/igt_device.h | 1 +
> tests/core_hotunplug.c | 18 ++----------------
> 3 files changed, 25 insertions(+), 16 deletions(-)
>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index c617a98bc..b7227dc91 100644
> --- a/lib/igt_device.c
> +++ b/lib/igt_device.c
I'm wondering why you've placed this function here, in lib/igt_device.c,
not in lib/igt_device_scan.c where it seems to fit better, at least to me.
Is that because of dependencies that the latter now doesn't need so would
have to be added?
Thanks,
Janusz
> @@ -31,6 +31,7 @@
> #endif
> #include "igt.h"
> #include "igt_device.h"
> +#include "igt_device_scan.h"
> #include "igt_sysfs.h"
> #include "igt_pci.h"
>
> @@ -351,3 +352,24 @@ igt_device_get_pci_upstream_port(int fd)
>
> return NULL;
> }
> +
> +/**
> + * igt_device_set_filter_from_fd:
> + * @fd: DRM device file descriptor
> + *
> + * Set device filter to the device corresponding to @fd.
> + */
> +void igt_device_set_filter_from_fd(int fd)
> +{
> + const char *filter_type = "sys:";
> + char filter[strlen(filter_type) + PATH_MAX + 1];
> + char *dst = stpcpy(filter, filter_type);
> + char path[PATH_MAX + 1];
> +
> + igt_assert(igt_sysfs_path(fd, path, PATH_MAX));
> + igt_ignore_warn(strncat(path, "/device", PATH_MAX - strlen(path)));
> + igt_assert(realpath(path, dst));
> +
> + igt_device_filter_free_all();
> + igt_assert_eq(igt_device_filter_add(filter), 1);
> +}
> diff --git a/lib/igt_device.h b/lib/igt_device.h
> index 781a72235..3ad08d3ee 100644
> --- a/lib/igt_device.h
> +++ b/lib/igt_device.h
> @@ -38,4 +38,5 @@ struct pci_device *igt_device_get_pci_root_port(int fd);
> struct pci_device *igt_device_get_pci_upstream_port(int fd);
>
> void igt_device_get_pci_slot_name(int fd, char *pci_slot_name);
> +void igt_device_set_filter_from_fd(int fd);
> #endif /* __IGT_DEVICE_H__ */
> diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
> index 7c9dae1bf..c6e9d4854 100644
> --- a/tests/core_hotunplug.c
> +++ b/tests/core_hotunplug.c
> @@ -35,6 +35,7 @@
> #include "i915/gem_create.h"
> #include "i915/perf.h"
> #include "igt.h"
> +#include "igt_device.h"
> #include "igt_device_scan.h"
> #include "igt_kmod.h"
> #include "igt_sysfs.h"
> @@ -550,21 +551,6 @@ static void post_healthcheck(struct hotunplug *priv)
> cleanup(priv);
> }
>
> -static void set_filter_from_device(int fd)
> -{
> - const char *filter_type = "sys:";
> - char filter[strlen(filter_type) + PATH_MAX + 1];
> - char *dst = stpcpy(filter, filter_type);
> - char path[PATH_MAX + 1];
> -
> - igt_assert(igt_sysfs_path(fd, path, PATH_MAX));
> - igt_ignore_warn(strncat(path, "/device", PATH_MAX - strlen(path)));
> - igt_assert(realpath(path, dst));
> -
> - igt_device_filter_free_all();
> - igt_assert_eq(igt_device_filter_add(filter), 1);
> -}
> -
> /* Subtests */
>
> static void unbind_rebind(struct hotunplug *priv)
> @@ -713,7 +699,7 @@ int igt_main()
> }
>
> /* Make sure subtests always reopen the same device */
> - set_filter_from_device(fd_drm);
> + igt_device_set_filter_from_fd(fd_drm);
>
> igt_assert_eq(close_device(fd_drm, "", "selected "), -1);
>
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
next prev parent reply other threads:[~2026-07-24 8:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 9:57 [PATCH 1/2] lib/igt_device: Extract helper setting device filter from fd Lukasz Laguna
2026-07-23 9:57 ` [PATCH 2/2] tests/sriov_basic: Validate PF unbind with VFs enabled Lukasz Laguna
2026-07-23 11:21 ` Krzysztofik, Janusz [this message]
2026-07-23 13:28 ` ✓ Xe.CI.BAT: success for series starting with [1/2] lib/igt_device: Extract helper setting device filter from fd Patchwork
2026-07-23 13:48 ` ✓ i915.CI.BAT: " Patchwork
2026-07-24 13:37 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-07-24 17:11 ` ✗ i915.CI.Full: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67a441c7b0cc018b5c5e3905586501d6b22ebe86.camel@intel.com \
--to=janusz.krzysztofik@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--cc=marcin.bernatowicz@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).