All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 2/3] lib/igt_kmod: add support for Xe driver
Date: Wed, 22 Mar 2023 13:33:00 +0100	[thread overview]
Message-ID: <20230322123301.1791267-3-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20230322123301.1791267-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

Change the kmod logic to also work with the Xe driver.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 lib/igt_kmod.c | 34 +++++++++++++++++-----------------
 lib/igt_kmod.h | 32 +++++++++++++++++++++++++++++---
 2 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 6d6ecf0187ed..ccf0063ca1b1 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -404,23 +404,23 @@ static void *strdup_realloc(char *origptr, const char *strdata)
 }
 
 /**
- * igt_i915_driver_load:
- * @opts: options to pass to i915 driver
+ * igt_intel_driver_load:
+ * @opts: options to pass to Intel driver
  *
- * Loads the i915 driver and its dependencies.
+ * Loads an Intel driver and its dependencies.
  *
  */
 int
-igt_i915_driver_load(const char *opts)
+igt_intel_driver_load(const char *opts, const char *driver)
 {
 	int ret;
 
 	if (opts)
-		igt_info("Reloading i915 with %s\n\n", opts);
+		igt_info("Reloading %s with %s\n\n", driver, opts);
 
-	ret = igt_kmod_load("i915", opts);
+	ret = igt_kmod_load(driver, opts);
 	if (ret) {
-		igt_debug("Could not load i915\n");
+		igt_debug("Could not load %s\n", driver);
 		return ret;
 	}
 
@@ -496,7 +496,7 @@ int igt_audio_driver_unload(char **who)
 	return igt_always_unload_audio_driver(who);
 }
 
-int __igt_i915_driver_unload(char **who)
+int __igt_intel_driver_unload(char **who, const char *driver)
 {
 	int ret;
 
@@ -530,11 +530,11 @@ int __igt_i915_driver_unload(char **who)
 		}
 	}
 
-	if (igt_kmod_is_loaded("i915")) {
-		ret = igt_kmod_unload("i915", 0);
+	if (igt_kmod_is_loaded(driver)) {
+		ret = igt_kmod_unload(driver, 0);
 		if (ret) {
 			if (who)
-				*who = strdup_realloc(*who, "i915");
+				*who = strdup_realloc(*who, driver);
 
 			return ret;
 		}
@@ -544,18 +544,18 @@ int __igt_i915_driver_unload(char **who)
 }
 
 /**
- * igt_i915_driver_unload:
+ * igt_intel_driver_unload:
  *
- * Unloads the i915 driver and its dependencies.
+ * Unloads an Intel driver and its dependencies.
  *
  */
 int
-igt_i915_driver_unload(void)
+igt_intel_driver_unload(const char *driver)
 {
 	char *who = NULL;
 	int ret;
 
-	ret = __igt_i915_driver_unload(&who);
+	ret = __igt_intel_driver_unload(&who, driver);
 	if (ret) {
 		igt_warn("Could not unload %s\n", who);
 		igt_kmod_list_loaded();
@@ -572,8 +572,8 @@ igt_i915_driver_unload(void)
 	igt_kmod_unload("drm_kms_helper", 0);
 	igt_kmod_unload("drm", 0);
 
-	if (igt_kmod_is_loaded("i915")) {
-		igt_warn("i915.ko still loaded!\n");
+	if (igt_kmod_is_loaded("driver")) {
+		igt_warn("%s.ko still loaded!\n", driver);
 		return -EBUSY;
 	}
 
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29fb175..d05af4a69410 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -38,9 +38,35 @@ int igt_kmod_unload(const char *mod_name, unsigned int flags);
 
 int igt_audio_driver_unload(char **whom);
 
-int igt_i915_driver_load(const char *opts);
-int igt_i915_driver_unload(void);
-int __igt_i915_driver_unload(char **whom);
+int igt_intel_driver_load(const char *opts, const char *driver);
+int igt_intel_driver_unload(const char *driver);
+int __igt_intel_driver_unload(char **who, const char *driver);
+
+static inline int igt_i915_driver_load(const char *opts)
+{
+	return igt_intel_driver_load(opts, "i915");
+}
+
+static inline int igt_i915_driver_unload(void)
+{
+	return igt_intel_driver_unload("i915");
+}
+
+static inline int __igt_i915_driver_unload(char **whom)
+{
+	return __igt_intel_driver_unload(whom, "i915");
+};
+
+static inline int igt_xe_driver_load(const char *opts)
+{
+	return igt_intel_driver_load(opts, "xe");
+}
+
+
+static inline int igt_xe_driver_unload(void)
+{
+	return igt_intel_driver_unload("xe");
+}
 
 int igt_amdgpu_driver_load(const char *opts);
 int igt_amdgpu_driver_unload(void);
-- 
2.39.2

  parent reply	other threads:[~2023-03-22 12:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 12:32 [igt-dev] [PATCH i-g-t v2 0/3] xe/xe_module_load: add a test to load/unload Xe driver Mauro Carvalho Chehab
2023-03-22 12:32 ` [igt-dev] [PATCH i-g-t v2 1/3] intel-ci: update blacklists to work with the " Mauro Carvalho Chehab
2023-03-22 12:33 ` Mauro Carvalho Chehab [this message]
2023-03-22 12:33 ` [igt-dev] [PATCH i-g-t v2 3/3] xe/xe_module_load: add a test to load/unload " Mauro Carvalho Chehab
2023-03-22 13:18 ` [igt-dev] ✗ Fi.CI.BUILD: failure for " 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=20230322123301.1791267-3-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.