File nvidia-uvm-modeset-drm-support.patch of Package bumblebee

diff -urN bumblebee-3.2.1.orig/src/bbsecondary.c bumblebee-3.2.1/src/bbsecondary.c
--- bumblebee-3.2.1.orig/src/bbsecondary.c	2013-04-26 17:49:03.000000000 +0200
+++ bumblebee-3.2.1/src/bbsecondary.c	2016-04-11 11:16:03.561478327 +0200
@@ -119,6 +119,24 @@
     if (!module_load(module_name, driver_name)) {
       set_bb_error("Could not load GPU driver");
       return false;
+    } else {
+      /* XXX NVIDIA UVM-DRM support */
+      if (strstr(module_name, "nvidia")) { /* We are using NVIDIA's proprietary driver */
+        char drm_module_name[1024];
+        sprintf(drm_module_name, "%s-drm", module_name);
+        if (!module_load(drm_module_name, "nvidia_drm")) {
+          char log_string[1024];
+          sprintf(log_string, "Cannot load DRM module: %s\n", drm_module_name);
+          bb_log(LOG_ERR, log_string);
+        }
+        char uvm_module_name[1024];
+        sprintf(uvm_module_name, "%s-uvm", module_name);
+        if (!module_load(uvm_module_name, "nvidia_uvm")) {
+          char log_string[1024];
+          sprintf(log_string, "Cannot load UVM module: %s\n", uvm_module_name);
+          bb_log(LOG_ERR, log_string);
+        }
+      }
     }
   }
   return true;
@@ -232,6 +250,12 @@
       }
       /* unload the driver loaded by the graphica card */
       if (pci_get_driver(driver, pci_bus_id_discrete, sizeof driver)) {
+        /* XXX NVIDIA UVM,MODESET support */
+        if (strstr(driver, "nvidia")) {
+          module_unload("nvidia_drm");
+          module_unload("nvidia_modeset");
+          module_unload("nvidia_uvm");
+        }
         module_unload(driver);
       }