]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: fix incorrect zapping of handles
authorKrishna Reddy <vdumpa@nvidia.com>
Thu, 17 Apr 2014 00:36:07 +0000 (17:36 -0700)
committerSeema Khowala <seemaj@nvidia.com>
Wed, 23 Apr 2014 21:05:55 +0000 (14:05 -0700)
Bug 1444151

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

drivers/video/tegra/nvmap/nvmap_mm.c
drivers/video/tegra/nvmap/nvmap_priv.h

index 0c6eba2231637e59cc75923d606fc24cd56b7ed7..8626ffa8645019e2bd4076d430c06ac032e827f1 100644 (file)
@@ -139,9 +139,7 @@ int nvmap_do_cache_maint_list(struct nvmap_handle **handles, u32 *offsets,
        return 0;
 }
 
-void nvmap_zap_handle(struct nvmap_handle *handle,
-                     u32 offset,
-                     u32 size)
+void nvmap_zap_handle(struct nvmap_handle *handle, u32 offset, u32 size)
 {
        struct list_head *vmas;
        struct nvmap_vma_list *vma_list;
@@ -155,21 +153,29 @@ void nvmap_zap_handle(struct nvmap_handle *handle,
                size = handle->size;
        }
 
-       vmas = &handle->pgalloc.vmas;
        mutex_lock(&handle->lock);
+       vmas = &handle->pgalloc.vmas;
        list_for_each_entry(vma_list, vmas, list) {
+               struct nvmap_vma_priv *priv;
+
                vma = vma_list->vma;
-               zap_page_range(vma, vma->vm_start + offset,
-                               offset + size - vma->vm_start,
-                               NULL);
+               priv = vma->vm_private_data;
+               if (priv->offs || vma->vm_pgoff)
+                       /* vma mapping starts in the middle of handle memory.
+                        * zapping needs special care. zap entire range for now.
+                        * FIXME: optimze zapping.
+                        */
+                       zap_page_range(vma, vma->vm_start,
+                               vma->vm_end - vma->vm_start, NULL);
+               else
+                       zap_page_range(vma, vma->vm_start + offset,
+                               size, NULL);
        }
        mutex_unlock(&handle->lock);
 }
 
-void nvmap_zap_handles(struct nvmap_handle **handles,
-                      u32 *offsets,
-                      u32 *sizes,
-                      u32 nr)
+void nvmap_zap_handles(struct nvmap_handle **handles, u32 *offsets,
+                      u32 *sizes, u32 nr)
 {
        int i;
 
index b04a8282958252f76c877a66a9a9400d7ec1a4f0..81a5183f81f3a1e1f6aea1398ac7aceb27503ec0 100644 (file)
@@ -501,5 +501,10 @@ static inline struct page **nvmap_pages(struct page **pg_pages, u32 nr_pages)
        return pages;
 }
 
+void nvmap_zap_handle(struct nvmap_handle *handle, u32 offset, u32 size);
+
+void nvmap_zap_handles(struct nvmap_handle **handles, u32 *offsets,
+                      u32 *sizes, u32 nr);
+
 void nvmap_vma_open(struct vm_area_struct *vma);
 #endif /* __VIDEO_TEGRA_NVMAP_NVMAP_H */