aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/tegra/host/nvhost_syncpt.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-22 10:38:37 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-22 10:38:37 -0500
commitfcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch)
treea57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/video/tegra/host/nvhost_syncpt.h
parent8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff)
Added missing tegra files.HEADmaster
Diffstat (limited to 'drivers/video/tegra/host/nvhost_syncpt.h')
-rw-r--r--drivers/video/tegra/host/nvhost_syncpt.h155
1 files changed, 155 insertions, 0 deletions
diff --git a/drivers/video/tegra/host/nvhost_syncpt.h b/drivers/video/tegra/host/nvhost_syncpt.h
new file mode 100644
index 00000000000..5b339178d1e
--- /dev/null
+++ b/drivers/video/tegra/host/nvhost_syncpt.h
@@ -0,0 +1,155 @@
1/*
2 * drivers/video/tegra/host/nvhost_syncpt.h
3 *
4 * Tegra Graphics Host Syncpoints
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __NVHOST_SYNCPT_H
22#define __NVHOST_SYNCPT_H
23
24#include <linux/kernel.h>
25#include <linux/sched.h>
26#include <linux/nvhost.h>
27#include <mach/nvmap.h>
28#include <linux/atomic.h>
29
30struct nvhost_syncpt;
31struct nvhost_waitchk;
32
33/* host managed and invalid syncpt id */
34#define NVSYNCPT_GRAPHICS_HOST (0)
35#define NVSYNCPT_INVALID (-1)
36
37struct nvhost_syncpt {
38 atomic_t *min_val;
39 atomic_t *max_val;
40 u32 *base_val;
41 u32 nb_pts;
42 u32 nb_bases;
43 u32 client_managed;
44 atomic_t *lock_counts;
45 u32 nb_mlocks;
46};
47
48int nvhost_syncpt_init(struct nvhost_syncpt *);
49#define client_managed(id) (BIT(id) & sp->client_managed)
50#define syncpt_to_dev(sp) container_of(sp, struct nvhost_master, syncpt)
51#define syncpt_op(sp) (syncpt_to_dev(sp)->op.syncpt)
52#define SYNCPT_CHECK_PERIOD (2*HZ)
53
54
55/**
56 * Updates the value sent to hardware.
57 */
58static inline u32 nvhost_syncpt_incr_max(struct nvhost_syncpt *sp,
59 u32 id, u32 incrs)
60{
61 return (u32)atomic_add_return(incrs, &sp->max_val[id]);
62}
63
64/**
65 * Updated the value sent to hardware.
66 */
67static inline u32 nvhost_syncpt_set_max(struct nvhost_syncpt *sp,
68 u32 id, u32 val)
69{
70 atomic_set(&sp->max_val[id], val);
71 smp_wmb();
72 return val;
73}
74
75static inline u32 nvhost_syncpt_read_max(struct nvhost_syncpt *sp, u32 id)
76{
77 smp_rmb();
78 return (u32)atomic_read(&sp->max_val[id]);
79}
80
81static inline u32 nvhost_syncpt_read_min(struct nvhost_syncpt *sp, u32 id)
82{
83 smp_rmb();
84 return (u32)atomic_read(&sp->min_val[id]);
85}
86
87static inline bool nvhost_syncpt_check_max(struct nvhost_syncpt *sp,
88 u32 id, u32 real)
89{
90 u32 max;
91 if (client_managed(id))
92 return true;
93 max = nvhost_syncpt_read_max(sp, id);
94 return (s32)(max - real) >= 0;
95}
96
97/**
98 * Returns true if syncpoint min == max
99 */
100static inline bool nvhost_syncpt_min_eq_max(struct nvhost_syncpt *sp, u32 id)
101{
102 int min, max;
103 smp_rmb();
104 min = atomic_read(&sp->min_val[id]);
105 max = atomic_read(&sp->max_val[id]);
106 return (min == max);
107}
108
109void nvhost_syncpt_cpu_incr(struct nvhost_syncpt *sp, u32 id);
110
111u32 nvhost_syncpt_update_min(struct nvhost_syncpt *sp, u32 id);
112bool nvhost_syncpt_is_expired(struct nvhost_syncpt *sp, u32 id, u32 thresh);
113
114void nvhost_syncpt_save(struct nvhost_syncpt *sp);
115
116void nvhost_syncpt_reset(struct nvhost_syncpt *sp);
117
118u32 nvhost_syncpt_read(struct nvhost_syncpt *sp, u32 id);
119u32 nvhost_syncpt_read_wait_base(struct nvhost_syncpt *sp, u32 id);
120
121void nvhost_syncpt_incr(struct nvhost_syncpt *sp, u32 id);
122
123int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, u32 thresh,
124 u32 timeout, u32 *value);
125
126static inline int nvhost_syncpt_wait(struct nvhost_syncpt *sp, u32 id, u32 thresh)
127{
128 return nvhost_syncpt_wait_timeout(sp, id, thresh,
129 MAX_SCHEDULE_TIMEOUT, NULL);
130}
131
132/*
133 * Check driver supplied waitchk structs for syncpt thresholds
134 * that have already been satisfied and NULL the comparison (to
135 * avoid a wrap condition in the HW).
136 *
137 * @param: sp - global shadowed syncpt struct
138 * @param: nvmap - needed to access command buffer
139 * @param: mask - bit mask of syncpt IDs referenced in WAITs
140 * @param: wait - start of filled in array of waitchk structs
141 * @param: waitend - end ptr (one beyond last valid waitchk)
142 */
143int nvhost_syncpt_wait_check(struct nvhost_syncpt *sp,
144 struct nvmap_client *nvmap,
145 u32 mask,
146 struct nvhost_waitchk *wait,
147 int num_waitchk);
148
149void nvhost_syncpt_debug(struct nvhost_syncpt *sp);
150
151int nvhost_mutex_try_lock(struct nvhost_syncpt *sp, int idx);
152
153void nvhost_mutex_unlock(struct nvhost_syncpt *sp, int idx);
154
155#endif