[gnome-remote-desktop] hwaccel-nvidia: Unload modules before releasing CUDA context



commit 66892ebca07543ee7a1914ee817e47a08bcc091e
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Thu Mar 3 08:49:03 2022 +0100

    hwaccel-nvidia: Unload modules before releasing CUDA context
    
    The lifetime of CUDA modules depends on the lifetime of the current
    CUDA context.
    This information is hidden and apparently only documented in the
    function "cuFuncGetModule".
    Unloading CUDA modules after releasing the CUDA context can sometimes,
    but not always lead to a crash.
    
    So, fix this situation by unloading the CUDA modules before releasing
    the CUDA context.

 src/grd-hwaccel-nvidia.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/grd-hwaccel-nvidia.c b/src/grd-hwaccel-nvidia.c
index a2b88f97..fad95cbe 100644
--- a/src/grd-hwaccel-nvidia.c
+++ b/src/grd-hwaccel-nvidia.c
@@ -865,6 +865,11 @@ grd_hwaccel_nvidia_dispose (GObject *object)
 {
   GrdHwAccelNvidia *hwaccel_nvidia = GRD_HWACCEL_NVIDIA (object);
 
+  g_clear_pointer (&hwaccel_nvidia->cu_module_avc_utils,
+                   hwaccel_nvidia->cuda_funcs->cuModuleUnload);
+  g_clear_pointer (&hwaccel_nvidia->cu_module_dmg_utils,
+                   hwaccel_nvidia->cuda_funcs->cuModuleUnload);
+
   if (hwaccel_nvidia->initialized)
     {
       run_function_in_egl_thread (hwaccel_nvidia, pop_cuda_context_in_egl_thread);
@@ -875,11 +880,6 @@ grd_hwaccel_nvidia_dispose (GObject *object)
       hwaccel_nvidia->initialized = FALSE;
     }
 
-  g_clear_pointer (&hwaccel_nvidia->cu_module_avc_utils,
-                   hwaccel_nvidia->cuda_funcs->cuModuleUnload);
-  g_clear_pointer (&hwaccel_nvidia->cu_module_dmg_utils,
-                   hwaccel_nvidia->cuda_funcs->cuModuleUnload);
-
   g_clear_pointer (&hwaccel_nvidia->cuda_lib, dlclose);
   g_clear_pointer (&hwaccel_nvidia->extra_cuda_funcs, g_free);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]