diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-05-18 07:19:53 -0400 |
---|---|---|
committer | Terje Bergstrom <tbergstrom@nvidia.com> | 2016-05-18 14:55:11 -0400 |
commit | abec0ddc19b89822138f3c8970516eed4d0e17d9 (patch) | |
tree | f788095b1bc9118c9afac81c77d27bd0044ac5ad /drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h | |
parent | dc45473eeb39d93100290a0f09bd787b3a5ce3f2 (diff) |
gpu: nvgpu: use mem_desc for semaphores
Replace manual buffer allocation and cpu_va pointer accesses with
gk20a_gmmu_{alloc,free}() and gk20a_mem_{rd,wr}() using a struct
mem_desc in gk20a_semaphore_pool, for buffer aperture flexibility.
JIRA DNVGPU-23
Change-Id: I394c38f407a9da02480bfd35062a892eec242ea3
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1146684
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/semaphore_gk20a.h | 20 |
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. */ |
22 | struct gk20a_semaphore_pool { | 22 | struct 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. */ |
49 | struct gk20a_semaphore { | 46 | struct 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. */ |
59 | struct gk20a_semaphore_pool * | 57 | struct gk20a_semaphore_pool * |
60 | gk20a_semaphore_pool_alloc(struct device *, const char *unique_name, | 58 | gk20a_semaphore_pool_alloc(struct gk20a *, const char *unique_name, |
61 | size_t capacity); | 59 | size_t capacity); |
62 | void gk20a_semaphore_pool_put(struct gk20a_semaphore_pool *); | 60 | void gk20a_semaphore_pool_put(struct gk20a_semaphore_pool *); |
63 | int gk20a_semaphore_pool_map(struct gk20a_semaphore_pool *, | 61 | int 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 | ||
84 | static inline bool gk20a_semaphore_is_acquired(struct gk20a_semaphore *s) | 82 | static 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) | |||
94 | static inline void gk20a_semaphore_release(struct gk20a_semaphore *s) | 92 | static 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 |