[PATCH i-g-t 1/2] lib/igt_kmod: Export igt_kmod_unbind()

Lucas De Marchi lucas.demarchi at intel.com
Wed Oct 30 14:11:16 UTC 2024


On Tue, Oct 29, 2024 at 05:08:07PM -0700, Umesh Nerlige Ramappa wrote:
>On Tue, Oct 22, 2024 at 10:05:01PM -0700, Lucas De Marchi wrote:
>>So it can be used directly by tests and other libs.
>>
>>Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>>---
>>lib/igt_kmod.c | 6 +++---
>>lib/igt_kmod.h | 2 ++
>>2 files changed, 5 insertions(+), 3 deletions(-)
>>
>>diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
>>index 75a0d057c..039309328 100644
>>--- a/lib/igt_kmod.c
>>+++ b/lib/igt_kmod.c
>>@@ -663,7 +663,7 @@ int __igt_intel_driver_unload(char **who, const char *driver)
>>/*
>> * Unbind driver from devices. Currently supports only PCI bus
>> */
>>-static int unbind(const char *driver)
>>+int igt_kmod_unbind(const char *mod_name)
>>{
>>	char path[PATH_MAX];
>>	struct dirent *de;
>>@@ -671,7 +671,7 @@ static int unbind(const char *driver)
>>	DIR *dir;
>>
>>	dirlen = snprintf(path, sizeof(path), "/sys/module/%s/drivers/pci:%s/",
>>-			  driver, driver);
>>+			  mod_name, mod_name);
>>	igt_assert(dirlen < sizeof(path));
>>
>>	dir = opendir(path);
>
>Maybe unrelated, but another issue I am seeing in this path is that 
>power/control attribute is not present in some kernel configs. Can we 

humn... I think that would only happen with !CONFIG_PM - is this really
your case? Also, do we actually have this running anywhere in CI?
I'd expect a bunch of other tests failing in this case.

Maybe we can just remove writing to this file since we are writing
"auto" (the default) and I don't expect anyone to be writing "on" for
our gpu. Even if it was "on", unbinding the driver would still work
AFAIR but the device would be left in D0.

Lucas De Marchi

>add a check in igt_kmod_unbind that would check if the attribute 
>exists and only then set it? If I do that, then unbind does go through 
>and the test passes as expected (with this series).
>
>Thanks,
>Umesh
>>@@ -744,7 +744,7 @@ igt_intel_driver_unload(const char *driver)
>>
>>int igt_xe_driver_unload(void)
>>{
>>-	unbind("xe");
>>+	igt_kmod_unbind("xe");
>>
>>	igt_kmod_unload("xe");
>>	if (igt_kmod_is_loaded("xe"))
>>diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
>>index ee1719a8f..193b95627 100644
>>--- a/lib/igt_kmod.h
>>+++ b/lib/igt_kmod.h
>>@@ -36,6 +36,8 @@ bool igt_kmod_has_param(const char *mod_name, const char *param);
>>int igt_kmod_load(const char *mod_name, const char *opts);
>>int igt_kmod_unload(const char *mod_name);
>>
>>+int igt_kmod_unbind(const char *mod_name);
>>+
>>int igt_audio_driver_unload(char **whom);
>>
>>int igt_intel_driver_load(const char *opts, const char *driver);
>>-- 
>>2.47.0
>>


More information about the igt-dev mailing list