## Automatically generated incremental diff
## From:   linux-2.5.68-bk6
## To:     linux-2.5.68-bk7
## Robot:  $Id: make-incremental-diff,v 1.11 2002/02/20 02:59:33 hpa Exp $

diff -urN linux-2.5.68-bk6/Makefile linux-2.5.68-bk7/Makefile
--- linux-2.5.68-bk6/Makefile	2003-04-26 04:37:07.000000000 -0700
+++ linux-2.5.68-bk7/Makefile	2003-04-26 04:37:12.000000000 -0700
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 68
-EXTRAVERSION = -bk6
+EXTRAVERSION = -bk7
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
diff -urN linux-2.5.68-bk6/arch/i386/kernel/io_apic.c linux-2.5.68-bk7/arch/i386/kernel/io_apic.c
--- linux-2.5.68-bk6/arch/i386/kernel/io_apic.c	2003-04-26 04:37:07.000000000 -0700
+++ linux-2.5.68-bk7/arch/i386/kernel/io_apic.c	2003-04-26 04:37:12.000000000 -0700
@@ -269,7 +269,7 @@
 # include <linux/slab.h>		/* kmalloc() */
 # include <linux/timer.h>	/* time_after() */
  
-# if CONFIG_BALANCED_IRQ_DEBUG
+# ifdef CONFIG_BALANCED_IRQ_DEBUG
 #  define TDprintk(x...) do { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } while (0)
 #  define Dprintk(x...) do { TDprintk(x); } while (0)
 # else
diff -urN linux-2.5.68-bk6/drivers/char/drm/Kconfig linux-2.5.68-bk7/drivers/char/drm/Kconfig
--- linux-2.5.68-bk6/drivers/char/drm/Kconfig	2003-04-19 19:50:44.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/Kconfig	2003-04-26 04:37:13.000000000 -0700
@@ -39,7 +39,7 @@
 
 config DRM_RADEON
 	tristate "ATI Radeon"
-	depends on DRM && AGP
+	depends on DRM
 	help
 	  Choose this option if you have an ATI Radeon graphics card.  There
 	  are both PCI and AGP versions.  You don't need to choose this to
@@ -56,8 +56,14 @@
 	  for this driver to work.
 
 config DRM_I830
-	tristate "Intel 830M"
+	tristate "Intel 830M, 845G, 852GM, 855GM, 865G"
 	depends on DRM && AGP
+	help
+	  Choose this option if you have a system that has Intel 830M, 845G,
+	  852GM, 855GM or 865G integrated graphics.  If M is selected, the
+	  module will be called i830.  AGP support is required for this driver
+	  to work.
+
 
 config DRM_MGA
 	tristate "Matrox g200/g400"
diff -urN linux-2.5.68-bk6/drivers/char/drm/drmP.h linux-2.5.68-bk7/drivers/char/drm/drmP.h
--- linux-2.5.68-bk6/drivers/char/drm/drmP.h	2003-04-26 04:37:08.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drmP.h	2003-04-26 04:37:13.000000000 -0700
@@ -95,9 +95,6 @@
 #ifndef __HAVE_DMA_FREELIST
 #define __HAVE_DMA_FREELIST	0
 #endif
-#ifndef __HAVE_DMA_HISTOGRAM
-#define __HAVE_DMA_HISTOGRAM	0
-#endif
 
 #define __REALLY_HAVE_AGP	(__HAVE_AGP && (defined(CONFIG_AGP) || \
 						defined(CONFIG_AGP_MODULE)))
@@ -119,7 +116,6 @@
 #define DRM_LOCK_SLICE	      1	/* Time slice for lock, in jiffies	  */
 
 #define DRM_FLAG_DEBUG	  0x01
-#define DRM_FLAG_NOCTX	  0x02
 
 #define DRM_MEM_DMA	   0
 #define DRM_MEM_SAREA	   1
@@ -339,38 +335,11 @@
 		DRM_LIST_RECLAIM = 5
 	}		  list;	       /* Which list we're on		     */
 
-#if DRM_DMA_HISTOGRAM
-	cycles_t	  time_queued;	   /* Queued to kernel DMA queue     */
-	cycles_t	  time_dispatched; /* Dispatched to hardware	     */
-	cycles_t	  time_completed;  /* Completed by hardware	     */
-	cycles_t	  time_freed;	   /* Back on freelist		     */
-#endif
 
 	int		  dev_priv_size; /* Size of buffer private stoarge   */
 	void		  *dev_private;  /* Per-buffer private storage       */
 } drm_buf_t;
 
-#if DRM_DMA_HISTOGRAM
-#define DRM_DMA_HISTOGRAM_SLOTS		  9
-#define DRM_DMA_HISTOGRAM_INITIAL	 10
-#define DRM_DMA_HISTOGRAM_NEXT(current)	 ((current)*10)
-typedef struct drm_histogram {
-	atomic_t	  total;
-
-	atomic_t	  queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
-
-	atomic_t	  queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
-
-	atomic_t	  dma[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  schedule[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  ctx[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  lacq[DRM_DMA_HISTOGRAM_SLOTS];
-	atomic_t	  lhld[DRM_DMA_HISTOGRAM_SLOTS];
-} drm_histogram_t;
-#endif
 
 				/* bufs is one longer than it has to be */
 typedef struct drm_waitlist {
@@ -422,6 +391,7 @@
 	struct drm_file	  *prev;
 	struct drm_device *dev;
 	int 		  remove_auth_on_close;
+	unsigned long     lock_count;
 } drm_file_t;
 
 
@@ -451,21 +421,6 @@
 } drm_lock_data_t;
 
 typedef struct drm_device_dma {
-#if 0
-				/* Performance Counters */
-	atomic_t	  total_prio;	/* Total DRM_DMA_PRIORITY	   */
-	atomic_t	  total_bytes;	/* Total bytes DMA'd		   */
-	atomic_t	  total_dmas;	/* Total DMA buffers dispatched	   */
-
-	atomic_t	  total_missed_dma;  /* Missed drm_do_dma	    */
-	atomic_t	  total_missed_lock; /* Missed lock in drm_do_dma   */
-	atomic_t	  total_missed_free; /* Missed drm_free_this_buffer */
-	atomic_t	  total_missed_sched;/* Missed drm_dma_schedule	    */
-
-	atomic_t	  total_tried;	/* Tried next_buffer		    */
-	atomic_t	  total_hit;	/* Sent next_buffer		    */
-	atomic_t	  total_lost;	/* Lost interrupt		    */
-#endif
 
 	drm_buf_entry_t	  bufs[DRM_MAX_ORDER+1];
 	int		  buf_count;
@@ -573,7 +528,6 @@
 
 				/* Memory management */
 	drm_map_list_t	  *maplist;	/* Linked list of regions	   */
-	int		  map_count;	/* Number of mappable regions	   */
 
 	drm_map_t	  **context_sareas;
 	int		  max_context;
@@ -608,9 +562,6 @@
 #endif
 	cycles_t	  ctx_start;
 	cycles_t	  lck_start;
-#if __HAVE_DMA_HISTOGRAM
-	drm_histogram_t	  histo;
-#endif
 
 				/* Callback to X server for context switch
 				   and for heavy-handed reset. */
@@ -666,13 +617,7 @@
 extern int	     DRM(open_helper)(struct inode *inode, struct file *filp,
 				      drm_device_t *dev);
 extern int	     DRM(flush)(struct file *filp);
-extern int	     DRM(release_fuck)(struct inode *inode, struct file *filp);
 extern int	     DRM(fasync)(int fd, struct file *filp, int on);
-extern ssize_t	     DRM(read)(struct file *filp, char *buf, size_t count,
-			       loff_t *off);
-extern int	     DRM(write_string)(drm_device_t *dev, const char *s);
-extern unsigned int  DRM(poll)(struct file *filp,
-			       struct poll_table_struct *wait);
 
 				/* Mapping support (drm_vm.h) */
 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
@@ -693,6 +638,8 @@
 extern int	     DRM(mmap_dma)(struct file *filp,
 				   struct vm_area_struct *vma);
 extern int	     DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
+extern unsigned int  DRM(poll)(struct file *filp, struct poll_table_struct *wait);
+extern ssize_t       DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off);
 
 				/* Memory management support (drm_memory.h) */
 extern void	     DRM(mem_init)(void);
@@ -701,8 +648,6 @@
 extern void	     *DRM(alloc)(size_t size, int area);
 extern void	     *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
 				   int area);
-extern char	     *DRM(strdup)(const char *s, int area);
-extern void	     DRM(strfree)(const char *s, int area);
 extern void	     DRM(free)(void *pt, size_t size, int area);
 extern unsigned long DRM(alloc_pages)(int order, int area);
 extern void	     DRM(free_pages)(unsigned long address, int order,
@@ -777,12 +722,11 @@
 extern int	     DRM(authmagic)(struct inode *inode, struct file *filp,
 				    unsigned int cmd, unsigned long arg);
 
+                                /* Placeholder for ioctls past */
+extern int	     DRM(noop)(struct inode *inode, struct file *filp,
+				  unsigned int cmd, unsigned long arg);
 
 				/* Locking IOCTL support (drm_lock.h) */
-extern int	     DRM(block)(struct inode *inode, struct file *filp,
-				unsigned int cmd, unsigned long arg);
-extern int	     DRM(unblock)(struct inode *inode, struct file *filp,
-				  unsigned int cmd, unsigned long arg);
 extern int	     DRM(lock_take)(__volatile__ unsigned int *lock,
 				    unsigned int context);
 extern int	     DRM(lock_transfer)(drm_device_t *dev,
@@ -822,15 +766,6 @@
 extern void	     DRM(dma_takedown)(drm_device_t *dev);
 extern void	     DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
 extern void	     DRM(reclaim_buffers)( struct file *filp );
-#if __HAVE_OLD_DMA
-/* GH: This is a dirty hack for now...
- */
-extern void	     DRM(clear_next_buffer)(drm_device_t *dev);
-extern int	     DRM(select_queue)(drm_device_t *dev,
-				       void (*wrapper)(unsigned long));
-extern int	     DRM(dma_enqueue)(struct file *filp, drm_dma_t *dma);
-extern int	     DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma);
-#endif
 #if __HAVE_DMA_IRQ
 extern int           DRM(control)( struct inode *inode, struct file *filp,
 				   unsigned int cmd, unsigned long arg );
@@ -851,25 +786,7 @@
 extern void          DRM(dma_immediate_bh)( void *dev );
 #endif
 #endif
-#if DRM_DMA_HISTOGRAM
-extern int	     DRM(histogram_slot)(unsigned long count);
-extern void	     DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf);
-#endif
-
-				/* Buffer list support (drm_lists.h) */
-#if __HAVE_DMA_WAITLIST
-extern int	     DRM(waitlist_create)(drm_waitlist_t *bl, int count);
-extern int	     DRM(waitlist_destroy)(drm_waitlist_t *bl);
-extern int	     DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
-extern drm_buf_t     *DRM(waitlist_get)(drm_waitlist_t *bl);
-#endif
-#if __HAVE_DMA_FREELIST
-extern int	     DRM(freelist_create)(drm_freelist_t *bl, int count);
-extern int	     DRM(freelist_destroy)(drm_freelist_t *bl);
-extern int	     DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
-				       drm_buf_t *buf);
-extern drm_buf_t     *DRM(freelist_get)(drm_freelist_t *bl, int block);
-#endif
+
 #endif /* __HAVE_DMA */
 
 #if __REALLY_HAVE_AGP
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_agpsupport.h linux-2.5.68-bk7/drivers/char/drm/drm_agpsupport.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_agpsupport.h	2003-04-19 19:48:46.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_agpsupport.h	2003-04-26 04:37:13.000000000 -0700
@@ -146,7 +146,7 @@
 		return -ENOMEM;
 	}
 
-	entry->handle    = (unsigned long)memory->memory;
+	entry->handle    = (unsigned long)memory->key;
 	entry->memory    = memory;
 	entry->bound     = 0;
 	entry->pages     = pages;
@@ -186,6 +186,7 @@
 	drm_device_t	  *dev	 = priv->dev;
 	drm_agp_binding_t request;
 	drm_agp_mem_t     *entry;
+	int ret;
 
 	if (!dev->agp || !dev->agp->acquired) return -EINVAL;
 	if (copy_from_user(&request, (drm_agp_binding_t *)arg, sizeof(request)))
@@ -193,7 +194,10 @@
 	if (!(entry = DRM(agp_lookup_entry)(dev, request.handle)))
 		return -EINVAL;
 	if (!entry->bound) return -EINVAL;
-	return DRM(unbind_agp)(entry->memory);
+	ret = DRM(unbind_agp)(entry->memory);
+	if (ret == 0)
+	    entry->bound = 0;
+	return ret;
 }
 
 int DRM(agp_bind)(struct inode *inode, struct file *filp,
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_bufs.h linux-2.5.68-bk7/drivers/char/drm/drm_bufs.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_bufs.h	2003-04-19 19:48:55.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_bufs.h	2003-04-26 04:37:13.000000000 -0700
@@ -128,7 +128,7 @@
 
 	case _DRM_SHM:
 		map->handle = vmalloc_32(map->size);
-		DRM_DEBUG( "%ld %d %p\n",
+		DRM_DEBUG( "%lu %d %p\n",
 			   map->size, DRM(order)( map->size ), map->handle );
 		if ( !map->handle ) {
 			DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
@@ -269,9 +269,11 @@
 
 	if (entry->seg_count) {
 		for (i = 0; i < entry->seg_count; i++) {
-			DRM(free_pages)(entry->seglist[i],
-					entry->page_order,
-					DRM_MEM_DMA);
+			if (entry->seglist[i]) {
+				DRM(free_pages)(entry->seglist[i],
+					        entry->page_order,
+					        DRM_MEM_DMA);
+			}
 		}
 		DRM(free)(entry->seglist,
 			  entry->seg_count *
@@ -281,9 +283,9 @@
 		entry->seg_count = 0;
 	}
 
-   	if(entry->buf_count) {
-	   	for(i = 0; i < entry->buf_count; i++) {
-			if(entry->buflist[i].dev_private) {
+   	if (entry->buf_count) {
+	   	for (i = 0; i < entry->buf_count; i++) {
+			if (entry->buflist[i].dev_private) {
 				DRM(free)(entry->buflist[i].dev_private,
 					  entry->buflist[i].dev_priv_size,
 					  DRM_MEM_BUFS);
@@ -345,7 +347,7 @@
 	DRM_DEBUG( "count:      %d\n",  count );
 	DRM_DEBUG( "order:      %d\n",  order );
 	DRM_DEBUG( "size:       %d\n",  size );
-	DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
+	DRM_DEBUG( "agp_offset: %lu\n", agp_offset );
 	DRM_DEBUG( "alignment:  %d\n",  alignment );
 	DRM_DEBUG( "page_order: %d\n",  page_order );
 	DRM_DEBUG( "total:      %d\n",  total );
@@ -412,15 +414,12 @@
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
 			DRM(cleanup_buf_error)(entry);
+			up( &dev->struct_sem );
+			atomic_dec( &dev->buf_alloc );
+			return -ENOMEM;
 		}
 		memset( buf->dev_private, 0, buf->dev_priv_size );
 
-#if __HAVE_DMA_HISTOGRAM
-		buf->time_queued = 0;
-		buf->time_dispatched = 0;
-		buf->time_completed = 0;
-		buf->time_freed = 0;
-#endif
 		DRM_DEBUG( "buffer %d @ %p\n",
 			   entry->buf_count, buf->address );
 
@@ -565,12 +564,13 @@
 	}
 	memset( entry->seglist, 0, count * sizeof(*entry->seglist) );
 
-	temp_pagelist = DRM(realloc)( dma->pagelist,
-				      dma->page_count * sizeof(*dma->pagelist),
-				      (dma->page_count + (count << page_order))
-				      * sizeof(*dma->pagelist),
-				      DRM_MEM_PAGES );
-	if(!temp_pagelist) {
+	/* Keep the original pagelist until we know all the allocations
+	 * have succeeded
+	 */
+	temp_pagelist = DRM(alloc)( (dma->page_count + (count << page_order))
+				    * sizeof(*dma->pagelist),
+				    DRM_MEM_PAGES );
+	if (!temp_pagelist) {
 		DRM(free)( entry->buflist,
 			   count * sizeof(*entry->buflist),
 			   DRM_MEM_BUFS );
@@ -581,8 +581,9 @@
 		atomic_dec( &dev->buf_alloc );
 		return -ENOMEM;
 	}
-
-	dma->pagelist = temp_pagelist;
+	memcpy(temp_pagelist,
+	       dma->pagelist,
+	       dma->page_count * sizeof(*dma->pagelist));
 	DRM_DEBUG( "pagelist: %d entries\n",
 		   dma->page_count + (count << page_order) );
 
@@ -593,13 +594,25 @@
 
 	while ( entry->buf_count < count ) {
 		page = DRM(alloc_pages)( page_order, DRM_MEM_DMA );
-		if ( !page ) break;
+		if ( !page ) {
+			/* Set count correctly so we free the proper amount. */
+			entry->buf_count = count;
+			entry->seg_count = count;
+			DRM(cleanup_buf_error)(entry);
+			DRM(free)( temp_pagelist,
+				   (dma->page_count + (count << page_order))
+				   * sizeof(*dma->pagelist),
+				   DRM_MEM_PAGES );
+			up( &dev->struct_sem );
+			atomic_dec( &dev->buf_alloc );
+			return -ENOMEM;
+		}
 		entry->seglist[entry->seg_count++] = page;
 		for ( i = 0 ; i < (1 << page_order) ; i++ ) {
 			DRM_DEBUG( "page %d @ 0x%08lx\n",
 				   dma->page_count + page_count,
 				   page + PAGE_SIZE * i );
-			dma->pagelist[dma->page_count + page_count++]
+			temp_pagelist[dma->page_count + page_count++]
 				= page + PAGE_SIZE * i;
 		}
 		for ( offset = 0 ;
@@ -617,12 +630,25 @@
 			buf->pending = 0;
 			init_waitqueue_head( &buf->dma_wait );
 			buf->filp    = 0;
-#if __HAVE_DMA_HISTOGRAM
-			buf->time_queued     = 0;
-			buf->time_dispatched = 0;
-			buf->time_completed  = 0;
-			buf->time_freed      = 0;
-#endif
+
+			buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
+			buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+						       DRM_MEM_BUFS );
+			if(!buf->dev_private) {
+				/* Set count correctly so we free the proper amount. */
+				entry->buf_count = count;
+				entry->seg_count = count;
+				DRM(cleanup_buf_error)(entry);
+				DRM(free)( temp_pagelist,
+					   (dma->page_count + (count << page_order))
+					   * sizeof(*dma->pagelist),
+					   DRM_MEM_PAGES );
+				up( &dev->struct_sem );
+				atomic_dec( &dev->buf_alloc );
+				return -ENOMEM;
+			}
+			memset( buf->dev_private, 0, buf->dev_priv_size );
+
 			DRM_DEBUG( "buffer %d @ %p\n",
 				   entry->buf_count, buf->address );
 		}
@@ -634,9 +660,13 @@
 				     (dma->buf_count + entry->buf_count)
 				     * sizeof(*dma->buflist),
 				     DRM_MEM_BUFS );
-	if(!temp_buflist) {
+	if (!temp_buflist) {
 		/* Free the entry because it isn't valid */
 		DRM(cleanup_buf_error)(entry);
+		DRM(free)( temp_pagelist,
+			   (dma->page_count + (count << page_order))
+			   * sizeof(*dma->pagelist),
+			   DRM_MEM_PAGES );
 		up( &dev->struct_sem );
 		atomic_dec( &dev->buf_alloc );
 		return -ENOMEM;
@@ -647,6 +677,14 @@
 		dma->buflist[i + dma->buf_count] = &entry->buflist[i];
 	}
 
+	/* No allocations failed, so now we can replace the orginal pagelist
+	 * with the new one.
+	 */
+	DRM(free)(dma->pagelist,
+		  dma->page_count * sizeof(*dma->pagelist),
+		  DRM_MEM_PAGES);
+	dma->pagelist = temp_pagelist;
+
 	dma->buf_count += entry->buf_count;
 	dma->seg_count += entry->seg_count;
 	dma->page_count += entry->seg_count << page_order;
@@ -715,7 +753,7 @@
 	DRM_DEBUG( "count:      %d\n",  count );
 	DRM_DEBUG( "order:      %d\n",  order );
 	DRM_DEBUG( "size:       %d\n",  size );
-	DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
+	DRM_DEBUG( "agp_offset: %lu\n", agp_offset );
 	DRM_DEBUG( "alignment:  %d\n",  alignment );
 	DRM_DEBUG( "page_order: %d\n",  page_order );
 	DRM_DEBUG( "total:      %d\n",  total );
@@ -789,12 +827,6 @@
 
 		memset( buf->dev_private, 0, buf->dev_priv_size );
 
-# if __HAVE_DMA_HISTOGRAM
-		buf->time_queued = 0;
-		buf->time_dispatched = 0;
-		buf->time_completed = 0;
-		buf->time_freed = 0;
-# endif
 		DRM_DEBUG( "buffer %d @ %p\n",
 			   entry->buf_count, buf->address );
 
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_context.h linux-2.5.68-bk7/drivers/char/drm/drm_context.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_context.h	2003-04-19 19:48:46.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_context.h	2003-04-26 04:37:13.000000000 -0700
@@ -35,7 +35,10 @@
 
 #include "drmP.h"
 
-#if __HAVE_CTX_BITMAP
+#if !__HAVE_CTX_BITMAP
+#error "__HAVE_CTX_BITMAP must be defined"
+#endif
+
 
 /* ================================================================
  * Context bitmap support
@@ -221,16 +224,11 @@
 
 int DRM(context_switch)( drm_device_t *dev, int old, int new )
 {
-        char buf[64];
-
         if ( test_and_set_bit( 0, &dev->context_flag ) ) {
                 DRM_ERROR( "Reentering -- FIXME\n" );
                 return -EBUSY;
         }
 
-#if __HAVE_DMA_HISTOGRAM
-        dev->ctx_start = get_cycles();
-#endif
 
         DRM_DEBUG( "Context switch from %d to %d\n", old, new );
 
@@ -239,13 +237,6 @@
                 return 0;
         }
 
-        if ( DRM(flags) & DRM_FLAG_NOCTX ) {
-                DRM(context_switch_complete)( dev, new );
-        } else {
-                sprintf( buf, "C %d %d\n", old, new );
-                DRM(write_string)( dev, buf );
-        }
-
         return 0;
 }
 
@@ -261,11 +252,6 @@
 				/* If a context switch is ever initiated
                                    when the kernel holds the lock, release
                                    that lock here. */
-#if __HAVE_DMA_HISTOGRAM
-        atomic_inc( &dev->histo.ctx[DRM(histogram_slot)(get_cycles()
-							- dev->ctx_start)] );
-
-#endif
         clear_bit( 0, &dev->context_flag );
         wake_up( &dev->context_wait );
 
@@ -406,375 +392,3 @@
 	return 0;
 }
 
-
-#else /* __HAVE_CTX_BITMAP */
-
-/* ================================================================
- * Old-style context support
- */
-
-
-int DRM(context_switch)(drm_device_t *dev, int old, int new)
-{
-	char	    buf[64];
-	drm_queue_t *q;
-
-#if 0
-	atomic_inc(&dev->total_ctx);
-#endif
-
-	if (test_and_set_bit(0, &dev->context_flag)) {
-		DRM_ERROR("Reentering -- FIXME\n");
-		return -EBUSY;
-	}
-
-#if __HAVE_DMA_HISTOGRAM
-	dev->ctx_start = get_cycles();
-#endif
-
-	DRM_DEBUG("Context switch from %d to %d\n", old, new);
-
-	if (new >= dev->queue_count) {
-		clear_bit(0, &dev->context_flag);
-		return -EINVAL;
-	}
-
-	if (new == dev->last_context) {
-		clear_bit(0, &dev->context_flag);
-		return 0;
-	}
-
-	q = dev->queuelist[new];
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-		atomic_dec(&q->use_count);
-		clear_bit(0, &dev->context_flag);
-		return -EINVAL;
-	}
-
-	if (DRM(flags) & DRM_FLAG_NOCTX) {
-		DRM(context_switch_complete)(dev, new);
-	} else {
-		sprintf(buf, "C %d %d\n", old, new);
-		DRM(write_string)(dev, buf);
-	}
-
-	atomic_dec(&q->use_count);
-
-	return 0;
-}
-
-int DRM(context_switch_complete)(drm_device_t *dev, int new)
-{
-	drm_device_dma_t *dma = dev->dma;
-
-	dev->last_context = new;  /* PRE/POST: This is the _only_ writer. */
-	dev->last_switch  = jiffies;
-
-	if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
-		DRM_ERROR("Lock isn't held after context switch\n");
-	}
-
-	if (!dma || !(dma->next_buffer && dma->next_buffer->while_locked)) {
-		if (DRM(lock_free)(dev, &dev->lock.hw_lock->lock,
-				  DRM_KERNEL_CONTEXT)) {
-			DRM_ERROR("Cannot free lock\n");
-		}
-	}
-
-#if __HAVE_DMA_HISTOGRAM
-	atomic_inc(&dev->histo.ctx[DRM(histogram_slot)(get_cycles()
-						      - dev->ctx_start)]);
-
-#endif
-	clear_bit(0, &dev->context_flag);
-	wake_up_interruptible(&dev->context_wait);
-
-	return 0;
-}
-
-static int DRM(init_queue)(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
-{
-	DRM_DEBUG("\n");
-
-	if (atomic_read(&q->use_count) != 1
-	    || atomic_read(&q->finalization)
-	    || atomic_read(&q->block_count)) {
-		DRM_ERROR("New queue is already in use: u%d f%d b%d\n",
-			  atomic_read(&q->use_count),
-			  atomic_read(&q->finalization),
-			  atomic_read(&q->block_count));
-	}
-
-	atomic_set(&q->finalization,  0);
-	atomic_set(&q->block_count,   0);
-	atomic_set(&q->block_read,    0);
-	atomic_set(&q->block_write,   0);
-	atomic_set(&q->total_queued,  0);
-	atomic_set(&q->total_flushed, 0);
-	atomic_set(&q->total_locks,   0);
-
-	init_waitqueue_head(&q->write_queue);
-	init_waitqueue_head(&q->read_queue);
-	init_waitqueue_head(&q->flush_queue);
-
-	q->flags = ctx->flags;
-
-	DRM(waitlist_create)(&q->waitlist, dev->dma->buf_count);
-
-	return 0;
-}
-
-
-/* drm_alloc_queue:
-PRE: 1) dev->queuelist[0..dev->queue_count] is allocated and will not
-	disappear (so all deallocation must be done after IOCTLs are off)
-     2) dev->queue_count < dev->queue_slots
-     3) dev->queuelist[i].use_count == 0 and
-	dev->queuelist[i].finalization == 0 if i not in use
-POST: 1) dev->queuelist[i].use_count == 1
-      2) dev->queue_count < dev->queue_slots */
-
-static int DRM(alloc_queue)(drm_device_t *dev)
-{
-	int	    i;
-	drm_queue_t *queue;
-	int	    oldslots;
-	int	    newslots;
-				/* Check for a free queue */
-	for (i = 0; i < dev->queue_count; i++) {
-		atomic_inc(&dev->queuelist[i]->use_count);
-		if (atomic_read(&dev->queuelist[i]->use_count) == 1
-		    && !atomic_read(&dev->queuelist[i]->finalization)) {
-			DRM_DEBUG("%d (free)\n", i);
-			return i;
-		}
-		atomic_dec(&dev->queuelist[i]->use_count);
-	}
-				/* Allocate a new queue */
-	down(&dev->struct_sem);
-
-	queue = DRM(alloc)(sizeof(*queue), DRM_MEM_QUEUES);
-	memset(queue, 0, sizeof(*queue));
-	atomic_set(&queue->use_count, 1);
-
-	++dev->queue_count;
-	if (dev->queue_count >= dev->queue_slots) {
-		oldslots = dev->queue_slots * sizeof(*dev->queuelist);
-		if (!dev->queue_slots) dev->queue_slots = 1;
-		dev->queue_slots *= 2;
-		newslots = dev->queue_slots * sizeof(*dev->queuelist);
-
-		dev->queuelist = DRM(realloc)(dev->queuelist,
-					      oldslots,
-					      newslots,
-					      DRM_MEM_QUEUES);
-		if (!dev->queuelist) {
-			up(&dev->struct_sem);
-			DRM_DEBUG("out of memory\n");
-			return -ENOMEM;
-		}
-	}
-	dev->queuelist[dev->queue_count-1] = queue;
-
-	up(&dev->struct_sem);
-	DRM_DEBUG("%d (new)\n", dev->queue_count - 1);
-	return dev->queue_count - 1;
-}
-
-int DRM(resctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_ctx_res_t	res;
-	drm_ctx_t	ctx;
-	int		i;
-
-	DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
-	if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res)))
-		return -EFAULT;
-	if (res.count >= DRM_RESERVED_CONTEXTS) {
-		memset(&ctx, 0, sizeof(ctx));
-		for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
-			ctx.handle = i;
-			if (copy_to_user(&res.contexts[i],
-					 &i,
-					 sizeof(i)))
-				return -EFAULT;
-		}
-	}
-	res.count = DRM_RESERVED_CONTEXTS;
-	if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res)))
-		return -EFAULT;
-	return 0;
-}
-
-int DRM(addctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	if ((ctx.handle = DRM(alloc_queue)(dev)) == DRM_KERNEL_CONTEXT) {
-				/* Init kernel's context and get a new one. */
-		DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx);
-		ctx.handle = DRM(alloc_queue)(dev);
-	}
-	DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx);
-	DRM_DEBUG("%d\n", ctx.handle);
-	if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
-		return -EFAULT;
-	return 0;
-}
-
-int DRM(modctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-	drm_queue_t	*q;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle < 0 || ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	if (DRM_BUFCOUNT(&q->waitlist)) {
-		atomic_dec(&q->use_count);
-		return -EBUSY;
-	}
-
-	q->flags = ctx.flags;
-
-	atomic_dec(&q->use_count);
-	return 0;
-}
-
-int DRM(getctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-	drm_queue_t	*q;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	ctx.flags = q->flags;
-	atomic_dec(&q->use_count);
-
-	if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
-		return -EFAULT;
-
-	return 0;
-}
-
-int DRM(switchctx)(struct inode *inode, struct file *filp,
-		   unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-	return DRM(context_switch)(dev, dev->last_context, ctx.handle);
-}
-
-int DRM(newctx)(struct inode *inode, struct file *filp,
-		unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-	DRM(context_switch_complete)(dev, ctx.handle);
-
-	return 0;
-}
-
-int DRM(rmctx)(struct inode *inode, struct file *filp,
-	       unsigned int cmd, unsigned long arg)
-{
-	drm_file_t	*priv	= filp->private_data;
-	drm_device_t	*dev	= priv->dev;
-	drm_ctx_t	ctx;
-	drm_queue_t	*q;
-	drm_buf_t	*buf;
-
-	if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
-		return -EFAULT;
-	DRM_DEBUG("%d\n", ctx.handle);
-
-	if (ctx.handle >= dev->queue_count) return -EINVAL;
-	q = dev->queuelist[ctx.handle];
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) == 1) {
-				/* No longer in use */
-		atomic_dec(&q->use_count);
-		return -EINVAL;
-	}
-
-	atomic_inc(&q->finalization); /* Mark queue in finalization state */
-	atomic_sub(2, &q->use_count); /* Mark queue as unused (pending
-					 finalization) */
-
-	while (test_and_set_bit(0, &dev->interrupt_flag)) {
-		schedule();
-		if (signal_pending(current)) {
-			clear_bit(0, &dev->interrupt_flag);
-			return -EINTR;
-		}
-	}
-				/* Remove queued buffers */
-	while ((buf = DRM(waitlist_get)(&q->waitlist))) {
-		DRM(free_buffer)(dev, buf);
-	}
-	clear_bit(0, &dev->interrupt_flag);
-
-				/* Wakeup blocked processes */
-	wake_up_interruptible(&q->read_queue);
-	wake_up_interruptible(&q->write_queue);
-	wake_up_interruptible(&q->flush_queue);
-
-				/* Finalization over.  Queue is made
-				   available when both use_count and
-				   finalization become 0, which won't
-				   happen until all the waiting processes
-				   stop waiting. */
-	atomic_dec(&q->finalization);
-	return 0;
-}
-
-#endif /* __HAVE_CTX_BITMAP */
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_dma.h linux-2.5.68-bk7/drivers/char/drm/drm_dma.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_dma.h	2003-04-19 19:50:05.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_dma.h	2003-04-26 04:37:13.000000000 -0700
@@ -83,22 +83,24 @@
 				  dma->bufs[i].buf_count,
 				  dma->bufs[i].seg_count);
 			for (j = 0; j < dma->bufs[i].seg_count; j++) {
-				DRM(free_pages)(dma->bufs[i].seglist[j],
-						dma->bufs[i].page_order,
-						DRM_MEM_DMA);
+				if (dma->bufs[i].seglist[j]) {
+					DRM(free_pages)(dma->bufs[i].seglist[j],
+							dma->bufs[i].page_order,
+							DRM_MEM_DMA);
+				}
 			}
 			DRM(free)(dma->bufs[i].seglist,
 				  dma->bufs[i].seg_count
 				  * sizeof(*dma->bufs[0].seglist),
 				  DRM_MEM_SEGS);
 		}
-	   	if(dma->bufs[i].buf_count) {
-		   	for(j = 0; j < dma->bufs[i].buf_count; j++) {
-			   if(dma->bufs[i].buflist[j].dev_private) {
-			      DRM(free)(dma->bufs[i].buflist[j].dev_private,
-					dma->bufs[i].buflist[j].dev_priv_size,
-					DRM_MEM_BUFS);
-			   }
+	   	if (dma->bufs[i].buf_count) {
+		   	for (j = 0; j < dma->bufs[i].buf_count; j++) {
+				if (dma->bufs[i].buflist[j].dev_private) {
+					DRM(free)(dma->bufs[i].buflist[j].dev_private,
+						  dma->bufs[i].buflist[j].dev_priv_size,
+						  DRM_MEM_BUFS);
+				}
 			}
 		   	DRM(free)(dma->bufs[i].buflist,
 				  dma->bufs[i].buf_count *
@@ -126,61 +128,6 @@
 }
 
 
-#if __HAVE_DMA_HISTOGRAM
-/* This is slow, but is useful for debugging. */
-int DRM(histogram_slot)(unsigned long count)
-{
-	int value = DRM_DMA_HISTOGRAM_INITIAL;
-	int slot;
-
-	for (slot = 0;
-	     slot < DRM_DMA_HISTOGRAM_SLOTS;
-	     ++slot, value = DRM_DMA_HISTOGRAM_NEXT(value)) {
-		if (count < value) return slot;
-	}
-	return DRM_DMA_HISTOGRAM_SLOTS - 1;
-}
-
-void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf)
-{
-	cycles_t queued_to_dispatched;
-	cycles_t dispatched_to_completed;
-	cycles_t completed_to_freed;
-	int	 q2d, d2c, c2f, q2c, q2f;
-
-	if (buf->time_queued) {
-		queued_to_dispatched	= (buf->time_dispatched
-					   - buf->time_queued);
-		dispatched_to_completed = (buf->time_completed
-					   - buf->time_dispatched);
-		completed_to_freed	= (buf->time_freed
-					   - buf->time_completed);
-
-		q2d = DRM(histogram_slot)(queued_to_dispatched);
-		d2c = DRM(histogram_slot)(dispatched_to_completed);
-		c2f = DRM(histogram_slot)(completed_to_freed);
-
-		q2c = DRM(histogram_slot)(queued_to_dispatched
-					  + dispatched_to_completed);
-		q2f = DRM(histogram_slot)(queued_to_dispatched
-					  + dispatched_to_completed
-					  + completed_to_freed);
-
-		atomic_inc(&dev->histo.total);
-		atomic_inc(&dev->histo.queued_to_dispatched[q2d]);
-		atomic_inc(&dev->histo.dispatched_to_completed[d2c]);
-		atomic_inc(&dev->histo.completed_to_freed[c2f]);
-
-		atomic_inc(&dev->histo.queued_to_completed[q2c]);
-		atomic_inc(&dev->histo.queued_to_freed[q2f]);
-
-	}
-	buf->time_queued     = 0;
-	buf->time_dispatched = 0;
-	buf->time_completed  = 0;
-	buf->time_freed	     = 0;
-}
-#endif
 
 void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
 {
@@ -190,9 +137,6 @@
 	buf->pending  = 0;
 	buf->filp     = 0;
 	buf->used     = 0;
-#if __HAVE_DMA_HISTOGRAM
-	buf->time_completed = get_cycles();
-#endif
 
 	if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
 		wake_up_interruptible(&buf->dma_wait);
@@ -237,276 +181,6 @@
 #endif
 
 
-/* GH: This is a big hack for now...
- */
-#if __HAVE_OLD_DMA
-
-void DRM(clear_next_buffer)(drm_device_t *dev)
-{
-	drm_device_dma_t *dma = dev->dma;
-
-	dma->next_buffer = NULL;
-	if (dma->next_queue && !DRM_BUFCOUNT(&dma->next_queue->waitlist)) {
-		wake_up_interruptible(&dma->next_queue->flush_queue);
-	}
-	dma->next_queue	 = NULL;
-}
-
-int DRM(select_queue)(drm_device_t *dev, void (*wrapper)(unsigned long))
-{
-	int	   i;
-	int	   candidate = -1;
-	int	   j	     = jiffies;
-
-	if (!dev) {
-		DRM_ERROR("No device\n");
-		return -1;
-	}
-	if (!dev->queuelist || !dev->queuelist[DRM_KERNEL_CONTEXT]) {
-				/* This only happens between the time the
-				   interrupt is initialized and the time
-				   the queues are initialized. */
-		return -1;
-	}
-
-				/* Doing "while locked" DMA? */
-	if (DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) {
-		return DRM_KERNEL_CONTEXT;
-	}
-
-				/* If there are buffers on the last_context
-				   queue, and we have not been executing
-				   this context very long, continue to
-				   execute this context. */
-	if (dev->last_switch <= j
-	    && dev->last_switch + DRM_TIME_SLICE > j
-	    && DRM_WAITCOUNT(dev, dev->last_context)) {
-		return dev->last_context;
-	}
-
-				/* Otherwise, find a candidate */
-	for (i = dev->last_checked + 1; i < dev->queue_count; i++) {
-		if (DRM_WAITCOUNT(dev, i)) {
-			candidate = dev->last_checked = i;
-			break;
-		}
-	}
-
-	if (candidate < 0) {
-		for (i = 0; i < dev->queue_count; i++) {
-			if (DRM_WAITCOUNT(dev, i)) {
-				candidate = dev->last_checked = i;
-				break;
-			}
-		}
-	}
-
-	if (wrapper
-	    && candidate >= 0
-	    && candidate != dev->last_context
-	    && dev->last_switch <= j
-	    && dev->last_switch + DRM_TIME_SLICE > j) {
-		if (dev->timer.expires != dev->last_switch + DRM_TIME_SLICE) {
-			del_timer(&dev->timer);
-			dev->timer.function = wrapper;
-			dev->timer.data	    = (unsigned long)dev;
-			dev->timer.expires  = dev->last_switch+DRM_TIME_SLICE;
-			add_timer(&dev->timer);
-		}
-		return -1;
-	}
-
-	return candidate;
-}
-
-
-int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int		  i;
-	drm_queue_t	  *q;
-	drm_buf_t	  *buf;
-	int		  idx;
-	int		  while_locked = 0;
-	drm_device_dma_t  *dma = dev->dma;
-	DECLARE_WAITQUEUE(entry, current);
-
-	DRM_DEBUG("%d\n", d->send_count);
-
-	if (d->flags & _DRM_DMA_WHILE_LOCKED) {
-		int context = dev->lock.hw_lock->lock;
-
-		if (!_DRM_LOCK_IS_HELD(context)) {
-			DRM_ERROR("No lock held during \"while locked\""
-				  " request\n");
-			return -EINVAL;
-		}
-		if (d->context != _DRM_LOCKING_CONTEXT(context)
-		    && _DRM_LOCKING_CONTEXT(context) != DRM_KERNEL_CONTEXT) {
-			DRM_ERROR("Lock held by %d while %d makes"
-				  " \"while locked\" request\n",
-				  _DRM_LOCKING_CONTEXT(context),
-				  d->context);
-			return -EINVAL;
-		}
-		q = dev->queuelist[DRM_KERNEL_CONTEXT];
-		while_locked = 1;
-	} else {
-		q = dev->queuelist[d->context];
-	}
-
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->block_write)) {
-		add_wait_queue(&q->write_queue, &entry);
-		atomic_inc(&q->block_count);
-		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
-			if (!atomic_read(&q->block_write)) break;
-			schedule();
-			if (signal_pending(current)) {
-				atomic_dec(&q->use_count);
-				remove_wait_queue(&q->write_queue, &entry);
-				return -EINTR;
-			}
-		}
-		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&q->write_queue, &entry);
-	}
-
-	for (i = 0; i < d->send_count; i++) {
-		idx = d->send_indices[i];
-		if (idx < 0 || idx >= dma->buf_count) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Index %d (of %d max)\n",
-				  d->send_indices[i], dma->buf_count - 1);
-			return -EINVAL;
-		}
-		buf = dma->buflist[ idx ];
-		if (buf->filp != filp) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Process %d using buffer not owned\n",
-				  current->pid);
-			return -EINVAL;
-		}
-		if (buf->list != DRM_LIST_NONE) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Process %d using buffer %d on list %d\n",
-				  current->pid, buf->idx, buf->list);
-		}
-		buf->used	  = d->send_sizes[i];
-		buf->while_locked = while_locked;
-		buf->context	  = d->context;
-		if (!buf->used) {
-			DRM_ERROR("Queueing 0 length buffer\n");
-		}
-		if (buf->pending) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Queueing pending buffer:"
-				  " buffer %d, offset %d\n",
-				  d->send_indices[i], i);
-			return -EINVAL;
-		}
-		if (buf->waiting) {
-			atomic_dec(&q->use_count);
-			DRM_ERROR("Queueing waiting buffer:"
-				  " buffer %d, offset %d\n",
-				  d->send_indices[i], i);
-			return -EINVAL;
-		}
-		buf->waiting = 1;
-		if (atomic_read(&q->use_count) == 1
-		    || atomic_read(&q->finalization)) {
-			DRM(free_buffer)(dev, buf);
-		} else {
-			DRM(waitlist_put)(&q->waitlist, buf);
-			atomic_inc(&q->total_queued);
-		}
-	}
-	atomic_dec(&q->use_count);
-
-	return 0;
-}
-
-static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d,
-					 int order)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int		  i;
-	drm_buf_t	  *buf;
-	drm_device_dma_t  *dma = dev->dma;
-
-	for (i = d->granted_count; i < d->request_count; i++) {
-		buf = DRM(freelist_get)(&dma->bufs[order].freelist,
-					d->flags & _DRM_DMA_WAIT);
-		if (!buf) break;
-		if (buf->pending || buf->waiting) {
-			DRM_ERROR("Free buffer %d in use: filp %p (w%d, p%d)\n",
-				  buf->idx,
-				  buf->filp,
-				  buf->waiting,
-				  buf->pending);
-		}
-		buf->filp     = filp;
-		if (copy_to_user(&d->request_indices[i],
-				 &buf->idx,
-				 sizeof(buf->idx)))
-			return -EFAULT;
-
-		if (copy_to_user(&d->request_sizes[i],
-				 &buf->total,
-				 sizeof(buf->total)))
-			return -EFAULT;
-
-		++d->granted_count;
-	}
-	return 0;
-}
-
-
-int DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma)
-{
-	int		  order;
-	int		  retcode = 0;
-	int		  tmp_order;
-
-	order = DRM(order)(dma->request_size);
-
-	dma->granted_count = 0;
-	retcode		   = DRM(dma_get_buffers_of_order)(filp, dma, order);
-
-	if (dma->granted_count < dma->request_count
-	    && (dma->flags & _DRM_DMA_SMALLER_OK)) {
-		for (tmp_order = order - 1;
-		     !retcode
-			     && dma->granted_count < dma->request_count
-			     && tmp_order >= DRM_MIN_ORDER;
-		     --tmp_order) {
-
-			retcode = DRM(dma_get_buffers_of_order)(filp, dma,
-								tmp_order);
-		}
-	}
-
-	if (dma->granted_count < dma->request_count
-	    && (dma->flags & _DRM_DMA_LARGER_OK)) {
-		for (tmp_order = order + 1;
-		     !retcode
-			     && dma->granted_count < dma->request_count
-			     && tmp_order <= DRM_MAX_ORDER;
-		     ++tmp_order) {
-
-			retcode = DRM(dma_get_buffers_of_order)(filp, dma,
-								tmp_order);
-		}
-	}
-	return 0;
-}
-
-#endif /* __HAVE_OLD_DMA */
 
 
 #if __HAVE_DMA_IRQ
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_drv.h linux-2.5.68-bk7/drivers/char/drm/drm_drv.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_drv.h	2003-04-19 19:50:40.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_drv.h	2003-04-26 04:37:13.000000000 -0700
@@ -84,8 +84,11 @@
 #ifndef __HAVE_SG
 #define __HAVE_SG			0
 #endif
-#ifndef __HAVE_KERNEL_CTX_SWITCH
-#define __HAVE_KERNEL_CTX_SWITCH	0
+#ifndef __HAVE_DRIVER_FOPS_READ
+#define __HAVE_DRIVER_FOPS_READ		0
+#endif
+#ifndef __HAVE_DRIVER_FOPS_POLL
+#define __HAVE_DRIVER_FOPS_POLL		0
 #endif
 
 #ifndef DRIVER_PREINIT
@@ -121,9 +124,9 @@
 	.release = DRM(release),		\
 	.ioctl	 = DRM(ioctl),			\
 	.mmap	 = DRM(mmap),			\
-	.read	 = DRM(read),			\
 	.fasync  = DRM(fasync),			\
 	.poll	 = DRM(poll),			\
+	.read	 = DRM(read),			\
 }
 #endif
 
@@ -167,8 +170,8 @@
 	[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)]     = { DRM(getstats),    0, 0 },
 
 	[DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)]    = { DRM(setunique),   1, 1 },
-	[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)]         = { DRM(block),       1, 1 },
-	[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)]       = { DRM(unblock),     1, 1 },
+	[DRM_IOCTL_NR(DRM_IOCTL_BLOCK)]         = { DRM(noop),        1, 1 },
+	[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)]       = { DRM(noop),        1, 1 },
 	[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)]    = { DRM(authmagic),   1, 1 },
 
 	[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)]       = { DRM(addmap),      1, 1 },
@@ -192,7 +195,13 @@
 
 	[DRM_IOCTL_NR(DRM_IOCTL_LOCK)]	        = { DRM(lock),        1, 0 },
 	[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)]        = { DRM(unlock),      1, 0 },
+
+#if __HAVE_DMA_FLUSH
+	/* Gamma only, really */
 	[DRM_IOCTL_NR(DRM_IOCTL_FINISH)]        = { DRM(finish),      1, 0 },
+#else
+	[DRM_IOCTL_NR(DRM_IOCTL_FINISH)]        = { DRM(noop),      1, 0 },
+#endif
 
 #if __HAVE_DMA
 	[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)]      = { DRM(addbufs),     1, 1 },
@@ -307,7 +316,6 @@
 	if(dev->maplist == NULL) return -ENOMEM;
 	memset(dev->maplist, 0, sizeof(*dev->maplist));
 	INIT_LIST_HEAD(&dev->maplist->head);
-	dev->map_count = 0;
 
 	dev->vmalist = NULL;
 	dev->sigdata.lock = dev->lock.hw_lock = NULL;
@@ -475,7 +483,9 @@
 #if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
 	if ( dev->queuelist ) {
 		for ( i = 0 ; i < dev->queue_count ; i++ ) {
+#if __HAVE_DMA_WAITLIST
 			DRM(waitlist_destroy)( &dev->queuelist[i]->waitlist );
+#endif
 			if ( dev->queuelist[i] ) {
 				DRM(free)( dev->queuelist[i],
 					  sizeof(*dev->queuelist[0]),
@@ -764,7 +774,7 @@
 	DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
 		   current->pid, (long)dev->device, dev->open_count );
 
-	if ( dev->lock.hw_lock &&
+	if ( priv->lock_count && dev->lock.hw_lock &&
 	     _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
 	     dev->lock.filp == filp ) {
 		DRM_DEBUG( "File %p released, freeing lock for context %d\n",
@@ -782,7 +792,7 @@
                                    server. */
 	}
 #if __HAVE_RELEASE
-	else if ( dev->lock.hw_lock ) {
+	else if ( priv->lock_count && dev->lock.hw_lock ) {
 		/* The lock is required to reclaim buffers */
 		DECLARE_WAITQUEUE( entry, current );
 
@@ -802,9 +812,6 @@
 				break;	/* Got lock */
 			}
 				/* Contention */
-#if 0
-			atomic_inc( &dev->total_sleeps );
-#endif
 			schedule();
 			if ( signal_pending( current ) ) {
 				retcode = -ERESTARTSYS;
@@ -925,11 +932,8 @@
 #if __HAVE_MULTIPLE_DMA_QUEUES
 	drm_queue_t *q;
 #endif
-#if __HAVE_DMA_HISTOGRAM
-        cycles_t start;
 
-        dev->lck_start = start = get_cycles();
-#endif
+	++priv->lock_count;
 
         if ( copy_from_user( &lock, (drm_lock_t *)arg, sizeof(lock) ) )
 		return -EFAULT;
@@ -1009,19 +1013,10 @@
 			DRIVER_DMA_QUIESCENT();
 		}
 #endif
-#if __HAVE_KERNEL_CTX_SWITCH
-		if ( dev->last_context != lock.context ) {
-			DRM(context_switch)(dev, dev->last_context,
-					    lock.context);
-		}
-#endif
         }
 
         DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
 
-#if __HAVE_DMA_HISTOGRAM
-        atomic_inc(&dev->histo.lacq[DRM(histogram_slot)(get_cycles()-start)]);
-#endif
         return ret;
 }
 
@@ -1044,25 +1039,6 @@
 
 	atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
 
-#if __HAVE_KERNEL_CTX_SWITCH
-	/* We no longer really hold it, but if we are the next
-	 * agent to request it then we should just be able to
-	 * take it immediately and not eat the ioctl.
-	 */
-	dev->lock.filp = 0;
-	{
-		__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
-		unsigned int old, new, prev, ctx;
-
-		ctx = lock.context;
-		do {
-			old  = *plock;
-			new  = ctx;
-			prev = cmpxchg(plock, old, new);
-		} while (prev != old);
-	}
-	wake_up_interruptible(&dev->lock.lock_queue);
-#else
 	DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
 			    DRM_KERNEL_CONTEXT );
 #if __HAVE_DMA_SCHEDULE
@@ -1077,7 +1053,6 @@
 			DRM_ERROR( "\n" );
 		}
 	}
-#endif /* !__HAVE_KERNEL_CTX_SWITCH */
 
 	unblock_all_signals();
 	return 0;
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_fops.h linux-2.5.68-bk7/drivers/char/drm/drm_fops.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_fops.h	2003-04-19 19:49:56.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_fops.h	2003-04-26 04:37:13.000000000 -0700
@@ -56,6 +56,7 @@
 	priv->dev	    = dev;
 	priv->ioctl_count   = 0;
 	priv->authenticated = capable(CAP_SYS_ADMIN);
+	priv->lock_count    = 0;
 
 	down(&dev->struct_sem);
 	if (!dev->file_last) {
@@ -111,98 +112,17 @@
 	return 0;
 }
 
-
-/* The drm_read and drm_write_string code (especially that which manages
-   the circular buffer), is based on Alessandro Rubini's LINUX DEVICE
-   DRIVERS (Cambridge: O'Reilly, 1998), pages 111-113. */
-
-ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off)
-{
-	drm_file_t    *priv   = filp->private_data;
-	drm_device_t  *dev    = priv->dev;
-	int	      left;
-	int	      avail;
-	int	      send;
-	int	      cur;
-
-	DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp);
-
-	while (dev->buf_rp == dev->buf_wp) {
-		DRM_DEBUG("  sleeping\n");
-		if (filp->f_flags & O_NONBLOCK) {
-			return -EAGAIN;
-		}
-		interruptible_sleep_on(&dev->buf_readers);
-		if (signal_pending(current)) {
-			DRM_DEBUG("  interrupted\n");
-			return -ERESTARTSYS;
-		}
-		DRM_DEBUG("  awake\n");
-	}
-
-	left  = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
-	avail = DRM_BSZ - left;
-	send  = DRM_MIN(avail, count);
-
-	while (send) {
-		if (dev->buf_wp > dev->buf_rp) {
-			cur = DRM_MIN(send, dev->buf_wp - dev->buf_rp);
-		} else {
-			cur = DRM_MIN(send, dev->buf_end - dev->buf_rp);
-		}
-		if (copy_to_user(buf, dev->buf_rp, cur))
-			return -EFAULT;
-		dev->buf_rp += cur;
-		if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf;
-		send -= cur;
-	}
-
-	wake_up_interruptible(&dev->buf_writers);
-	return DRM_MIN(avail, count);;
-}
-
-int DRM(write_string)(drm_device_t *dev, const char *s)
+#if !__HAVE_DRIVER_FOPS_POLL
+unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
 {
-	int left   = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
-	int send   = strlen(s);
-	int count;
-
-	DRM_DEBUG("%d left, %d to send (%p, %p)\n",
-		  left, send, dev->buf_rp, dev->buf_wp);
-
-	if (left == 1 || dev->buf_wp != dev->buf_rp) {
-		DRM_ERROR("Buffer not empty (%d left, wp = %p, rp = %p)\n",
-			  left,
-			  dev->buf_wp,
-			  dev->buf_rp);
-	}
-
-	while (send) {
-		if (dev->buf_wp >= dev->buf_rp) {
-			count = DRM_MIN(send, dev->buf_end - dev->buf_wp);
-			if (count == left) --count; /* Leave a hole */
-		} else {
-			count = DRM_MIN(send, dev->buf_rp - dev->buf_wp - 1);
-		}
-		strncpy(dev->buf_wp, s, count);
-		dev->buf_wp += count;
-		if (dev->buf_wp == dev->buf_end) dev->buf_wp = dev->buf;
-		send -= count;
-	}
-
-	if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN);
-
-	DRM_DEBUG("waking\n");
-	wake_up_interruptible(&dev->buf_readers);
 	return 0;
 }
+#endif
 
-unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
-{
-	drm_file_t   *priv = filp->private_data;
-	drm_device_t *dev  = priv->dev;
 
-	poll_wait(filp, &dev->buf_readers, wait);
-	if (dev->buf_wp != dev->buf_rp) return POLLIN | POLLRDNORM;
+#if !__HAVE_DRIVER_FOPS_READ
+ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off)
+{
 	return 0;
 }
+#endif
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_init.h linux-2.5.68-bk7/drivers/char/drm/drm_init.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_init.h	2003-04-19 19:50:44.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_init.h	2003-04-26 04:37:13.000000000 -0700
@@ -49,11 +49,6 @@
 	for (c = s; *c && *c != ':'; c++); /* find : or \0 */
 	if (*c) r = c + 1; else r = NULL;  /* remember remainder */
 	*c = '\0';			   /* terminate */
-	if (!strcmp(s, "noctx")) {
-		DRM(flags) |= DRM_FLAG_NOCTX;
-		DRM_INFO("Server-mediated context switching OFF\n");
-		return;
-	}
 	if (!strcmp(s, "debug")) {
 		DRM(flags) |= DRM_FLAG_DEBUG;
 		DRM_INFO("Debug messages ON\n");
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_ioctl.h linux-2.5.68-bk7/drivers/char/drm/drm_ioctl.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_ioctl.h	2003-04-19 19:48:55.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_ioctl.h	2003-04-26 04:37:13.000000000 -0700
@@ -196,7 +196,7 @@
 	idx = map.offset;
 
 	down(&dev->struct_sem);
-	if (idx < 0 || idx >= dev->map_count) {
+	if (idx < 0) {
 		up(&dev->struct_sem);
 		return -EINVAL;
 	}
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_lock.h linux-2.5.68-bk7/drivers/char/drm/drm_lock.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_lock.h	2003-04-19 19:50:06.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_lock.h	2003-04-26 04:37:13.000000000 -0700
@@ -31,19 +31,13 @@
 
 #include "drmP.h"
 
-int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd,
+int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
 	       unsigned long arg)
 {
 	DRM_DEBUG("\n");
 	return 0;
 }
 
-int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd,
-		 unsigned long arg)
-{
-	DRM_DEBUG("\n");
-	return 0;
-}
 
 int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
 {
@@ -108,113 +102,6 @@
 	return 0;
 }
 
-static int DRM(flush_queue)(drm_device_t *dev, int context)
-{
-	DECLARE_WAITQUEUE(entry, current);
-	int		  ret	= 0;
-	drm_queue_t	  *q	= dev->queuelist[context];
-
-	DRM_DEBUG("\n");
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) > 1) {
-		atomic_inc(&q->block_write);
-		add_wait_queue(&q->flush_queue, &entry);
-		atomic_inc(&q->block_count);
-		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
-			if (!DRM_BUFCOUNT(&q->waitlist)) break;
-			schedule();
-			if (signal_pending(current)) {
-				ret = -EINTR; /* Can't restart */
-				break;
-			}
-		}
-		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
-		remove_wait_queue(&q->flush_queue, &entry);
-	}
-	atomic_dec(&q->use_count);
-
-				/* NOTE: block_write is still incremented!
-				   Use drm_flush_unlock_queue to decrement. */
-	return ret;
-}
-
-static int DRM(flush_unblock_queue)(drm_device_t *dev, int context)
-{
-	drm_queue_t	  *q	= dev->queuelist[context];
-
-	DRM_DEBUG("\n");
-
-	atomic_inc(&q->use_count);
-	if (atomic_read(&q->use_count) > 1) {
-		if (atomic_read(&q->block_write)) {
-			atomic_dec(&q->block_write);
-			wake_up_interruptible(&q->write_queue);
-		}
-	}
-	atomic_dec(&q->use_count);
-	return 0;
-}
-
-int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
-			       drm_lock_flags_t flags)
-{
-	int ret = 0;
-	int i;
-
-	DRM_DEBUG("\n");
-
-	if (flags & _DRM_LOCK_FLUSH) {
-		ret = DRM(flush_queue)(dev, DRM_KERNEL_CONTEXT);
-		if (!ret) ret = DRM(flush_queue)(dev, context);
-	}
-	if (flags & _DRM_LOCK_FLUSH_ALL) {
-		for (i = 0; !ret && i < dev->queue_count; i++) {
-			ret = DRM(flush_queue)(dev, i);
-		}
-	}
-	return ret;
-}
-
-int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags)
-{
-	int ret = 0;
-	int i;
-
-	DRM_DEBUG("\n");
-
-	if (flags & _DRM_LOCK_FLUSH) {
-		ret = DRM(flush_unblock_queue)(dev, DRM_KERNEL_CONTEXT);
-		if (!ret) ret = DRM(flush_unblock_queue)(dev, context);
-	}
-	if (flags & _DRM_LOCK_FLUSH_ALL) {
-		for (i = 0; !ret && i < dev->queue_count; i++) {
-			ret = DRM(flush_unblock_queue)(dev, i);
-		}
-	}
-
-	return ret;
-}
-
-int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd,
-		unsigned long arg)
-{
-	drm_file_t	  *priv	  = filp->private_data;
-	drm_device_t	  *dev	  = priv->dev;
-	int		  ret	  = 0;
-	drm_lock_t	  lock;
-
-	DRM_DEBUG("\n");
-
-	if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
-		return -EFAULT;
-	ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags);
-	DRM(flush_unblock)(dev, lock.context, lock.flags);
-	return ret;
-}
-
 /* If we get here, it means that the process has called DRM_IOCTL_LOCK
    without calling DRM_IOCTL_UNLOCK.
 
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_memory.h linux-2.5.68-bk7/drivers/char/drm/drm_memory.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_memory.h	2003-04-26 04:37:08.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_memory.h	2003-04-26 04:37:13.000000000 -0700
@@ -32,186 +32,47 @@
 #include <linux/config.h>
 #include "drmP.h"
 
-typedef struct drm_mem_stats {
-	const char	  *name;
-	int		  succeed_count;
-	int		  free_count;
-	int		  fail_count;
-	unsigned long	  bytes_allocated;
-	unsigned long	  bytes_freed;
-} drm_mem_stats_t;
-
-static spinlock_t	  DRM(mem_lock)	     = SPIN_LOCK_UNLOCKED;
-static unsigned long	  DRM(ram_available) = 0; /* In pages */
-static unsigned long	  DRM(ram_used)      = 0;
-static drm_mem_stats_t	  DRM(mem_stats)[]   = {
-	[DRM_MEM_DMA]	    = { "dmabufs"  },
-	[DRM_MEM_SAREA]	    = { "sareas"   },
-	[DRM_MEM_DRIVER]    = { "driver"   },
-	[DRM_MEM_MAGIC]	    = { "magic"	   },
-	[DRM_MEM_IOCTLS]    = { "ioctltab" },
-	[DRM_MEM_MAPS]	    = { "maplist"  },
-	[DRM_MEM_VMAS]	    = { "vmalist"  },
-	[DRM_MEM_BUFS]	    = { "buflist"  },
-	[DRM_MEM_SEGS]	    = { "seglist"  },
-	[DRM_MEM_PAGES]	    = { "pagelist" },
-	[DRM_MEM_FILES]	    = { "files"	   },
-	[DRM_MEM_QUEUES]    = { "queues"   },
-	[DRM_MEM_CMDS]	    = { "commands" },
-	[DRM_MEM_MAPPINGS]  = { "mappings" },
-	[DRM_MEM_BUFLISTS]  = { "buflists" },
-	[DRM_MEM_AGPLISTS]  = { "agplist"  },
-	[DRM_MEM_SGLISTS]   = { "sglist"   },
-	[DRM_MEM_TOTALAGP]  = { "totalagp" },
-	[DRM_MEM_BOUNDAGP]  = { "boundagp" },
-	[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
-	[DRM_MEM_STUB]      = { "stub"     },
-	{ NULL, 0, }		/* Last entry must be null */
-};
+/* Cut down version of drm_memory_debug.h, which used to be called
+ * drm_memory.h.  If you want the debug functionality, change 0 to 1
+ * below.
+ */
+#define DEBUG_MEMORY 0
 
+
+#if DEBUG_MEMORY
+#include "drm_memory_debug.h"
+#else
 void DRM(mem_init)(void)
 {
-	drm_mem_stats_t *mem;
-	struct sysinfo	si;
-
-	for (mem = DRM(mem_stats); mem->name; ++mem) {
-		mem->succeed_count   = 0;
-		mem->free_count	     = 0;
-		mem->fail_count	     = 0;
-		mem->bytes_allocated = 0;
-		mem->bytes_freed     = 0;
-	}
-
-	si_meminfo(&si);
-	DRM(ram_available) = si.totalram;
-	DRM(ram_used)	   = 0;
 }
 
 /* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-
-static int DRM(_mem_info)(char *buf, char **start, off_t offset,
-			  int request, int *eof, void *data)
-{
-	drm_mem_stats_t *pt;
-	int             len = 0;
-
-	if (offset > DRM_PROC_LIMIT) {
-		*eof = 1;
-		return 0;
-	}
-
-	*eof   = 0;
-	*start = &buf[offset];
-
-	DRM_PROC_PRINT("		  total counts			"
-		       " |    outstanding  \n");
-	DRM_PROC_PRINT("type	   alloc freed fail	bytes	   freed"
-		       " | allocs      bytes\n\n");
-	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
-		       "system", 0, 0, 0,
-		       DRM(ram_available) << (PAGE_SHIFT - 10));
-	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
-		       "locked", 0, 0, 0, DRM(ram_used) >> 10);
-	DRM_PROC_PRINT("\n");
-	for (pt = DRM(mem_stats); pt->name; pt++) {
-		DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
-			       pt->name,
-			       pt->succeed_count,
-			       pt->free_count,
-			       pt->fail_count,
-			       pt->bytes_allocated,
-			       pt->bytes_freed,
-			       pt->succeed_count - pt->free_count,
-			       (long)pt->bytes_allocated
-			       - (long)pt->bytes_freed);
-	}
-
-	if (len > request + offset) return request;
-	*eof = 1;
-	return len - offset;
-}
-
 int DRM(mem_info)(char *buf, char **start, off_t offset,
 		  int len, int *eof, void *data)
 {
-	int ret;
-
-	spin_lock(&DRM(mem_lock));
-	ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
-	spin_unlock(&DRM(mem_lock));
-	return ret;
+	return 0;
 }
 
 void *DRM(alloc)(size_t size, int area)
 {
-	void *pt;
-
-	if (!size) {
-		DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
-		return NULL;
-	}
-
-	if (!(pt = kmalloc(size, GFP_KERNEL))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[area].fail_count;
-		spin_unlock(&DRM(mem_lock));
-		return NULL;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_allocated += size;
-	spin_unlock(&DRM(mem_lock));
-	return pt;
+	return kmalloc(size, GFP_KERNEL);
 }
 
 void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
 {
 	void *pt;
 
-	if (!(pt = DRM(alloc)(size, area))) return NULL;
+	if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL;
 	if (oldpt && oldsize) {
 		memcpy(pt, oldpt, oldsize);
-		DRM(free)(oldpt, oldsize, area);
+		kfree(oldpt);
 	}
 	return pt;
 }
 
-char *DRM(strdup)(const char *s, int area)
-{
-	char *pt;
-	int	 length = s ? strlen(s) : 0;
-
-	if (!(pt = DRM(alloc)(length+1, area))) return NULL;
-	strcpy(pt, s);
-	return pt;
-}
-
-void DRM(strfree)(const char *s, int area)
-{
-	unsigned int size;
-
-	if (!s) return;
-
-	size = 1 + (s ? strlen(s) : 0);
-	DRM(free)((void *)s, size, area);
-}
-
 void DRM(free)(void *pt, size_t size, int area)
 {
-	int alloc_count;
-	int free_count;
-
-	if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
-	else	 kfree(pt);
-	spin_lock(&DRM(mem_lock));
-	DRM(mem_stats)[area].bytes_freed += size;
-	free_count  = ++DRM(mem_stats)[area].free_count;
-	alloc_count =	DRM(mem_stats)[area].succeed_count;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
+	kfree(pt);
 }
 
 unsigned long DRM(alloc_pages)(int order, int area)
@@ -221,29 +82,11 @@
 	unsigned long addr;
 	unsigned int  sz;
 
-	spin_lock(&DRM(mem_lock));
-	if ((DRM(ram_used) >> PAGE_SHIFT)
-	    > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
-		spin_unlock(&DRM(mem_lock));
-		return 0;
-	}
-	spin_unlock(&DRM(mem_lock));
-
 	address = __get_free_pages(GFP_KERNEL, order);
-	if (!address) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[area].fail_count;
-		spin_unlock(&DRM(mem_lock));
+	if (!address) 
 		return 0;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_allocated += bytes;
-	DRM(ram_used)		             += bytes;
-	spin_unlock(&DRM(mem_lock));
-
 
-				/* Zero outside the lock */
+				/* Zero */
 	memset((void *)address, 0, bytes);
 
 				/* Reserve */
@@ -259,207 +102,56 @@
 void DRM(free_pages)(unsigned long address, int order, int area)
 {
 	unsigned long bytes = PAGE_SIZE << order;
-	int		  alloc_count;
-	int		  free_count;
 	unsigned long addr;
 	unsigned int  sz;
 
-	if (!address) {
-		DRM_MEM_ERROR(area, "Attempt to free address 0\n");
-	} else {
-				/* Unreserve */
-		for (addr = address, sz = bytes;
-		     sz > 0;
-		     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
-			ClearPageReserved(virt_to_page(addr));
-		}
-		free_pages(address, order);
-	}
+	if (!address) 
+		return;
 
-	spin_lock(&DRM(mem_lock));
-	free_count  = ++DRM(mem_stats)[area].free_count;
-	alloc_count =	DRM(mem_stats)[area].succeed_count;
-	DRM(mem_stats)[area].bytes_freed += bytes;
-	DRM(ram_used)			 -= bytes;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(area,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
+	/* Unreserve */
+	for (addr = address, sz = bytes;
+	     sz > 0;
+	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+		ClearPageReserved(virt_to_page(addr));
 	}
+
+	free_pages(address, order);
 }
 
 void *DRM(ioremap)(unsigned long offset, unsigned long size)
 {
-	void *pt;
-
-	if (!size) {
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Mapping 0 bytes at 0x%08lx\n", offset);
-		return NULL;
-	}
-
-	if (!(pt = ioremap(offset, size))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
-		spin_unlock(&DRM(mem_lock));
-		return NULL;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
-	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
-	spin_unlock(&DRM(mem_lock));
-	return pt;
+	return ioremap(offset, size);
 }
 
 void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size)
 {
-	void *pt;
-
-	if (!size) {
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Mapping 0 bytes at 0x%08lx\n", offset);
-		return NULL;
-	}
-
-	if (!(pt = ioremap_nocache(offset, size))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
-		spin_unlock(&DRM(mem_lock));
-		return NULL;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
-	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
-	spin_unlock(&DRM(mem_lock));
-	return pt;
+	return ioremap_nocache(offset, size);
 }
 
 void DRM(ioremapfree)(void *pt, unsigned long size)
 {
-	int alloc_count;
-	int free_count;
-
-	if (!pt)
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Attempt to free NULL pointer\n");
-	else
-		iounmap(pt);
-
-	spin_lock(&DRM(mem_lock));
-	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
-	free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
-	alloc_count =	DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
+	iounmap(pt);
 }
 
 #if __REALLY_HAVE_AGP
-
 agp_memory *DRM(alloc_agp)(int pages, u32 type)
 {
-	agp_memory *handle;
-
-	if (!pages) {
-		DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
-		return NULL;
-	}
-
-	if ((handle = DRM(agp_allocate_memory)(pages, type))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
-			+= pages << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		return handle;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
-	spin_unlock(&DRM(mem_lock));
-	return NULL;
+	return DRM(agp_allocate_memory)(pages, type);
 }
 
 int DRM(free_agp)(agp_memory *handle, int pages)
 {
-	int           alloc_count;
-	int           free_count;
-	int           retval = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
-			      "Attempt to free NULL AGP handle\n");
-		return retval;;
-	}
-
-	if (DRM(agp_free_memory)(handle)) {
-		spin_lock(&DRM(mem_lock));
-		free_count  = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
-		alloc_count =   DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
-			+= pages << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		if (free_count > alloc_count) {
-			DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
-				      "Excess frees: %d frees, %d allocs\n",
-				      free_count, alloc_count);
-		}
-		return 0;
-	}
-	return retval;
+	return DRM(agp_free_memory)(handle) ? 0 : -EINVAL;
 }
 
 int DRM(bind_agp)(agp_memory *handle, unsigned int start)
 {
-	int retcode = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Attempt to bind NULL AGP handle\n");
-		return retcode;
-	}
-
-	if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
-		spin_lock(&DRM(mem_lock));
-		++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
-		DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
-			+= handle->page_count << PAGE_SHIFT;
-		spin_unlock(&DRM(mem_lock));
-		return retcode;
-	}
-	spin_lock(&DRM(mem_lock));
-	++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
-	spin_unlock(&DRM(mem_lock));
-	return retcode;
+	return DRM(agp_bind_memory)(handle, start);
 }
 
 int DRM(unbind_agp)(agp_memory *handle)
 {
-	int alloc_count;
-	int free_count;
-	int retcode = -EINVAL;
-
-	if (!handle) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Attempt to unbind NULL AGP handle\n");
-		return retcode;
-	}
-
-	if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
-	spin_lock(&DRM(mem_lock));
-	free_count  = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
-	alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
-	DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
-		+= handle->page_count << PAGE_SHIFT;
-	spin_unlock(&DRM(mem_lock));
-	if (free_count > alloc_count) {
-		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
-			      "Excess frees: %d frees, %d allocs\n",
-			      free_count, alloc_count);
-	}
-	return retcode;
+	return DRM(agp_unbind_memory)(handle);
 }
-#endif
+#endif /* agp */
+#endif /* debug_memory */
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_memory_debug.h linux-2.5.68-bk7/drivers/char/drm/drm_memory_debug.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_memory_debug.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.5.68-bk7/drivers/char/drm/drm_memory_debug.h	2003-04-26 04:37:13.000000000 -0700
@@ -0,0 +1,445 @@
+/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
+ * Created: Thu Feb  4 14:00:34 1999 by faith@valinux.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Rickard E. (Rik) Faith <faith@valinux.com>
+ *    Gareth Hughes <gareth@valinux.com>
+ */
+
+#include <linux/config.h>
+#include "drmP.h"
+
+typedef struct drm_mem_stats {
+	const char	  *name;
+	int		  succeed_count;
+	int		  free_count;
+	int		  fail_count;
+	unsigned long	  bytes_allocated;
+	unsigned long	  bytes_freed;
+} drm_mem_stats_t;
+
+static spinlock_t	  DRM(mem_lock)	     = SPIN_LOCK_UNLOCKED;
+static unsigned long	  DRM(ram_available) = 0; /* In pages */
+static unsigned long	  DRM(ram_used)      = 0;
+static drm_mem_stats_t	  DRM(mem_stats)[]   = {
+	[DRM_MEM_DMA]	    = { "dmabufs"  },
+	[DRM_MEM_SAREA]	    = { "sareas"   },
+	[DRM_MEM_DRIVER]    = { "driver"   },
+	[DRM_MEM_MAGIC]	    = { "magic"	   },
+	[DRM_MEM_IOCTLS]    = { "ioctltab" },
+	[DRM_MEM_MAPS]	    = { "maplist"  },
+	[DRM_MEM_VMAS]	    = { "vmalist"  },
+	[DRM_MEM_BUFS]	    = { "buflist"  },
+	[DRM_MEM_SEGS]	    = { "seglist"  },
+	[DRM_MEM_PAGES]	    = { "pagelist" },
+	[DRM_MEM_FILES]	    = { "files"	   },
+	[DRM_MEM_QUEUES]    = { "queues"   },
+	[DRM_MEM_CMDS]	    = { "commands" },
+	[DRM_MEM_MAPPINGS]  = { "mappings" },
+	[DRM_MEM_BUFLISTS]  = { "buflists" },
+	[DRM_MEM_AGPLISTS]  = { "agplist"  },
+	[DRM_MEM_SGLISTS]   = { "sglist"   },
+	[DRM_MEM_TOTALAGP]  = { "totalagp" },
+	[DRM_MEM_BOUNDAGP]  = { "boundagp" },
+	[DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
+	[DRM_MEM_STUB]      = { "stub"     },
+	{ NULL, 0, }		/* Last entry must be null */
+};
+
+void DRM(mem_init)(void)
+{
+	drm_mem_stats_t *mem;
+	struct sysinfo	si;
+
+	for (mem = DRM(mem_stats); mem->name; ++mem) {
+		mem->succeed_count   = 0;
+		mem->free_count	     = 0;
+		mem->fail_count	     = 0;
+		mem->bytes_allocated = 0;
+		mem->bytes_freed     = 0;
+	}
+
+	si_meminfo(&si);
+	DRM(ram_available) = si.totalram;
+	DRM(ram_used)	   = 0;
+}
+
+/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
+
+static int DRM(_mem_info)(char *buf, char **start, off_t offset,
+			  int request, int *eof, void *data)
+{
+	drm_mem_stats_t *pt;
+	int             len = 0;
+
+	if (offset > DRM_PROC_LIMIT) {
+		*eof = 1;
+		return 0;
+	}
+
+	*eof   = 0;
+	*start = &buf[offset];
+
+	DRM_PROC_PRINT("		  total counts			"
+		       " |    outstanding  \n");
+	DRM_PROC_PRINT("type	   alloc freed fail	bytes	   freed"
+		       " | allocs      bytes\n\n");
+	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
+		       "system", 0, 0, 0,
+		       DRM(ram_available) << (PAGE_SHIFT - 10));
+	DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB         |\n",
+		       "locked", 0, 0, 0, DRM(ram_used) >> 10);
+	DRM_PROC_PRINT("\n");
+	for (pt = DRM(mem_stats); pt->name; pt++) {
+		DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
+			       pt->name,
+			       pt->succeed_count,
+			       pt->free_count,
+			       pt->fail_count,
+			       pt->bytes_allocated,
+			       pt->bytes_freed,
+			       pt->succeed_count - pt->free_count,
+			       (long)pt->bytes_allocated
+			       - (long)pt->bytes_freed);
+	}
+
+	if (len > request + offset) return request;
+	*eof = 1;
+	return len - offset;
+}
+
+int DRM(mem_info)(char *buf, char **start, off_t offset,
+		  int len, int *eof, void *data)
+{
+	int ret;
+
+	spin_lock(&DRM(mem_lock));
+	ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
+	spin_unlock(&DRM(mem_lock));
+	return ret;
+}
+
+void *DRM(alloc)(size_t size, int area)
+{
+	void *pt;
+
+	if (!size) {
+		DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
+		return NULL;
+	}
+
+	if (!(pt = kmalloc(size, GFP_KERNEL))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[area].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return NULL;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_allocated += size;
+	spin_unlock(&DRM(mem_lock));
+	return pt;
+}
+
+void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
+{
+	void *pt;
+
+	if (!(pt = DRM(alloc)(size, area))) return NULL;
+	if (oldpt && oldsize) {
+		memcpy(pt, oldpt, oldsize);
+		DRM(free)(oldpt, oldsize, area);
+	}
+	return pt;
+}
+
+void DRM(free)(void *pt, size_t size, int area)
+{
+	int alloc_count;
+	int free_count;
+
+	if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
+	else	 kfree(pt);
+	spin_lock(&DRM(mem_lock));
+	DRM(mem_stats)[area].bytes_freed += size;
+	free_count  = ++DRM(mem_stats)[area].free_count;
+	alloc_count =	DRM(mem_stats)[area].succeed_count;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+unsigned long DRM(alloc_pages)(int order, int area)
+{
+	unsigned long address;
+	unsigned long bytes	  = PAGE_SIZE << order;
+	unsigned long addr;
+	unsigned int  sz;
+
+	spin_lock(&DRM(mem_lock));
+	if ((DRM(ram_used) >> PAGE_SHIFT)
+	    > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
+		spin_unlock(&DRM(mem_lock));
+		return 0;
+	}
+	spin_unlock(&DRM(mem_lock));
+
+	address = __get_free_pages(GFP_KERNEL, order);
+	if (!address) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[area].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return 0;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_allocated += bytes;
+	DRM(ram_used)		             += bytes;
+	spin_unlock(&DRM(mem_lock));
+
+
+				/* Zero outside the lock */
+	memset((void *)address, 0, bytes);
+
+				/* Reserve */
+	for (addr = address, sz = bytes;
+	     sz > 0;
+	     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+		SetPageReserved(virt_to_page(addr));
+	}
+
+	return address;
+}
+
+void DRM(free_pages)(unsigned long address, int order, int area)
+{
+	unsigned long bytes = PAGE_SIZE << order;
+	int		  alloc_count;
+	int		  free_count;
+	unsigned long addr;
+	unsigned int  sz;
+
+	if (!address) {
+		DRM_MEM_ERROR(area, "Attempt to free address 0\n");
+	} else {
+				/* Unreserve */
+		for (addr = address, sz = bytes;
+		     sz > 0;
+		     addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+			ClearPageReserved(virt_to_page(addr));
+		}
+		free_pages(address, order);
+	}
+
+	spin_lock(&DRM(mem_lock));
+	free_count  = ++DRM(mem_stats)[area].free_count;
+	alloc_count =	DRM(mem_stats)[area].succeed_count;
+	DRM(mem_stats)[area].bytes_freed += bytes;
+	DRM(ram_used)			 -= bytes;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(area,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+void *DRM(ioremap)(unsigned long offset, unsigned long size)
+{
+	void *pt;
+
+	if (!size) {
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Mapping 0 bytes at 0x%08lx\n", offset);
+		return NULL;
+	}
+
+	if (!(pt = ioremap(offset, size))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return NULL;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
+	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
+	spin_unlock(&DRM(mem_lock));
+	return pt;
+}
+
+void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size)
+{
+	void *pt;
+
+	if (!size) {
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Mapping 0 bytes at 0x%08lx\n", offset);
+		return NULL;
+	}
+
+	if (!(pt = ioremap_nocache(offset, size))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
+		spin_unlock(&DRM(mem_lock));
+		return NULL;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
+	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
+	spin_unlock(&DRM(mem_lock));
+	return pt;
+}
+
+void DRM(ioremapfree)(void *pt, unsigned long size)
+{
+	int alloc_count;
+	int free_count;
+
+	if (!pt)
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Attempt to free NULL pointer\n");
+	else
+		iounmap(pt);
+
+	spin_lock(&DRM(mem_lock));
+	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
+	free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
+	alloc_count =	DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+}
+
+#if __REALLY_HAVE_AGP
+
+agp_memory *DRM(alloc_agp)(int pages, u32 type)
+{
+	agp_memory *handle;
+
+	if (!pages) {
+		DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
+		return NULL;
+	}
+
+	if ((handle = DRM(agp_allocate_memory)(pages, type))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
+			+= pages << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		return handle;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
+	spin_unlock(&DRM(mem_lock));
+	return NULL;
+}
+
+int DRM(free_agp)(agp_memory *handle, int pages)
+{
+	int           alloc_count;
+	int           free_count;
+	int           retval = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+			      "Attempt to free NULL AGP handle\n");
+		return retval;;
+	}
+
+	if (DRM(agp_free_memory)(handle)) {
+		spin_lock(&DRM(mem_lock));
+		free_count  = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
+		alloc_count =   DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
+			+= pages << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		if (free_count > alloc_count) {
+			DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+				      "Excess frees: %d frees, %d allocs\n",
+				      free_count, alloc_count);
+		}
+		return 0;
+	}
+	return retval;
+}
+
+int DRM(bind_agp)(agp_memory *handle, unsigned int start)
+{
+	int retcode = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Attempt to bind NULL AGP handle\n");
+		return retcode;
+	}
+
+	if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
+		spin_lock(&DRM(mem_lock));
+		++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
+		DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
+			+= handle->page_count << PAGE_SHIFT;
+		spin_unlock(&DRM(mem_lock));
+		return retcode;
+	}
+	spin_lock(&DRM(mem_lock));
+	++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
+	spin_unlock(&DRM(mem_lock));
+	return retcode;
+}
+
+int DRM(unbind_agp)(agp_memory *handle)
+{
+	int alloc_count;
+	int free_count;
+	int retcode = -EINVAL;
+
+	if (!handle) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Attempt to unbind NULL AGP handle\n");
+		return retcode;
+	}
+
+	if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
+	spin_lock(&DRM(mem_lock));
+	free_count  = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
+	alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
+	DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
+		+= handle->page_count << PAGE_SHIFT;
+	spin_unlock(&DRM(mem_lock));
+	if (free_count > alloc_count) {
+		DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+			      "Excess frees: %d frees, %d allocs\n",
+			      free_count, alloc_count);
+	}
+	return retcode;
+}
+#endif
diff -urN linux-2.5.68-bk6/drivers/char/drm/drm_proc.h linux-2.5.68-bk7/drivers/char/drm/drm_proc.h
--- linux-2.5.68-bk6/drivers/char/drm/drm_proc.h	2003-04-19 19:48:51.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/drm_proc.h	2003-04-26 04:37:13.000000000 -0700
@@ -49,10 +49,6 @@
 static int	   DRM(vma_info)(char *buf, char **start, off_t offset,
 				 int request, int *eof, void *data);
 #endif
-#if __HAVE_DMA_HISTOGRAM
-static int	   DRM(histo_info)(char *buf, char **start, off_t offset,
-				   int request, int *eof, void *data);
-#endif
 
 struct drm_proc_list {
 	const char *name;
@@ -67,9 +63,6 @@
 #if DRM_DEBUG_CODE
 	{ "vma",     DRM(vma_info)     },
 #endif
-#if __HAVE_DMA_HISTOGRAM
-	{ "histo",   DRM(histo_info)   },
-#endif
 };
 #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
 
@@ -490,143 +483,3 @@
 #endif
 
 
-#if __HAVE_DMA_HISTOGRAM
-static int DRM(_histo_info)(char *buf, char **start, off_t offset, int request,
-			    int *eof, void *data)
-{
-	drm_device_t	 *dev = (drm_device_t *)data;
-	int              len  = 0;
-	drm_device_dma_t *dma = dev->dma;
-	int		 i;
-	unsigned long	 slot_value = DRM_DMA_HISTOGRAM_INITIAL;
-	unsigned long	 prev_value = 0;
-	drm_buf_t	 *buffer;
-
-	if (offset > DRM_PROC_LIMIT) {
-		*eof = 1;
-		return 0;
-	}
-
-	*start = &buf[offset];
-	*eof   = 0;
-
-	DRM_PROC_PRINT("general statistics:\n");
-	DRM_PROC_PRINT("total	 %10u\n", atomic_read(&dev->histo.total));
-	DRM_PROC_PRINT("open	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_OPENS]));
-	DRM_PROC_PRINT("close	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_CLOSES]));
-	DRM_PROC_PRINT("ioctl	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_IOCTLS]));
-
-	DRM_PROC_PRINT("\nlock statistics:\n");
-	DRM_PROC_PRINT("locks	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_LOCKS]));
-	DRM_PROC_PRINT("unlocks	 %10u\n",
-		       atomic_read(&dev->counts[_DRM_STAT_UNLOCKS]));
-
-	if (dma) {
-#if 0
-		DRM_PROC_PRINT("\ndma statistics:\n");
-		DRM_PROC_PRINT("prio	 %10u\n",
-			       atomic_read(&dma->total_prio));
-		DRM_PROC_PRINT("bytes	 %10u\n",
-			       atomic_read(&dma->total_bytes));
-		DRM_PROC_PRINT("dmas	 %10u\n",
-			       atomic_read(&dma->total_dmas));
-		DRM_PROC_PRINT("missed:\n");
-		DRM_PROC_PRINT("  dma	 %10u\n",
-			       atomic_read(&dma->total_missed_dma));
-		DRM_PROC_PRINT("  lock	 %10u\n",
-			       atomic_read(&dma->total_missed_lock));
-		DRM_PROC_PRINT("  free	 %10u\n",
-			       atomic_read(&dma->total_missed_free));
-		DRM_PROC_PRINT("  sched	 %10u\n",
-			       atomic_read(&dma->total_missed_sched));
-		DRM_PROC_PRINT("tried	 %10u\n",
-			       atomic_read(&dma->total_tried));
-		DRM_PROC_PRINT("hit	 %10u\n",
-			       atomic_read(&dma->total_hit));
-		DRM_PROC_PRINT("lost	 %10u\n",
-			       atomic_read(&dma->total_lost));
-#endif
-
-		buffer = dma->next_buffer;
-		if (buffer) {
-			DRM_PROC_PRINT("next_buffer %7d\n", buffer->idx);
-		} else {
-			DRM_PROC_PRINT("next_buffer    none\n");
-		}
-		buffer = dma->this_buffer;
-		if (buffer) {
-			DRM_PROC_PRINT("this_buffer %7d\n", buffer->idx);
-		} else {
-			DRM_PROC_PRINT("this_buffer    none\n");
-		}
-	}
-
-
-	DRM_PROC_PRINT("\nvalues:\n");
-	if (dev->lock.hw_lock) {
-		DRM_PROC_PRINT("lock	       0x%08x\n",
-			       dev->lock.hw_lock->lock);
-	} else {
-		DRM_PROC_PRINT("lock		     none\n");
-	}
-	DRM_PROC_PRINT("context_flag   0x%08lx\n", dev->context_flag);
-	DRM_PROC_PRINT("interrupt_flag 0x%08lx\n", dev->interrupt_flag);
-	DRM_PROC_PRINT("dma_flag       0x%08lx\n", dev->dma_flag);
-
-	DRM_PROC_PRINT("queue_count    %10d\n",	 dev->queue_count);
-	DRM_PROC_PRINT("last_context   %10d\n",	 dev->last_context);
-	DRM_PROC_PRINT("last_switch    %10lu\n", dev->last_switch);
-	DRM_PROC_PRINT("last_checked   %10d\n",	 dev->last_checked);
-
-
-	DRM_PROC_PRINT("\n		       q2d	  d2c	     c2f"
-		       "	q2c	   q2f	      dma	 sch"
-		       "	ctx	  lacq	     lhld\n\n");
-	for (i = 0; i < DRM_DMA_HISTOGRAM_SLOTS; i++) {
-		DRM_PROC_PRINT("%s %10lu %10u %10u %10u %10u %10u"
-			       " %10u %10u %10u %10u %10u\n",
-			       i == DRM_DMA_HISTOGRAM_SLOTS - 1 ? ">=" : "< ",
-			       i == DRM_DMA_HISTOGRAM_SLOTS - 1
-			       ? prev_value : slot_value ,
-
-			       atomic_read(&dev->histo
-					   .queued_to_dispatched[i]),
-			       atomic_read(&dev->histo
-					   .dispatched_to_completed[i]),
-			       atomic_read(&dev->histo
-					   .completed_to_freed[i]),
-
-			       atomic_read(&dev->histo
-					   .queued_to_completed[i]),
-			       atomic_read(&dev->histo
-					   .queued_to_freed[i]),
-			       atomic_read(&dev->histo.dma[i]),
-			       atomic_read(&dev->histo.schedule[i]),
-			       atomic_read(&dev->histo.ctx[i]),
-			       atomic_read(&dev->histo.lacq[i]),
-			       atomic_read(&dev->histo.lhld[i]));
-		prev_value = slot_value;
-		slot_value = DRM_DMA_HISTOGRAM_NEXT(slot_value);
-	}
-
-	if (len > request + offset) return request;
-	*eof = 1;
-	return len - offset;
-}
-
-static int DRM(histo_info)(char *buf, char **start, off_t offset, int request,
-			   int *eof, void *data)
-{
-	drm_device_t *dev = (drm_device_t *)data;
-	int	     ret;
-
-	down(&dev->struct_sem);
-	ret = DRM(_histo_info)(buf, start, offset, request, eof, data);
-	up(&dev->struct_sem);
-	return ret;
-}
-#endif
diff -urN linux-2.5.68-bk6/drivers/char/drm/gamma.h linux-2.5.68-bk7/drivers/char/drm/gamma.h
--- linux-2.5.68-bk6/drivers/char/drm/gamma.h	2003-04-19 19:48:46.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/gamma.h	2003-04-26 04:37:13.000000000 -0700
@@ -71,6 +71,9 @@
 #define __HAVE_OLD_DMA			1
 #define __HAVE_PCI_DMA			1
 
+#define __HAVE_DRIVER_FOPS_READ		1
+#define __HAVE_DRIVER_FOPS_POLL		1
+
 #define __HAVE_MULTIPLE_DMA_QUEUES	1
 #define __HAVE_DMA_WAITQUEUE		1
 
@@ -87,62 +90,19 @@
 
 #define __HAVE_DMA_QUIESCENT		1
 #define DRIVER_DMA_QUIESCENT() do {					\
-	/* FIXME ! */ 							\
-	gamma_dma_quiescent_single(dev);					\
+	drm_gamma_private_t *dev_priv =					\
+		(drm_gamma_private_t *)dev->dev_private;		\
+	if (dev_priv->num_rast == 2)					\
+		gamma_dma_quiescent_dual(dev);				\
+	else gamma_dma_quiescent_single(dev);				\
 	return 0;							\
 } while (0)
 
 #define __HAVE_DMA_IRQ			1
 #define __HAVE_DMA_IRQ_BH		1
 
-#if 1
-#define DRIVER_PREINSTALL() do {					\
-	drm_gamma_private_t *dev_priv =					\
-				(drm_gamma_private_t *)dev->dev_private;\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	0x00000004 );		\
-	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );		\
-} while (0)
-#define DRIVER_POSTINSTALL() do {					\
-	drm_gamma_private_t *dev_priv =					\
-				(drm_gamma_private_t *)dev->dev_private;\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);			\
-	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002001 );		\
-	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000008 );		\
-	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00039090 );		\
-} while (0)
-#else
-#define DRIVER_POSTINSTALL() do {					\
-	drm_gamma_private_t *dev_priv =					\
-				(drm_gamma_private_t *)dev->dev_private;\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002000 );		\
-	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000004 );		\
-} while (0)
-
-#define DRIVER_PREINSTALL() do {					\
-	drm_gamma_private_t *dev_priv =					\
-				(drm_gamma_private_t *)dev->dev_private;\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	GAMMA_QUEUED_DMA_MODE );\
-	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );\
-} while (0)
-#endif
-
-#define DRIVER_UNINSTALL() do {						\
-	drm_gamma_private_t *dev_priv =					\
-				(drm_gamma_private_t *)dev->dev_private;\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);			\
-	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);			\
-	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00000000 );		\
-	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000000 );		\
-	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00000000 );		\
-} while (0)
-
 #define DRIVER_AGP_BUFFERS_MAP( dev )					\
 	((drm_gamma_private_t *)((dev)->dev_private))->buffers
 
+
 #endif /* __GAMMA_H__ */
diff -urN linux-2.5.68-bk6/drivers/char/drm/gamma_dma.c linux-2.5.68-bk7/drivers/char/drm/gamma_dma.c
--- linux-2.5.68-bk6/drivers/char/drm/gamma_dma.c	2003-04-19 19:51:08.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/gamma_dma.c	2003-04-26 04:37:13.000000000 -0700
@@ -139,15 +139,9 @@
 	drm_buf_t	 *buf;
 	int		 retcode = 0;
 	drm_device_dma_t *dma = dev->dma;
-#if DRM_DMA_HISTOGRAM
-	cycles_t	 dma_start, dma_stop;
-#endif
 
 	if (test_and_set_bit(0, &dev->dma_flag)) return -EBUSY;
 
-#if DRM_DMA_HISTOGRAM
-	dma_start = get_cycles();
-#endif
 
 	if (!dma->next_buffer) {
 		DRM_ERROR("No next_buffer\n");
@@ -221,9 +215,6 @@
 	buf->pending	 = 1;
 	buf->waiting	 = 0;
 	buf->list	 = DRM_LIST_PEND;
-#if DRM_DMA_HISTOGRAM
-	buf->time_dispatched = get_cycles();
-#endif
 
 	/* WE NOW ARE ON LOGICAL PAGES!!! - overriding address */
 	address = buf->idx << 12;
@@ -245,10 +236,6 @@
 
 	clear_bit(0, &dev->dma_flag);
 
-#if DRM_DMA_HISTOGRAM
-	dma_stop = get_cycles();
-	atomic_inc(&dev->histo.dma[gamma_histogram_slot(dma_stop - dma_start)]);
-#endif
 
 	return retcode;
 }
@@ -273,9 +260,6 @@
 	int		 missed;
 	int		 expire	   = 20;
 	drm_device_dma_t *dma	   = dev->dma;
-#if DRM_DMA_HISTOGRAM
-	cycles_t	 schedule_start;
-#endif
 
 	if (test_and_set_bit(0, &dev->interrupt_flag)) {
 				/* Not reentrant */
@@ -284,9 +268,6 @@
 	}
 	missed = atomic_read(&dev->counts[10]);
 
-#if DRM_DMA_HISTOGRAM
-	schedule_start = get_cycles();
-#endif
 
 again:
 	if (dev->context_flag) {
@@ -333,10 +314,6 @@
 
 	clear_bit(0, &dev->interrupt_flag);
 
-#if DRM_DMA_HISTOGRAM
-	atomic_inc(&dev->histo.schedule[gamma_histogram_slot(get_cycles()
-							   - schedule_start)]);
-#endif
 	return retcode;
 }
 
@@ -448,10 +425,6 @@
 			}
 		}
 
-#if DRM_DMA_HISTOGRAM
-		buf->time_queued     = get_cycles();
-		buf->time_dispatched = buf->time_queued;
-#endif
 		gamma_dma_dispatch(dev, address, length);
 		atomic_inc(&dev->counts[9]); /* _DRM_STAT_SPECIAL */
 		atomic_add(length, &dev->counts[8]); /* _DRM_STAT_PRIMARY */
@@ -604,6 +577,8 @@
 
 	memset( dev_priv, 0, sizeof(drm_gamma_private_t) );
 
+	dev_priv->num_rast = init->num_rast;
+
 	list_for_each(list, &dev->maplist->head) {
 		drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
 		if( r_list->map &&
@@ -667,7 +642,8 @@
 	if ( dev->dev_private ) {
 		drm_gamma_private_t *dev_priv = dev->dev_private;
 
-		DRM_IOREMAPFREE( dev_priv->buffers );
+		if ( dev_priv->buffers != NULL )
+			DRM_IOREMAPFREE( dev_priv->buffers );
 
 		DRM(free)( dev->dev_private, sizeof(drm_gamma_private_t),
 			   DRM_MEM_DRIVER );
@@ -831,3 +807,35 @@
 	up(&dev->struct_sem);
 	return 0;
 }
+
+void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 2);
+
+	GAMMA_WRITE( GAMMA_GCOMMANDMODE,	0x00000004 );
+	GAMMA_WRITE( GAMMA_GDMACONTROL,		0x00000000 );
+}
+
+void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
+
+	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00002001 );
+	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000008 );
+	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00039090 );
+}
+
+void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+	drm_gamma_private_t *dev_priv =
+				(drm_gamma_private_t *)dev->dev_private;
+
+	while(GAMMA_READ(GAMMA_INFIFOSPACE) < 3);
+
+	GAMMA_WRITE( GAMMA_GDELAYTIMER,		0x00000000 );
+	GAMMA_WRITE( GAMMA_COMMANDINTENABLE,	0x00000000 );
+	GAMMA_WRITE( GAMMA_GINTENABLE,		0x00000000 );
+}
diff -urN linux-2.5.68-bk6/drivers/char/drm/gamma_drm.h linux-2.5.68-bk7/drivers/char/drm/gamma_drm.h
--- linux-2.5.68-bk6/drivers/char/drm/gamma_drm.h	2003-04-19 19:50:49.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/gamma_drm.h	2003-04-26 04:37:13.000000000 -0700
@@ -84,6 +84,7 @@
 	unsigned int mmio2;
 	unsigned int mmio3;
 	unsigned int buffers_offset;
+	int num_rast;
 } drm_gamma_init_t;
 
 #endif /* _GAMMA_DRM_H_ */
diff -urN linux-2.5.68-bk6/drivers/char/drm/gamma_drv.c linux-2.5.68-bk7/drivers/char/drm/gamma_drv.c
--- linux-2.5.68-bk6/drivers/char/drm/gamma_drv.c	2003-04-19 19:50:48.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/gamma_drv.c	2003-04-26 04:37:13.000000000 -0700
@@ -39,16 +39,18 @@
 #include "drm_auth.h"
 #include "drm_agpsupport.h"
 #include "drm_bufs.h"
-#include "drm_context.h"
+#include "gamma_context.h"	/* NOTE! */
 #include "drm_dma.h"
+#include "gamma_old_dma.h"	/* NOTE */
 #include "drm_drawable.h"
 #include "drm_drv.h"
 
 #include "drm_fops.h"
 #include "drm_init.h"
 #include "drm_ioctl.h"
-#include "drm_lists.h"
+#include "gamma_lists.h"        /* NOTE */
 #include "drm_lock.h"
+#include "gamma_lock.h"		/* NOTE */
 #include "drm_memory.h"
 #include "drm_proc.h"
 #include "drm_vm.h"
diff -urN linux-2.5.68-bk6/drivers/char/drm/gamma_drv.h linux-2.5.68-bk7/drivers/char/drm/gamma_drv.h
--- linux-2.5.68-bk6/drivers/char/drm/gamma_drv.h	2003-04-19 19:49:17.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/gamma_drv.h	2003-04-26 04:37:13.000000000 -0700
@@ -40,6 +40,7 @@
 	drm_map_t *mmio1;
 	drm_map_t *mmio2;
 	drm_map_t *mmio3;
+	int num_rast;
 } drm_gamma_private_t;
 
 				/* gamma_dma.c */
@@ -59,6 +60,29 @@
 extern int  gamma_find_devices(void);
 extern int  gamma_found(void);
 
+/* Gamma-specific code pulled from drm_dma.h:
+ */
+extern void	     DRM(clear_next_buffer)(drm_device_t *dev);
+extern int	     DRM(select_queue)(drm_device_t *dev,
+				       void (*wrapper)(unsigned long));
+extern int	     DRM(dma_enqueue)(struct file *filp, drm_dma_t *dma);
+extern int	     DRM(dma_get_buffers)(struct file *filp, drm_dma_t *dma);
+
+
+/* Gamma-specific code pulled from drm_lists.h (now renamed gamma_lists.h):
+ */
+extern int	     DRM(waitlist_create)(drm_waitlist_t *bl, int count);
+extern int	     DRM(waitlist_destroy)(drm_waitlist_t *bl);
+extern int	     DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
+extern drm_buf_t     *DRM(waitlist_get)(drm_waitlist_t *bl);
+extern int	     DRM(freelist_create)(drm_freelist_t *bl, int count);
+extern int	     DRM(freelist_destroy)(drm_freelist_t *bl);
+extern int	     DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
+				       drm_buf_t *buf);
+extern drm_buf_t     *DRM(freelist_get)(drm_freelist_t *bl, int block);
+
+
+
 #define GLINT_DRI_BUF_COUNT 256
 
 #define GAMMA_OFF(reg)						   \
diff -urN linux-2.5.68-bk6/drivers/char/drm/i810.h linux-2.5.68-bk7/drivers/char/drm/i810.h
--- linux-2.5.68-bk6/drivers/char/drm/i810.h	2003-04-19 19:49:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i810.h	2003-04-26 04:37:13.000000000 -0700
@@ -93,7 +93,7 @@
  */
 #define __HAVE_DMA		1
 #define __HAVE_DMA_QUEUE	1
-#define __HAVE_DMA_WAITLIST	1
+#define __HAVE_DMA_WAITLIST	0
 #define __HAVE_DMA_RECLAIM	1
 
 #define __HAVE_DMA_QUIESCENT	1
diff -urN linux-2.5.68-bk6/drivers/char/drm/i810_dma.c linux-2.5.68-bk7/drivers/char/drm/i810_dma.c
--- linux-2.5.68-bk6/drivers/char/drm/i810_dma.c	2003-04-19 19:49:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i810_dma.c	2003-04-26 04:37:13.000000000 -0700
@@ -55,7 +55,7 @@
 {
    	drm_device_dma_t *dma = dev->dma;
       	drm_i810_private_t *dev_priv = dev->dev_private;
-	u32 *temp = (u32 *)dev_priv->hw_status_page;
+	u32 *temp = dev_priv->hw_status_page;
    	int i;
 
    	DRM_DEBUG(  "hw_status: Interrupt Status : %x\n", temp[0]);
@@ -115,9 +115,7 @@
 	.release = DRM(release),
 	.ioctl	 = DRM(ioctl),
 	.mmap	 = i810_mmap_buffers,
-	.read	 = DRM(read),
 	.fasync  = DRM(fasync),
-      	.poll	 = DRM(poll),
 };
 
 int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
@@ -242,9 +240,9 @@
 		   	DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
 					 dev_priv->ring.Size);
 		}
-	   	if(dev_priv->hw_status_page != 0UL) {
+	   	if (dev_priv->hw_status_page) {
 		   	pci_free_consistent(dev->pdev, PAGE_SIZE,
-					    (void *)dev_priv->hw_status_page,
+					    dev_priv->hw_status_page,
 					    dev_priv->dma_status_page);
 		   	/* Need to rewrite hardware status page */
 		   	I810_WRITE(0x02080, 0x1ffff000);
@@ -256,7 +254,8 @@
 		for (i = 0; i < dma->buf_count; i++) {
 			drm_buf_t *buf = dma->buflist[ i ];
 			drm_i810_buf_priv_t *buf_priv = buf->dev_private;
-			DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
+			if ( buf_priv->kernel_virtual && buf->total )
+				DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
 		}
 	}
    	return 0;
@@ -406,15 +405,15 @@
 
    	/* Program Hardware Status Page */
    	dev_priv->hw_status_page =
-		(unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+		pci_alloc_consistent(dev->pdev, PAGE_SIZE,
 						&dev_priv->dma_status_page);
-   	if(dev_priv->hw_status_page == 0UL) {
+   	if (!dev_priv->hw_status_page) {
 		dev->dev_private = (void *)dev_priv;
 		i810_dma_cleanup(dev);
 		DRM_ERROR("Can not allocate hardware status page\n");
 		return -ENOMEM;
 	}
-   	memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
+   	memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
    	DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
 
 	I810_WRITE(0x02080, dev_priv->dma_status_page);
@@ -900,7 +899,7 @@
 	drm_device_t *dev = priv->dev;
 	drm_device_dma_t *dma = dev->dma;
    	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 	drm_i810_vertex_t vertex;
@@ -976,7 +975,7 @@
    	drm_file_t	  *priv	    = filp->private_data;
 	drm_device_t	  *dev	    = priv->dev;
    	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 
@@ -992,7 +991,7 @@
 	int		  retcode   = 0;
 	drm_i810_dma_t	  d;
    	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
      					dev_priv->sarea_priv;
 
@@ -1101,7 +1100,7 @@
 	drm_device_t *dev = priv->dev;
 	drm_device_dma_t *dma = dev->dma;
 	drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
-	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+	u32 *hw_status = dev_priv->hw_status_page;
 	drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
 		dev_priv->sarea_priv;
 	drm_i810_mc_t mc;
diff -urN linux-2.5.68-bk6/drivers/char/drm/i810_drv.c linux-2.5.68-bk7/drivers/char/drm/i810_drv.c
--- linux-2.5.68-bk6/drivers/char/drm/i810_drv.c	2003-04-19 19:51:12.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i810_drv.c	2003-04-26 04:37:13.000000000 -0700
@@ -49,7 +49,6 @@
 #include "drm_init.h"
 #include "drm_ioctl.h"
 #include "drm_lock.h"
-#include "drm_lists.h"
 #include "drm_memory.h"
 #include "drm_proc.h"
 #include "drm_vm.h"
diff -urN linux-2.5.68-bk6/drivers/char/drm/i810_drv.h linux-2.5.68-bk7/drivers/char/drm/i810_drv.h
--- linux-2.5.68-bk6/drivers/char/drm/i810_drv.h	2003-04-19 19:51:08.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i810_drv.h	2003-04-26 04:37:13.000000000 -0700
@@ -61,7 +61,7 @@
 	drm_i810_sarea_t *sarea_priv;
    	drm_i810_ring_buffer_t ring;
 
-      	unsigned long hw_status_page;
+      	void *hw_status_page;
    	unsigned long counter;
 
 	dma_addr_t dma_status_page;
diff -urN linux-2.5.68-bk6/drivers/char/drm/i830.h linux-2.5.68-bk7/drivers/char/drm/i830.h
--- linux-2.5.68-bk6/drivers/char/drm/i830.h	2003-04-19 19:48:57.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i830.h	2003-04-26 04:37:13.000000000 -0700
@@ -94,7 +94,7 @@
  */
 #define __HAVE_DMA		1
 #define __HAVE_DMA_QUEUE	1
-#define __HAVE_DMA_WAITLIST	1
+#define __HAVE_DMA_WAITLIST	0
 #define __HAVE_DMA_RECLAIM	1
 
 #define __HAVE_DMA_QUIESCENT	1
diff -urN linux-2.5.68-bk6/drivers/char/drm/i830_dma.c linux-2.5.68-bk7/drivers/char/drm/i830_dma.c
--- linux-2.5.68-bk6/drivers/char/drm/i830_dma.c	2003-04-26 04:37:08.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i830_dma.c	2003-04-26 04:37:13.000000000 -0700
@@ -56,7 +56,7 @@
 {
    	drm_device_dma_t *dma = dev->dma;
       	drm_i830_private_t *dev_priv = dev->dev_private;
-	u32 *temp = (u32 *)dev_priv->hw_status_page;
+	u32 *temp = dev_priv->hw_status_page;
    	int i;
 
    	DRM_DEBUG(  "hw_status: Interrupt Status : %x\n", temp[0]);
@@ -115,9 +115,7 @@
 	.release = DRM(release),
 	.ioctl	 = DRM(ioctl),
 	.mmap	 = i830_mmap_buffers,
-	.read	 = DRM(read),
 	.fasync  = DRM(fasync),
-      	.poll	 = DRM(poll),
 };
 
 int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
@@ -242,9 +240,9 @@
 		   	DRM(ioremapfree)((void *) dev_priv->ring.virtual_start,
 					 dev_priv->ring.Size);
 		}
-	   	if(dev_priv->hw_status_page != 0UL) {
+	   	if (dev_priv->hw_status_page) {
 			pci_free_consistent(dev->pdev, PAGE_SIZE,
-					    (void *)dev_priv->hw_status_page,
+					    dev_priv->hw_status_page,
 					    dev_priv->dma_status_page);
 		   	/* Need to rewrite hardware status page */
 		   	I830_WRITE(0x02080, 0x1ffff000);
@@ -265,7 +263,8 @@
 		for (i = 0; i < dma->buf_count; i++) {
 			drm_buf_t *buf = dma->buflist[ i ];
 			drm_i830_buf_priv_t *buf_priv = buf->dev_private;
-			DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
+			if ( buf_priv->kernel_virtual && buf->total )
+				DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total);
 		}
 	}
    	return 0;
@@ -435,16 +434,16 @@
 
    	/* Program Hardware Status Page */
    	dev_priv->hw_status_page =
-		(unsigned long) pci_alloc_consistent(dev->pdev, PAGE_SIZE,
+		pci_alloc_consistent(dev->pdev, PAGE_SIZE,
 						&dev_priv->dma_status_page);
-   	if(dev_priv->hw_status_page == 0UL) {
+   	if (!dev_priv->hw_status_page) {
 		dev->dev_private = (void *)dev_priv;
 		i830_dma_cleanup(dev);
 		DRM_ERROR("Can not allocate hardware status page\n");
 		return -ENOMEM;
 	}
-   	memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
-	DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
+   	memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
+	DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page);
    
    	I830_WRITE(0x02080, dev_priv->dma_status_page);
 	DRM_DEBUG("Enabled hardware status page\n");
@@ -1336,7 +1335,7 @@
 	drm_device_t *dev = priv->dev;
 	drm_device_dma_t *dma = dev->dma;
    	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
-      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 	drm_i830_vertex_t vertex;
@@ -1461,7 +1460,7 @@
    	drm_file_t	  *priv	    = filp->private_data;
 	drm_device_t	  *dev	    = priv->dev;
    	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
-      	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+      	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 
@@ -1477,7 +1476,7 @@
 	int		  retcode   = 0;
 	drm_i830_dma_t	  d;
    	drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
-   	u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+   	u32 *hw_status = dev_priv->hw_status_page;
    	drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) 
      					dev_priv->sarea_priv; 
 
diff -urN linux-2.5.68-bk6/drivers/char/drm/i830_drv.c linux-2.5.68-bk7/drivers/char/drm/i830_drv.c
--- linux-2.5.68-bk6/drivers/char/drm/i830_drv.c	2003-04-19 19:48:57.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i830_drv.c	2003-04-26 04:37:13.000000000 -0700
@@ -51,7 +51,6 @@
 #include "drm_init.h"
 #include "drm_ioctl.h"
 #include "drm_lock.h"
-#include "drm_lists.h"
 #include "drm_memory.h"
 #include "drm_proc.h"
 #include "drm_vm.h"
diff -urN linux-2.5.68-bk6/drivers/char/drm/i830_drv.h linux-2.5.68-bk7/drivers/char/drm/i830_drv.h
--- linux-2.5.68-bk6/drivers/char/drm/i830_drv.h	2003-04-19 19:50:07.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/i830_drv.h	2003-04-26 04:37:13.000000000 -0700
@@ -61,7 +61,7 @@
 	drm_i830_sarea_t *sarea_priv;
    	drm_i830_ring_buffer_t ring;
 
-      	unsigned long hw_status_page;
+      	void * hw_status_page;
    	unsigned long counter;
 
 	dma_addr_t dma_status_page;
diff -urN linux-2.5.68-bk6/drivers/char/drm/mga_dma.c linux-2.5.68-bk7/drivers/char/drm/mga_dma.c
--- linux-2.5.68-bk6/drivers/char/drm/mga_dma.c	2003-04-19 19:50:45.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/mga_dma.c	2003-04-26 04:37:13.000000000 -0700
@@ -642,9 +642,12 @@
 	if ( dev->dev_private ) {
 		drm_mga_private_t *dev_priv = dev->dev_private;
 
-		DRM_IOREMAPFREE( dev_priv->warp );
-		DRM_IOREMAPFREE( dev_priv->primary );
-		DRM_IOREMAPFREE( dev_priv->buffers );
+		if ( dev_priv->warp != NULL )
+			DRM_IOREMAPFREE( dev_priv->warp );
+		if ( dev_priv->primary != NULL )
+			DRM_IOREMAPFREE( dev_priv->primary );
+		if ( dev_priv->buffers != NULL )
+			DRM_IOREMAPFREE( dev_priv->buffers );
 
 		if ( dev_priv->head != NULL ) {
 			mga_freelist_cleanup( dev );
diff -urN linux-2.5.68-bk6/drivers/char/drm/r128_cce.c linux-2.5.68-bk7/drivers/char/drm/r128_cce.c
--- linux-2.5.68-bk6/drivers/char/drm/r128_cce.c	2003-04-19 19:48:52.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/r128_cce.c	2003-04-26 04:37:13.000000000 -0700
@@ -619,9 +619,12 @@
 #if __REALLY_HAVE_SG
 		if ( !dev_priv->is_pci ) {
 #endif
-			DRM_IOREMAPFREE( dev_priv->cce_ring );
-			DRM_IOREMAPFREE( dev_priv->ring_rptr );
-			DRM_IOREMAPFREE( dev_priv->buffers );
+			if ( dev_priv->cce_ring != NULL )
+				DRM_IOREMAPFREE( dev_priv->cce_ring );
+			if ( dev_priv->ring_rptr != NULL )
+				DRM_IOREMAPFREE( dev_priv->ring_rptr );
+			if ( dev_priv->buffers != NULL )
+				DRM_IOREMAPFREE( dev_priv->buffers );
 #if __REALLY_HAVE_SG
 		} else {
 			if (!DRM(ati_pcigart_cleanup)( dev,
diff -urN linux-2.5.68-bk6/drivers/char/drm/radeon.h linux-2.5.68-bk7/drivers/char/drm/radeon.h
--- linux-2.5.68-bk6/drivers/char/drm/radeon.h	2003-04-19 19:50:46.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/radeon.h	2003-04-26 04:37:13.000000000 -0700
@@ -78,6 +78,7 @@
  *       Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and
  *       R200_EMIT_PP_CUBIC_OFFSETS_[0..5].  (brian)
  * 1.8 - Remove need to call cleanup ioctls on last client exit (keith)
+ *       Add 'GET' queries for starting additional clients on different VT's.
  */
 #define DRIVER_IOCTLS							     \
  [DRM_IOCTL_NR(DRM_IOCTL_DMA)]               = { radeon_cp_buffers,  1, 0 }, \
diff -urN linux-2.5.68-bk6/drivers/char/drm/radeon_cp.c linux-2.5.68-bk7/drivers/char/drm/radeon_cp.c
--- linux-2.5.68-bk6/drivers/char/drm/radeon_cp.c	2003-04-19 19:48:53.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/radeon_cp.c	2003-04-26 04:37:13.000000000 -0700
@@ -36,12 +36,6 @@
 
 #define RADEON_FIFO_DEBUG	0
 
-#if defined(__alpha__) || defined(__powerpc__)
-# define PCIGART_ENABLED
-#else
-# undef PCIGART_ENABLED
-#endif
-
 
 /* CP microcode (from ATI) */
 static u32 R200_cp_microcode[][2] = {
@@ -777,7 +771,7 @@
 
 	cur_read_ptr = RADEON_READ( RADEON_CP_RB_RPTR );
 	RADEON_WRITE( RADEON_CP_RB_WPTR, cur_read_ptr );
-	*dev_priv->ring.head = cur_read_ptr;
+	SET_RING_HEAD( dev_priv, cur_read_ptr );
 	dev_priv->ring.tail = cur_read_ptr;
 }
 
@@ -889,13 +883,18 @@
 	/* Initialize the ring buffer's read and write pointers */
 	cur_read_ptr = RADEON_READ( RADEON_CP_RB_RPTR );
 	RADEON_WRITE( RADEON_CP_RB_WPTR, cur_read_ptr );
-	*dev_priv->ring.head = cur_read_ptr;
+	SET_RING_HEAD( dev_priv, cur_read_ptr );
 	dev_priv->ring.tail = cur_read_ptr;
 
+#if __REALLY_HAVE_AGP
 	if ( !dev_priv->is_pci ) {
 		RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
-			      dev_priv->ring_rptr->offset );
-	} else {
+			      dev_priv->ring_rptr->offset
+			      - dev->agp->base
+			      + dev_priv->agp_vm_start);
+	} else
+#endif
+	{
 		drm_sg_mem_t *entry = dev->sg;
 		unsigned long tmp_ofs, page_ofs;
 
@@ -920,7 +919,7 @@
 					 + RADEON_SCRATCH_REG_OFFSET );
 
 	dev_priv->scratch = ((__volatile__ u32 *)
-			     dev_priv->ring.head +
+			     dev_priv->ring_rptr->handle +
 			     (RADEON_SCRATCH_REG_OFFSET / sizeof(u32)));
 
 	RADEON_WRITE( RADEON_SCRATCH_UMSK, 0x7 );
@@ -990,17 +989,6 @@
 
 	dev_priv->is_pci = init->is_pci;
 
-#if !defined(PCIGART_ENABLED)
-	/* PCI support is not 100% working, so we disable it here.
-	 */
-	if ( dev_priv->is_pci ) {
-		DRM_ERROR( "PCI GART not yet supported for Radeon!\n" );
-		dev->dev_private = (void *)dev_priv;
-		radeon_do_cleanup_cp(dev);
-		return DRM_ERR(EINVAL);
-	}
-#endif
-
 	if ( dev_priv->is_pci && !dev->sg ) {
 		DRM_ERROR( "PCI GART memory not allocated!\n" );
 		dev->dev_private = (void *)dev_priv;
@@ -1097,6 +1085,13 @@
 					 RADEON_ROUND_PREC_8TH_PIX);
 
 	DRM_GETSAREA();
+
+	dev_priv->fb_offset = init->fb_offset;
+	dev_priv->mmio_offset = init->mmio_offset;
+	dev_priv->ring_offset = init->ring_offset;
+	dev_priv->ring_rptr_offset = init->ring_rptr_offset;
+	dev_priv->buffers_offset = init->buffers_offset;
+	dev_priv->agp_textures_offset = init->agp_textures_offset;
 	
 	if(!dev_priv->sarea) {
 		DRM_ERROR("could not find sarea!\n");
@@ -1204,9 +1199,6 @@
 	DRM_DEBUG( "dev_priv->agp_buffers_offset 0x%lx\n",
 		   dev_priv->agp_buffers_offset );
 
-	dev_priv->ring.head = ((__volatile__ u32 *)
-			       dev_priv->ring_rptr->handle);
-
 	dev_priv->ring.start = (u32 *)dev_priv->cp_ring->handle;
 	dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
 			      + init->ring_size / sizeof(u32));
@@ -1217,7 +1209,6 @@
 		(dev_priv->ring.size / sizeof(u32)) - 1;
 
 	dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
-	dev_priv->ring.ring_rptr = dev_priv->ring_rptr;
 
 #if __REALLY_HAVE_SG
 	if ( dev_priv->is_pci ) {
@@ -1279,9 +1270,12 @@
 		drm_radeon_private_t *dev_priv = dev->dev_private;
 
 		if ( !dev_priv->is_pci ) {
-			DRM_IOREMAPFREE( dev_priv->cp_ring );
-			DRM_IOREMAPFREE( dev_priv->ring_rptr );
-			DRM_IOREMAPFREE( dev_priv->buffers );
+			if ( dev_priv->cp_ring != NULL )
+				DRM_IOREMAPFREE( dev_priv->cp_ring );
+			if ( dev_priv->ring_rptr != NULL )
+				DRM_IOREMAPFREE( dev_priv->ring_rptr );
+			if ( dev_priv->buffers != NULL )
+				DRM_IOREMAPFREE( dev_priv->buffers );
 		} else {
 #if __REALLY_HAVE_SG
 			if (!DRM(ati_pcigart_cleanup)( dev,
@@ -1592,10 +1586,10 @@
 {
 	drm_radeon_ring_buffer_t *ring = &dev_priv->ring;
 	int i;
-	u32 last_head = GET_RING_HEAD(ring);
+	u32 last_head = GET_RING_HEAD( dev_priv );
 
 	for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
-		u32 head = GET_RING_HEAD(ring);
+		u32 head = GET_RING_HEAD( dev_priv );
 
 		ring->space = (head - ring->tail) * sizeof(u32);
 		if ( ring->space <= 0 )
diff -urN linux-2.5.68-bk6/drivers/char/drm/radeon_drm.h linux-2.5.68-bk7/drivers/char/drm/radeon_drm.h
--- linux-2.5.68-bk6/drivers/char/drm/radeon_drm.h	2003-04-19 19:50:06.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/radeon_drm.h	2003-04-26 04:37:13.000000000 -0700
@@ -532,6 +532,10 @@
 #define RADEON_PARAM_LAST_CLEAR            4
 #define RADEON_PARAM_IRQ_NR                5
 #define RADEON_PARAM_AGP_BASE              6 /* card offset of agp base */
+#define RADEON_PARAM_REGISTER_HANDLE       7 /* for drmMap() */
+#define RADEON_PARAM_STATUS_HANDLE         8
+#define RADEON_PARAM_SAREA_HANDLE          9
+#define RADEON_PARAM_AGP_TEX_HANDLE        10
 
 typedef struct drm_radeon_getparam {
 	int param;
diff -urN linux-2.5.68-bk6/drivers/char/drm/radeon_drv.h linux-2.5.68-bk7/drivers/char/drm/radeon_drv.h
--- linux-2.5.68-bk6/drivers/char/drm/radeon_drv.h	2003-04-19 19:49:32.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/radeon_drv.h	2003-04-26 04:37:13.000000000 -0700
@@ -31,8 +31,8 @@
 #ifndef __RADEON_DRV_H__
 #define __RADEON_DRV_H__
 
-#define GET_RING_HEAD(ring)		DRM_READ32(  (ring)->ring_rptr, 0 ) /* (ring)->head */
-#define SET_RING_HEAD(ring,val)		DRM_WRITE32( (ring)->ring_rptr, 0, (val) ) /* (ring)->head */
+#define GET_RING_HEAD(dev_priv)		DRM_READ32(  (dev_priv)->ring_rptr, 0 )
+#define SET_RING_HEAD(dev_priv,val)	DRM_WRITE32( (dev_priv)->ring_rptr, 0, (val) )
 
 typedef struct drm_radeon_freelist {
    	unsigned int age;
@@ -47,13 +47,11 @@
 	int size;
 	int size_l2qw;
 
-	volatile u32 *head;
 	u32 tail;
 	u32 tail_mask;
 	int space;
 
 	int high_mark;
-	drm_local_map_t *ring_rptr;
 } drm_radeon_ring_buffer_t;
 
 typedef struct drm_radeon_depth_clear_t {
@@ -126,6 +124,13 @@
 	u32 depth_pitch_offset;
 
 	drm_radeon_depth_clear_t depth_clear;
+	
+	unsigned long fb_offset;
+	unsigned long mmio_offset;
+	unsigned long ring_offset;
+	unsigned long ring_rptr_offset;
+	unsigned long buffers_offset;
+	unsigned long agp_textures_offset;
 
 	drm_local_map_t *sarea;
 	drm_local_map_t *fb;
@@ -775,7 +780,7 @@
 #define RING_SPACE_TEST_WITH_RETURN( dev_priv )				\
 do {									\
 	if (!(dev_priv->stats.boxes & RADEON_BOX_DMA_IDLE)) {		\
-		u32 head = GET_RING_HEAD(&dev_priv->ring);		\
+		u32 head = GET_RING_HEAD( dev_priv );			\
 		if (head == dev_priv->ring.tail)			\
 			dev_priv->stats.boxes |= RADEON_BOX_DMA_IDLE;	\
 	}								\
@@ -847,8 +852,8 @@
 
 #define COMMIT_RING() do {						\
 	/* Flush writes to ring */					\
-	DRM_READMEMORYBARRIER(dev_priv->mmio);					\
-	GET_RING_HEAD( &dev_priv->ring );				\
+	DRM_READMEMORYBARRIER( dev_priv->mmio );			\
+	GET_RING_HEAD( dev_priv );					\
 	RADEON_WRITE( RADEON_CP_RB_WPTR, dev_priv->ring.tail );		\
 	/* read from PCI bus to ensure correct posting */		\
 	RADEON_READ( RADEON_CP_RB_RPTR );				\
diff -urN linux-2.5.68-bk6/drivers/char/drm/radeon_state.c linux-2.5.68-bk7/drivers/char/drm/radeon_state.c
--- linux-2.5.68-bk6/drivers/char/drm/radeon_state.c	2003-04-19 19:50:43.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/radeon_state.c	2003-04-26 04:37:13.000000000 -0700
@@ -2191,6 +2191,19 @@
 	case RADEON_PARAM_AGP_BASE:
 		value = dev_priv->agp_vm_start;
 		break;
+	case RADEON_PARAM_REGISTER_HANDLE:
+		value = dev_priv->mmio_offset;
+		break;
+	case RADEON_PARAM_STATUS_HANDLE:
+		value = dev_priv->ring_rptr_offset;
+		break;
+	case RADEON_PARAM_SAREA_HANDLE:
+		/* The lock is the first dword in the sarea. */
+		value = (int)dev->lock.hw_lock; 
+		break;	
+	case RADEON_PARAM_AGP_TEX_HANDLE:
+		value = dev_priv->agp_textures_offset;
+		break;
 	default:
 		return DRM_ERR(EINVAL);
 	}
diff -urN linux-2.5.68-bk6/drivers/char/drm/sis_drv.c linux-2.5.68-bk7/drivers/char/drm/sis_drv.c
--- linux-2.5.68-bk6/drivers/char/drm/sis_drv.c	2003-04-19 19:48:48.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/drm/sis_drv.c	2003-04-26 04:37:13.000000000 -0700
@@ -41,7 +41,6 @@
 #include "drm_fops.h"
 #include "drm_init.h"
 #include "drm_ioctl.h"
-#include "drm_lists.h"
 #include "drm_lock.h"
 #include "drm_memory.h"
 #include "drm_proc.h"
diff -urN linux-2.5.68-bk6/drivers/char/hw_random.c linux-2.5.68-bk7/drivers/char/hw_random.c
--- linux-2.5.68-bk6/drivers/char/hw_random.c	2003-04-19 19:49:10.000000000 -0700
+++ linux-2.5.68-bk7/drivers/char/hw_random.c	2003-04-26 04:37:13.000000000 -0700
@@ -47,7 +47,7 @@
 /*
  * core module and version information
  */
-#define RNG_VERSION "0.9.0"
+#define RNG_VERSION "1.0.0"
 #define RNG_MODULE_NAME "hw_random"
 #define RNG_DRIVER_NAME   RNG_MODULE_NAME " hardware driver " RNG_VERSION
 #define PFX RNG_MODULE_NAME ": "
@@ -499,7 +499,7 @@
 
 		spin_unlock (&rng_lock);
 
-		while (have_data > 0) {
+		while (have_data && size) {
 			if (put_user((u8)data, buf++)) {
 				ret = ret ? : -EFAULT;
 				break;
diff -urN linux-2.5.68-bk6/drivers/net/sundance.c linux-2.5.68-bk7/drivers/net/sundance.c
--- linux-2.5.68-bk6/drivers/net/sundance.c	2003-04-26 04:37:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/net/sundance.c	2003-04-26 04:37:14.000000000 -0700
@@ -71,19 +71,29 @@
 
 	Versin LK1.06b (D-Link):
 	- New tx scheme, adaptive tx_coalesce
+	
+	Version LK1.07 (D-Link):
+	- Fix tx bugs in big-endian machines
+	- Remove unused max_interrupt_work module parameter, the new 
+	  NAPI-like rx scheme doesn't need it.
+	- Remove redundancy get_stats() in intr_handler(), those 
+	  I/O access could affect performance in ARM-based system
+	- Add Linux software VLAN support
+	
+	Version LK1.08 (D-Link):
+	- Fix bug of custom mac address 
+	(StationAddr register only accept word write) 
 
 */
 
 #define DRV_NAME	"sundance"
-#define DRV_VERSION	"1.01+LK1.06b"
-#define DRV_RELDATE	"6-Nov-2002"
+#define DRV_VERSION	"1.01+LK1.08a"
+#define DRV_RELDATE	"23-Apr-2003"
 
 
 /* The user-configurable values.
    These may be modified when a driver module is loaded.*/
 static int debug = 1;			/* 1 normal messages, 0 quiet .. 7 verbose. */
-/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
-static int max_interrupt_work = 0;
 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
    Typical is a 64 element hash table based on the Ethernet CRC.  */
 static int multicast_filter_limit = 32;
@@ -129,8 +139,7 @@
 /* Operational parameters that usually are not changed. */
 /* Time in jiffies before concluding the transmitter is hung. */
 #define TX_TIMEOUT  (4*HZ)
-
-#define PKT_BUF_SZ		1536			/* Size of each temporary Rx buffer.*/
+#define PKT_BUF_SZ		1536	/* Size of each temporary Rx buffer.*/
 
 #ifndef __KERNEL__
 #define __KERNEL__
@@ -181,12 +190,10 @@
 MODULE_DESCRIPTION("Sundance Alta Ethernet driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(max_interrupt_work, "i");
 MODULE_PARM(debug, "i");
 MODULE_PARM(rx_copybreak, "i");
 MODULE_PARM(media, "1-" __MODULE_STRING(MAX_UNITS) "s");
 MODULE_PARM(flowctrl, "i");
-MODULE_PARM_DESC(max_interrupt_work, "Sundance Alta maximum events handled per interrupt");
 MODULE_PARM_DESC(debug, "Sundance Alta debug level (0-5)");
 MODULE_PARM_DESC(rx_copybreak, "Sundance Alta copy breakpoint for copy-only-tiny-frames");
 MODULE_PARM_DESC(flowctrl, "Sundance Alta flow control [0|1]");
@@ -502,6 +509,7 @@
 static void netdev_error(struct net_device *dev, int intr_status);
 static void netdev_error(struct net_device *dev, int intr_status);
 static void set_rx_mode(struct net_device *dev);
+static int __set_mac_addr(struct net_device *dev);
 static struct net_device_stats *get_stats(struct net_device *dev);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static int  netdev_close(struct net_device *dev);
@@ -847,17 +855,18 @@
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
 			   dev->name, dev->irq);
-
 	init_ring(dev);
 
 	writel(np->rx_ring_dma, ioaddr + RxListPtr);
 	/* The Tx list pointer is written as packets are queued. */
 
-	for (i = 0; i < 6; i++)
-		writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
-
 	/* Initialize other registers. */
+	__set_mac_addr(dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+	writew(dev->mtu + 18, ioaddr + MaxFrameSize);
+#else
 	writew(dev->mtu + 14, ioaddr + MaxFrameSize);
+#endif
 	if (dev->mtu > 2047)
 		writel(readl(ioaddr + ASICCtrl) | 0x0C, ioaddr + ASICCtrl);
 
@@ -879,7 +888,7 @@
 		writeb(0x01, ioaddr + DebugCtrl1);
 	netif_start_queue(dev);
 
-	writew(StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
+	writew (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
 
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: Done netdev_open(), status: Rx %x Tx %x "
@@ -966,11 +975,11 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) & 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1157,7 +1166,6 @@
 	struct net_device *dev = (struct net_device *)dev_instance;
 	struct netdev_private *np;
 	long ioaddr;
-	int boguscnt = max_interrupt_work;
 	int hw_frame_id;
 	int tx_cnt;
 	int tx_status;
@@ -1229,11 +1237,14 @@
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
 				int sw_frame_id;
-				sw_frame_id = (np->tx_ring[entry].status >> 2) & 0xff;
-					if (sw_frame_id == hw_frame_id &&
-						!(np->tx_ring[entry].status & 0x00010000))
+				sw_frame_id = (le32_to_cpu(
+					np->tx_ring[entry].status) >> 2) & 0xff;
+				if (sw_frame_id == hw_frame_id &&
+					!(le32_to_cpu(np->tx_ring[entry].status)
+					& 0x00010000))
 						break;
-					if (sw_frame_id == (hw_frame_id + 1) % TX_RING_SIZE)
+				if (sw_frame_id == (hw_frame_id + 1) % 
+					TX_RING_SIZE)
 						break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1251,7 +1262,8 @@
 			for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) {
 				int entry = np->dirty_tx % TX_RING_SIZE;
 				struct sk_buff *skb;
-				if (!(np->tx_ring[entry].status & 0x00010000))
+				if (!(le32_to_cpu(np->tx_ring[entry].status) 
+							& 0x00010000))
 					break;
 				skb = np->tx_skbuff[entry];
 				/* Free the original skb. */
@@ -1274,15 +1286,7 @@
 		/* Abnormal error summary/uncommon events handlers. */
 		if (intr_status & (IntrPCIErr | LinkChange | StatsMax))
 			netdev_error(dev, intr_status);
-		if (--boguscnt < 0) {
-			get_stats(dev);
-			if (netif_msg_hw(np))
-				printk(KERN_WARNING "%s: Too much work at interrupt, "
-				   "status=0x%4.4x / 0x%4.4x.\n",
-				   dev->name, intr_status, readw(ioaddr + IntrClear));
-			break;
-		}
-	} while (1);
+	} while (0);
 	if (netif_msg_intr(np))
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
 			   dev->name, readw(ioaddr + IntrStatus));
@@ -1466,8 +1470,8 @@
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-	long ioaddr = dev->base_addr;
 	struct netdev_private *np = dev->priv;
+	long ioaddr = dev->base_addr;
 	int i;
 
 	/* We should lock this segment of code for SMP eventually, although
@@ -1480,7 +1484,7 @@
 	np->stats.collisions += readb(ioaddr + StatsLateColl);
 	np->stats.collisions += readb(ioaddr + StatsMultiColl);
 	np->stats.collisions += readb(ioaddr + StatsOneColl);
-	readb(ioaddr + StatsCarrierError);
+	np->stats.tx_carrier_errors += readb(ioaddr + StatsCarrierError);
 	readb(ioaddr + StatsTxDefer);
 	for (i = StatsTxDefer; i <= StatsMcastRx; i++)
 		readb(ioaddr + i);
@@ -1532,6 +1536,20 @@
 	writeb(rx_mode, ioaddr + RxMode);
 }
 
+static int __set_mac_addr(struct net_device *dev)
+{
+	u16 addr16;
+
+	addr16 = (dev->dev_addr[0] | (dev->dev_addr[1] << 8));
+	writew(addr16, dev->base_addr + StationAddr);
+	addr16 = (dev->dev_addr[2] | (dev->dev_addr[3] << 8));
+	writew(addr16, dev->base_addr + StationAddr+2);
+	addr16 = (dev->dev_addr[4] | (dev->dev_addr[5] << 8));
+	writew(addr16, dev->base_addr + StationAddr+4);
+	return 0;
+}
+	
+
 static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
 {
 	struct netdev_private *np = dev->priv;
@@ -1618,6 +1636,7 @@
 	struct mii_ioctl_data *data = (struct mii_ioctl_data *) & rq->ifr_data;
 	int rc;
 	int i;
+	long ioaddr = dev->base_addr;
 
 	if (!netif_running(dev))
 		return -EINVAL;
@@ -1635,11 +1654,12 @@
 		for (i=0; i<TX_RING_SIZE; i++) {
 			printk(KERN_DEBUG "%02x %08x %08x %08x(%02x) %08x %08x\n", i,
 				np->tx_ring_dma + i*sizeof(*np->tx_ring),	
-				np->tx_ring[i].next_desc,
-				np->tx_ring[i].status,
-				(np->tx_ring[i].status >> 2) & 0xff,
-				np->tx_ring[i].frag[0].addr, 
-				np->tx_ring[i].frag[0].length);
+				le32_to_cpu(np->tx_ring[i].next_desc),
+				le32_to_cpu(np->tx_ring[i].status),
+				(le32_to_cpu(np->tx_ring[i].status) >> 2) 
+					& 0xff,
+				le32_to_cpu(np->tx_ring[i].frag[0].addr), 
+				le32_to_cpu(np->tx_ring[i].frag[0].length));
 		}
 		printk(KERN_DEBUG "TxListPtr=%08x netif_queue_stopped=%d\n", 
 			readl(dev->base_addr + TxListPtr), 
@@ -1649,6 +1669,7 @@
 			np->dirty_tx, np->dirty_tx % TX_RING_SIZE);
 		printk(KERN_DEBUG "cur_rx=%d dirty_rx=%d\n", np->cur_rx, np->dirty_rx);
 		printk(KERN_DEBUG "cur_task=%d\n", np->cur_task);
+		printk(KERN_DEBUG "TxStatus=%04x\n", readw(ioaddr + TxStatus));
 			return 0;
 	}
 				
diff -urN linux-2.5.68-bk6/drivers/net/tg3.c linux-2.5.68-bk7/drivers/net/tg3.c
--- linux-2.5.68-bk6/drivers/net/tg3.c	2003-04-26 04:37:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/net/tg3.c	2003-04-26 04:37:14.000000000 -0700
@@ -2154,6 +2154,7 @@
 	struct tg3 *tp = dev->priv;
 	struct tg3_hw_status *sblk = tp->hw_status;
 	unsigned long flags;
+	unsigned int handled = 1;
 
 	spin_lock_irqsave(&tp->lock, flags);
 
@@ -2184,11 +2185,13 @@
 			     	0x00000000);
 			tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
 		}
+	} else {	/* shared interrupt */
+		handled = 0;
 	}
 
 	spin_unlock_irqrestore(&tp->lock, flags);
 
-	return IRQ_HANDLED;
+	return IRQ_RETVAL(handled);
 }
 
 static void tg3_init_rings(struct tg3 *);
@@ -3102,6 +3105,7 @@
 	err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE);
 	err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE);
 	err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
+	err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE);
 	err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE);
 	if (err)
 		goto out;
diff -urN linux-2.5.68-bk6/drivers/net/typhoon.c linux-2.5.68-bk7/drivers/net/typhoon.c
--- linux-2.5.68-bk6/drivers/net/typhoon.c	2003-04-26 04:37:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/net/typhoon.c	2003-04-26 04:37:14.000000000 -0700
@@ -2135,7 +2135,7 @@
 	return 0;
 }
 
-#if CONFIG_PM
+#ifdef CONFIG_PM
 static int
 typhoon_resume(struct pci_dev *pdev)
 {
@@ -2483,7 +2483,7 @@
 	.id_table	= typhoon_pci_tbl,
 	.probe		= typhoon_init_one,
 	.remove		= __devexit_p(typhoon_remove_one),
-#if CONFIG_PM
+#ifdef CONFIG_PM
 	.suspend	= typhoon_suspend,
 	.resume		= typhoon_resume,
 	.enable_wake	= typhoon_enable_wake,
diff -urN linux-2.5.68-bk6/drivers/net/via-rhine.c linux-2.5.68-bk7/drivers/net/via-rhine.c
--- linux-2.5.68-bk6/drivers/net/via-rhine.c	2003-04-26 04:37:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/net/via-rhine.c	2003-04-26 04:37:14.000000000 -0700
@@ -1694,6 +1694,8 @@
 		/* Unconditionally log net taps. */
 		printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
 		rx_mode = 0x1C;
+		writel(0xffffffff, ioaddr + MulticastFilter0);
+		writel(0xffffffff, ioaddr + MulticastFilter1);
 	} else if ((dev->mc_count > multicast_filter_limit)
 			   ||  (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to match, or accept all multicasts. */
diff -urN linux-2.5.68-bk6/drivers/net/wireless/airo.c linux-2.5.68-bk7/drivers/net/wireless/airo.c
--- linux-2.5.68-bk6/drivers/net/wireless/airo.c	2003-04-26 04:37:09.000000000 -0700
+++ linux-2.5.68-bk7/drivers/net/wireless/airo.c	2003-04-26 04:37:14.000000000 -0700
@@ -3158,7 +3158,7 @@
 	readStatsRid(apriv, &stats, rid);
 
         j = 0;
-	for(i=0; (int)statsLabels[i]!=-1 &&
+	for(i=0; statsLabels[i]!=(char *)-1 &&
 		    i*4<stats.len; i++){
 		if (!statsLabels[i]) continue;
 		if (j+strlen(statsLabels[i])+16>4096) {
diff -urN linux-2.5.68-bk6/drivers/scsi/ncr53c8xx.c linux-2.5.68-bk7/drivers/scsi/ncr53c8xx.c
--- linux-2.5.68-bk6/drivers/scsi/ncr53c8xx.c	2003-04-19 19:48:57.000000000 -0700
+++ linux-2.5.68-bk7/drivers/scsi/ncr53c8xx.c	2003-04-26 04:37:15.000000000 -0700
@@ -115,15 +115,15 @@
 **==========================================================
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
+#include <linux/version.h>
 
 #include <linux/module.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 #include <asm/spinlock.h>
 #endif
 #include <linux/delay.h>
@@ -140,10 +140,9 @@
 #include <linux/timer.h>
 #include <linux/stat.h>
 
-#include <linux/version.h>
 #include <linux/blk.h>
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,35)
 #include <linux/init.h>
 #endif
 
@@ -154,7 +153,7 @@
 #define	__initdata
 #endif
 
-#if LINUX_VERSION_CODE <= LinuxVersionCode(2,1,92)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
 #include <linux/bios32.h>
 #endif
 
@@ -205,7 +204,7 @@
 **	Donnot compile integrity checking code for Linux-2.3.0 
 **	and above since SCSI data structures are not ready yet.
 */
-/* #if LINUX_VERSION_CODE < LinuxVersionCode(2,3,0) */
+/* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 #if 0
 #define	SCSI_NCR_INTEGRITY_CHECKING
 #endif
@@ -1049,7 +1048,7 @@
 					/*  when lcb is not allocated.	*/
 	Scsi_Cmnd	*done_list;	/* Commands waiting for done()  */
 					/* callback to be invoked.      */ 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t	smp_lock;	/* Lock for SMP threading       */
 #endif
 
@@ -3816,7 +3815,7 @@
 	instance->max_id	= np->maxwide ? 16 : 8;
 	instance->max_lun	= SCSI_NCR_MAX_LUN;
 #ifndef SCSI_NCR_IOMAPPED
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,29)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
 	instance->base		= (unsigned long) np->reg;
 #else
 	instance->base		= (char *) np->reg;
@@ -3901,7 +3900,7 @@
 
 	if (request_irq(device->slot.irq, ncr53c8xx_intr,
 			((driver_setup.irqm & 0x10) ? 0 : SA_SHIRQ) |
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			0,
@@ -9335,7 +9334,7 @@
 **
 **==========================================================
 */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
 static struct proc_dir_entry proc_scsi_ncr53c8xx = {
     PROC_SCSI_NCR53C8XX, 9, NAME53C8XX,
     S_IFDIR | S_IRUGO | S_IXUGO, 2
@@ -9350,7 +9349,7 @@
 */
 #ifdef	MODULE
 char *ncr53c8xx = 0;	/* command line passed by insmod */
-# if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30)
 MODULE_PARM(ncr53c8xx, "s");
 # endif
 #endif
@@ -9360,7 +9359,7 @@
 	return sym53c8xx__setup(str);
 }
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,13)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
 #ifndef MODULE
 __setup("ncr53c8xx=", ncr53c8xx_setup);
 #endif
@@ -9469,7 +9468,7 @@
 	**    Initialize driver general stuff.
 	*/
 #ifdef SCSI_NCR_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
      tpnt->proc_dir  = &proc_scsi_ncr53c8xx;
 #else
      tpnt->proc_name = NAME53C8XX;
@@ -9502,10 +9501,10 @@
 */
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 static
 #endif
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) || defined(MODULE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
 #ifdef ENABLE_SCSI_ZALON
 Scsi_Host_Template driver_template =  {
 	.proc_name =		"zalon720",
diff -urN linux-2.5.68-bk6/drivers/scsi/sym53c8xx.c linux-2.5.68-bk7/drivers/scsi/sym53c8xx.c
--- linux-2.5.68-bk6/drivers/scsi/sym53c8xx.c	2003-04-19 19:50:07.000000000 -0700
+++ linux-2.5.68-bk7/drivers/scsi/sym53c8xx.c	2003-04-26 04:37:15.000000000 -0700
@@ -99,16 +99,16 @@
 **==========================================================
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
+#include <linux/version.h>
 
 #include <linux/module.h>
 
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,17)
 #include <linux/spinlock.h>
-#elif LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 #include <asm/spinlock.h>
 #endif
 #include <linux/delay.h>
@@ -123,10 +123,9 @@
 #include <linux/timer.h>
 #include <linux/stat.h>
 
-#include <linux/version.h>
 #include <linux/blk.h>
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,35)
 #include <linux/init.h>
 #endif
 
@@ -137,7 +136,7 @@
 #define	__initdata
 #endif
 
-#if LINUX_VERSION_CODE <= LinuxVersionCode(2,1,92)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,1,92)
 #include <linux/bios32.h>
 #endif
 
@@ -170,7 +169,7 @@
 **	Donnot compile integrity checking code for Linux-2.3.0 
 **	and above since SCSI data structures are not ready yet.
 */
-/* #if LINUX_VERSION_CODE < LinuxVersionCode(2,3,0) */
+/* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 #if 0
 #define	SCSI_NCR_INTEGRITY_CHECKING
 #endif
@@ -183,7 +182,7 @@
 **	despite the fact that the PCI specifications are looking 
 **	so smart and simple! ;-)
 */
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,47)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,47)
 #define SCSI_NCR_DYNAMIC_DMA_MAPPING
 #endif
 
@@ -439,7 +438,7 @@
 **	code.
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
 
 typedef struct pci_dev *pcidev_t;
 #define PCIDEV_NULL		(0)
@@ -454,7 +453,7 @@
 {
 	u_long base;
 
-#if LINUX_VERSION_CODE > LinuxVersionCode(2,3,12)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,12)
 	base = pdev->resource[index].start;
 #else
 	base = pdev->base_address[index];
@@ -574,13 +573,13 @@
 	return base;
 }
 
-#endif	/* LINUX_VERSION_CODE >= LinuxVersionCode(2,2,0) */
+#endif	/* LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) */
 
 /* Does not make sense in earlier kernels */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 #define pci_enable_device(pdev)		(0)
 #endif
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,4,4)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
 #define	scsi_set_pci_device(inst, pdev)	(0)
 #endif
 
@@ -630,7 +629,7 @@
 **	  wished (e.g.: threaded by controller).
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 
 spinlock_t sym53c8xx_lock = SPIN_LOCK_UNLOCKED;
 #define	NCR_LOCK_DRIVER(flags)     spin_lock_irqsave(&sym53c8xx_lock, flags)
@@ -670,7 +669,7 @@
 **	architecture.
 */
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,1,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,0)
 #define ioremap vremap
 #define iounmap vfree
 #endif
@@ -713,7 +712,7 @@
 **	inaccurate on Pentium processors.
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,105)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,105)
 #define UDELAY udelay
 #define MDELAY mdelay
 #else
@@ -735,7 +734,7 @@
 **	real bus astraction, btw).
 */
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
 #define __GetFreePages(flags, order) __get_free_pages(flags, order)
 #else
 #define __GetFreePages(flags, order) __get_free_pages(flags, order, 0)
@@ -1282,7 +1281,7 @@
 /*
 **	/proc directory entry and proc_info function
 */
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
 static struct proc_dir_entry proc_scsi_sym53c8xx = {
     PROC_SCSI_SYM53C8XX, 9, NAME53C8XX,
     S_IFDIR | S_IRUGO | S_IXUGO, 2
@@ -1307,7 +1306,7 @@
 	driver_safe_setup __initdata	= SCSI_NCR_DRIVER_SAFE_SETUP;
 # ifdef	MODULE
 char *sym53c8xx = 0;	/* command line passed by insmod */
-#  if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30)
+#  if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30)
 MODULE_PARM(sym53c8xx, "s");
 #  endif
 # endif
@@ -2026,7 +2025,7 @@
 					/*  when lcb is not allocated.	*/
 	Scsi_Cmnd	*done_list;	/* Commands waiting for done()  */
 					/* callback to be invoked.      */ 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93)
 	spinlock_t	smp_lock;	/* Lock for SMP threading       */
 #endif
 
@@ -5843,7 +5842,7 @@
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			((driver_setup.irqm & 0x10) ? 0 : SA_SHIRQ) |
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 			((driver_setup.irqm & 0x20) ? 0 : SA_INTERRUPT),
 #else
 			0,
@@ -5907,7 +5906,7 @@
 	instance->max_id	= np->maxwide ? 16 : 8;
 	instance->max_lun	= MAX_LUN;
 #ifndef SCSI_NCR_IOMAPPED
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,29)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,29)
 	instance->base		= (unsigned long) np->reg;
 #else
 	instance->base		= (char *) np->reg;
@@ -7406,7 +7405,7 @@
 		}
 	}
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,99)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,99)
 	/*
 	**	Move residual byte count to user structure.
 	*/
@@ -12774,7 +12773,7 @@
 	return 1;
 }
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,13)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
 #ifndef MODULE
 __setup("sym53c8xx=", sym53c8xx_setup);
 #endif
@@ -12915,7 +12914,7 @@
 	**    Initialize driver general stuff.
 	*/
 #ifdef SCSI_NCR_PROC_INFO_SUPPORT
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,27)
      tpnt->proc_dir  = &proc_scsi_sym53c8xx;
 #else
      tpnt->proc_name = NAME53C8XX;
@@ -13244,7 +13243,7 @@
 		pci_write_config_word(pdev, PCI_COMMAND, command);
 	}
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,2,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 	if ( is_prep ) {
 		if (io_port >= 0x10000000) {
 			printk(NAME53C8XX ": reallocating io_port (Wacky IBM)");
@@ -13270,7 +13269,7 @@
 
 #if defined(__i386__) && !defined(MODULE)
 	if (!cache_line_size) {
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,1,75)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,75)
 		extern char x86;
 		switch(x86) {
 #else
@@ -14719,10 +14718,10 @@
 
 MODULE_LICENSE("GPL");
 
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
 static
 #endif
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,0) || defined(MODULE)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) || defined(MODULE)
 Scsi_Host_Template driver_template = SYM53C8XX;
 #include "scsi_module.c"
 #endif
diff -urN linux-2.5.68-bk6/fs/isofs/rock.c linux-2.5.68-bk7/fs/isofs/rock.c
--- linux-2.5.68-bk6/fs/isofs/rock.c	2003-04-19 19:49:52.000000000 -0700
+++ linux-2.5.68-bk7/fs/isofs/rock.c	2003-04-26 04:37:16.000000000 -0700
@@ -84,76 +84,6 @@
     printk("Unable to read rock-ridge attributes\n");    \
   }}
 
-/* This is the inner layer of the get filename routine, and is called
-   for each system area and continuation record related to the file */
-
-int find_rock_ridge_relocation(struct iso_directory_record * de, 
-			       struct inode * inode) {
-  int flag;
-  int len;
-  int retval;
-  unsigned char * chr;
-  CONTINUE_DECLS;
-  flag = 0;
-  
-  /* If this is a '..' then we are looking for the parent, otherwise we
-     are looking for the child */
-  
-  if (de->name[0]==1 && de->name_len[0]==1) flag = 1;
-  /* Return value if we do not find appropriate record. */
-  retval = isonum_733 (de->extent);
-  
-  if (!ISOFS_SB(inode->i_sb)->s_rock) return retval;
-
-  SETUP_ROCK_RIDGE(de, chr, len);
- repeat:
-  {
-    int rrflag, sig;
-    struct rock_ridge * rr;
-    
-    while (len > 1){ /* There may be one byte for padding somewhere */
-      rr = (struct rock_ridge *) chr;
-      if (rr->len == 0) goto out; /* Something got screwed up here */
-      sig = isonum_721(chr);
-      chr += rr->len; 
-      len -= rr->len;
-
-      switch(sig){
-      case SIG('R','R'):
-	rrflag = rr->u.RR.flags[0];
-	if (flag && !(rrflag & RR_PL)) goto out;
-	if (!flag && !(rrflag & RR_CL)) goto out;
-	break;
-      case SIG('S','P'):
-	CHECK_SP(goto out);
-	break;
-      case SIG('C','L'):
-	if (flag == 0) {
-	  retval = isonum_733(rr->u.CL.location);
-	  goto out;
-	}
-	break;
-      case SIG('P','L'):
-	if (flag != 0) {
-	  retval = isonum_733(rr->u.PL.location);
-	  goto out;
-	}
-	break;
-      case SIG('C','E'):
-	CHECK_CE; /* This tells is if there is a continuation record */
-	break;
-      default:
-	break;
-      }
-    }
-  }
-  MAYBE_CONTINUE(repeat, inode);
-  return retval;
- out:
-  if(buffer) kfree(buffer);
-  return retval;
-}
-
 /* return length of name field; 0: not found, -1: to be ignored */
 int get_rock_ridge_filename(struct iso_directory_record * de,
 			    char * retname, struct inode * inode)
diff -urN linux-2.5.68-bk6/include/linux/interrupt.h linux-2.5.68-bk7/include/linux/interrupt.h
--- linux-2.5.68-bk6/include/linux/interrupt.h	2003-04-26 04:37:10.000000000 -0700
+++ linux-2.5.68-bk7/include/linux/interrupt.h	2003-04-26 04:37:16.000000000 -0700
@@ -49,7 +49,7 @@
 /*
  * Temporary defines for UP kernels, until all code gets fixed.
  */
-#if !CONFIG_SMP
+#ifndef CONFIG_SMP
 # define cli()			local_irq_disable()
 # define sti()			local_irq_enable()
 # define save_flags(x)		local_save_flags(x)
diff -urN linux-2.5.68-bk6/include/linux/iso_fs.h linux-2.5.68-bk7/include/linux/iso_fs.h
--- linux-2.5.68-bk6/include/linux/iso_fs.h	2003-04-19 19:50:02.000000000 -0700
+++ linux-2.5.68-bk7/include/linux/iso_fs.h	2003-04-26 04:37:16.000000000 -0700
@@ -224,8 +224,6 @@
 extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
 extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
 
-extern int find_rock_ridge_relocation(struct iso_directory_record *, struct inode *);
-
 int get_joliet_filename(struct iso_directory_record *, unsigned char *, struct inode *);
 int get_acorn_filename(struct iso_directory_record *, char *, struct inode *);
 
diff -urN linux-2.5.68-bk6/include/linux/quotaops.h linux-2.5.68-bk7/include/linux/quotaops.h
--- linux-2.5.68-bk6/include/linux/quotaops.h	2003-04-19 19:48:56.000000000 -0700
+++ linux-2.5.68-bk7/include/linux/quotaops.h	2003-04-26 04:37:16.000000000 -0700
@@ -166,6 +166,7 @@
  */
 #define sb_dquot_ops				(NULL)
 #define sb_quotactl_ops				(NULL)
+#define sync_dquots_dev(dev,type)		(NULL)
 #define DQUOT_INIT(inode)			do { } while(0)
 #define DQUOT_DROP(inode)			do { } while(0)
 #define DQUOT_ALLOC_INODE(inode)		(0)
diff -urN linux-2.5.68-bk6/include/linux/sched.h linux-2.5.68-bk7/include/linux/sched.h
--- linux-2.5.68-bk6/include/linux/sched.h	2003-04-26 04:37:10.000000000 -0700
+++ linux-2.5.68-bk7/include/linux/sched.h	2003-04-26 04:37:16.000000000 -0700
@@ -467,7 +467,7 @@
 #define PF_KSWAPD	0x00040000	/* I am kswapd */
 #define PF_SWAPOFF	0x00080000	/* I am in swapoff */
 
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
 extern void set_cpus_allowed(task_t *p, unsigned long new_mask);
 #else
 # define set_cpus_allowed(p, new_mask) do { } while (0)
diff -urN linux-2.5.68-bk6/include/linux/timer.h linux-2.5.68-bk7/include/linux/timer.h
--- linux-2.5.68-bk6/include/linux/timer.h	2003-04-19 19:50:30.000000000 -0700
+++ linux-2.5.68-bk7/include/linux/timer.h	2003-04-26 04:37:16.000000000 -0700
@@ -65,7 +65,7 @@
 extern int del_timer(struct timer_list * timer);
 extern int mod_timer(struct timer_list *timer, unsigned long expires);
   
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
   extern int del_timer_sync(struct timer_list * timer);
 #else
 # define del_timer_sync(t) del_timer(t)
diff -urN linux-2.5.68-bk6/sound/oss/trident.c linux-2.5.68-bk7/sound/oss/trident.c
--- linux-2.5.68-bk6/sound/oss/trident.c	2003-04-26 04:37:10.000000000 -0700
+++ linux-2.5.68-bk7/sound/oss/trident.c	2003-04-26 04:37:16.000000000 -0700
@@ -206,7 +206,7 @@
 #include <asm/io.h>
 #include <asm/dma.h>
 
-#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+#if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 #include <asm/hwrpb.h>
 #endif
 
@@ -4284,7 +4284,7 @@
 		if(card->revision == ALI_5451_V02)
 			ali_close_multi_channels();
 		/* edited by HMSEO for GT sound */
-#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+#if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 		{
 			u16 ac97_data;
 			extern struct hwrpb_struct *hwrpb;
