diff options
author | Rik Faith <faith@alephnull.com> | 2000-08-04 10:04:55 +0000 |
---|---|---|
committer | Rik Faith <faith@alephnull.com> | 2000-08-04 10:04:55 +0000 |
commit | f3ae6786f89a4f63dbba93c5519d3792a1744dd7 (patch) | |
tree | 0d9ef964855fc32189fd5553373bb9dcf904ed12 /linux/vm.c | |
parent | bcad11818296fa58a356175bc7e13060579012d0 (diff) |
Sync with Linux 2.4.0-test6-pre2
Diffstat (limited to 'linux/vm.c')
-rw-r--r-- | linux/vm.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/linux/vm.c b/linux/vm.c index 9dfd0d2b0..5ee9e3242 100644 --- a/linux/vm.c +++ b/linux/vm.c @@ -145,7 +145,11 @@ void drm_vm_open(struct vm_area_struct *vma) DRM_DEBUG("0x%08lx,0x%08lx\n", vma->vm_start, vma->vm_end - vma->vm_start); atomic_inc(&dev->vma_count); - MOD_INC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + /* The map can exist after the fd is closed. */ + MOD_INC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif + #if DRM_DEBUG_CODE vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); @@ -170,7 +174,9 @@ void drm_vm_close(struct vm_area_struct *vma) DRM_DEBUG("0x%08lx,0x%08lx\n", vma->vm_start, vma->vm_end - vma->vm_start); - MOD_DEC_USE_COUNT; +#if LINUX_VERSION_CODE < 0x020333 + MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */ +#endif atomic_dec(&dev->vma_count); #if DRM_DEBUG_CODE @@ -193,15 +199,22 @@ void drm_vm_close(struct vm_area_struct *vma) int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) { drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; + drm_device_t *dev; + drm_device_dma_t *dma; unsigned long length = vma->vm_end - vma->vm_start; + lock_kernel(); + dev = priv->dev; + dma = dev->dma; DRM_DEBUG("start = 0x%lx, end = 0x%lx, offset = 0x%lx\n", vma->vm_start, vma->vm_end, VM_OFFSET(vma)); /* Length must match exact page count */ - if ((length >> PAGE_SHIFT) != dma->page_count) return -EINVAL; + if ((length >> PAGE_SHIFT) != dma->page_count) { + unlock_kernel(); + return -EINVAL; + } + unlock_kernel(); vma->vm_ops = &drm_vm_dma_ops; vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */ |