View Single Post
Old 10-02-07, 11:12 PM   #1
johnjen
Registered User
 
Join Date: Jun 2007
Posts: 4
Default 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;
}
johnjen is offline   Reply With Quote