]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: vma need to be tracked during mmap
authorKrishna Reddy <vdumpa@nvidia.com>
Wed, 16 Apr 2014 23:22:33 +0000 (16:22 -0700)
committerSeema Khowala <seemaj@nvidia.com>
Wed, 23 Apr 2014 21:05:54 +0000 (14:05 -0700)
Add missing vma tracking during mmap.

Bug 1444151

Change-Id: Id0485237c96e97a3e1da55f14e5533a48fd2bde7
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/397390

drivers/video/tegra/nvmap/nvmap_dev.c
drivers/video/tegra/nvmap/nvmap_ioctl.c
drivers/video/tegra/nvmap/nvmap_priv.h

index 076c7fa14c0706e89196bb653e27afd3d146302f..7cb0a9ec752229b52aa3f1a3dfbbe468fb0658e6 100644 (file)
@@ -85,7 +85,6 @@ static int nvmap_open(struct inode *inode, struct file *filp);
 static int nvmap_release(struct inode *inode, struct file *filp);
 static long nvmap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
 static int nvmap_map(struct file *filp, struct vm_area_struct *vma);
-static void nvmap_vma_open(struct vm_area_struct *vma);
 static void nvmap_vma_close(struct vm_area_struct *vma);
 static int nvmap_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 
@@ -524,10 +523,7 @@ int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
-
-       priv->offs = 0;
        priv->handle = h;
-       atomic_set(&priv->count, 1);
 
        vma->vm_flags |= VM_SHARED | VM_DONTEXPAND |
                          VM_DONTDUMP | VM_DONTCOPY |
@@ -536,6 +532,7 @@ int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
        BUG_ON(vma->vm_private_data != NULL);
        vma->vm_private_data = priv;
        vma->vm_page_prot = nvmap_pgprot(h, vma->vm_page_prot);
+       nvmap_vma_open(vma);
        return 0;
 }
 
@@ -552,15 +549,10 @@ static int nvmap_map(struct file *filp, struct vm_area_struct *vma)
        if (!priv)
                return -ENOMEM;
 
-       priv->offs = 0;
-       priv->handle = NULL;
-       atomic_set(&priv->count, 1);
-
        vma->vm_flags |= (VM_SHARED | VM_DONTEXPAND |
                          VM_DONTDUMP | VM_DONTCOPY);
        vma->vm_ops = &nvmap_vma_ops;
        vma->vm_private_data = priv;
-
        return 0;
 }
 
@@ -687,7 +679,7 @@ static long nvmap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  * the handle, and nvmap_vma_close decrements it. alternatively, we could
  * disallow copying of the vma, or behave like pmem and zap the pages. FIXME.
 */
-static void nvmap_vma_open(struct vm_area_struct *vma)
+void nvmap_vma_open(struct vm_area_struct *vma)
 {
        struct nvmap_vma_priv *priv;
        struct nvmap_handle *h;
index f5d9ac3af2f9f4e9cea8b24d313932f28d2d97e8..9ebdb1d00cbf6f3338d05657d8e1a4ae113144e7 100644 (file)
@@ -509,6 +509,7 @@ int nvmap_map_into_caller_ptr(struct file *filp, void __user *arg, bool is32)
        vpriv->handle = h;
        vpriv->offs = op.offset;
        vma->vm_page_prot = nvmap_pgprot(h, vma->vm_page_prot);
+       nvmap_vma_open(vma);
 
 out:
        up_read(&current->mm->mmap_sem);
index 242f8473d66eaa02892495ddaa31c7a6be80c442..b04a8282958252f76c877a66a9a9400d7ec1a4f0 100644 (file)
@@ -501,4 +501,5 @@ static inline struct page **nvmap_pages(struct page **pg_pages, u32 nr_pages)
        return pages;
 }
 
+void nvmap_vma_open(struct vm_area_struct *vma);
 #endif /* __VIDEO_TEGRA_NVMAP_NVMAP_H */