0002-bb_nvidia_modeset-detection_bug699_02.patch 1.5 KB

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