Merge remote branch 'common/android-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / drivers / video / tegra / nvmap / nvmap_mru.h
1 /*
2  * drivers/video/tegra/nvmap_mru.c
3  *
4  * IOVMM virtualization support for nvmap
5  *
6  * Copyright (c) 2009-2010, NVIDIA Corporation.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  * more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21  */
22
23
24 #ifndef __VIDEO_TEGRA_NVMAP_MRU_H
25 #define __VIDEO_TEGRA_NVMAP_MRU_H
26
27 #include <linux/spinlock.h>
28
29 #include "nvmap.h"
30
31 struct tegra_iovmm_area;
32 struct tegra_iovmm_client;
33
34 #ifdef CONFIG_NVMAP_RECLAIM_UNPINNED_VM
35
36 static inline void nvmap_mru_lock(struct nvmap_share *share)
37 {
38         spin_lock(&share->mru_lock);
39 }
40
41 static inline void nvmap_mru_unlock(struct nvmap_share *share)
42 {
43         spin_unlock(&share->mru_lock);
44 }
45
46 int nvmap_mru_init(struct nvmap_share *share);
47
48 void nvmap_mru_destroy(struct nvmap_share *share);
49
50 size_t nvmap_mru_vm_size(struct tegra_iovmm_client *iovmm);
51
52 void nvmap_mru_insert_locked(struct nvmap_share *share, struct nvmap_handle *h);
53
54 void nvmap_mru_remove(struct nvmap_share *s, struct nvmap_handle *h);
55
56 struct tegra_iovmm_area *nvmap_handle_iovmm(struct nvmap_client *c,
57                                             struct nvmap_handle *h);
58
59 #else
60
61 #define nvmap_mru_lock(_s)      do { } while (0)
62 #define nvmap_mru_unlock(_s)    do { } while (0)
63 #define nvmap_mru_init(_s)      0
64 #define nvmap_mru_destroy(_s)   do { } while (0)
65 #define nvmap_mru_vm_size(_a)   tegra_iovmm_get_vm_size(_a)
66
67 static inline void nvmap_mru_insert_locked(struct nvmap_share *share,
68                                            struct nvmap_handle *h)
69 { }
70
71 static inline void nvmap_mru_remove(struct nvmap_share *s,
72                                     struct nvmap_handle *h)
73 { }
74
75 static inline struct tegra_iovmm_area *nvmap_handle_iovmm(struct nvmap_client *c,
76                                                           struct nvmap_handle *h)
77 {
78         BUG_ON(!h->pgalloc.area);
79         return h->pgalloc.area;
80 }
81
82 #endif
83
84 #endif