Simply impossible to use an Nvidia card on a real-time kernel (no musician can use nvidia)

This was shared on the Gentoo forums awhile back and also somewhere else on these forums but here it is.

Works good on my computer, but I do not take any responsibility. Nvidia also does not support this fix. CYA, I am sure you understand.

  1. Download the driver for your video card.

  2. Run:
    cd /usr/src
    /[path to the downloaded driver]/NVIDIA-Linux-x86_64-260.19.29.run -x

  3. Open the file /usr/src/NVIDIA-Linux-x86_64-260.19.29/kernel/nv-linux.h and make the following changes:

Replace:
#if defined(CONFIG_PREEMPT_RT)
typedef atomic_spinlock_t nv_spinlock_t;
#define NV_SPIN_LOCK_INIT(lock) atomic_spin_lock_init(lock)
#define NV_SPIN_LOCK_IRQ(lock) atomic_spin_lock_irq(lock)
#define NV_SPIN_UNLOCK_IRQ(lock) atomic_spin_unlock_irq(lock)
#define NV_SPIN_LOCK_IRQSAVE(lock,flags) atomic_spin_lock_irqsave(lock,flags)
#define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) \
atomic_spin_unlock_irqrestore(lock,flags)
#define NV_SPIN_LOCK(lock) atomic_spin_lock(lock)
#define NV_SPIN_UNLOCK(lock) atomic_spin_unlock(lock)
#define NV_SPIN_UNLOCK_WAIT(lock) atomic_spin_unlock_wait(lock)
#else
typedef spinlock_t nv_spinlock_t;
#define NV_SPIN_LOCK_INIT(lock) spin_lock_init(lock)

With:
#if defined(CONFIG_PREEMPT_RT)
typedef raw_spinlock_t nv_spinlock_t;
#define NV_SPIN_LOCK_INIT(lock) raw_spin_lock_init(lock)
#define NV_SPIN_LOCK_IRQ(lock) raw_spin_lock_irq(lock)
#define NV_SPIN_UNLOCK_IRQ(lock) raw_spin_unlock_irq(lock)
#define NV_SPIN_LOCK_IRQSAVE(lock,flags) raw_spin_lock_irqsave(lock,flags)
#define NV_SPIN_UNLOCK_IRQRESTORE(lock,flags) \
raw_spin_unlock_irqrestore(lock,flags)
#define NV_SPIN_LOCK(lock) raw_spin_lock(lock)
#define NV_SPIN_UNLOCK(lock) raw_spin_unlock(lock)
#define NV_SPIN_UNLOCK_WAIT(lock) raw_spin_unlock_wait(lock)
#else
typedef spinlock_t nv_spinlock_t;
#define NV_SPIN_LOCK_INIT(lock) spin_lock_init(lock)

Replace:
#if defined(CONFIG_PREEMPT_RT)
#define NV_INIT_MUTEX(mutex) semaphore_init(mutex)
#else
#if !defined(__SEMAPHORE_INITIALIZER) && defined(__COMPAT_SEMAPHORE_INITIALIZER)
#define __SEMAPHORE_INITIALIZER __COMPAT_SEMAPHORE_INITIALIZER

With:
#if defined(CONFIG_PREEMPT_RT)
#define NV_INIT_MUTEX(mutex) sema_init(mutex,1)
#else
#if !defined(__SEMAPHORE_INITIALIZER) && defined(__COMPAT_SEMAPHORE_INITIALIZER)
#define __SEMAPHORE_INITIALIZER __COMPAT_SEMAPHORE_INITIALIZER

  1. Run:
    /usr/src/NVIDIA-Linux-x86_64-260.19.29/nvidia-installer

Hope that helps. Good luck.