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 v4 3/4] lib/drmtest: invalidate cached fds after unbind
Date: Tue, 26 Nov 2024 19:10:22 +0100 [thread overview]
Message-ID: <20241126181024.1398259-5-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20241126181024.1398259-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 00d5822fd..e903a9857 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -1448,6 +1448,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.34.1
next prev parent reply other threads:[~2024-11-26 18:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 18:10 [PATCH i-g-t v3 0/2] Ignore more warns in xe_wedged tests Kamil Konieczny
2024-11-26 18:10 ` [PATCH i-g-t v4 0/4] " Kamil Konieczny
2024-11-26 18:10 ` [PATCH i-g-t v4 1/4] tests/intel/xe_wedged: Ignore more dmesg warnings Kamil Konieczny
2024-11-26 23:09 ` Matt Roper
2024-11-26 18:10 ` [PATCH i-g-t v4 2/4] HAX/DO_NOT_MERGE: xe-fast-feedback: test xe_wedged Kamil Konieczny
2024-11-26 18:10 ` Kamil Konieczny [this message]
2024-12-19 15:17 ` [PATCH i-g-t v4 3/4] lib/drmtest: invalidate cached fds after unbind Lucas De Marchi
2024-11-26 18:10 ` [PATCH i-g-t v4 4/4] lib/igt_sysfs: improve xe sysfs checks Kamil Konieczny
2024-11-26 19:07 ` ✗ Xe.CI.BAT: failure for Ignore more warns in xe_wedged tests (rev5) Patchwork
2024-11-26 20:15 ` ✗ Xe.CI.Full: " Patchwork
2024-11-26 20:40 ` ✓ i915.CI.BAT: success " Patchwork
2024-11-26 21:50 ` ✗ i915.CI.Full: failure " Patchwork
2024-11-29 21:21 ` ✗ Xe.CI.BAT: failure for Ignore more warns in xe_wedged tests (rev6) Patchwork
2024-11-30 6:06 ` ✗ Xe.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=20241126181024.1398259-5-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