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/drm/drm_bufs.c | |
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/drm/drm_bufs.c')
-rw-r--r-- | sys/dev/pci/drm/drm_bufs.c | 32 |
1 files changed, 28 insertions, 4 deletions
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 |