diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-03-08 20:08:50 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-03-30 15:36:09 -0400 |
commit | 24e1c7e0a729158be36d63b821550d206a8a0436 (patch) | |
tree | cf26c850cc63957f63f3e8f97914268839d8e0de /drivers/gpu/nvgpu/gk20a/fence_gk20a.c | |
parent | 7010bf88399ea81b2b35844f738baac19dc5a441 (diff) |
gpu: nvgpu: Use new kmem API functions (misc)
Use the new kmem API functions in misc gk20a code. Some additional
modifications were also made:
o Add a struct gk20a pointer to gk20a_fence to enable proper
kmem free usage.
o Add gk20a pointer to alloc_session() in dbg_gpu_gk20a.c to
use kmem API for allocating a session.
o Plumb a gk20a pointer through the fence creation and deletion.
o Use statically allocated buffers for names in file creation.
Bug 1799159
Bug 1823380
Change-Id: I3678080e3ffa1f9bcf6934e3f4819a1bc531689b
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1318323
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/fence_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/fence_gk20a.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c index ea3cd3ff..63da0959 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/version.h> | 18 | #include <linux/version.h> |
19 | 19 | ||
20 | #include <nvgpu/semaphore.h> | 20 | #include <nvgpu/semaphore.h> |
21 | #include <nvgpu/kmem.h> | ||
21 | 22 | ||
22 | #include "gk20a.h" | 23 | #include "gk20a.h" |
23 | #include "channel_gk20a.h" | 24 | #include "channel_gk20a.h" |
@@ -42,6 +43,8 @@ static void gk20a_fence_free(struct kref *ref) | |||
42 | { | 43 | { |
43 | struct gk20a_fence *f = | 44 | struct gk20a_fence *f = |
44 | container_of(ref, struct gk20a_fence, ref); | 45 | container_of(ref, struct gk20a_fence, ref); |
46 | struct gk20a *g = f->g; | ||
47 | |||
45 | #ifdef CONFIG_SYNC | 48 | #ifdef CONFIG_SYNC |
46 | if (f->sync_fence) | 49 | if (f->sync_fence) |
47 | sync_fence_put(f->sync_fence); | 50 | sync_fence_put(f->sync_fence); |
@@ -53,7 +56,7 @@ static void gk20a_fence_free(struct kref *ref) | |||
53 | if (nvgpu_alloc_initialized(f->allocator)) | 56 | if (nvgpu_alloc_initialized(f->allocator)) |
54 | nvgpu_free(f->allocator, (size_t)f); | 57 | nvgpu_free(f->allocator, (size_t)f); |
55 | } else | 58 | } else |
56 | kfree(f); | 59 | nvgpu_kfree(g, f); |
57 | } | 60 | } |
58 | 61 | ||
59 | void gk20a_fence_put(struct gk20a_fence *f) | 62 | void gk20a_fence_put(struct gk20a_fence *f) |
@@ -124,7 +127,7 @@ int gk20a_alloc_fence_pool(struct channel_gk20a *c, unsigned int count) | |||
124 | size = sizeof(struct gk20a_fence); | 127 | size = sizeof(struct gk20a_fence); |
125 | if (count <= UINT_MAX / size) { | 128 | if (count <= UINT_MAX / size) { |
126 | size = count * size; | 129 | size = count * size; |
127 | fence_pool = vzalloc(size); | 130 | fence_pool = nvgpu_vzalloc(c->g, size); |
128 | } | 131 | } |
129 | 132 | ||
130 | if (!fence_pool) | 133 | if (!fence_pool) |
@@ -139,7 +142,7 @@ int gk20a_alloc_fence_pool(struct channel_gk20a *c, unsigned int count) | |||
139 | return 0; | 142 | return 0; |
140 | 143 | ||
141 | fail: | 144 | fail: |
142 | vfree(fence_pool); | 145 | nvgpu_vfree(c->g, fence_pool); |
143 | return err; | 146 | return err; |
144 | } | 147 | } |
145 | 148 | ||
@@ -150,7 +153,7 @@ void gk20a_free_fence_pool(struct channel_gk20a *c) | |||
150 | nvgpu_alloc_base(&c->fence_allocator); | 153 | nvgpu_alloc_base(&c->fence_allocator); |
151 | 154 | ||
152 | nvgpu_alloc_destroy(&c->fence_allocator); | 155 | nvgpu_alloc_destroy(&c->fence_allocator); |
153 | vfree(base); | 156 | nvgpu_vfree(c->g, base); |
154 | } | 157 | } |
155 | } | 158 | } |
156 | 159 | ||
@@ -171,10 +174,12 @@ struct gk20a_fence *gk20a_alloc_fence(struct channel_gk20a *c) | |||
171 | } | 174 | } |
172 | } | 175 | } |
173 | } else | 176 | } else |
174 | fence = kzalloc(sizeof(struct gk20a_fence), GFP_KERNEL); | 177 | fence = nvgpu_kzalloc(c->g, sizeof(struct gk20a_fence)); |
175 | 178 | ||
176 | if (fence) | 179 | if (fence) { |
177 | kref_init(&fence->ref); | 180 | kref_init(&fence->ref); |
181 | fence->g = c->g; | ||
182 | } | ||
178 | 183 | ||
179 | return fence; | 184 | return fence; |
180 | } | 185 | } |
@@ -223,6 +228,7 @@ static const struct gk20a_fence_ops nvgpu_semaphore_fence_ops = { | |||
223 | 228 | ||
224 | /* This function takes ownership of the semaphore */ | 229 | /* This function takes ownership of the semaphore */ |
225 | int gk20a_fence_from_semaphore( | 230 | int gk20a_fence_from_semaphore( |
231 | struct gk20a *g, | ||
226 | struct gk20a_fence *fence_out, | 232 | struct gk20a_fence *fence_out, |
227 | struct sync_timeline *timeline, | 233 | struct sync_timeline *timeline, |
228 | struct nvgpu_semaphore *semaphore, | 234 | struct nvgpu_semaphore *semaphore, |
@@ -235,7 +241,7 @@ int gk20a_fence_from_semaphore( | |||
235 | 241 | ||
236 | #ifdef CONFIG_SYNC | 242 | #ifdef CONFIG_SYNC |
237 | if (need_sync_fence) { | 243 | if (need_sync_fence) { |
238 | sync_fence = gk20a_sync_fence_create(timeline, semaphore, | 244 | sync_fence = gk20a_sync_fence_create(g, timeline, semaphore, |
239 | dependency, "f-gk20a-0x%04x", | 245 | dependency, "f-gk20a-0x%04x", |
240 | nvgpu_semaphore_gpu_ro_va(semaphore)); | 246 | nvgpu_semaphore_gpu_ro_va(semaphore)); |
241 | if (!sync_fence) | 247 | if (!sync_fence) |