summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-08 20:08:50 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-30 15:36:09 -0400
commit24e1c7e0a729158be36d63b821550d206a8a0436 (patch)
treecf26c850cc63957f63f3e8f97914268839d8e0de /drivers/gpu/nvgpu/gk20a/sync_gk20a.c
parent7010bf88399ea81b2b35844f738baac19dc5a441 (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/sync_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/sync_gk20a.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
index f57871d5..b6105a40 100644
--- a/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/sync_gk20a.c
@@ -23,6 +23,7 @@
23#include <nvgpu/lock.h> 23#include <nvgpu/lock.h>
24#include <uapi/linux/nvgpu.h> 24#include <uapi/linux/nvgpu.h>
25 25
26#include <nvgpu/kmem.h>
26#include <nvgpu/semaphore.h> 27#include <nvgpu/semaphore.h>
27 28
28#include "../drivers/staging/android/sync.h" 29#include "../drivers/staging/android/sync.h"
@@ -42,6 +43,7 @@ struct gk20a_sync_timeline {
42 * refcounted gk20a_sync_pt for each duped pt. 43 * refcounted gk20a_sync_pt for each duped pt.
43 */ 44 */
44struct gk20a_sync_pt { 45struct gk20a_sync_pt {
46 struct gk20a *g;
45 struct kref refcount; 47 struct kref refcount;
46 u32 thresh; 48 u32 thresh;
47 struct nvgpu_semaphore *sema; 49 struct nvgpu_semaphore *sema;
@@ -203,26 +205,29 @@ static void gk20a_sync_pt_free_shared(struct kref *ref)
203{ 205{
204 struct gk20a_sync_pt *pt = 206 struct gk20a_sync_pt *pt =
205 container_of(ref, struct gk20a_sync_pt, refcount); 207 container_of(ref, struct gk20a_sync_pt, refcount);
208 struct gk20a *g = pt->g;
206 209
207 if (pt->dep) 210 if (pt->dep)
208 sync_fence_put(pt->dep); 211 sync_fence_put(pt->dep);
209 if (pt->sema) 212 if (pt->sema)
210 nvgpu_semaphore_put(pt->sema); 213 nvgpu_semaphore_put(pt->sema);
211 kfree(pt); 214 nvgpu_kfree(g, pt);
212} 215}
213 216
214static struct gk20a_sync_pt *gk20a_sync_pt_create_shared( 217static struct gk20a_sync_pt *gk20a_sync_pt_create_shared(
218 struct gk20a *g,
215 struct gk20a_sync_timeline *obj, 219 struct gk20a_sync_timeline *obj,
216 struct nvgpu_semaphore *sema, 220 struct nvgpu_semaphore *sema,
217 struct sync_fence *dependency) 221 struct sync_fence *dependency)
218{ 222{
219 struct gk20a_sync_pt *shared; 223 struct gk20a_sync_pt *shared;
220 224
221 shared = kzalloc(sizeof(*shared), GFP_KERNEL); 225 shared = nvgpu_kzalloc(g, sizeof(*shared));
222 if (!shared) 226 if (!shared)
223 return NULL; 227 return NULL;
224 228
225 kref_init(&shared->refcount); 229 kref_init(&shared->refcount);
230 shared->g = g;
226 shared->obj = obj; 231 shared->obj = obj;
227 shared->sema = sema; 232 shared->sema = sema;
228 shared->thresh = ++obj->max; /* sync framework has a lock */ 233 shared->thresh = ++obj->max; /* sync framework has a lock */
@@ -249,6 +254,7 @@ static struct gk20a_sync_pt *gk20a_sync_pt_create_shared(
249} 254}
250 255
251static struct sync_pt *gk20a_sync_pt_create_inst( 256static struct sync_pt *gk20a_sync_pt_create_inst(
257 struct gk20a *g,
252 struct gk20a_sync_timeline *obj, 258 struct gk20a_sync_timeline *obj,
253 struct nvgpu_semaphore *sema, 259 struct nvgpu_semaphore *sema,
254 struct sync_fence *dependency) 260 struct sync_fence *dependency)
@@ -260,7 +266,7 @@ static struct sync_pt *gk20a_sync_pt_create_inst(
260 if (!pti) 266 if (!pti)
261 return NULL; 267 return NULL;
262 268
263 pti->shared = gk20a_sync_pt_create_shared(obj, sema, dependency); 269 pti->shared = gk20a_sync_pt_create_shared(g, obj, sema, dependency);
264 if (!pti->shared) { 270 if (!pti->shared) {
265 sync_pt_free(&pti->pt); 271 sync_pt_free(&pti->pt);
266 return NULL; 272 return NULL;
@@ -506,7 +512,9 @@ struct sync_timeline *gk20a_sync_timeline_create(
506 return &obj->obj; 512 return &obj->obj;
507} 513}
508 514
509struct sync_fence *gk20a_sync_fence_create(struct sync_timeline *obj, 515struct sync_fence *gk20a_sync_fence_create(
516 struct gk20a *g,
517 struct sync_timeline *obj,
510 struct nvgpu_semaphore *sema, 518 struct nvgpu_semaphore *sema,
511 struct sync_fence *dependency, 519 struct sync_fence *dependency,
512 const char *fmt, ...) 520 const char *fmt, ...)
@@ -517,7 +525,7 @@ struct sync_fence *gk20a_sync_fence_create(struct sync_timeline *obj,
517 struct sync_fence *fence; 525 struct sync_fence *fence;
518 struct gk20a_sync_timeline *timeline = to_gk20a_timeline(obj); 526 struct gk20a_sync_timeline *timeline = to_gk20a_timeline(obj);
519 527
520 pt = gk20a_sync_pt_create_inst(timeline, sema, dependency); 528 pt = gk20a_sync_pt_create_inst(g, timeline, sema, dependency);
521 if (pt == NULL) 529 if (pt == NULL)
522 return NULL; 530 return NULL;
523 531