nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   NVIDIA FreeBSD (http://www.nvnews.net/vbulletin/forumdisplay.php?f=47)
-   -   Patch for driver on -current (http://www.nvnews.net/vbulletin/showthread.php?t=99604)

johnjen 10-02-07 11:12 PM

Patch for driver on -current
 
I know -current isn't "officially supported" but once 7.0-CURRENT goes to 7.0-RELEASE, maybe it will :) . I just noticed a message on the current mailing list from Craig Boston stating that he found and fixed something that was plaguing him. I'm reproducing the message here for those who might be able to use the patch ... just FYI .....

-----------------------------

From: Craig Boston <cb at severious.net>

Hi all, I did some more investigating and found what was causing the
nvidia driver to occasionally panic on my machine. It calls cv_wait(9)
using a spin mutex, which according to the man page is a no-no.

I simply changed the os_*_sema interfaces to use a standard mutex
instead. Tried running a bunch of glxgears and xscreensaver GL demos in
parallel and haven't been able to reproduce a panic since. As a bonus,
the 5 second pause I would sometimes get when a GL-based xscreensaver
process terminates seems to be gone as well.

There doesn't appear to be any documentation that I could find as to
what contexts those functions may be called from. I'm not a locking
guru, so I can't say for certain why a spin mutex was being used. Wild
guess: an artifact from the 4.x or 5.x code that may be obsoleted by
adaptive mutexes.

Patch is attached; cc danfe@ in case others report this problem to him.

Craig

------------- patch --------------------

--- src/nvidia_os.c.orig 2007-10-02 15:27:33.211059621 -0500
+++ src/nvidia_os.c 2007-10-02 15:27:43.708791970 -0500
@@ -598,7 +598,7 @@
!= RM_OK))
return status;

- mtx_init(&mtx->mutex_mtx, "rm.mutex_mtx", NULL, MTX_SPIN | MTX_RECURSE);
+ mtx_init(&mtx->mutex_mtx, "rm.mutex_mtx", NULL, MTX_DEF | MTX_RECURSE);
cv_init(&mtx->mutex_wait, "rm.mutex_wait");

mtx->refcnt = 1;
@@ -624,13 +624,13 @@
{
struct os_mutex *mtx = semaphore;

- mtx_lock_spin(&mtx->mutex_mtx);
+ mtx_lock(&mtx->mutex_mtx);
if (mtx->refcnt > 0)
rm_disable_interrupts(NULL);
mtx->refcnt--;
if (mtx->refcnt < 0)
cv_wait(&mtx->mutex_wait, &mtx->mutex_mtx);
- mtx_unlock_spin(&mtx->mutex_mtx);
+ mtx_unlock(&mtx->mutex_mtx);

return RM_OK;
}
@@ -639,14 +639,14 @@
{
struct os_mutex *mtx = semaphore;

- mtx_lock_spin(&mtx->mutex_mtx);
+ mtx_lock(&mtx->mutex_mtx);
if (mtx->refcnt < 1) {
- mtx_unlock_spin(&mtx->mutex_mtx);
+ mtx_unlock(&mtx->mutex_mtx);
return FALSE;
} else {
rm_disable_interrupts(NULL);
mtx->refcnt--;
- mtx_unlock_spin(&mtx->mutex_mtx);
+ mtx_unlock(&mtx->mutex_mtx);
}

return TRUE;
@@ -656,13 +656,13 @@
{
struct os_mutex *mtx = semaphore;

- mtx_lock_spin(&mtx->mutex_mtx);
+ mtx_lock(&mtx->mutex_mtx);
if (mtx->refcnt < 0)
cv_signal(&mtx->mutex_wait);
if (!mtx->refcnt)
rm_enable_interrupts(NULL);
mtx->refcnt++;
- mtx_unlock_spin(&mtx->mutex_mtx);
+ mtx_unlock(&mtx->mutex_mtx);

return RM_OK;
}

zander 10-03-07 12:07 AM

Re: Patch for driver on -current
 
Thanks, I'll take a closer look.

zander 10-10-07 08:54 PM

Re: Patch for driver on -current
 
Thanks again for bringing this to my attention. Unfortunately, it is not FreeBSD 7.0-CURRENT specific, though it may be masked on UP systems. I recently ran into the same problem with a FreeBSD 6.2-RELEASE SMP system and convinced myself that the switching from a spin mutex to a regular/adaptive mutex is correct. This bug should be fixed in a future NVIDIA FreeBSD graphics driver release.


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

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