-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for nvidia_modeset #709
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,23 +92,64 @@ 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("nvidia_uvm") == 1) { | ||
int retries = 30; | ||
bb_log(LOG_INFO, "Unloading nvidia_uvm driver\n"); | ||
char *mod_argv[] = { | ||
"modprobe", | ||
"-r", | ||
"nvidia_uvm", | ||
"nvidia_modeset", | ||
NULL | ||
}; | ||
bb_run_fork_wait(mod_argv, 10); | ||
while (retries-- > 0 && module_is_loaded("nvidia_uvm") == 1) { | ||
usleep(100000); | ||
} | ||
if (module_is_loaded(driver) == 1) { | ||
bb_log(LOG_ERR, "Unloading %s driver timed out.\n", driver); | ||
return 0; | ||
} | ||
} | ||
|
||
else if (module_is_loaded("nvidia_modeset") == 1) { | ||
int retries = 30; | ||
bb_log(LOG_INFO, "Unloading %s driver\n", driver); | ||
bb_log(LOG_INFO, "Unloading nvidia_modeset driver\n"); | ||
char *mod_argv[] = { | ||
"rmmod", | ||
driver, | ||
"modprobe", | ||
"-r", | ||
"nvidia_modeset", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||
NULL | ||
}; | ||
bb_run_fork_wait(mod_argv, 10); | ||
while (retries-- > 0 && module_is_loaded(driver) == 1) { | ||
while (retries-- > 0 && module_is_loaded("nvidia_modeset") == 1) { | ||
usleep(100000); | ||
} | ||
if (module_is_loaded(driver) == 1) { | ||
bb_log(LOG_ERR, "Unloading %s driver timed out.\n", 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; | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just came across this line of code. You need to add
driver
as well, otherwise you will unload onlymodeset
module, but notnvidia
. Alternatively, you can change the logic removingelse if
statements and unload modules one by one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case, the driver line was unnecessary, since
modprobe -r nvidia_modeset
also unloadednvidia
. This may be specific to my system (Lenovo ThinkPad W540 running Arch Linux).I agree with @invidian below that the whole thing needs a rewrite, not only because it's an inefficient fix, but a superior function would be modular, i.e. if nVidia starts throwing in
nvidia_x
with a new driver, we could simply addnvidia_x
alongsidenvidia
,nvidia_modeset
, andnvidia_uvm
. Auto-detection would be ideal by parsing the output oflsmod | grep nvidia
and automagically generating a list of modules to feed tomodule_unload
based on that particular system.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arafey I have Arch Linux also, but I use
nvidia-dkms
package, so it might be somehow introduce a different behaviour, though, I haven't seen a case where one module would unload another unless you write so in modprobe.conf.