From f0147665b2d9c3faa673e6b0001be596018c4e9c Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 31 Mar 2017 16:37:30 +0530 Subject: gpu: nvgpu: use nvgpu list for CE2 ctx list Use nvgpu list APIs instead of linux list APIs to store CE2 contexts Jira NVGPU-13 Change-Id: I0c9b8b69e7e19a63265802abb4455a5cb2308b6f Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1454011 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 26 +++++++++++++------------- drivers/gpu/nvgpu/gk20a/ce2_gk20a.h | 11 +++++++++-- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index 3ca38715..48f0cf8d 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c @@ -110,8 +110,8 @@ static void gk20a_ce_notify_all_user(struct gk20a *g, u32 event) nvgpu_mutex_acquire(&ce_app->app_mutex); - list_for_each_entry_safe(ce_ctx, ce_ctx_save, - &ce_app->allocated_contexts, list) { + nvgpu_list_for_each_entry_safe(ce_ctx, ce_ctx_save, + &ce_app->allocated_contexts, gk20a_gpu_ctx, list) { if (ce_ctx->user_event_callback) { ce_ctx->user_event_callback(ce_ctx->ctx_id, event); @@ -187,7 +187,7 @@ static void gk20a_ce_free_command_buffer_stored_fence(struct gk20a_gpu_ctx *ce_c /* assume this api should need to call under nvgpu_mutex_acquire(&ce_app->app_mutex) */ static void gk20a_ce_delete_gpu_context(struct gk20a_gpu_ctx *ce_ctx) { - struct list_head *list = &ce_ctx->list; + struct nvgpu_list_node *list = &ce_ctx->list; ce_ctx->gpu_ctx_state = NVGPU_CE_GPU_CTX_DELETED; @@ -204,7 +204,7 @@ static void gk20a_ce_delete_gpu_context(struct gk20a_gpu_ctx *ce_ctx) /* housekeeping on app */ if (list->prev && list->next) - list_del(list); + nvgpu_list_del(list); nvgpu_mutex_release(&ce_ctx->gpu_ctx_mutex); nvgpu_mutex_destroy(&ce_ctx->gpu_ctx_mutex); @@ -361,7 +361,7 @@ int gk20a_init_ce_support(struct gk20a *g) nvgpu_mutex_acquire(&ce_app->app_mutex); - INIT_LIST_HEAD(&ce_app->allocated_contexts); + nvgpu_init_list_node(&ce_app->allocated_contexts); ce_app->ctx_count = 0; ce_app->next_ctx_id = 0; ce_app->initialised = true; @@ -386,12 +386,12 @@ void gk20a_ce_destroy(struct gk20a *g) nvgpu_mutex_acquire(&ce_app->app_mutex); - list_for_each_entry_safe(ce_ctx, ce_ctx_save, - &ce_app->allocated_contexts, list) { + nvgpu_list_for_each_entry_safe(ce_ctx, ce_ctx_save, + &ce_app->allocated_contexts, gk20a_gpu_ctx, list) { gk20a_ce_delete_gpu_context(ce_ctx); } - INIT_LIST_HEAD(&ce_app->allocated_contexts); + nvgpu_init_list_node(&ce_app->allocated_contexts); ce_app->ctx_count = 0; ce_app->next_ctx_id = 0; @@ -520,7 +520,7 @@ u32 gk20a_ce_create_context_with_cb(struct device *dev, nvgpu_mutex_acquire(&ce_app->app_mutex); ctx_id = ce_ctx->ctx_id = ce_app->next_ctx_id; - list_add(&ce_ctx->list, &ce_app->allocated_contexts); + nvgpu_list_add(&ce_ctx->list, &ce_app->allocated_contexts); ++ce_app->next_ctx_id; ++ce_app->ctx_count; nvgpu_mutex_release(&ce_app->app_mutex); @@ -570,8 +570,8 @@ int gk20a_ce_execute_ops(struct device *dev, nvgpu_mutex_acquire(&ce_app->app_mutex); - list_for_each_entry_safe(ce_ctx, ce_ctx_save, - &ce_app->allocated_contexts, list) { + nvgpu_list_for_each_entry_safe(ce_ctx, ce_ctx_save, + &ce_app->allocated_contexts, gk20a_gpu_ctx, list) { if (ce_ctx->ctx_id == ce_ctx_id) { found = true; break; @@ -706,8 +706,8 @@ void gk20a_ce_delete_context_priv(struct gk20a *g, nvgpu_mutex_acquire(&ce_app->app_mutex); - list_for_each_entry_safe(ce_ctx, ce_ctx_save, - &ce_app->allocated_contexts, list) { + nvgpu_list_for_each_entry_safe(ce_ctx, ce_ctx_save, + &ce_app->allocated_contexts, gk20a_gpu_ctx, list) { if (ce_ctx->ctx_id == ce_ctx_id) { gk20a_ce_delete_gpu_context(ce_ctx); --ce_app->ctx_count; diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h index 7ecf130f..7a4e4861 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.h @@ -91,7 +91,7 @@ struct gk20a_ce_app { struct nvgpu_mutex app_mutex; int app_state; - struct list_head allocated_contexts; + struct nvgpu_list_node allocated_contexts; u32 ctx_count; u32 next_ctx_id; }; @@ -112,7 +112,7 @@ struct gk20a_gpu_ctx { /* cmd buf mem_desc */ struct mem_desc cmd_buf_mem; - struct list_head list; + struct nvgpu_list_node list; u64 submitted_seq_number; u64 completed_seq_number; @@ -121,6 +121,13 @@ struct gk20a_gpu_ctx { u32 cmd_buf_end_queue_offset; }; +static inline struct gk20a_gpu_ctx * +gk20a_gpu_ctx_from_list(struct nvgpu_list_node *node) +{ + return (struct gk20a_gpu_ctx *) + ((uintptr_t)node - offsetof(struct gk20a_gpu_ctx, list)); +}; + /* global CE app related apis */ int gk20a_init_ce_support(struct gk20a *g); void gk20a_ce_suspend(struct gk20a *g); -- cgit v1.2.2