05-05-2008 03:15 PM
05-23-2008 02:04 PM
02-15-2011 03:58 AM - edited 02-15-2011 04:00 AM
I had this same exact problem except on RHEL 5.6, and RHEL *is* a supported OS and it actually compiles fine on RHEL 4.7. Since NI hasn't released a driver update after 2.1, I decided to see if I could fix it myself. The problem lies in the fact that the header 'lockdep.h' was added with the following code:
#ifdef CONFIG_DEBUG_LOCK_ALLOC # ifdef CONFIG_PROVE_LOCKING # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) # else # define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) # endif # define mutex_release(l, n, i) lock_release(l, n, i) #else # define mutex_acquire(l, s, t, i) do { } while (0) # define mutex_release(l, n, i) do { } while (0) #endif
As you can see, the above function names directly conflict with the 'mutex_acquire' and 'mutex_release' function names defined in the NI source code.
The *correct* fix would be to simply rename 'mutex_release` and 'mutex_acquire' to 'ni_mutex_release' and 'ni_mutex_acquire' respecitvely in the files mutex.h, mutex.c and vxi.c so they no longer conflict with the function definitions in lockdep.h. Unfortunately, the source code for nivxi.o is not given and this object file calls the two aforemented functions and this cannot be changed without the source. However, NI has the source so they could do the function name change no problems.
There is also a name conflict with the struct named 'mutex' and this can be fixed by changing the following in mutex.h:
OLD
typedef struct mutex mutex_t
NEW
typedef struct ni_mutex mutex_t
And also the following in mutex.c:
OLD
struct mutex { struct semaphore sema; };
NEW
struct ni_mutex { struct semaphore sema; };
Finally, in vxi_kernel.c there is a call to '__put_page()' that needs to be updated like so:
OLD
NIVXICC void vxi_dec_page_usage_count(struct page *pg) { __put_page(pg); }
NEW
NIVXICC void vxi_dec_page_usage_count(struct page *pg) { put_page(pg); }
If NI were to do all of the above, this kernel module should compile cleanly under the latest 2.6.X kernels. In the interim, since we don't have the luxury of changing the names of 'mutex_acquire' and 'mutex_release' due to not having the 'nivxi.o' source, we have to do a small kludge and alter the 'lockdep.h' directly (mine is in /usr/src/kernels/2.6.18-238.el5-i686/include/linux/lockdep.h)
OLD
#ifdef CONFIG_DEBUG_LOCK_ALLOC
# ifdef CONFIG_PROVE_LOCKING
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i)
# else
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i)
# endif
# define mutex_release(l, n, i) lock_release(l, n, i)
#else
# define mutex_acquire(l, s, t, i) do { } while (0)
# define mutex_release(l, n, i) do { } while (0)
#endif
NEW
#ifndef NOLOCKDEP
# ifdef CONFIG_DEBUG_LOCK_ALLOC
# ifdef CONFIG_PROVE_LOCKING
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i)
# else
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i)
# endif
# define mutex_release(l, n, i) lock_release(l, n, i)
# else
# define mutex_acquire(l, s, t, i) do { } while (0)
# define mutex_release(l, n, i) do { } while (0)
# endif
#endif
And finally we need to alter the Makefile script in 'nivxi/src' to pass the 'NOLOCKDEP' define when compiling so that the offending block of code above is skipped for only the compilation of vximod.ko
OLD
EXTRA_CFLAGS := -DVXI_MAJOR=0 $(KERNEL_VARIANT) $(DEBUG_KERNEL)
NEW
EXTRA_CFLAGS := -DVXI_MAJOR=0 $(KERNEL_VARIANT) $(DEBUG_KERNEL) -DNOLOCKDEP
To reiterate, if NI were to update the source code of nivxi.c, vxi.c, mutex.c and mutex.h by changing all instances of 'mutex_acquire', 'mutex_release' and 'struct mutex' to 'ni_mutex_acquire', 'ni_mutex_release' and 'struct ni_mutex' then everything would be fixed. They also need to change '__put_page()' to 'put_page()'. But until they do (if they ever do), then we as users are forced to leave the names as-is, and instead do the -DNOLOCKDEP kludge in lockdep.h and the Makefile as well as fix '__put_page()'