]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: track handle's vma list
authorManeet Singh <mmaneetsingh@nvidia.com>
Tue, 22 Jul 2014 23:33:23 +0000 (16:33 -0700)
committerEric Chuang <echuang@nvidia.com>
Wed, 8 Oct 2014 03:00:42 +0000 (20:00 -0700)
Patch includes following nvmap changes:
 - added "pid" field in nvmap_vma_list so now looking at handle's vma list,
   we can say which vma belongs to which process.
 - sorted handle's vma list in ascending order of handle offsets.

Bug 1529015

Change-Id: Ide548e2d97bab8072461c11c9b8865ab4aa01989
Signed-off-by: Maneet Singh <mmaneetsingh@nvidia.com>
Reviewed-on: http://git-master/r/440914
(cherry picked from commit 267b61e83ebff53dc297a7e8ff5f3005f91b2276)
Reviewed-on: http://git-master/r/448493
(cherry picked from commit 37132fa461d23552b805e32d268acd14b27588c3)
Reviewed-on: http://git-master/r/553677
Reviewed-by: Harry Lin <harlin@nvidia.com>
Tested-by: Harry Lin <harlin@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
drivers/video/tegra/nvmap/nvmap_dev.c
drivers/video/tegra/nvmap/nvmap_priv.h

index 5bf5261b58cfcfdf5c4fd8ef2502f0039c4b560d..0e1b1256e7c0d982104b75b51bbe7cf5551765d6 100644 (file)
@@ -680,6 +680,9 @@ void nvmap_vma_open(struct vm_area_struct *vma)
        struct nvmap_vma_priv *priv;
        struct nvmap_handle *h;
        struct nvmap_vma_list *vma_list, *tmp;
+       struct list_head *tmp_head = NULL;
+       pid_t current_pid = current->pid;
+       bool vma_pos_found = false;
 
        priv = vma->vm_private_data;
        BUG_ON(!priv);
@@ -692,11 +695,27 @@ void nvmap_vma_open(struct vm_area_struct *vma)
        vma_list = kmalloc(sizeof(*vma_list), GFP_KERNEL);
        if (vma_list) {
                mutex_lock(&h->lock);
-               list_for_each_entry(tmp, &h->vmas, list)
+               tmp_head = &h->vmas;
+
+               /* insert vma into handle's vmas list in the increasing order of
+                * handle offsets
+                */
+               list_for_each_entry(tmp, &h->vmas, list) {
                        BUG_ON(tmp->vma == vma);
 
+                       if (!vma_pos_found && (current_pid == tmp->pid)) {
+                               if (vma->vm_pgoff < tmp->vma->vm_pgoff) {
+                                       tmp_head = &tmp->list;
+                                       vma_pos_found = true;
+                               } else {
+                                       tmp_head = tmp->list.next;
+                               }
+                       }
+               }
+
                vma_list->vma = vma;
-               list_add(&vma_list->list, &h->vmas);
+               vma_list->pid = current_pid;
+               list_add_tail(&vma_list->list, tmp_head);
                mutex_unlock(&h->lock);
        } else {
                WARN(1, "vma not tracked");
index b180425843943f4e40e2c272dc8f9bb6692789e6..40d5a0ac325331ab3107d52fd1bac5bd42794816 100644 (file)
@@ -111,6 +111,7 @@ extern void __flush_dcache_page(struct address_space *, struct page *);
 struct nvmap_vma_list {
        struct list_head list;
        struct vm_area_struct *vma;
+       pid_t pid;
 };
 
 /* handles allocated using shared system memory (either IOVMM- or high-order