diff -Nurp nv.orig/os-interface.c nv/os-interface.c --- nv.orig/os-interface.c 2009-08-15 02:58:45.000000000 +0200 +++ nv/os-interface.c 2009-10-25 11:38:18.366928071 +0100 @@ -88,7 +88,7 @@ typedef struct os_sema_s nv_stack_t *sp; struct completion completion; #if defined(CONFIG_PREEMPT_RT) - raw_spinlock_t lock; + atomic_spinlock_t lock; #else spinlock_t lock; #endif @@ -127,7 +127,11 @@ RM_STATUS NV_API_CALL os_alloc_sema os_sema = (os_sema_t *)*ppSema; os_sema->sp = sp; init_completion(&os_sema->completion); +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_lock_init(&os_sema->lock); +#else spin_lock_init(&os_sema->lock); +#endif os_sema->count = 1; return RM_OK; @@ -171,18 +175,30 @@ RM_STATUS NV_API_CALL os_acquire_sema os_sema_t *os_sema = (os_sema_t *)pSema; unsigned long old_irq; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_lock_irqsave(&os_sema->lock, old_irq); +#else spin_lock_irqsave(&os_sema->lock, old_irq); +#endif if (os_sema->count <= 0) { os_sema->count--; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif wait_for_completion(&os_sema->completion); } else { os_sema->count--; rm_disable_interrupts(os_sema->sp); +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif } return RM_OK; @@ -205,17 +221,29 @@ BOOL NV_API_CALL os_cond_acquire_sema os_sema_t *os_sema = (os_sema_t *)pSema; unsigned long old_irq; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_lock_irqsave(&os_sema->lock, old_irq); +#else spin_lock_irqsave(&os_sema->lock, old_irq); +#endif if (os_sema->count <= 0) { +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif return FALSE; } else { os_sema->count--; rm_disable_interrupts(os_sema->sp); +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif return TRUE; } @@ -239,7 +267,11 @@ RM_STATUS NV_API_CALL os_release_sema unsigned long old_irq; BOOL doWakeup; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_lock_irqsave(&os_sema->lock, old_irq); +#else spin_lock_irqsave(&os_sema->lock, old_irq); +#endif if (os_sema->count < 0) { doWakeup = TRUE; @@ -250,7 +282,11 @@ RM_STATUS NV_API_CALL os_release_sema rm_enable_interrupts(os_sema->sp); } os_sema->count++; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif if (doWakeup) complete(&os_sema->completion); @@ -1319,7 +1355,11 @@ NvU64 NV_API_CALL os_acquire_spinlock(vo unsigned long oldIrql; os_sema = (os_sema_t *) pSema; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_lock_irqsave(&os_sema->lock, oldIrql); +#else spin_lock_irqsave(&os_sema->lock, oldIrql); +#endif return oldIrql; } @@ -1330,7 +1370,11 @@ void NV_API_CALL os_release_spinlock(voi unsigned long old_irq = (unsigned long) oldIrql; os_sema = (os_sema_t *) pSema; +#if defined(CONFIG_PREEMPT_RT) + atomic_spin_unlock_irqrestore(&os_sema->lock, old_irq); +#else spin_unlock_irqrestore(&os_sema->lock, old_irq); +#endif }