patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / char / drm / drm_bufs.h
index e4cce8d..a0361c0 100644 (file)
@@ -147,7 +147,9 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
                                              MTRR_TYPE_WRCOMB, 1 );
                }
 #endif
-               map->handle = DRM(ioremap)( map->offset, map->size, dev );
+               if (map->type == _DRM_REGISTERS)
+                       map->handle = DRM(ioremap)( map->offset, map->size,
+                                                   dev );
                break;
 
        case _DRM_SHM:
@@ -160,6 +162,12 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
                }
                map->offset = (unsigned long)map->handle;
                if ( map->flags & _DRM_CONTAINS_LOCK ) {
+                       /* Prevent a 2nd X Server from creating a 2nd lock */
+                       if (dev->lock.hw_lock != NULL) {
+                               vfree( map->handle );
+                               DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
+                               return -EBUSY;
+                       }
                        dev->sigdata.lock =
                        dev->lock.hw_lock = map->handle; /* Pointer to lock */
                }
@@ -767,7 +775,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
 }
 #endif /* __HAVE_PCI_DMA */
 
-#ifdef __HAVE_SG
+#if __HAVE_SG
 int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
                      unsigned int cmd, unsigned long arg )
 {