Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 09-17-09, 04:13 PM   #13
ibuclaw
Registered User
 
Join Date: Apr 2009
Posts: 5
Default Re: NViDIA on Linux 2.6.31

UPDATE: Wrote a patch! And it is working!!!

This is inspired by the following link: http://article.gmane.org/gmane.linux.rt.user/5065

Code:
diff -Naur NVIDIA-Linux-x86-190.32-orig/usr/src/nv/nv-linux.h NVIDIA-Linux-x86-190.32/usr/src/nv/nv-linux.h
--- NVIDIA-Linux-x86-190.32-orig/usr/src/nv/nv-linux.h	2009-09-02 11:54:49.000000000 +0100
+++ NVIDIA-Linux-x86-190.32/usr/src/nv/nv-linux.h	2009-09-17 21:05:45.000000000 +0100
@@ -742,20 +742,28 @@
 #define nv_down(lock)                   down(&lock)
 #define nv_up(lock)                     up(&lock)
 
+#if defined(CONFIG_PREEMPT_RT) && !defined(init_MUTEX)
+#  define nv_spin_lock_init(lock)              atomic_spin_lock_init(lock)
+#  define nv_spin_lock_irqsave(lock, irq)      atomic_spin_lock_irqsave(lock, irq)
+#  define nv_spin_unlock_irqrestore(lock, irq) atomic_spin_unlock_irqrestore(lock, irq)
+#else
+#  define nv_spin_lock_init(lock)              spin_lock_init(lock)
+#  define nv_spin_lock_irqsave(lock, irq)      spin_lock_irqsave(lock, irq)
+#  define nv_spin_unlock_irqrestore(lock, irq) spin_unlock_irqrestore(lock, irq)
+#endif
+
 #if defined(CONFIG_PREEMPT_RT)
-#define NV_INIT_MUTEX(mutex) init_MUTEX(mutex)
+#  if defined(init_MUTEX)
+#    define nv_spinlock_t raw_spinlock_t
+#  else
+#    define nv_spinlock_t atomic_spinlock_t
+#  endif
 #else
-#if !defined(__SEMAPHORE_INITIALIZER) && defined(__COMPAT_SEMAPHORE_INITIALIZER)
-#define __SEMAPHORE_INITIALIZER __COMPAT_SEMAPHORE_INITIALIZER
-#endif
-#define NV_INIT_MUTEX(mutex)                       \
-    {                                              \
-        struct semaphore __mutex =                 \
-            __SEMAPHORE_INITIALIZER(*(mutex), 1);  \
-        *(mutex) = __mutex;                        \
-    }
+#  define nv_spinlock_t   spinlock_t
 #endif
 
+#define NV_INIT_MUTEX(mutex) sema_init(mutex, 1)
+
 #if defined (KERNEL_2_4)
 #  define NV_IS_SUSER()                 suser()
 #  define NV_PCI_DEVICE_NAME(dev)       ((dev)->name)
diff -Naur NVIDIA-Linux-x86-190.32-orig/usr/src/nv/os-interface.c NVIDIA-Linux-x86-190.32/usr/src/nv/os-interface.c
--- NVIDIA-Linux-x86-190.32-orig/usr/src/nv/os-interface.c	2009-09-02 11:54:48.000000000 +0100
+++ NVIDIA-Linux-x86-190.32/usr/src/nv/os-interface.c	2009-09-17 21:05:45.000000000 +0100
@@ -108,11 +108,7 @@
 {
     nv_stack_t        *sp;
     struct completion  completion;
-#if defined(CONFIG_PREEMPT_RT)
-    raw_spinlock_t     lock;
-#else
-    spinlock_t         lock;
-#endif
+    nv_spinlock_t      lock;
     S032               count;
 } os_sema_t;
 
@@ -148,7 +144,7 @@
     os_sema = (os_sema_t *)*ppSema;
     os_sema->sp = sp;
     init_completion(&os_sema->completion);
-    spin_lock_init(&os_sema->lock);
+    nv_spin_lock_init(&os_sema->lock);
     os_sema->count = 1;
 
     if (nv_os_smp_barrier_init())
@@ -199,18 +195,18 @@
     os_sema_t *os_sema = (os_sema_t *)pSema;
     unsigned long old_irq;
 
-    spin_lock_irqsave(&os_sema->lock, old_irq);
+    nv_spin_lock_irqsave(&os_sema->lock, old_irq);
     if (os_sema->count <= 0)
     {
         os_sema->count--;
-        spin_unlock_irqrestore(&os_sema->lock, old_irq);
+        nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
         wait_for_completion(&os_sema->completion);
     }
     else
     {
         os_sema->count--;
         rm_disable_interrupts(os_sema->sp);
-        spin_unlock_irqrestore(&os_sema->lock, old_irq);
+        nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
     }
 
     return RM_OK;
@@ -233,17 +229,17 @@
     os_sema_t *os_sema = (os_sema_t *)pSema;
     unsigned long old_irq;
 
-    spin_lock_irqsave(&os_sema->lock, old_irq);
+    nv_spin_lock_irqsave(&os_sema->lock, old_irq);
     if (os_sema->count <= 0)
     {
-        spin_unlock_irqrestore(&os_sema->lock, old_irq);
+        nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
         return RM_ERROR;
     }
     else
     {
         os_sema->count--;
         rm_disable_interrupts(os_sema->sp);
-        spin_unlock_irqrestore(&os_sema->lock, old_irq);
+        nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
         return RM_OK;
     }
 
@@ -267,7 +263,7 @@
     unsigned long old_irq;
     BOOL doWakeup;
 
-    spin_lock_irqsave(&os_sema->lock, old_irq);
+    nv_spin_lock_irqsave(&os_sema->lock, old_irq);
     if (os_sema->count < 0)
     {
         doWakeup = TRUE;
@@ -278,7 +274,7 @@
         rm_enable_interrupts(os_sema->sp);
     }
     os_sema->count++;
-    spin_unlock_irqrestore(&os_sema->lock, old_irq);
+    nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
 
     if (doWakeup)
         complete(&os_sema->completion);
@@ -1383,7 +1379,7 @@
     unsigned long oldIrql;
 
     os_sema = (os_sema_t *) pSema;
-    spin_lock_irqsave(&os_sema->lock, oldIrql);
+    nv_spin_lock_irqsave(&os_sema->lock, oldIrql);
 
     return oldIrql;
 }
@@ -1394,7 +1390,7 @@
     unsigned long old_irq = (unsigned long) oldIrql;
 
     os_sema = (os_sema_t *) pSema;
-    spin_unlock_irqrestore(&os_sema->lock, old_irq);
+    nv_spin_unlock_irqrestore(&os_sema->lock, old_irq);
 }
 
 RM_STATUS NV_API_CALL os_get_address_space_info(
I can confirm that this is working on a 2.6.29 kernel with rt patches.
I can confirm that this is working on a 2.6.31 kernel with rt patches.

Can someone confirm that this works on a kernel without rt patches installed?

What are the routes one would take to submit a patch?

Regards
Iain
Attached Files
File Type: gz nv-2.6.31-rt.patch.gz (1.1 KB, 226 views)
ibuclaw is offline   Reply With Quote
Old 09-23-09, 04:19 AM   #14
th0rgal
Registered User
 
Join Date: Nov 2004
Posts: 31
Default Re: NViDIA on Linux 2.6.31

hey!

I tried your patch against 2.6.31-rt11.

It compiles and loads fine, 2D perf is great. 3D perf sucks big time.
I am not doing 3D stuff so it is not really a problem to me, but still, this is not what I would expect from a proprietary driver.

But the nice thing is that it does not compromise the realtime audio processing. I have been stress-testing my system with jackd running at very low latency (< 1ms) with a heavy ardour session, jamin, rosegarden and 2 VSTis, one running through wine : no xrun at all
th0rgal is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 06:56 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.