summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm/drm_drv.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-03-27 19:00:46 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-03-27 19:00:46 +0000
commit7eab1c3354287ce572c4e83fa13c6714c57cd03c (patch)
tree3a330b542a0b978b4499569bafafecb4de31c9d0 /sys/dev/pci/drm/drm_drv.c
parent6b9d819b8bcb1c0c17f40578151e34adc84133c9 (diff)
Rework the dma buffer api a bit to make it smaller and to have less
duplicated code. Also, switch the dma_lock to a rwlock (it never should have been a spinlock) and move it and some other accounting data into the dma structure, not the main softc. Finally, the funcitons in drm_dma are tiny, move them in with the rest of the dma_bufs api in drm_bufs and remove the file.
Diffstat (limited to 'sys/dev/pci/drm/drm_drv.c')
-rw-r--r--sys/dev/pci/drm/drm_drv.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index 48ddf17b0cf..093ccedbad5 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -287,9 +287,8 @@ drm_firstopen(struct drm_device *dev)
dev->driver->firstopen(dev);
if (dev->driver->flags & DRIVER_DMA) {
- i = drm_dma_setup(dev);
- if (i != 0)
- return i;
+ if ((i = drm_dma_setup(dev)) != 0)
+ return (i);
}
dev->magicid = 1;
@@ -618,7 +617,7 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
case DRM_IOCTL_RM_CTX:
return (drm_rmctx(dev, data, file_priv));
case DRM_IOCTL_ADD_BUFS:
- return (drm_addbufs_ioctl(dev, data, file_priv));
+ return (drm_addbufs(dev, (struct drm_buf_desc *)data));
case DRM_IOCTL_CONTROL:
return (drm_control(dev, data, file_priv));
case DRM_IOCTL_AGP_ACQUIRE:
@@ -701,18 +700,14 @@ drmmmap(dev_t kdev, off_t offset, int prot)
if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
drm_device_dma_t *dma = dev->dma;
+ paddr_t phys = -1;
- DRM_SPINLOCK(&dev->dma_lock);
+ rw_enter_write(&dma->dma_lock);
+ if (dma->pagelist != NULL)
+ phys = atop(dma->pagelist[offset >> PAGE_SHIFT]);
+ rw_exit_write(&dma->dma_lock);
- if (dma->pagelist != NULL) {
- paddr_t phys = dma->pagelist[offset >> PAGE_SHIFT];
-
- DRM_SPINUNLOCK(&dev->dma_lock);
- return (atop(phys));
- } else {
- DRM_SPINUNLOCK(&dev->dma_lock);
- return (-1);
- }
+ return (phys);
}
/*