1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
From 09d537e8e5313cd0f2c7bf6620ca70454de8a04a Mon Sep 17 00:00:00 2001
From: Abuzer Rafey <abuzer@rafey.ch>
Date: Tue, 8 Dec 2015 12:01:05 -0500
Subject: [PATCH] Added nvidia_modeset detection for issue #699
---
src/module.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/module.c b/src/module.c
index 6b6cb09..eea0139 100644
--- a/src/module.c
+++ b/src/module.c
@@ -92,13 +92,15 @@ int module_load(char *module_name, char *driver) {
* @return 1 if the driver is succesfully unloaded, 0 otherwise
*/
int module_unload(char *driver) {
- if (module_is_loaded(driver) == 1) {
+
+ if (module_is_loaded(driver) == 1 &&
+ module_is_loaded("nvidia_modeset") == 1) {
int retries = 30;
bb_log(LOG_INFO, "Unloading %s driver\n", driver);
char *mod_argv[] = {
"modprobe",
"-r",
- "nvidia_modeset",
+ "nvidia-modeset",
driver,
NULL
};
@@ -111,6 +113,24 @@ int module_unload(char *driver) {
return 0;
}
}
+ else if (module_is_loaded(driver) == 1) {
+ int retries = 30;
+ bb_log(LOG_INFO, "Unloading %s driver\n", driver);
+ char *mod_argv[] = {
+ "modprobe",
+ "-r",
+ driver,
+ NULL
+ };
+ bb_run_fork_wait(mod_argv, 10);
+ while (retries-- > 0 && module_is_loaded(driver) == 1) {
+ usleep(100000);
+ }
+ if (module_is_loaded(driver) == 1) {
+ bb_log(LOG_ERR, "Unloading %s driver timed out.\n", driver);
+ return 0;
+ }
+ }
return 1;
}
|