Paul Mackerras writes:
 > Based on Egbert's comments about the use of an idr structure
 > restricting our choice of token values, I have taken an alternative
 > approach where I put the user token in the drm_map_list_t structure,
 > which is private to the kernel.
 > 
 > This patch is against the current DRM code in the kernel tree.  The
 > DRM code in CVS looks a bit different and I'm not sure where it is up
 > to.

I've made a patch against the DRM code in CVS adding a few pieces that
were missing.
The code works for me on both radeon and r128. I've also tried to test
mga however the mga code in CVS doesn't seem to work at all right now.

 > 
 > I am currently assigning completely arbitrary 32-bit tokens for maps
 > just to see how that works, and it seems to be fine on my G5 (which
 > has AGP and a radeon 9600 card).  I think it would be preferable to
 > use Egbert's code which uses the map->offset value if it fits into 32
 > bits in the longer term.

I've changed this to use the address value if possible (if it fits into
32bits and if the value has not been used as token for something else).

This should help to maintain backward compatibility, on the other
hand it may not sufficiently deter people from using handles as base 
addresses.

 > 
 > I am also assigning 32-bit tokens even if CONFIG_COMPAT isn't
 > defined.  For 64-bit kernels that don't have CONFIG_COMPAT defined, do
 > we still want to generate 32-bit tokens?  We will have to if we make
 > the tokens passed between the X server and the client 32-bit.

Yes, it's probably best to stick with one code base.
I've used the _LP64 define to check for platforms whose pointers don't
fit into 32bit and thus cannot be used as 32bit tokens.

 > 
 > If people don't like me adding the dev->agp_buffer_token field, the
 > alternative would be to search the dev->maplist list to find the token
 > for dev->agp_buffer_list in drm_mapbufs.  I didn't see the point in
 > throwing away the token and then having to search for it, though.
 > 
 > I have incorporated the drm_core_findmap_by_base from Egbert's patch.
 > Nothing in the kernel tree's DRM seems to need it at present.

The present code does not seem to need it. Once there was code in the
Radeon driver that did, though.
I've eliminated it from my patch. 

The code for CVS head is below.

1. To make user space data structures that are passed
   between 32 and 64 bit parts identical in size we 
   have to change drm_handle_t from unsigned long to 
   unsigned int.
   This change also part of the patch below.
   This change will introduce a compatibility issue un user space.
   DRM will work with either version.
   The kernel does not use drm_handle_t (except for the mga driver)
   where the use of it has been introduced just recently.
   We may consider changing this to an unsigned long to keep the
   kernel ABI. If we do the ioctl using this structure needs a
   32bit compatibility wrapper.
   I've also added these changes to the patch below.

2. Beyond the change of the type of drm_handle_t some DRIRecs need
   to be changed:
   replace (unsigned long) by drm_handle_t (sis, via)
   replace the use of drmRegion (mga)
   replace the use of drmAddress
3. 1 and 2 describe the bare minimum of what needs to be done in the
   user space parts. 
   In some places unsigned long is used for handles instead of drm_handle_t,
   changing this will make the code more consistent.

We need to make a plan what would be a good time to make the changes
described in 1 and 2.

I hope we can come to an agreement on this, finally.

Cheers,
        Egbert.

Index: linux-core/drmP.h
===================================================================
RCS file: /cvs/dri/drm/linux-core/drmP.h,v
retrieving revision 1.156
diff -u -r1.156 drmP.h
--- linux-core/drmP.h   3 Jul 2005 18:07:03 -0000       1.156
+++ linux-core/drmP.h   12 Jul 2005 17:44:03 -0000
@@ -497,6 +497,7 @@
 typedef struct drm_map_list {
        struct list_head head;          /**< list head */
        drm_map_t *map;                 /**< mapping */
+       unsigned int user_token;
 } drm_map_list_t;
 
 typedef drm_map_t drm_local_map_t;
@@ -722,6 +723,7 @@
 
        struct drm_driver *driver;
        drm_local_map_t *agp_buffer_map;
+       unsigned int agp_buffer_token;
        drm_head_t primary;             /**< primary screen head */
 } drm_device_t;
 
@@ -1011,18 +1013,14 @@
                drm_ioremapfree(map->handle, map->size, dev);
 }
 
-static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
-                                                  unsigned long offset)
+static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, 
unsigned int token)
 {
-       struct list_head *_list;
-       list_for_each(_list, &dev->maplist->head) {
-               drm_map_list_t *_entry =
-                   list_entry(_list, drm_map_list_t, head);
-               if (_entry->map && _entry->map->offset == offset) {
+       drm_map_list_t *_entry;
+
+       list_for_each_entry(_entry, &dev->maplist->head, head)
+               if (_entry->user_token == token)
                        return _entry->map;
-               }
-       }
-       return NULL;
+               return NULL;
 }
 
 static __inline__ int drm_device_is_agp(drm_device_t *dev)
Index: linux-core/drm_bufs.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_bufs.c,v
retrieving revision 1.62
diff -u -r1.62 drm_bufs.c
--- linux-core/drm_bufs.c       29 Jun 2005 13:00:29 -0000      1.62
+++ linux-core/drm_bufs.c       12 Jul 2005 17:44:03 -0000
@@ -64,13 +64,41 @@
        return NULL;
 }
 
-#ifdef CONFIG_COMPAT
 /*
- * Used to allocate 32-bit handles for _DRM_SHM regions
- * The 0x10000000 value is chosen to be out of the way of
- * FB/register and GART physical addresses.
+ * Used to allocate 32-bit handles for mappings.
  */
-static unsigned int map32_handle = 0x10000000;
+#define START_RANGE 0x10000000
+#define END_RANGE 0x40000000
+
+#ifdef _LP64
+static __inline__ unsigned int HandleID(unsigned long lhandle, drm_device_t 
*dev) 
+{
+       static unsigned int map32_handle = START_RANGE;
+        unsigned int hash;
+   
+       if (lhandle & 0xffffffff00000000) {
+               hash = map32_handle;
+               map32_handle += PAGE_SIZE;
+               if (map32_handle > END_RANGE)
+                       map32_handle = START_RANGE;
+       } else 
+               hash = lhandle;
+
+       while (1) {
+               drm_map_list_t *_entry;
+               list_for_each_entry(_entry, &dev->maplist->head,head) {
+                       if (_entry->user_token == hash)
+                               break;
+               }
+               if(&_entry->head == &dev->maplist->head)
+                       return hash;
+
+               hash += PAGE_SIZE;
+               map32_handle += PAGE_SIZE;
+       }
+}
+#else
+# define HandleID(x,dev) (unsigned int)(x)
 #endif
 
 /**
@@ -195,7 +223,7 @@
                        drm_free(map, sizeof(*map), DRM_MEM_MAPS);
                        return -EINVAL;
                }
-               map->offset += dev->sg->handle;
+               map->offset += (unsigned long)dev->sg->virtual;
                break;
        case _DRM_CONSISTENT: {
                /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G.
@@ -227,12 +255,11 @@
 
        down(&dev->struct_sem);
        list_add(&list->head, &dev->maplist->head);
-#ifdef CONFIG_COMPAT
-       /* Assign a 32-bit handle for _DRM_SHM mappings */
+       /* Assign a 32-bit handle */
        /* We do it here so that dev->struct_sem protects the increment */
-       if (map->type == _DRM_SHM)
-               map->offset = map32_handle += PAGE_SIZE;
-#endif
+       list->user_token = HandleID(map->type == _DRM_SHM 
+                                   ? (unsigned long) map->handle
+                                   : map->offset, dev);
 
        up(&dev->struct_sem);
 
@@ -250,6 +277,7 @@
        drm_map_t *map_ptr;
        drm_map_t __user *argp = (void __user *)arg;
        int err;
+       unsigned long handle = 0;
 
        if (!(filp->f_mode & 3))
                return -EACCES; /* Require read/write */
@@ -264,14 +292,19 @@
        if (err) {
                return err;
        }
-
-       if (copy_to_user(argp, map_ptr, sizeof(*map_ptr)))
-               return -EFAULT;
-       if (map_ptr->type != _DRM_SHM) {
-               if (copy_to_user(&argp->handle,
-                                &map_ptr->offset, sizeof(map_ptr->offset)))
+       {
+               drm_map_list_t *_entry;
+               list_for_each_entry(_entry, &dev->maplist->head,head) {
+                       if (_entry->map == map_ptr)
+                               handle = _entry->user_token;
+               }
+               if (!handle)
                        return -EFAULT;
        }
+       if (copy_to_user(argp, map_ptr, sizeof(*map_ptr)))
+               return -EFAULT;
+       if (put_user(handle, &argp->handle))
+               return -EFAULT;
        return 0;
 }
 
@@ -386,7 +419,7 @@
                drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
 
                if (r_list->map &&
-                   r_list->map->handle == request.handle &&
+                   r_list->user_token == (unsigned long)request.handle &&
                    r_list->map->flags & _DRM_REMOVABLE) {
                        map = r_list->map;
                        break;
@@ -937,7 +970,8 @@
 
                buf->offset = (dma->byte_count + offset);
                buf->bus_address = agp_offset + offset;
-               buf->address = (void *)(agp_offset + offset + dev->sg->handle);
+               buf->address = (void *)(agp_offset + offset 
+                                       + (unsigned long)dev->sg->virtual);
                buf->next = NULL;
                buf->waiting = 0;
                buf->pending = 0;
@@ -1460,6 +1494,7 @@
                     || (drm_core_check_feature(dev, DRIVER_FB_DMA)
                     && (dma->flags & _DRM_DMA_USE_FB))) {
                        drm_map_t *map = dev->agp_buffer_map;
+                       unsigned long token = dev->agp_buffer_token;
 
                        if (!map) {
                                retcode = -EINVAL;
@@ -1473,7 +1508,7 @@
                        virtual = do_mmap(filp, 0, map->size,
                                          PROT_READ | PROT_WRITE,
                                          MAP_SHARED,
-                                         (unsigned long)map->offset);
+                                         token);
 #if LINUX_VERSION_CODE <= 0x020402
                        up(&current->mm->mmap_sem);
 #else
Index: linux-core/drm_context.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_context.c,v
retrieving revision 1.31
diff -u -r1.31 drm_context.c
--- linux-core/drm_context.c    4 Jun 2005 06:18:11 -0000       1.31
+++ linux-core/drm_context.c    12 Jul 2005 17:44:03 -0000
@@ -217,6 +217,7 @@
        drm_ctx_priv_map_t __user *argp = (void __user *)arg;
        drm_ctx_priv_map_t request;
        drm_map_t *map;
+       drm_map_list_t *_entry;
 
        if (copy_from_user(&request, argp, sizeof(request)))
                return -EFAULT;
@@ -231,7 +232,16 @@
        map = dev->context_sareas[request.ctx_id];
        up(&dev->struct_sem);
 
-       request.handle = map->handle;
+       request.handle = 0;
+       list_for_each_entry(_entry, &dev->maplist->head,head) {
+               if (_entry->map == map) {
+                           request.handle = (void *)(unsigned 
long)_entry->user_token;
+                           break;
+               }
+       }
+       if (request.handle == 0)
+               return -EINVAL;
+
        if (copy_to_user(argp, &request, sizeof(request)))
                return -EFAULT;
        return 0;
@@ -266,7 +276,7 @@
        down(&dev->struct_sem);
        list_for_each(list, &dev->maplist->head) {
                r_list = list_entry(list, drm_map_list_t, head);
-               if (r_list->map && r_list->map->handle == request.handle)
+               if (r_list->user_token == (unsigned long)request.handle)
                        goto found;
        }
       bad:
@@ -372,7 +382,7 @@
                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)))
+                       if (copy_to_user(&res.contexts[i], &i, sizeof(ctx)))
                                return -EFAULT;
                }
        }
Index: linux-core/drm_ioctl.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_ioctl.c,v
retrieving revision 1.34
diff -u -r1.34 drm_ioctl.c
--- linux-core/drm_ioctl.c      8 Mar 2005 23:47:11 -0000       1.34
+++ linux-core/drm_ioctl.c      12 Jul 2005 17:44:03 -0000
@@ -211,7 +211,7 @@
        map.size = r_list->map->size;
        map.type = r_list->map->type;
        map.flags = r_list->map->flags;
-       map.handle = r_list->map->handle;
+       map.handle = (void *)(unsigned long) r_list->user_token;
        map.mtrr = r_list->map->mtrr;
        up(&dev->struct_sem);
 
Index: linux-core/drm_proc.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_proc.c,v
retrieving revision 1.25
diff -u -r1.25 drm_proc.c
--- linux-core/drm_proc.c       4 Jun 2005 06:18:11 -0000       1.25
+++ linux-core/drm_proc.c       12 Jul 2005 17:44:03 -0000
@@ -238,11 +238,12 @@
                        type = "??";
                else
                        type = types[map->type];
-               DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s  0x%02x 0x%08lx ",
+               DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s  0x%02x 0x%08x ",
                               i,
                               map->offset,
                               map->size,
-                              type, map->flags, (unsigned long)map->handle);
+                              type, map->flags, 
+                              r_list->user_token);
                if (map->mtrr < 0) {
                        DRM_PROC_PRINT("none\n");
                } else {
Index: linux-core/drm_scatter.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_scatter.c,v
retrieving revision 1.23
diff -u -r1.23 drm_scatter.c
--- linux-core/drm_scatter.c    18 Oct 2004 14:16:41 -0000      1.23
+++ linux-core/drm_scatter.c    12 Jul 2005 17:44:03 -0000
@@ -58,6 +58,12 @@
        drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
 }
 
+#ifdef _LP64
+# define ScatterHandle(x) (unsigned int)((x >> 32) + (x & ((1L << 32) - 1)))
+#else
+# define ScatterHandle(x) (unsigned int)(x)
+#endif
+
 int drm_sg_alloc(struct inode *inode, struct file *filp,
                 unsigned int cmd, unsigned long arg)
 {
@@ -125,12 +131,13 @@
         */
        memset(entry->virtual, 0, pages << PAGE_SHIFT);
 
-       entry->handle = (unsigned long)entry->virtual;
+       entry->handle = ScatterHandle((unsigned long)entry->virtual);
 
        DRM_DEBUG("sg alloc handle  = %08lx\n", entry->handle);
        DRM_DEBUG("sg alloc virtual = %p\n", entry->virtual);
 
-       for (i = entry->handle, j = 0; j < pages; i += PAGE_SIZE, j++) {
+       for (i = (unsigned long)entry->virtual, j = 0; j < pages; 
+            i += PAGE_SIZE, j++) {
                entry->pagelist[j] = vmalloc_to_page((void *)i);
                if (!entry->pagelist[j])
                        goto failed;
Index: linux-core/drm_vm.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_vm.c,v
retrieving revision 1.53
diff -u -r1.53 drm_vm.c
--- linux-core/drm_vm.c 4 Jun 2005 06:18:11 -0000       1.53
+++ linux-core/drm_vm.c 12 Jul 2005 17:44:03 -0000
@@ -75,13 +75,13 @@
                map = r_list->map;
                if (!map)
                        continue;
-               if (map->offset == VM_OFFSET(vma))
+               if (r_list->user_token == VM_OFFSET(vma))
                        break;
        }
 
        if (map && map->type == _DRM_AGP) {
                unsigned long offset = address - vma->vm_start;
-               unsigned long baddr = VM_OFFSET(vma) + offset;
+               unsigned long baddr = map->offset + offset;
                struct drm_agp_mem *agpmem;
                struct page *page;
 
@@ -319,7 +319,7 @@
                return NOPAGE_OOM;      /* Nothing allocated */
 
        offset = address - vma->vm_start;
-       map_offset = map->offset - dev->sg->handle;
+       map_offset = map->offset - (unsigned long)dev->sg->virtual;
        page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
        page = entry->pagelist[page_offset];
        get_page(page);
@@ -586,14 +586,12 @@
           for performance, even if the list was a
           bit longer. */
        list_for_each(list, &dev->maplist->head) {
-               unsigned long off;
 
                r_list = list_entry(list, drm_map_list_t, head);
                map = r_list->map;
                if (!map)
                        continue;
-               off = dev->driver->get_map_ofs(map);
-               if (off == VM_OFFSET(vma))
+               if (r_list->user_token == VM_OFFSET(vma))
                        break;
        }
 
@@ -636,7 +634,7 @@
                /* fall through to _DRM_FRAME_BUFFER... */
        case _DRM_FRAME_BUFFER:
        case _DRM_REGISTERS:
-               if (VM_OFFSET(vma) >= __pa(high_memory)) {
+               if (map->offset >= __pa(high_memory)) {
 #if defined(__i386__) || defined(__x86_64__)
                        if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
                                pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
@@ -660,12 +658,12 @@
                offset = dev->driver->get_reg_ofs(dev);
 #ifdef __sparc__
                if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-                                       VM_OFFSET(vma) + offset,
+                                       map->offset + offset,
                                        vma->vm_end - vma->vm_start,
                                        vma->vm_page_prot, 0))
 #else
                if (remap_pfn_range(vma, vma->vm_start,
-                                    (VM_OFFSET(vma) + offset) >> PAGE_SHIFT,
+                                    (map->offset + offset) >> PAGE_SHIFT,
                                     vma->vm_end - vma->vm_start,
                                     vma->vm_page_prot))
 #endif
@@ -673,7 +671,7 @@
                DRM_DEBUG("   Type = %d; start = 0x%lx, end = 0x%lx,"
                          " offset = 0x%lx\n",
                          map->type,
-                         vma->vm_start, vma->vm_end, VM_OFFSET(vma) + offset);
+                         vma->vm_start, vma->vm_end, map->offset + offset);
                vma->vm_ops = &drm_vm_ops;
                break;
        case _DRM_SHM:
Index: linux-core/ffb_drv.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/ffb_drv.c,v
retrieving revision 1.13
diff -u -r1.13 ffb_drv.c
--- linux-core/ffb_drv.c        13 Oct 2004 16:40:53 -0000      1.13
+++ linux-core/ffb_drv.c        12 Jul 2005 17:44:03 -0000
@@ -177,14 +177,11 @@
                return NULL;
 
        list_for_each(list, &dev->maplist->head) {
-               unsigned long uoff;
-
                r_list = (drm_map_list_t *)list;
                map = r_list->map;
                if (!map)
                        continue;
-               uoff = (map->offset & 0xffffffff);
-               if (uoff == off)
+               if (r_list->user_token == off)
                        return map;
        }
 
Index: linux-core/i810_dma.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/i810_dma.c,v
retrieving revision 1.79
diff -u -r1.79 i810_dma.c
--- linux-core/i810_dma.c       16 Jun 2005 19:58:00 -0000      1.79
+++ linux-core/i810_dma.c       12 Jul 2005 17:44:03 -0000
@@ -373,6 +373,7 @@
                DRM_ERROR("can not find mmio map!\n");
                return -EINVAL;
        }
+       dev->agp_buffer_token = init->buffers_offset;
        dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
        if (!dev->agp_buffer_map) {
                dev->dev_private = (void *)dev_priv;
Index: linux-core/i830_dma.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/i830_dma.c,v
retrieving revision 1.44
diff -u -r1.44 i830_dma.c
--- linux-core/i830_dma.c       16 Jun 2005 19:58:00 -0000      1.44
+++ linux-core/i830_dma.c       12 Jul 2005 17:44:03 -0000
@@ -366,6 +366,7 @@
                DRM_ERROR("can not find mmio map!\n");
                return -EINVAL;
        }
+       dev->agp_buffer_token = init->buffers_offset;
        dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
        if (!dev->agp_buffer_map) {
                dev->dev_private = (void *)dev_priv;
Index: linux-core/mga_ioc32.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/mga_ioc32.c,v
retrieving revision 1.3
diff -u -r1.3 mga_ioc32.c
--- linux-core/mga_ioc32.c      29 Jun 2005 12:02:18 -0000      1.3
+++ linux-core/mga_ioc32.c      12 Jul 2005 17:44:03 -0000
@@ -129,9 +129,75 @@
                         DRM_IOCTL_MGA_GETPARAM, (unsigned long)getparam);
 }
 
+typedef struct drm_mga_dma_bootstrap32 {
+       u32 texture_handle;
+       u32 texture_size; 
+       u32 primary_size;
+       u32 secondary_bin_count;
+       u32 secondary_bin_size;
+       u32 agp_mode;
+       u8 agp_size;
+} drm_mga_dma_bootstrap32_t;
+
+static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
+                              unsigned long arg)
+{
+       drm_mga_dma_bootstrap32_t dma_bootstrap32;
+       drm_mga_dma_bootstrap_t __user *dma_bootstrap;
+       int err;
+
+       if (copy_from_user(&dma_bootstrap32, (void __user *)arg, 
sizeof(dma_bootstrap32)))
+               return -EFAULT;
+
+       dma_bootstrap = compat_alloc_user_space(sizeof(*dma_bootstrap));
+       if (!access_ok(VERIFY_WRITE, dma_bootstrap, sizeof(*dma_bootstrap))
+           || __put_user(dma_bootstrap32.texture_handle, 
+                         &dma_bootstrap->texture_handle)
+           || __put_user(dma_bootstrap32.texture_size, 
+                         &dma_bootstrap->texture_size)
+           || __put_user(dma_bootstrap32.primary_size, 
+                         &dma_bootstrap->primary_size)
+           || __put_user(dma_bootstrap32.secondary_bin_count, 
+                         &dma_bootstrap->secondary_bin_count)
+           || __put_user(dma_bootstrap32.secondary_bin_size, 
+                         &dma_bootstrap->secondary_bin_size)
+           || __put_user(dma_bootstrap32.agp_mode, &dma_bootstrap->agp_mode)
+           || __put_user(dma_bootstrap32.agp_size, &dma_bootstrap->agp_size))
+               return -EFAULT;
+
+       err = drm_ioctl(file->f_dentry->d_inode, file, 
+                        DRM_IOCTL_MGA_DMA_BOOTSTRAP, 
+                       (unsigned long)dma_bootstrap);
+       if (err)
+           return err;
+
+       if ( __get_user(dma_bootstrap32.texture_handle, 
+                       &dma_bootstrap->texture_handle)
+           || __get_user(dma_bootstrap32.texture_size, 
+                         &dma_bootstrap->texture_size)
+           || __get_user(dma_bootstrap32.primary_size, 
+                         &dma_bootstrap->primary_size)
+           || __get_user(dma_bootstrap32.secondary_bin_count, 
+                         &dma_bootstrap->secondary_bin_count)
+           || __get_user(dma_bootstrap32.secondary_bin_size, 
+                         &dma_bootstrap->secondary_bin_size)
+           || __get_user(dma_bootstrap32.agp_mode, 
+                         &dma_bootstrap->agp_mode)
+           || __get_user(dma_bootstrap32.agp_size, 
+                         &dma_bootstrap->agp_size))
+               return -EFAULT;
+
+       if (copy_to_user((void __user *)arg, &dma_bootstrap32, 
+                        sizeof(dma_bootstrap32)))
+               return -EFAULT;
+
+       return 0;
+}
+
 drm_ioctl_compat_t *mga_compat_ioctls[] = {
        [DRM_MGA_INIT] = compat_mga_init,
        [DRM_MGA_GETPARAM] = compat_mga_getparam,
+       [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
 };
 
 /**
Index: shared-core/drm.h
===================================================================
RCS file: /cvs/dri/drm/shared-core/drm.h,v
retrieving revision 1.64
diff -u -r1.64 drm.h
--- shared-core/drm.h   11 Jun 2005 10:08:39 -0000      1.64
+++ shared-core/drm.h   12 Jul 2005 17:44:03 -0000
@@ -127,7 +127,7 @@
 #define _DRM_LOCK_IS_CONT(lock)           ((lock) & _DRM_LOCK_CONT)
 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
 
-typedef unsigned long drm_handle_t;    /**< To mapped regions */
+typedef unsigned int drm_handle_t;     /**< To mapped regions */
 typedef unsigned int drm_context_t;    /**< GLXContext handle */
 typedef unsigned int drm_drawable_t;
 typedef unsigned int drm_magic_t;      /**< Magic for authentication */
Index: shared-core/mga_dma.c
===================================================================
RCS file: /cvs/dri/drm/shared-core/mga_dma.c,v
retrieving revision 1.27
diff -u -r1.27 mga_dma.c
--- shared-core/mga_dma.c       28 Jun 2005 20:58:34 -0000      1.27
+++ shared-core/mga_dma.c       12 Jul 2005 17:44:04 -0000
@@ -817,6 +817,7 @@
                        DRM_ERROR("failed to find primary dma region!\n");
                        return DRM_ERR(EINVAL);
                }
+               dev->agp_buffer_token = init->buffers_offset;
                dev->agp_buffer_map = drm_core_findmap(dev, 
init->buffers_offset);
                if (!dev->agp_buffer_map) {
                        DRM_ERROR("failed to find dma buffer region!\n");
Index: shared-core/mga_drm.h
===================================================================
RCS file: /cvs/dri/drm/shared-core/mga_drm.h,v
retrieving revision 1.9
diff -u -r1.9 mga_drm.h
--- shared-core/mga_drm.h       14 Jun 2005 22:34:11 -0000      1.9
+++ shared-core/mga_drm.h       12 Jul 2005 17:44:04 -0000
@@ -312,7 +312,7 @@
         * an IOMMU) is being used for "AGP" textures.
         */
        /[EMAIL PROTECTED]/
-       drm_handle_t texture_handle;  /**< Handle used to map AGP textures. */
+       unsigned long texture_handle;  /**< Handle used to map AGP textures. */
        uint32_t     texture_size;    /**< Size of the AGP texture region. */
        /[EMAIL PROTECTED]/
 
Index: shared-core/r128_cce.c
===================================================================
RCS file: /cvs/dri/drm/shared-core/r128_cce.c,v
retrieving revision 1.24
diff -u -r1.24 r128_cce.c
--- shared-core/r128_cce.c      1 Feb 2005 11:08:31 -0000       1.24
+++ shared-core/r128_cce.c      12 Jul 2005 17:44:04 -0000
@@ -323,7 +323,8 @@
                ring_start = dev_priv->cce_ring->offset - dev->agp->base;
        else
 #endif
-               ring_start = dev_priv->cce_ring->offset - dev->sg->handle;
+               ring_start = dev_priv->cce_ring->offset 
+                       - (unsigned long)dev->sg->virtual;
 
        R128_WRITE(R128_PM4_BUFFER_OFFSET, ring_start | R128_AGP_OFFSET);
 
@@ -484,6 +485,7 @@
                r128_do_cleanup_cce(dev);
                return DRM_ERR(EINVAL);
        }
+       dev->agp_buffer_token = init->buffers_offset;
        dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
        if (!dev->agp_buffer_map) {
                DRM_ERROR("could not find dma buffer region!\n");
@@ -535,7 +537,7 @@
                dev_priv->cce_buffers_offset = dev->agp->base;
        else
 #endif
-               dev_priv->cce_buffers_offset = dev->sg->handle;
+               dev_priv->cce_buffers_offset = (unsigned long)dev->sg->virtual;
 
        dev_priv->ring.start = (u32 *) dev_priv->cce_ring->handle;
        dev_priv->ring.end = ((u32 *) dev_priv->cce_ring->handle
Index: shared-core/r128_drm.h
===================================================================
RCS file: /cvs/dri/drm/shared-core/r128_drm.h,v
retrieving revision 1.10
diff -u -r1.10 r128_drm.h
--- shared-core/r128_drm.h      30 Sep 2004 21:12:10 -0000      1.10
+++ shared-core/r128_drm.h      12 Jul 2005 17:44:04 -0000
@@ -213,7 +213,7 @@
 #define DRM_IOCTL_R128_INDIRECT   DRM_IOWR(DRM_COMMAND_BASE + 
DRM_R128_INDIRECT, drm_r128_indirect_t)
 #define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + 
DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
 #define DRM_IOCTL_R128_CLEAR2     DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, 
drm_r128_clear2_t)
-#define DRM_IOCTL_R128_GETPARAM   DRM_IOW( DRM_COMMAND_BASE + 
DRM_R128_GETPARAM, drm_r128_getparam_t)
+#define DRM_IOCTL_R128_GETPARAM   DRM_IOWR( DRM_COMMAND_BASE + 
DRM_R128_GETPARAM, drm_r128_getparam_t)
 #define DRM_IOCTL_R128_FLIP       DRM_IO(  DRM_COMMAND_BASE + DRM_R128_FLIP)
 
 typedef struct drm_r128_init {
Index: shared-core/radeon_cp.c
===================================================================
RCS file: /cvs/dri/drm/shared-core/radeon_cp.c,v
retrieving revision 1.58
diff -u -r1.58 radeon_cp.c
--- shared-core/radeon_cp.c     28 Jun 2005 20:58:34 -0000      1.58
+++ shared-core/radeon_cp.c     12 Jul 2005 17:44:04 -0000
@@ -1394,6 +1394,7 @@
                radeon_do_cleanup_cp(dev);
                return DRM_ERR(EINVAL);
        }
+       dev->agp_buffer_token = init->buffers_offset;
        dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
        if (!dev->agp_buffer_map) {
                DRM_ERROR("could not find dma buffer region!\n");


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to