diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-03-27 19:36:56 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-03-27 19:36:56 +0000 |
commit | 8e3e79cf7467b48337c6496f70ff6c0cbd8332ff (patch) | |
tree | 984476e02176575e4a4588967caeb95982f9fd35 /sys/dev/pci | |
parent | 7eab1c3354287ce572c4e83fa13c6714c57cd03c (diff) |
Push the per-driver dma hook a little further down.
All for all the drivers using the dma-bufs interface, their per-driver
ioctl hooks all started out the same way, followed by a call to another
function to actually select the buffer. Save some space by moving that
selection logic into the main dma_ioctl call, and make the second
function the hook.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 10 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_bufs.c | 32 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_dma.c | 41 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_drv.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_dma.c | 46 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_drv.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_cce.c | 39 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_cp.c | 39 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_bci.c | 38 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_drv.h | 3 |
12 files changed, 63 insertions, 199 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 9ef2b8aa426..79871e8a014 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -202,7 +202,8 @@ DRM_SPINUNLOCK(&dev->irq_lock) #define DRM_ERROR(fmt, arg...) \ printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ - DRM_CURRENTPID, __func__ , ## arg) + curproc->p_pid, __func__ , ## arg) + #define DRM_INFO(fmt, arg...) printf("%s: " fmt, dev_priv->dev.dv_xname, ## arg) @@ -210,7 +211,7 @@ DRM_SPINUNLOCK(&dev->irq_lock) #undef DRM_DEBUG #define DRM_DEBUG(fmt, arg...) do { \ if (drm_debug_flag) \ - printf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \ + printf("[" DRM_NAME ":pid%d:%s] " fmt, curproc->p_pid, \ __func__ , ## arg); \ } while (0) #else @@ -390,7 +391,8 @@ struct drm_driver_info { void (*lastclose)(struct drm_device *); void (*reclaim_buffers_locked)(struct drm_device *, struct drm_file *); - int (*dma_ioctl)(struct drm_device *, void *, struct drm_file *); + int (*dma_ioctl)(struct drm_device *, struct drm_dma *, + struct drm_file *); int (*dma_quiescent)(struct drm_device *); int (*context_ctor)(struct drm_device *, int); int (*context_dtor)(struct drm_device *, int); @@ -470,7 +472,7 @@ struct drm_device { struct timeout vblank_disable_timer; /* timer for disable */ struct drm_vblank *vblank; /* One per ctrc */ - pid_t buf_pgid; + pid_t buf_pgid; struct drm_agp_head *agp; struct drm_sg_mem *sg; /* Scatter gather memory */ diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c index 18fb26907f9..519bbdfd4f0 100644 --- a/sys/dev/pci/drm/drm_bufs.c +++ b/sys/dev/pci/drm/drm_bufs.c @@ -441,13 +441,37 @@ drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv) { + struct drm_device_dma *dma = dev->dma; + struct drm_dma *d = data; + int ret = 0; - if (dev->driver->dma_ioctl != NULL) { - return (dev->driver->dma_ioctl(dev, data, file_priv)); - } else { + if (dev->driver->dma_ioctl == NULL) { DRM_DEBUG("DMA ioctl on driver with no dma handler\n"); - return EINVAL; + return (EINVAL); } + + LOCK_TEST_WITH_RETURN(dev, file_priv); + + /* Please don't send us buffers. + */ + if (d->send_count != 0) { + DRM_ERROR("process trying to send %d buffers via drmDMA\n", + d->send_count); + return (EINVAL); + } + + /* We'll send you buffers. + */ + if (d->request_count < 0 || d->request_count > dma->buf_count) { + DRM_ERROR("Process trying to get %d buffers (of %d max)\n", + curproc->p_pid, d->request_count, dma->buf_count); + return (EINVAL); + } + d->granted_count = 0; + + if (d->request_count) + ret = dev->driver->dma_ioctl(dev, d, file_priv); + return (ret); } int diff --git a/sys/dev/pci/drm/mach64_dma.c b/sys/dev/pci/drm/mach64_dma.c index 73f84d1d4a9..97373150b43 100644 --- a/sys/dev/pci/drm/mach64_dma.c +++ b/sys/dev/pci/drm/mach64_dma.c @@ -1658,9 +1658,10 @@ int mach64_freelist_put(drm_mach64_private_t *dev_priv, struct drm_buf *copy_buf /** \name DMA buffer request and submission IOCTL handler */ /*@{*/ -static int mach64_dma_get_buffers(struct drm_device *dev, - struct drm_file *file_priv, - struct drm_dma * d) + +int +mach64_dma_buffers(struct drm_device *dev, struct drm_dma *d, + struct drm_file *file_priv) { int i; struct drm_buf *buf; @@ -1690,40 +1691,6 @@ static int mach64_dma_get_buffers(struct drm_device *dev, return 0; } -int mach64_dma_buffers(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct drm_device_dma *dma = dev->dma; - struct drm_dma *d = data; - int ret = 0; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - - /* Please don't send us buffers. - */ - if (d->send_count != 0) { - DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", - DRM_CURRENTPID, d->send_count); - return EINVAL; - } - - /* We'll send you buffers. - */ - if (d->request_count < 0 || d->request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_CURRENTPID, d->request_count, dma->buf_count); - ret = EINVAL; - } - - d->granted_count = 0; - - if (d->request_count) { - ret = mach64_dma_get_buffers(dev, file_priv, d); - } - - return ret; -} - void mach64_driver_lastclose(struct drm_device * dev) { mach64_do_cleanup_dma(dev); diff --git a/sys/dev/pci/drm/mach64_drv.h b/sys/dev/pci/drm/mach64_drv.h index fb0ca6a8a1a..73449388e2e 100644 --- a/sys/dev/pci/drm/mach64_drv.h +++ b/sys/dev/pci/drm/mach64_drv.h @@ -126,8 +126,8 @@ extern int mach64_dma_flush(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int mach64_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int mach64_dma_buffers(struct drm_device *dev, void *data, - struct drm_file *file_priv); +extern int mach64_dma_buffers(struct drm_device *, struct drm_dma *, + struct drm_file *); extern void mach64_driver_lastclose(struct drm_device * dev); extern int mach64_init_freelist(struct drm_device * dev); diff --git a/sys/dev/pci/drm/mga_dma.c b/sys/dev/pci/drm/mga_dma.c index 366da653f23..5bd300be9ea 100644 --- a/sys/dev/pci/drm/mga_dma.c +++ b/sys/dev/pci/drm/mga_dma.c @@ -1001,12 +1001,17 @@ int mga_dma_reset(struct drm_device *dev, void *data, * DMA buffer management */ -static int mga_dma_get_buffers(struct drm_device * dev, - struct drm_file *file_priv, struct drm_dma * d) + +int +mga_dma_buffers(struct drm_device *dev, struct drm_dma * d, + struct drm_file *file_priv) { + drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; struct drm_buf *buf; int i; + WRAP_TEST_WITH_RETURN(dev_priv); + for (i = d->granted_count; i < d->request_count; i++) { buf = mga_freelist_get(dev); if (!buf) @@ -1026,43 +1031,6 @@ static int mga_dma_get_buffers(struct drm_device * dev, return 0; } -int mga_dma_buffers(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct drm_device_dma *dma = dev->dma; - drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - struct drm_dma *d = data; - int ret = 0; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - - /* Please don't send us buffers. - */ - if (d->send_count != 0) { - DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", - DRM_CURRENTPID, d->send_count); - return EINVAL; - } - - /* We'll send you buffers. - */ - if (d->request_count < 0 || d->request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_CURRENTPID, d->request_count, dma->buf_count); - return EINVAL; - } - - WRAP_TEST_WITH_RETURN(dev_priv); - - d->granted_count = 0; - - if (d->request_count) { - ret = mga_dma_get_buffers(dev, file_priv, d); - } - - return ret; -} - /** * Called when the last opener of the device is closed. */ diff --git a/sys/dev/pci/drm/mga_drv.h b/sys/dev/pci/drm/mga_drv.h index a46858aa549..8ca1d7cca3a 100644 --- a/sys/dev/pci/drm/mga_drv.h +++ b/sys/dev/pci/drm/mga_drv.h @@ -155,8 +155,8 @@ extern int mga_dma_flush(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int mga_dma_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int mga_dma_buffers(struct drm_device *dev, void *data, - struct drm_file *file_priv); +extern int mga_dma_buffers(struct drm_device *, struct drm_dma *, + struct drm_file *); extern void mga_driver_lastclose(struct drm_device * dev); extern int mga_driver_dma_quiescent(struct drm_device * dev); extern int mga_dma_swap(struct drm_device *, void *, struct drm_file *); diff --git a/sys/dev/pci/drm/r128_cce.c b/sys/dev/pci/drm/r128_cce.c index aae7092cc79..f80a97f78d9 100644 --- a/sys/dev/pci/drm/r128_cce.c +++ b/sys/dev/pci/drm/r128_cce.c @@ -835,9 +835,9 @@ int r128_wait_ring(drm_r128_private_t * dev_priv, int n) return EBUSY; } -static int r128_cce_get_buffers(struct drm_device * dev, - struct drm_file *file_priv, - struct drm_dma * d) +int +r128_cce_buffers(struct drm_device *dev, struct drm_dma * d, + struct drm_file *file_priv) { int i; struct drm_buf *buf; @@ -860,36 +860,3 @@ static int r128_cce_get_buffers(struct drm_device * dev, } return 0; } - -int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - struct drm_device_dma *dma = dev->dma; - int ret = 0; - struct drm_dma *d = data; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - - /* Please don't send us buffers. - */ - if (d->send_count != 0) { - DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", - DRM_CURRENTPID, d->send_count); - return EINVAL; - } - - /* We'll send you buffers. - */ - if (d->request_count < 0 || d->request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_CURRENTPID, d->request_count, dma->buf_count); - return EINVAL; - } - - d->granted_count = 0; - - if (d->request_count) { - ret = r128_cce_get_buffers(dev, file_priv, d); - } - - return ret; -} diff --git a/sys/dev/pci/drm/r128_drv.h b/sys/dev/pci/drm/r128_drv.h index 2ae4b002a2f..8353b6346c6 100644 --- a/sys/dev/pci/drm/r128_drv.h +++ b/sys/dev/pci/drm/r128_drv.h @@ -146,7 +146,8 @@ extern int r128_cce_reset(struct drm_device *dev, void *data, struct drm_file *f extern int r128_cce_idle(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_engine_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_fullscreen(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int r128_cce_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int r128_cce_buffers(struct drm_device *, struct drm_dma *, + struct drm_file *); extern int r128_cce_swap(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_cce_flip(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int r128_cce_clear(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/sys/dev/pci/drm/radeon_cp.c b/sys/dev/pci/drm/radeon_cp.c index e3f40db24fc..b098518ff3a 100644 --- a/sys/dev/pci/drm/radeon_cp.c +++ b/sys/dev/pci/drm/radeon_cp.c @@ -1622,8 +1622,8 @@ radeon_wait_ring(drm_radeon_private_t *dev_priv, int n) } int -radeon_cp_get_buffers(struct drm_device *dev, struct drm_file *file_priv, - struct drm_dma * d) +radeon_cp_buffers(struct drm_device *dev, struct drm_dma * d, + struct drm_file *file_priv) { int i; struct drm_buf *buf; @@ -1647,41 +1647,6 @@ radeon_cp_get_buffers(struct drm_device *dev, struct drm_file *file_priv, return 0; } -int -radeon_cp_buffers(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - struct drm_device_dma *dma = dev->dma; - int ret = 0; - struct drm_dma *d = data; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - - /* Please don't send us buffers. - */ - if (d->send_count != 0) { - DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", - DRM_CURRENTPID, d->send_count); - return EINVAL; - } - - /* We'll send you buffers. - */ - if (d->request_count < 0 || d->request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_CURRENTPID, d->request_count, dma->buf_count); - return EINVAL; - } - - d->granted_count = 0; - - if (d->request_count) { - ret = radeon_cp_get_buffers(dev, file_priv, d); - } - - return ret; -} - /* Create mappings for registers and framebuffer so userland doesn't necessarily * have to find them. */ diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h index bc229dea96f..88143a575ed 100644 --- a/sys/dev/pci/drm/radeon_drv.h +++ b/sys/dev/pci/drm/radeon_drv.h @@ -337,7 +337,8 @@ extern int radeon_cp_stop(struct drm_device *dev, void *data, struct drm_file *f extern int radeon_cp_reset(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int radeon_cp_idle(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int radeon_cp_resume(struct drm_device *dev); -extern int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int radeon_cp_buffers(struct drm_device *, struct drm_dma *, + struct drm_file *); extern u32 radeon_read_fb_location(drm_radeon_private_t *dev_priv); extern int radeon_surface_alloc(struct drm_device *, void *, struct drm_file *); diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c index 4327ad4a84d..f513e8040d6 100644 --- a/sys/dev/pci/drm/savage_bci.c +++ b/sys/dev/pci/drm/savage_bci.c @@ -921,9 +921,9 @@ int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *f * DMA buffer management */ -static int savage_bci_get_buffers(struct drm_device *dev, - struct drm_file *file_priv, - struct drm_dma *d) +int +savage_bci_buffers(struct drm_device *dev, struct drm_dma *d, + struct drm_file *file_priv) { struct drm_buf *buf; int i; @@ -947,38 +947,6 @@ static int savage_bci_get_buffers(struct drm_device *dev, return 0; } -int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv) -{ - struct drm_device_dma *dma = dev->dma; - struct drm_dma *d = data; - int ret = 0; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - - /* Please don't send us buffers. - */ - if (d->send_count != 0) { - DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", - DRM_CURRENTPID, d->send_count); - return EINVAL; - } - - /* We'll send you buffers. - */ - if (d->request_count < 0 || d->request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_CURRENTPID, d->request_count, dma->buf_count); - return EINVAL; - } - - d->granted_count = 0; - - if (d->request_count) { - ret = savage_bci_get_buffers(dev, file_priv, d); - } - - return ret; -} void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv) { diff --git a/sys/dev/pci/drm/savage_drv.h b/sys/dev/pci/drm/savage_drv.h index 8176ebb8c32..a82ccc5016f 100644 --- a/sys/dev/pci/drm/savage_drv.h +++ b/sys/dev/pci/drm/savage_drv.h @@ -202,7 +202,8 @@ typedef struct drm_savage_private { /* ioctls */ extern int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int savage_bci_buffers(struct drm_device *, struct drm_dma *, + struct drm_file *); extern int savage_bci_init(struct drm_device *, void *, struct drm_file *); extern int savage_bci_event_emit(struct drm_device *, void *, struct drm_file *); extern int savage_bci_event_wait(struct drm_device *, void *, struct drm_file *); |