From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Dominik Karol Piątkowski" <dominik.karol.piatkowski@intel.com>,
"Janusz Krzysztofik" <janusz.krzysztofik@linux.intel.com>,
"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>
Subject: [PATCH i-g-t v14 2/5] lib/drmtest: Introduced drm_open_driver_another
Date: Wed, 20 Mar 2024 16:56:56 +0100 [thread overview]
Message-ID: <20240320155659.33518-3-kamil.konieczny@linux.intel.com> (raw)
In-Reply-To: <20240320155659.33518-1-kamil.konieczny@linux.intel.com>
From: Dominik Karol Piątkowski <dominik.karol.piatkowski@intel.com>
For user convenience, introduce drm_open_driver_another as
a wrapper for __drm_open_driver_another with skip on fail.
Also add counterpart to open: __drm_close_driver() with
no warning for non-opened fd.
v2: rebased (Kamil)
v6: reword description (Janusz)
v10: change assert into skip, add TODO note about atomic reset
before tests starts for i915 and on exit path (Janusz)
add __drm_close_driver() (Kamil)
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Signed-off-by: "Dominik Karol Piątkowski" <dominik.karol.piatkowski@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
lib/drmtest.c | 109 ++++++++++++++++++++++++++++++++++----------------
lib/drmtest.h | 2 +
2 files changed, 76 insertions(+), 35 deletions(-)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 52b5a2020..f8810da43 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -241,6 +241,35 @@ static void modulename_to_chipset(const char *name, unsigned int *chip)
}
}
+static const char *chipset_to_str(int chipset)
+{
+ switch (chipset) {
+ case DRIVER_INTEL:
+ return "intel";
+ case DRIVER_V3D:
+ return "v3d";
+ case DRIVER_VC4:
+ return "vc4";
+ case DRIVER_VGEM:
+ return "vgem";
+ case DRIVER_AMDGPU:
+ return "amdgpu";
+ case DRIVER_PANFROST:
+ return "panfrost";
+ case DRIVER_MSM:
+ return "msm";
+ case DRIVER_XE:
+ return "xe";
+ case DRIVER_VMWGFX:
+ return "vmwgfx";
+ case DRIVER_ANY:
+ return "any";
+ default:
+ return "other";
+ }
+}
+
+
/*
* Logs path of opened device. Device path opened for the first time is logged at info level,
* subsequent opens (if any) are logged at debug level.
@@ -563,6 +592,27 @@ int __drm_open_driver_another(int idx, int chipset)
return fd;
}
+/**
+ * drm_open_driver_another:
+ * @idx: index of the device you are opening
+ * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
+ *
+ * A wrapper for __drm_open_driver with skip on fail.
+ *
+ * Returns:
+ * An open DRM fd or skips
+ */
+int drm_open_driver_another(int idx, int chipset)
+{
+ int fd = __drm_open_driver_another(idx, chipset);
+
+ igt_skip_on_f(fd < 0, "No known gpu found for chipset flags %d (%s)\n",
+ chipset, chipset_to_str(chipset));
+
+ /* TODO: for i915 and idx > 0 add atomic reset before test */
+ return fd;
+}
+
/**
* __drm_open_driver:
* @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
@@ -643,34 +693,6 @@ static void cancel_work_at_exit_render(int sig)
at_exit_drm_render_fd = -1;
}
-static const char *chipset_to_str(int chipset)
-{
- switch (chipset) {
- case DRIVER_INTEL:
- return "intel";
- case DRIVER_V3D:
- return "v3d";
- case DRIVER_VC4:
- return "vc4";
- case DRIVER_VGEM:
- return "vgem";
- case DRIVER_AMDGPU:
- return "amdgpu";
- case DRIVER_PANFROST:
- return "panfrost";
- case DRIVER_MSM:
- return "msm";
- case DRIVER_XE:
- return "xe";
- case DRIVER_VMWGFX:
- return "vmwgfx";
- case DRIVER_ANY:
- return "any";
- default:
- return "other";
- }
-}
-
static const char *chipset_to_vendor_str(int chipset)
{
return chipset == DRIVER_XE ? chipset_to_str(DRIVER_INTEL) : chipset_to_str(chipset);
@@ -733,12 +755,33 @@ static bool is_valid_fd(int fd)
return false;
}
+/**
+ * __drm_close_driver:
+ * @fd: a drm file descriptor
+ *
+ * Check the given drm file descriptor @fd is valid and if not,
+ * return -1. For valid fd close it and make cleanups.
+ *
+ * Returns: 0 on success or -1 on error.
+ */
+int __drm_close_driver(int fd)
+{
+ if (!is_valid_fd(fd))
+ return -1;
+
+ /* Remove xe_device from cache. */
+ if (is_xe_device(fd))
+ xe_device_put(fd);
+
+ return close(fd);
+}
+
/**
* drm_close_driver:
* @fd: a drm file descriptor
*
- * Check the given drm file descriptor @fd is valid & Close if it is
- * an valid drm fd.
+ * Check the given drm file descriptor @fd is valid and if not issue warning.
+ * For valid fd close it and make cleanups.
*
* Returns: 0 on success or -1 on error.
*/
@@ -750,11 +793,7 @@ int drm_close_driver(int fd)
return -1;
}
- /* Remove xe_device from cache. */
- if (is_xe_device(fd))
- xe_device_put(fd);
-
- return close(fd);
+ return __drm_close_driver(fd);
}
/**
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 588d7da17..bbe5f252f 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -110,12 +110,14 @@ void __set_forced_driver(const char *name);
int __drm_open_device(const char *name, unsigned int chipset);
void drm_load_module(unsigned int chipset);
+int drm_open_driver_another(int idx, int chipset);
int drm_open_driver(int chipset);
int drm_open_driver_master(int chipset);
int drm_open_driver_render(int chipset);
int __drm_open_driver_another(int idx, int chipset);
int __drm_open_driver(int chipset);
int __drm_open_driver_render(int chipset);
+int __drm_close_driver(int fd);
int drm_close_driver(int fd);
int drm_reopen_driver(int fd);
--
2.42.0
next prev parent reply other threads:[~2024-03-20 15:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 15:56 [PATCH i-g-t v14 0/5] introduce Xe multigpu and other multi-GPU helpers Kamil Konieczny
2024-03-20 15:56 ` [PATCH i-g-t v14 1/5] lib/igt_device_scan: Introduce filtering out non-PCI devices Kamil Konieczny
2024-03-20 19:47 ` Janusz Krzysztofik
2024-03-20 15:56 ` Kamil Konieczny [this message]
2024-03-20 19:49 ` [PATCH i-g-t v14 2/5] lib/drmtest: Introduced drm_open_driver_another Janusz Krzysztofik
2024-03-20 15:56 ` [PATCH i-g-t v14 3/5] lib/igt_multigpu: Introduce library for multi-GPU scenarios Kamil Konieczny
2024-03-20 19:49 ` Janusz Krzysztofik
2024-03-20 15:56 ` [PATCH i-g-t v14 4/5] tests/intel/xe_exec_basic: add multigpu subtests Kamil Konieczny
2024-03-20 19:49 ` Janusz Krzysztofik
2024-03-21 13:07 ` Piatkowski, Dominik Karol
2024-03-20 15:56 ` [PATCH i-g-t v14 5/5] tests/intel/gem_exec_gttfill: simplify multiGPU subtest Kamil Konieczny
2024-03-20 19:50 ` Janusz Krzysztofik
2024-03-20 18:32 ` ✓ Fi.CI.BAT: success for introduce Xe multigpu and other multi-GPU helpers (rev14) Patchwork
2024-03-20 18:33 ` ✓ CI.xeBAT: " Patchwork
2024-03-20 19:47 ` [PATCH i-g-t v14 0/5] introduce Xe multigpu and other multi-GPU helpers Janusz Krzysztofik
2024-03-21 7:46 ` ✗ Fi.CI.IGT: failure for introduce Xe multigpu and other multi-GPU helpers (rev14) Patchwork
2024-03-21 12:49 ` Kamil Konieczny
2024-03-25 12:52 ` Illipilli, TejasreeX
2024-03-25 8:28 ` ✓ Fi.CI.IGT: success " 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=20240320155659.33518-3-kamil.konieczny@linux.intel.com \
--to=kamil.konieczny@linux.intel.com \
--cc=dominik.karol.piatkowski@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=zbigniew.kempczynski@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