summaryrefslogtreecommitdiff
path: root/bsd-core/drm_bufs.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-core/drm_bufs.c')
-rw-r--r--bsd-core/drm_bufs.c258
1 files changed, 120 insertions, 138 deletions
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 343ab1e8..9b58c593 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -1,6 +1,3 @@
-/* drm_bufs.h -- Generic buffer template -*- linux-c -*-
- * Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
- */
/*-
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
@@ -31,6 +28,10 @@
*
*/
+/** @file drm_bufs.c
+ * Implementation of the ioctls for setup of DRM mappings and DMA buffers.
+ */
+
#include "dev/pci/pcireg.h"
#include "drmP.h"
@@ -149,7 +150,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
*/
map = malloc(sizeof(*map), M_DRM, M_ZERO | M_NOWAIT);
if ( !map )
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
map->offset = offset;
map->size = size;
@@ -172,7 +173,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
map->size, drm_order(map->size), map->handle );
if ( !map->handle ) {
free(map, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
map->offset = (unsigned long)map->handle;
if ( map->flags & _DRM_CONTAINS_LOCK ) {
@@ -182,7 +183,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
DRM_UNLOCK();
free(map->handle, M_DRM);
free(map, M_DRM);
- return DRM_ERR(EBUSY);
+ return EBUSY;
}
dev->lock.hw_lock = map->handle; /* Pointer to lock */
DRM_UNLOCK();
@@ -190,7 +191,17 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
break;
case _DRM_AGP:
/*valid = 0;*/
- map->offset += dev->agp->base;
+ /* In some cases (i810 driver), user space may have already
+ * added the AGP base itself, because dev->agp->base previously
+ * only got set during AGP enable. So, only add the base
+ * address if the map's offset isn't already within the
+ * aperture.
+ */
+ if (map->offset < dev->agp->base ||
+ map->offset > dev->agp->base +
+ dev->agp->info.ai_aperture_size - 1) {
+ map->offset += dev->agp->base;
+ }
map->mtrr = dev->agp->mtrr; /* for getmap */
/*for (entry = dev->agp->memory; entry; entry = entry->next) {
if ((map->offset >= entry->bound) &&
@@ -202,13 +213,13 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
}
if (!valid) {
free(map, M_DRM);
- return DRM_ERR(EACCES);
+ return EACCES;
}*/
break;
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
free(map, M_DRM);
- return DRM_ERR(EINVAL);
+ return EINVAL;
}
map->offset = map->offset + dev->sg->handle;
break;
@@ -225,7 +236,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful);
if (map->dmah == NULL) {
free(map, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
map->handle = map->dmah->vaddr;
map->offset = map->dmah->busaddr;
@@ -233,7 +244,7 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
default:
DRM_ERROR("Bad map type %d\n", map->type);
free(map, M_DRM);
- return DRM_ERR(EINVAL);
+ return EINVAL;
}
DRM_LOCK();
@@ -250,39 +261,35 @@ done:
return 0;
}
-int drm_addmap_ioctl(DRM_IOCTL_ARGS)
+int drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- drm_map_t request;
+ drm_map_t *request = data;
drm_local_map_t *map;
int err;
- DRM_DEVICE;
if (!(dev->flags & (FREAD|FWRITE)))
- return DRM_ERR(EACCES); /* Require read/write */
+ return EACCES; /* Require read/write */
- DRM_COPY_FROM_USER_IOCTL(request, (drm_map_t *)data, sizeof(drm_map_t));
-
- if (!DRM_SUSER(p) && request.type != _DRM_AGP)
- return DRM_ERR(EACCES);
+ if (!DRM_SUSER(DRM_CURPROC) && request->type != _DRM_AGP)
+ return EACCES;
DRM_LOCK();
- err = drm_addmap(dev, request.offset, request.size, request.type,
- request.flags, &map);
+ err = drm_addmap(dev, request->offset, request->size, request->type,
+ request->flags, &map);
DRM_UNLOCK();
if (err != 0)
return err;
- request.offset = map->offset;
- request.size = map->size;
- request.type = map->type;
- request.flags = map->flags;
- request.mtrr = map->mtrr;
- request.handle = map->handle;
+ request->offset = map->offset;
+ request->size = map->size;
+ request->type = map->type;
+ request->flags = map->flags;
+ request->mtrr = map->mtrr;
+ request->handle = map->handle;
- if (request.type != _DRM_SHM) {
- request.handle = (void *)request.offset;
+ if (request->type != _DRM_SHM) {
+ request->handle = (void *)request->offset;
}
- DRM_COPY_TO_USER_IOCTL((drm_map_t *)data, request, sizeof(drm_map_t));
return 0;
}
@@ -333,17 +340,14 @@ void drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
* isn't in use.
*/
-int drm_rmmap_ioctl(DRM_IOCTL_ARGS)
+int drm_rmmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
drm_local_map_t *map;
- drm_map_t request;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_map_t *)data, sizeof(request) );
+ drm_map_t *request = data;
DRM_LOCK();
TAILQ_FOREACH(map, &dev->maplist, link) {
- if (map->handle == request.handle &&
+ if (map->handle == request->handle &&
map->flags & _DRM_REMOVABLE)
break;
}
@@ -351,7 +355,7 @@ int drm_rmmap_ioctl(DRM_IOCTL_ARGS)
/* No match found. */
if (map == NULL) {
DRM_UNLOCK();
- return DRM_ERR(EINVAL);
+ return EINVAL;
}
drm_rmmap(dev, map);
@@ -441,7 +445,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
}
if (!valid) {
DRM_DEBUG("zone invalid\n");
- return DRM_ERR(EINVAL);
+ return EINVAL;
}*/
entry = &dma->bufs[order];
@@ -449,7 +453,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
M_NOWAIT | M_ZERO);
if ( !entry->buflist ) {
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
entry->buf_size = size;
@@ -469,7 +473,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
buf->address = (void *)(agp_offset + offset);
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -478,7 +482,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
drm_cleanup_buf_error(dev, entry);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
offset += alignment;
@@ -494,7 +498,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
dma->buflist = temp_buflist;
@@ -563,7 +567,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
temp_pagelist == NULL) {
free(entry->buflist, M_DRM);
free(entry->seglist, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
memcpy(temp_pagelist, dma->pagelist, dma->page_count *
@@ -586,7 +590,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
entry->seg_count = count;
drm_cleanup_buf_error(dev, entry);
free(temp_pagelist, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
entry->seglist[entry->seg_count++] = dmah;
@@ -610,7 +614,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
buf->bus_address = dmah->busaddr + offset;
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -621,7 +625,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
entry->seg_count = count;
drm_cleanup_buf_error(dev, entry);
free(temp_pagelist, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
DRM_DEBUG( "buffer %d @ %p\n",
@@ -637,7 +641,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
free(temp_pagelist, M_DRM);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
dma->buflist = temp_buflist;
@@ -705,7 +709,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
M_NOWAIT | M_ZERO);
if (entry->buflist == NULL)
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
entry->buf_size = size;
entry->page_order = page_order;
@@ -724,7 +728,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
buf->address = (void *)(agp_offset + offset + dev->sg->handle);
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -733,7 +737,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
drm_cleanup_buf_error(dev, entry);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
DRM_DEBUG( "buffer %d @ %p\n",
@@ -752,7 +756,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
dma->buflist = temp_buflist;
@@ -781,21 +785,21 @@ int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
DRM_SPINLOCK(&dev->dma_lock);
if (request->count < 0 || request->count > 4096)
- return DRM_ERR(EINVAL);
+ return EINVAL;
order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return DRM_ERR(EINVAL);
+ return EINVAL;
/* No more allocations after first buffer-using ioctl. */
if (dev->buf_use != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(EBUSY);
+ return EBUSY;
}
/* No more than one allocation per order */
if (dev->dma->bufs[order].buf_count != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
ret = drm_do_addbufs_agp(dev, request);
@@ -812,24 +816,24 @@ int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
DRM_SPINLOCK(&dev->dma_lock);
if (!DRM_SUSER(DRM_CURPROC))
- return DRM_ERR(EACCES);
+ return EACCES;
if (request->count < 0 || request->count > 4096)
- return DRM_ERR(EINVAL);
+ return EINVAL;
order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return DRM_ERR(EINVAL);
+ return EINVAL;
/* No more allocations after first buffer-using ioctl. */
if (dev->buf_use != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(EBUSY);
+ return EBUSY;
}
/* No more than one allocation per order */
if (dev->dma->bufs[order].buf_count != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
ret = drm_do_addbufs_sg(dev, request);
@@ -846,24 +850,24 @@ int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
DRM_SPINLOCK(&dev->dma_lock);
if (!DRM_SUSER(DRM_CURPROC))
- return DRM_ERR(EACCES);
+ return EACCES;
if (request->count < 0 || request->count > 4096)
- return DRM_ERR(EINVAL);
+ return EINVAL;
order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return DRM_ERR(EINVAL);
+ return EINVAL;
/* No more allocations after first buffer-using ioctl. */
if (dev->buf_use != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(EBUSY);
+ return EBUSY;
}
/* No more than one allocation per order */
if (dev->dma->bufs[order].buf_count != 0) {
DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(ENOMEM);
+ return ENOMEM;
}
ret = drm_do_addbufs_pci(dev, request);
@@ -873,39 +877,29 @@ int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
return ret;
}
-int drm_addbufs_ioctl(DRM_IOCTL_ARGS)
+int drm_addbufs_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
- drm_buf_desc_t request;
+ drm_buf_desc_t *request = data;
int err;
- DRM_COPY_FROM_USER_IOCTL(request, (drm_buf_desc_t *)data,
- sizeof(request));
-
- if (request.flags & _DRM_AGP_BUFFER)
- err = drm_addbufs_agp(dev, &request);
- else if (request.flags & _DRM_SG_BUFFER)
- err = drm_addbufs_sg(dev, &request);
+ if (request->flags & _DRM_AGP_BUFFER)
+ err = drm_addbufs_agp(dev, request);
+ else if (request->flags & _DRM_SG_BUFFER)
+ err = drm_addbufs_sg(dev, request);
else
- err = drm_addbufs_pci(dev, &request);
-
- DRM_COPY_TO_USER_IOCTL((drm_buf_desc_t *)data, request,
- sizeof(request));
+ err = drm_addbufs_pci(dev, request);
return err;
}
-int drm_infobufs(DRM_IOCTL_ARGS)
+int drm_infobufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
- drm_buf_info_t request;
+ drm_buf_info_t *request = data;
int i;
int count;
int retcode = 0;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_info_t *)data, sizeof(request) );
-
DRM_SPINLOCK(&dev->dma_lock);
++dev->buf_use; /* Can't allocate more after this call */
DRM_SPINUNLOCK(&dev->dma_lock);
@@ -916,7 +910,7 @@ int drm_infobufs(DRM_IOCTL_ARGS)
DRM_DEBUG( "count = %d\n", count );
- if ( request.count >= count ) {
+ if ( request->count >= count ) {
for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
if ( dma->bufs[i].buf_count ) {
drm_buf_desc_t from;
@@ -926,9 +920,9 @@ int drm_infobufs(DRM_IOCTL_ARGS)
from.low_mark = dma->bufs[i].freelist.low_mark;
from.high_mark = dma->bufs[i].freelist.high_mark;
- if (DRM_COPY_TO_USER(&request.list[count], &from,
+ if (DRM_COPY_TO_USER(&request->list[count], &from,
sizeof(drm_buf_desc_t)) != 0) {
- retcode = DRM_ERR(EFAULT);
+ retcode = EFAULT;
break;
}
@@ -942,76 +936,68 @@ int drm_infobufs(DRM_IOCTL_ARGS)
}
}
}
- request.count = count;
-
- DRM_COPY_TO_USER_IOCTL( (drm_buf_info_t *)data, request, sizeof(request) );
+ request->count = count;
return retcode;
}
-int drm_markbufs(DRM_IOCTL_ARGS)
+int drm_markbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
- drm_buf_desc_t request;
+ drm_buf_desc_t *request = data;
int order;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) );
-
DRM_DEBUG( "%d, %d, %d\n",
- request.size, request.low_mark, request.high_mark );
+ request->size, request->low_mark, request->high_mark );
- order = drm_order(request.size);
+ order = drm_order(request->size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ||
- request.low_mark < 0 || request.high_mark < 0) {
- return DRM_ERR(EINVAL);
+ request->low_mark < 0 || request->high_mark < 0) {
+ return EINVAL;
}
DRM_SPINLOCK(&dev->dma_lock);
- if (request.low_mark > dma->bufs[order].buf_count ||
- request.high_mark > dma->bufs[order].buf_count) {
- return DRM_ERR(EINVAL);
+ if (request->low_mark > dma->bufs[order].buf_count ||
+ request->high_mark > dma->bufs[order].buf_count) {
+ return EINVAL;
}
- dma->bufs[order].freelist.low_mark = request.low_mark;
- dma->bufs[order].freelist.high_mark = request.high_mark;
+ dma->bufs[order].freelist.low_mark = request->low_mark;
+ dma->bufs[order].freelist.high_mark = request->high_mark;
DRM_SPINUNLOCK(&dev->dma_lock);
return 0;
}
-int drm_freebufs(DRM_IOCTL_ARGS)
+int drm_freebufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
- drm_buf_free_t request;
+ drm_buf_free_t *request = data;
int i;
int idx;
drm_buf_t *buf;
int retcode = 0;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_free_t *)data, sizeof(request) );
-
- DRM_DEBUG( "%d\n", request.count );
+ DRM_DEBUG( "%d\n", request->count );
DRM_SPINLOCK(&dev->dma_lock);
- for ( i = 0 ; i < request.count ; i++ ) {
- if (DRM_COPY_FROM_USER(&idx, &request.list[i], sizeof(idx))) {
- retcode = DRM_ERR(EFAULT);
+ for ( i = 0 ; i < request->count ; i++ ) {
+ if (DRM_COPY_FROM_USER(&idx, &request->list[i], sizeof(idx))) {
+ retcode = EFAULT;
break;
}
if ( idx < 0 || idx >= dma->buf_count ) {
DRM_ERROR( "Index %d (of %d max)\n",
idx, dma->buf_count - 1 );
- retcode = DRM_ERR(EINVAL);
+ retcode = EINVAL;
break;
}
buf = dma->buflist[idx];
- if ( buf->filp != filp ) {
+ if ( buf->file_priv != file_priv ) {
DRM_ERROR("Process %d freeing buffer not owned\n",
DRM_CURRENTPID);
- retcode = DRM_ERR(EINVAL);
+ retcode = EINVAL;
break;
}
drm_free_buffer(dev, buf);
@@ -1021,9 +1007,8 @@ int drm_freebufs(DRM_IOCTL_ARGS)
return retcode;
}
-int drm_mapbufs(DRM_IOCTL_ARGS)
+int drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
{
- DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
int retcode = 0;
const int zero = 0;
@@ -1040,27 +1025,25 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
vaddr_t vaddr;
#endif /* __NetBSD__ || __OpenBSD__ */
- drm_buf_map_t request;
+ drm_buf_map_t *request = data;
int i;
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_map_t *)data, sizeof(request) );
-
#if defined(__NetBSD__) || defined(__OpenBSD__)
if (!vfinddev(kdev, VCHR, &vn))
return 0; /* FIXME: Shouldn't this be EINVAL or something? */
#endif /* __NetBSD__ || __OpenBSD */
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- vms = p->td_proc->p_vmspace;
+ vms = DRM_CURPROC->td_proc->p_vmspace;
#else
- vms = p->p_vmspace;
+ vms = DRM_CURPROC->p_vmspace;
#endif
DRM_SPINLOCK(&dev->dma_lock);
dev->buf_use++; /* Can't allocate more after this call */
DRM_SPINUNLOCK(&dev->dma_lock);
- if (request.count < dma->buf_count)
+ if (request->count < dma->buf_count)
goto done;
if ((dev->driver.use_agp && (dma->flags & _DRM_DMA_USE_AGP)) ||
@@ -1082,10 +1065,11 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
vaddr = round_page((vm_offset_t)vms->vm_daddr + MAXDSIZ);
#if __FreeBSD_version >= 600023
retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE,
- VM_PROT_ALL, MAP_SHARED, OBJT_DEVICE, kdev, foff );
+ VM_PROT_ALL, MAP_SHARED, OBJT_DEVICE, dev->devnode, foff);
#else
retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE,
- VM_PROT_ALL, MAP_SHARED, SLIST_FIRST(&kdev->si_hlist), foff );
+ VM_PROT_ALL, MAP_SHARED, SLIST_FIRST(&dev->devnode->si_hlist),
+ foff);
#endif
#elif defined(__NetBSD__) || defined(__OpenBSD__)
vaddr = round_page((vaddr_t)vms->vm_daddr + MAXDSIZ);
@@ -1096,26 +1080,26 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
if (retcode)
goto done;
- request.virtual = (void *)vaddr;
+ request->virtual = (void *)vaddr;
for ( i = 0 ; i < dma->buf_count ; i++ ) {
- if (DRM_COPY_TO_USER(&request.list[i].idx,
- &dma->buflist[i]->idx, sizeof(request.list[0].idx))) {
+ if (DRM_COPY_TO_USER(&request->list[i].idx,
+ &dma->buflist[i]->idx, sizeof(request->list[0].idx))) {
retcode = EFAULT;
goto done;
}
- if (DRM_COPY_TO_USER(&request.list[i].total,
- &dma->buflist[i]->total, sizeof(request.list[0].total))) {
+ if (DRM_COPY_TO_USER(&request->list[i].total,
+ &dma->buflist[i]->total, sizeof(request->list[0].total))) {
retcode = EFAULT;
goto done;
}
- if (DRM_COPY_TO_USER(&request.list[i].used, &zero,
+ if (DRM_COPY_TO_USER(&request->list[i].used, &zero,
sizeof(zero))) {
retcode = EFAULT;
goto done;
}
address = vaddr + dma->buflist[i]->offset; /* *** */
- if (DRM_COPY_TO_USER(&request.list[i].address, &address,
+ if (DRM_COPY_TO_USER(&request->list[i].address, &address,
sizeof(address))) {
retcode = EFAULT;
goto done;
@@ -1123,11 +1107,9 @@ int drm_mapbufs(DRM_IOCTL_ARGS)
}
done:
- request.count = dma->buf_count;
-
- DRM_DEBUG( "%d buffers, retcode = %d\n", request.count, retcode );
+ request->count = dma->buf_count;
- DRM_COPY_TO_USER_IOCTL((drm_buf_map_t *)data, request, sizeof(request));
+ DRM_DEBUG( "%d buffers, retcode = %d\n", request->count, retcode );
- return DRM_ERR(retcode);
+ return retcode;
}