Brian Paul wrote:
> 
> Adam K Kirchhoff wrote:
> >
> > I pulled the DRI cvs this afternoon (main trunk) and gave it a whirl.
> > X never fully starts up.  After about five-ten seconds, the monitor puts
> > itself to sleep and /var/log/XFree86.0.log ends with:
> >
> >                 32 128x128 slots
> >                 21 256x256 slots
> >                 7 512x512 slots
> > (II) RADEON(0): Acceleration enabled
> > (II) RADEON(0): Using hardware cursor (scanline 4104)
> > (II) RADEON(0): Largest offscreen area available: 1280 x 3067
> > (II) RADEON(0): X context handle = 0x00000001
> > (II) RADEON(0): [drm] installed DRM signal handler
> > (II) RADEON(0): [DRI] installation complete
> > (II) RADEON(0): [drm] Added 32 65536 byte vertex/indirect buffers
> >
> > If I disable the DRI, the server starts up and runs fine (minus 3D, of
> > course).
> 
> Adam,
> 
> I'm having the same problem too since I updated on Friday.  I'm running
> a stock 2.4.0 kernel.  I'm looking into it now.


OK, here's what I've found.  It's basically a version problem between
the DRM code that's in the DRI trunk vs the 2.4.0 kernel.

Evidently the DRM code on the DRI trunk was updated for kernel 2.4.3
and that broke compatibility with 2.4.[012].

This was probably announced on the mailing list, but I must have missed it.

Here's a description of the problem.  When compiling radeon_drv.c there
are some warnings:

cc -O2 -Wall -Wwrite-strings -Wpointer-arith -Wcast-align -Wstrict-prototypes
-Wnested-externs -Wpointer-arith -D__KERNEL__ -DMODULE -fomit-frame-pointer 
-DCONFIG_AGP
-DCONFIG_AGP_MODULE -D__SMP__ -DMODVERSIONS -include
/usr/src/linux-2.4.0/include/linux/modversions.h -DKILLFASYNCHASTHREEPARAMETERS
-DEXPORT_SYMTAB -I/usr/src/linux-2.4.0/include -c radeon_drv.c -o radeon_drv.o
drm_bufs.h: In function `radeon_mapbufs':
In file included from radeon_drv.c:75:
drm_bufs.h:771: warning: passing arg 1 of `down_write' from incompatible pointer type
drm_bufs.h:776: warning: passing arg 1 of `up_write' from incompatible pointer type
drm_bufs.h:778: warning: passing arg 1 of `down_write' from incompatible pointer type
drm_bufs.h:782: warning: passing arg 1 of `up_write' from incompatible pointer type


down_write() and up_write() in 2.4.0 are defined in semaphore.h as:

static inline void down_write(struct rw_semaphore *sem)
static inline void up_write(struct rw_semaphore *sem)


The calls at line 771, 776, etc are:

771:    down_write( &current->mm->mmap_sem );

776:    up_write( &current->mm->mmap_sem );

&current->mm->mmap_sem comes from sched.h:

struct mm_struct {
        ...
        struct semaphore mmap_sem;
        ...
};


So, it looks like we're passing a 'struct semaphore' to a function that's
expecting a 'struct rw_semaphore'.

I replaced the calls to down_write() and up_write() with calls to
down() and up(), respectively.  down() and up() are defined in
semaphore.h as:

asmlinkage void __down(struct semaphore * sem);
asmlinkage void __up(struct semaphore * sem);

This fixes the warnings and appears to fix the start-up problem as well.
GLX demos seem to be OK now.


Looking at the CVS logs I see that that's how the code worked prior to
Alan's check-in on the 30th.


The following patch seems to fix the code so it works with 2.4.[0123]:

*** drm_bufs.h  2001/03/30 13:32:39     1.7
--- drm_bufs.h  2001/04/02 22:27:07
***************
*** 768,785 ****
--- 768,802 ----
                                goto done;
                        }
  
+ #if LINUX_VERSION_CODE >= 0x020403
                        down_write( &current->mm->mmap_sem );
+ #else
+                       down( &current->mm->mmap_sem );
+ #endif
                        virtual = do_mmap( filp, 0, map->size,
                                           PROT_READ | PROT_WRITE,
                                           MAP_SHARED,
                                           (unsigned long)map->offset );
+ 
+ #if LINUX_VERSION_CODE >= 0x020403
                        up_write( &current->mm->mmap_sem );
+ #else
+                       up( &current->mm->mmap_sem );
+ #endif
                } else {
+ #if LINUX_VERSION_CODE >= 0x020403
                        down_write( &current->mm->mmap_sem );
+ #else
+                       down( &current->mm->mmap_sem );
+ #endif
                        virtual = do_mmap( filp, 0, dma->byte_count,
                                           PROT_READ | PROT_WRITE,
                                           MAP_SHARED, 0 );
+ #if LINUX_VERSION_CODE >= 0x020403
                        up_write( &current->mm->mmap_sem );
+ #else
+                       up( &current->mm->mmap_sem );
+ #endif
                }
                if ( virtual > -1024UL ) {
                        /* Real error */


Alan (or anyone more familiar with kernel stuff), is this an acceptable
patch?

-Brian

_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to