summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
index 6ffe1fd2..1f12e262 100644
--- a/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h
@@ -20,11 +20,8 @@
20 20
21/* A memory pool for holding semaphores. */ 21/* A memory pool for holding semaphores. */
22struct gk20a_semaphore_pool { 22struct gk20a_semaphore_pool {
23 void *cpu_va; 23 struct mem_desc mem;
24 dma_addr_t iova; 24 struct gk20a *g;
25 size_t size;
26 struct device *dev;
27 struct sg_table *sgt;
28 struct list_head maps; 25 struct list_head maps;
29 struct mutex maps_mutex; 26 struct mutex maps_mutex;
30 struct kref ref; 27 struct kref ref;
@@ -48,16 +45,17 @@ struct gk20a_semaphore_pool_map {
48/* A semaphore that lives inside a semaphore pool. */ 45/* A semaphore that lives inside a semaphore pool. */
49struct gk20a_semaphore { 46struct gk20a_semaphore {
50 struct gk20a_semaphore_pool *pool; 47 struct gk20a_semaphore_pool *pool;
48 /*
49 * value exists within the pool's memory at the specified offset.
50 * 0=acquired, 1=released.
51 */
51 u32 offset; /* byte offset within pool */ 52 u32 offset; /* byte offset within pool */
52 struct kref ref; 53 struct kref ref;
53 /* value is a pointer within the pool's coherent cpu_va.
54 * It is shared between CPU and GPU, hence volatile. */
55 volatile u32 *value; /* 0=acquired, 1=released */
56}; 54};
57 55
58/* Create a semaphore pool that can hold at most 'capacity' semaphores. */ 56/* Create a semaphore pool that can hold at most 'capacity' semaphores. */
59struct gk20a_semaphore_pool * 57struct gk20a_semaphore_pool *
60gk20a_semaphore_pool_alloc(struct device *, const char *unique_name, 58gk20a_semaphore_pool_alloc(struct gk20a *, const char *unique_name,
61 size_t capacity); 59 size_t capacity);
62void gk20a_semaphore_pool_put(struct gk20a_semaphore_pool *); 60void gk20a_semaphore_pool_put(struct gk20a_semaphore_pool *);
63int gk20a_semaphore_pool_map(struct gk20a_semaphore_pool *, 61int gk20a_semaphore_pool_map(struct gk20a_semaphore_pool *,
@@ -83,7 +81,7 @@ static inline u64 gk20a_semaphore_gpu_va(struct gk20a_semaphore *s,
83 81
84static inline bool gk20a_semaphore_is_acquired(struct gk20a_semaphore *s) 82static inline bool gk20a_semaphore_is_acquired(struct gk20a_semaphore *s)
85{ 83{
86 u32 v = *s->value; 84 u32 v = gk20a_mem_rd(s->pool->g, &s->pool->mem, s->offset);
87 85
88 /* When often block on value reaching a certain threshold. We must make 86 /* When often block on value reaching a certain threshold. We must make
89 * sure that if we get unblocked, we haven't read anything too early. */ 87 * sure that if we get unblocked, we haven't read anything too early. */
@@ -94,6 +92,6 @@ static inline bool gk20a_semaphore_is_acquired(struct gk20a_semaphore *s)
94static inline void gk20a_semaphore_release(struct gk20a_semaphore *s) 92static inline void gk20a_semaphore_release(struct gk20a_semaphore *s)
95{ 93{
96 smp_wmb(); 94 smp_wmb();
97 *s->value = 1; 95 gk20a_mem_wr(s->pool->g, &s->pool->mem, s->offset, 1);
98} 96}
99#endif 97#endif