]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
video: tegra: nvmap: optimize handle mk clean/dirty operations
authorSri Krishna chowdary <schowdary@nvidia.com>
Fri, 11 Mar 2016 17:35:50 +0000 (23:05 +0530)
committerSri Krishna chowdary <schowdary@nvidia.com>
Tue, 5 Apr 2016 11:25:03 +0000 (16:55 +0530)
When handle has all clean pages, avoid any further clean operation.
Similarly for dirty pages. This avoids any unnecessary overeheads
in empty cuda kernel launch whose buffer is not accessed by cpu
before passing to GPU.

bug 200174682

Change-Id: Iac40de5b6d07a5abc6590647665768fd1965a130
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/1029688
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
drivers/video/tegra/nvmap/nvmap_priv.h

index 6485493675ed4e20b3738eff01482c1c66e60dd7..02dbbf227e25d0ea383dc6e7cf9c66e4635fa35d 100644 (file)
@@ -529,7 +529,12 @@ static inline int nvmap_handle_mk(struct nvmap_handle *h,
 static inline void nvmap_handle_mkclean(struct nvmap_handle *h,
                                        u32 offset, u32 size)
 {
-       int nchanged = nvmap_handle_mk(h, offset, size, nvmap_page_mkclean);
+       int nchanged;
+
+       if (h->heap_pgalloc && !atomic_read(&h->pgalloc.ndirty))
+               return;
+
+       nchanged = nvmap_handle_mk(h, offset, size, nvmap_page_mkclean);
        if (h->heap_pgalloc)
                atomic_sub(nchanged, &h->pgalloc.ndirty);
 }
@@ -537,8 +542,13 @@ static inline void nvmap_handle_mkclean(struct nvmap_handle *h,
 static inline void nvmap_handle_mkdirty(struct nvmap_handle *h,
                                        u32 offset, u32 size)
 {
-       int nchanged = nvmap_handle_mk(h, offset, size, nvmap_page_mkdirty);
+       int nchanged;
+
+       if (h->heap_pgalloc &&
+               (atomic_read(&h->pgalloc.ndirty) == (h->size >> PAGE_SHIFT)))
+               return;
 
+       nchanged = nvmap_handle_mk(h, offset, size, nvmap_page_mkdirty);
        if (h->heap_pgalloc)
                atomic_add(nchanged, &h->pgalloc.ndirty);
 }