2 * drivers/video/tegra/nvmap_mru.c
4 * IOVMM virtualization support for nvmap
6 * Copyright (c) 2009-2010, NVIDIA Corporation.
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.
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
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.
24 #ifndef __VIDEO_TEGRA_NVMAP_MRU_H
25 #define __VIDEO_TEGRA_NVMAP_MRU_H
27 #include <linux/spinlock.h>
31 struct tegra_iovmm_area;
32 struct tegra_iovmm_client;
34 #ifdef CONFIG_NVMAP_RECLAIM_UNPINNED_VM
36 static inline void nvmap_mru_lock(struct nvmap_share *share)
38 spin_lock(&share->mru_lock);
41 static inline void nvmap_mru_unlock(struct nvmap_share *share)
43 spin_unlock(&share->mru_lock);
46 int nvmap_mru_init(struct nvmap_share *share);
48 void nvmap_mru_destroy(struct nvmap_share *share);
50 size_t nvmap_mru_vm_size(struct tegra_iovmm_client *iovmm);
52 void nvmap_mru_insert_locked(struct nvmap_share *share, struct nvmap_handle *h);
54 void nvmap_mru_remove(struct nvmap_share *s, struct nvmap_handle *h);
56 struct tegra_iovmm_area *nvmap_handle_iovmm(struct nvmap_client *c,
57 struct nvmap_handle *h);
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)
67 static inline void nvmap_mru_insert_locked(struct nvmap_share *share,
68 struct nvmap_handle *h)
71 static inline void nvmap_mru_remove(struct nvmap_share *s,
72 struct nvmap_handle *h)
75 static inline struct tegra_iovmm_area *nvmap_handle_iovmm(struct nvmap_client *c,
76 struct nvmap_handle *h)
78 BUG_ON(!h->pgalloc.area);
79 return h->pgalloc.area;