From 6e49749b4d93261a9d151dd1e939b10661b381d9 Mon Sep 17 00:00:00 2001 From: Maneet Singh Date: Tue, 22 Jul 2014 16:33:23 -0700 Subject: 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 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 Tested-by: Winnie Hsu --- drivers/video/tegra/nvmap/nvmap_dev.c | 23 +++++++++++++++++++++-- drivers/video/tegra/nvmap/nvmap_priv.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'drivers/video') 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 -- cgit v1.2.3