diff options
author | Maneet Singh <mmaneetsingh@nvidia.com> | 2014-07-22 16:33:23 -0700 |
---|---|---|
committer | Winnie Hsu <whsu@nvidia.com> | 2014-08-08 14:49:02 -0700 |
commit | 6e49749b4d93261a9d151dd1e939b10661b381d9 (patch) | |
tree | 1a8522ba0451153974f6a86683f2dd4b0045fbdb /drivers/video | |
parent | ff171e6f371f3c50d3898c648800ba74fe4cb7ea (diff) |
video: tegra: nvmap: track handle's vma list
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/448493
(cherry picked from commit 37132fa461d23552b805e32d268acd14b27588c3)
Reviewed-on: http://git-master/r/448576
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Tested-by: Winnie Hsu <whsu@nvidia.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_dev.c | 23 | ||||
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_priv.h | 1 |
2 files changed, 22 insertions, 2 deletions
diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c index 0b93cc346c6a..5c0685ac8776 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev.c +++ b/drivers/video/tegra/nvmap/nvmap_dev.c @@ -625,6 +625,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); @@ -636,11 +639,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"); diff --git a/drivers/video/tegra/nvmap/nvmap_priv.h b/drivers/video/tegra/nvmap/nvmap_priv.h index 8dda14986ec8..5ce3db32384c 100644 --- a/drivers/video/tegra/nvmap/nvmap_priv.h +++ b/drivers/video/tegra/nvmap/nvmap_priv.h @@ -98,6 +98,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 |