From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Subject: [PATCH i-g-t v3 3/4] lib/drmtest: invalidate cached fds after unbind
Date: Fri, 8 Nov 2024 21:18:38 +0100 [thread overview]
Message-ID: <20241108201839.119079-4-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20241108201839.119079-1-kamil.konieczny@linux.intel.com>
After driver unbind or reload cached drm file descriptors could
become stale, so there is no point in preventing calling
drm_open_driver() again. This should prevent errors like:
(xe_wedged:3680) drmtest-DEBUG: Condition stat(path, &new) != 0 occurred
in function _is_already_opened, file ../lib/drmtest.c:407
(xe_wedged:3680) drmtest-WARNING: card maching filter 0 is already opened
when test tries to open again driver and make checks if
it is functional.
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
lib/drmtest.c | 18 ++++++++++++++++++
lib/drmtest.h | 2 ++
lib/igt_sysfs.c | 1 +
tests/core_hotunplug.c | 1 +
4 files changed, 22 insertions(+)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2dd4540b8..2919a4891 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -726,6 +726,24 @@ static void cancel_work_at_exit_render(int sig)
at_exit_drm_render_fd = -1;
}
+/**
+ * __drm_invalidate_opened_fds:
+ *
+ * Invalidate drmtest internal fd caches.
+ */
+void __drm_invalidate_opened_fds(void)
+{
+ _opened_fds_count = 0;
+ if (at_exit_drm_fd >= 0)
+ close(at_exit_drm_fd);
+
+ at_exit_drm_fd = -1;
+ if (at_exit_drm_render_fd >= 0)
+ close(at_exit_drm_render_fd);
+
+ at_exit_drm_render_fd = -1;
+}
+
static const char *chipset_to_vendor_str(int chipset)
{
return chipset == DRIVER_XE ? chipset_to_str(DRIVER_INTEL) : chipset_to_str(chipset);
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 27e5a18e2..fb37a1070 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -129,6 +129,8 @@ int drm_reopen_driver(int fd);
int drm_prepare_filtered_multigpu(int chipset);
int drm_open_filtered_card(int idx);
+void __drm_invalidate_opened_fds(void);
+
void igt_require_amdgpu(int fd);
void igt_require_intel(int fd);
void igt_require_i915(int fd);
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 26a3aa31f..356b20f29 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -1377,6 +1377,7 @@ int xe_sysfs_driver_do(int xe_device, char pci_slot[], enum xe_sysfs_driver_acti
sysfs = open("/sys/bus/pci/drivers/xe", O_DIRECTORY);
igt_assert(sysfs);
+ __drm_invalidate_opened_fds();
switch(action) {
case XE_SYSFS_DRIVER_BIND:
diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index 7f17f4423..39042f200 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -489,6 +489,7 @@ static bool healthcheck(struct hotunplug *priv, bool recover)
/* device name may have changed, rebuild IGT device list */
igt_devices_scan(true);
+ __drm_invalidate_opened_fds();
node_healthcheck(priv, recover ? FLAG_RECOVER : 0);
if (!priv->failure)
--
2.47.0
next prev parent reply other threads:[~2024-11-08 20:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 20:18 [PATCH i-g-t v3 0/2] Ignore more warns in xe_wedged tests Kamil Konieczny
2024-11-08 20:18 ` [PATCH i-g-t v3 1/4] tests/intel/xe_wedged: Ignore more dmesg warnings Kamil Konieczny
2024-11-08 22:25 ` Rodrigo Vivi
2024-11-08 20:18 ` [PATCH i-g-t v3 2/4] HAX/DO_NOT_MERGE: xe-fast-feedback: test xe_wedged Kamil Konieczny
2024-11-08 20:18 ` Kamil Konieczny [this message]
2024-11-08 20:18 ` [PATCH i-g-t v3 4/4] lib/igt_sysfs: improve xe sysfs checks Kamil Konieczny
2024-11-08 21:23 ` ✗ Fi.CI.BAT: failure for Ignore more warns in xe_wedged tests (rev3) Patchwork
2024-11-08 22:11 ` ✗ CI.xeBAT: " Patchwork
2024-11-10 0:33 ` ✗ CI.xeFULL: " Patchwork
2024-11-26 16:42 ` Kamil Konieczny
2024-11-25 21:35 ` ✗ i915.CI.BAT: failure for Ignore more warns in xe_wedged tests (rev4) Patchwork
2024-11-26 16:36 ` Kamil Konieczny
2024-11-25 21:43 ` ✗ Xe.CI.BAT: " Patchwork
2024-11-26 16:38 ` Kamil Konieczny
2024-11-26 0:12 ` ✗ Xe.CI.Full: " Patchwork
2024-11-26 16:40 ` Kamil Konieczny
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=20241108201839.119079-4-kamil.konieczny@linux.intel.com \
--to=kamil.konieczny@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.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