diff options
Diffstat (limited to 'drivers/char/drm/i830_dma.c')
-rw-r--r-- | drivers/char/drm/i830_dma.c | 210 |
1 files changed, 82 insertions, 128 deletions
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index dc20c1a7834e..43a1f78712d6 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c @@ -122,10 +122,9 @@ static const struct file_operations i830_buffer_fops = { .fasync = drm_fasync, }; -static int i830_map_buffer(struct drm_buf * buf, struct file *filp) +static int i830_map_buffer(struct drm_buf * buf, struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; + struct drm_device *dev = file_priv->head->dev; drm_i830_buf_priv_t *buf_priv = buf->dev_private; drm_i830_private_t *dev_priv = dev->dev_private; const struct file_operations *old_fops; @@ -136,13 +135,13 @@ static int i830_map_buffer(struct drm_buf * buf, struct file *filp) return -EINVAL; down_write(¤t->mm->mmap_sem); - old_fops = filp->f_op; - filp->f_op = &i830_buffer_fops; + old_fops = file_priv->filp->f_op; + file_priv->filp->f_op = &i830_buffer_fops; dev_priv->mmap_buffer = buf; - virtual = do_mmap(filp, 0, buf->total, PROT_READ | PROT_WRITE, + virtual = do_mmap(file_priv->filp, 0, buf->total, PROT_READ | PROT_WRITE, MAP_SHARED, buf->bus_address); dev_priv->mmap_buffer = NULL; - filp->f_op = old_fops; + file_priv->filp->f_op = old_fops; if (IS_ERR((void *)virtual)) { /* ugh */ /* Real error */ DRM_ERROR("mmap error\n"); @@ -177,7 +176,7 @@ static int i830_unmap_buffer(struct drm_buf * buf) } static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, - struct file *filp) + struct drm_file *file_priv) { struct drm_buf *buf; drm_i830_buf_priv_t *buf_priv; @@ -190,13 +189,13 @@ static int i830_dma_get_buffer(struct drm_device * dev, drm_i830_dma_t * d, return retcode; } - retcode = i830_map_buffer(buf, filp); + retcode = i830_map_buffer(buf, file_priv); if (retcode) { i830_freelist_put(dev, buf); DRM_ERROR("mapbuf failed, retcode %d\n", retcode); return retcode; } - buf->filp = filp; + buf->file_priv = file_priv; buf_priv = buf->dev_private; d->granted = 1; d->request_idx = buf->idx; @@ -389,7 +388,7 @@ static int i830_dma_initialize(struct drm_device * dev, i830_dma_cleanup(dev); DRM_ERROR("can not ioremap virtual address for" " ring buffer\n"); - return DRM_ERR(ENOMEM); + return -ENOMEM; } dev_priv->ring.virtual_start = dev_priv->ring.map.handle; @@ -451,25 +450,20 @@ static int i830_dma_initialize(struct drm_device * dev, return 0; } -static int i830_dma_init(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_dma_init(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; drm_i830_private_t *dev_priv; - drm_i830_init_t init; + drm_i830_init_t *init = data; int retcode = 0; - if (copy_from_user(&init, (void *__user)arg, sizeof(init))) - return -EFAULT; - - switch (init.func) { + switch (init->func) { case I830_INIT_DMA: dev_priv = drm_alloc(sizeof(drm_i830_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; - retcode = i830_dma_initialize(dev, dev_priv, &init); + retcode = i830_dma_initialize(dev, dev_priv, init); break; case I830_CLEANUP_DMA: retcode = i830_dma_cleanup(dev); @@ -1248,7 +1242,7 @@ static int i830_flush_queue(struct drm_device * dev) } /* Must be called with the lock held */ -static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) +static void i830_reclaim_buffers(struct drm_device * dev, struct drm_file *file_priv) { struct drm_device_dma *dma = dev->dma; int i; @@ -1266,7 +1260,7 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) struct drm_buf *buf = dma->buflist[i]; drm_i830_buf_priv_t *buf_priv = buf->dev_private; - if (buf->filp == filp && buf_priv) { + if (buf->file_priv == file_priv && buf_priv) { int used = cmpxchg(buf_priv->in_use, I830_BUF_CLIENT, I830_BUF_FREE); @@ -1278,45 +1272,36 @@ static void i830_reclaim_buffers(struct drm_device * dev, struct file *filp) } } -static int i830_flush_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_flush_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; - - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); i830_flush_queue(dev); return 0; } -static int i830_dma_vertex(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_dma_vertex(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; struct drm_device_dma *dma = dev->dma; drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; 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; - - if (copy_from_user - (&vertex, (drm_i830_vertex_t __user *) arg, sizeof(vertex))) - return -EFAULT; + drm_i830_vertex_t *vertex = data; - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); DRM_DEBUG("i830 dma vertex, idx %d used %d discard %d\n", - vertex.idx, vertex.used, vertex.discard); + vertex->idx, vertex->used, vertex->discard); - if (vertex.idx < 0 || vertex.idx > dma->buf_count) + if (vertex->idx < 0 || vertex->idx > dma->buf_count) return -EINVAL; i830_dma_dispatch_vertex(dev, - dma->buflist[vertex.idx], - vertex.discard, vertex.used); + dma->buflist[vertex->idx], + vertex->discard, vertex->used); sarea_priv->last_enqueue = dev_priv->counter - 1; sarea_priv->last_dispatch = (int)hw_status[5]; @@ -1324,39 +1309,30 @@ static int i830_dma_vertex(struct inode *inode, struct file *filp, return 0; } -static int i830_clear_bufs(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_clear_bufs(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; - drm_i830_clear_t clear; - - if (copy_from_user - (&clear, (drm_i830_clear_t __user *) arg, sizeof(clear))) - return -EFAULT; + drm_i830_clear_t *clear = data; - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); /* GH: Someone's doing nasty things... */ if (!dev->dev_private) { return -EINVAL; } - i830_dma_dispatch_clear(dev, clear.flags, - clear.clear_color, - clear.clear_depth, clear.clear_depthmask); + i830_dma_dispatch_clear(dev, clear->flags, + clear->clear_color, + clear->clear_depth, clear->clear_depthmask); return 0; } -static int i830_swap_bufs(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_swap_bufs(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; - DRM_DEBUG("i830_swap_bufs\n"); - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); i830_dma_dispatch_swap(dev); return 0; @@ -1386,16 +1362,14 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev) return 0; } -static int i830_flip_bufs(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_flip_bufs(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; drm_i830_private_t *dev_priv = dev->dev_private; DRM_DEBUG("%s\n", __FUNCTION__); - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); if (!dev_priv->page_flipping) i830_do_init_pageflip(dev); @@ -1404,11 +1378,9 @@ static int i830_flip_bufs(struct inode *inode, struct file *filp, return 0; } -static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +static int i830_getage(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; u32 *hw_status = dev_priv->hw_status_page; drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) @@ -1418,58 +1390,50 @@ static int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd, return 0; } -static int i830_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +static int i830_getbuf(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; int retcode = 0; - drm_i830_dma_t d; + drm_i830_dma_t *d = data; drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; u32 *hw_status = dev_priv->hw_status_page; drm_i830_sarea_t *sarea_priv = (drm_i830_sarea_t *) dev_priv->sarea_priv; DRM_DEBUG("getbuf\n"); - if (copy_from_user(&d, (drm_i830_dma_t __user *) arg, sizeof(d))) - return -EFAULT; - LOCK_TEST_WITH_RETURN(dev, filp); + LOCK_TEST_WITH_RETURN(dev, file_priv); - d.granted = 0; + d->granted = 0; - retcode = i830_dma_get_buffer(dev, &d, filp); + retcode = i830_dma_get_buffer(dev, d, file_priv); DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n", - current->pid, retcode, d.granted); + current->pid, retcode, d->granted); - if (copy_to_user((void __user *) arg, &d, sizeof(d))) - return -EFAULT; sarea_priv->last_dispatch = (int)hw_status[5]; return retcode; } -static int i830_copybuf(struct inode *inode, - struct file *filp, unsigned int cmd, unsigned long arg) +static int i830_copybuf(struct drm_device *dev, void *data, + struct drm_file *file_priv) { /* Never copy - 2.4.x doesn't need it */ return 0; } -static int i830_docopy(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +static int i830_docopy(struct drm_device *dev, void *data, + struct drm_file *file_priv) { return 0; } -static int i830_getparam(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_getparam(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; drm_i830_private_t *dev_priv = dev->dev_private; - drm_i830_getparam_t param; + drm_i830_getparam_t *param = data; int value; if (!dev_priv) { @@ -1477,11 +1441,7 @@ static int i830_getparam(struct inode *inode, struct file *filp, return -EINVAL; } - if (copy_from_user - (¶m, (drm_i830_getparam_t __user *) arg, sizeof(param))) - return -EFAULT; - - switch (param.param) { + switch (param->param) { case I830_PARAM_IRQ_ACTIVE: value = dev->irq_enabled; break; @@ -1489,7 +1449,7 @@ static int i830_getparam(struct inode *inode, struct file *filp, return -EINVAL; } - if (copy_to_user(param.value, &value, sizeof(int))) { + if (copy_to_user(param->value, &value, sizeof(int))) { DRM_ERROR("copy_to_user\n"); return -EFAULT; } @@ -1497,26 +1457,20 @@ static int i830_getparam(struct inode *inode, struct file *filp, return 0; } -static int i830_setparam(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static int i830_setparam(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - struct drm_file *priv = filp->private_data; - struct drm_device *dev = priv->head->dev; drm_i830_private_t *dev_priv = dev->dev_private; - drm_i830_setparam_t param; + drm_i830_setparam_t *param = data; if (!dev_priv) { DRM_ERROR("%s called with no initialization\n", __FUNCTION__); return -EINVAL; } - if (copy_from_user - (¶m, (drm_i830_setparam_t __user *) arg, sizeof(param))) - return -EFAULT; - - switch (param.param) { + switch (param->param) { case I830_SETPARAM_USE_MI_BATCHBUFFER_START: - dev_priv->use_mi_batchbuffer_start = param.value; + dev_priv->use_mi_batchbuffer_start = param->value; break; default: return -EINVAL; @@ -1542,7 +1496,7 @@ void i830_driver_lastclose(struct drm_device * dev) i830_dma_cleanup(dev); } -void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) +void i830_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) { if (dev->dev_private) { drm_i830_private_t *dev_priv = dev->dev_private; @@ -1552,9 +1506,9 @@ void i830_driver_preclose(struct drm_device * dev, DRMFILE filp) } } -void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct file *filp) +void i830_driver_reclaim_buffers_locked(struct drm_device * dev, struct drm_file *file_priv) { - i830_reclaim_buffers(dev, filp); + i830_reclaim_buffers(dev, file_priv); } int i830_driver_dma_quiescent(struct drm_device * dev) @@ -1563,21 +1517,21 @@ int i830_driver_dma_quiescent(struct drm_device * dev) return 0; } -drm_ioctl_desc_t i830_ioctls[] = { - [DRM_IOCTL_NR(DRM_I830_INIT)] = {i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, - [DRM_IOCTL_NR(DRM_I830_VERTEX)] = {i830_dma_vertex, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_CLEAR)] = {i830_clear_bufs, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_FLUSH)] = {i830_flush_ioctl, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_GETAGE)] = {i830_getage, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_GETBUF)] = {i830_getbuf, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_SWAP)] = {i830_swap_bufs, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_COPY)] = {i830_copybuf, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = {i830_docopy, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_FLIP)] = {i830_flip_bufs, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = {i830_irq_emit, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = {i830_irq_wait, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = {i830_getparam, DRM_AUTH}, - [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = {i830_setparam, DRM_AUTH} +struct drm_ioctl_desc i830_ioctls[] = { + DRM_IOCTL_DEF(DRM_I830_INIT, i830_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_I830_VERTEX, i830_dma_vertex, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_CLEAR, i830_clear_bufs, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_FLUSH, i830_flush_ioctl, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_GETAGE, i830_getage, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_GETBUF, i830_getbuf, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_SWAP, i830_swap_bufs, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_COPY, i830_copybuf, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_DOCOPY, i830_docopy, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_FLIP, i830_flip_bufs, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_IRQ_EMIT, i830_irq_emit, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_IRQ_WAIT, i830_irq_wait, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_GETPARAM, i830_getparam, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I830_SETPARAM, i830_setparam, DRM_AUTH) }; int i830_max_ioctl = DRM_ARRAY_SIZE(i830_ioctls); |