summaryrefslogtreecommitdiff
path: root/linux/i810_bufs.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2000-05-25 21:06:02 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2000-05-25 21:06:02 +0000
commitddcb28259f70d6808caf57e8eb9f74ca95b5f069 (patch)
tree4b55802bc1c48fdc509aa18584e543c53a1be186 /linux/i810_bufs.c
parent2bb4f7ef4252007c356c0fbb8597925d395cb6b1 (diff)
Merged mga-0-0-3-branch
- New security model for i810 - Enable i810 dri by default - New indexed vertex path for mga - Mga kernel driver rework - Removed dead files in i810 driver
Diffstat (limited to 'linux/i810_bufs.c')
-rw-r--r--linux/i810_bufs.c111
1 files changed, 1 insertions, 110 deletions
diff --git a/linux/i810_bufs.c b/linux/i810_bufs.c
index c025e400..9737ae92 100644
--- a/linux/i810_bufs.c
+++ b/linux/i810_bufs.c
@@ -120,6 +120,7 @@ int i810_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
buf->dev_private = drm_alloc(sizeof(drm_i810_buf_priv_t),
DRM_MEM_BUFS);
buf->dev_priv_size = sizeof(drm_i810_buf_priv_t);
+ memset(buf->dev_private, 0, sizeof(drm_i810_buf_priv_t));
#if DRM_DMA_HISTOGRAM
buf->time_queued = 0;
@@ -332,113 +333,3 @@ int i810_freebufs(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
-int i810_mapbufs(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_device_dma_t *dma = dev->dma;
- int retcode = 0;
- const int zero = 0;
- unsigned long virtual;
- unsigned long address;
- drm_buf_map_t request;
- int i;
-
- if (!dma) return -EINVAL;
-
- DRM_DEBUG("\n");
-
- spin_lock(&dev->count_lock);
- if (atomic_read(&dev->buf_alloc)) {
- spin_unlock(&dev->count_lock);
- DRM_DEBUG("Busy\n");
- return -EBUSY;
- }
- ++dev->buf_use; /* Can't allocate more after this call */
- spin_unlock(&dev->count_lock);
-
- copy_from_user_ret(&request,
- (drm_buf_map_t *)arg,
- sizeof(request),
- -EFAULT);
- DRM_DEBUG("dma->flags : %lx\n", dma->flags);
- if (request.count >= dma->buf_count) {
- if(dma->flags & _DRM_DMA_USE_AGP) {
- drm_i810_private_t *dev_priv =
- (drm_i810_private_t *)dev->dev_private;
- drm_map_t *map = NULL;
-
- map = dev->maplist[dev_priv->buffer_map_idx];
- if (!map) {
- DRM_DEBUG("map is null\n");
- retcode = -EINVAL;
- goto done;
- }
- DRM_DEBUG("map->offset : %lx\n", map->offset);
- DRM_DEBUG("map->size : %lx\n", map->size);
- DRM_DEBUG("map->type : %d\n", map->type);
- DRM_DEBUG("map->flags : %x\n", map->flags);
- DRM_DEBUG("map->handle : %lx\n", map->handle);
- DRM_DEBUG("map->mtrr : %d\n", map->mtrr);
- down(&current->mm->mmap_sem);
- virtual = do_mmap(filp, 0, map->size,
- PROT_READ|PROT_WRITE,
- MAP_SHARED,
- (unsigned long)map->offset);
-
- up(&current->mm->mmap_sem);
- } else {
- down(&current->mm->mmap_sem);
- virtual = do_mmap(filp, 0, dma->byte_count,
- PROT_READ|PROT_WRITE, MAP_SHARED, 0);
- up(&current->mm->mmap_sem);
- }
- if (virtual > -1024UL) {
- /* Real error */
- DRM_DEBUG("mmap error\n");
- retcode = (signed long)virtual;
- goto done;
- }
- request.virtual = (void *)virtual;
-
- for (i = 0; i < dma->buf_count; i++) {
- if (copy_to_user(&request.list[i].idx,
- &dma->buflist[i]->idx,
- sizeof(request.list[0].idx))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].total,
- &dma->buflist[i]->total,
- sizeof(request.list[0].total))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].used,
- &zero,
- sizeof(zero))) {
- retcode = -EFAULT;
- goto done;
- }
- address = virtual + dma->buflist[i]->offset;
- if (copy_to_user(&request.list[i].address,
- &address,
- sizeof(address))) {
- retcode = -EFAULT;
- goto done;
- }
- }
- }
- done:
- request.count = dma->buf_count;
- DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
-
- copy_to_user_ret((drm_buf_map_t *)arg,
- &request,
- sizeof(request),
- -EFAULT);
-
- DRM_DEBUG("retcode : %d\n", retcode);
- return retcode;
-}