diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/cde_gk20a.c | 38 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/cde_gk20a.h | 13 |
2 files changed, 29 insertions, 22 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c index 02636206..42850588 100644 --- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c | |||
@@ -85,7 +85,7 @@ __must_hold(&cde_app->mutex) | |||
85 | gk20a_channel_close(ch); | 85 | gk20a_channel_close(ch); |
86 | 86 | ||
87 | /* housekeeping on app */ | 87 | /* housekeeping on app */ |
88 | list_del(&cde_ctx->list); | 88 | nvgpu_list_del(&cde_ctx->list); |
89 | cde_ctx->g->cde_app.ctx_count--; | 89 | cde_ctx->g->cde_app.ctx_count--; |
90 | nvgpu_kfree(g, cde_ctx); | 90 | nvgpu_kfree(g, cde_ctx); |
91 | } | 91 | } |
@@ -120,14 +120,14 @@ __must_hold(&cde_app->mutex) | |||
120 | * deinitialised; no new jobs are started. deleter works may be only at | 120 | * deinitialised; no new jobs are started. deleter works may be only at |
121 | * waiting for the mutex or before, going to abort */ | 121 | * waiting for the mutex or before, going to abort */ |
122 | 122 | ||
123 | list_for_each_entry_safe(cde_ctx, cde_ctx_save, | 123 | nvgpu_list_for_each_entry_safe(cde_ctx, cde_ctx_save, |
124 | &cde_app->free_contexts, list) { | 124 | &cde_app->free_contexts, gk20a_cde_ctx, list) { |
125 | gk20a_cde_cancel_deleter(cde_ctx, true); | 125 | gk20a_cde_cancel_deleter(cde_ctx, true); |
126 | gk20a_cde_remove_ctx(cde_ctx); | 126 | gk20a_cde_remove_ctx(cde_ctx); |
127 | } | 127 | } |
128 | 128 | ||
129 | list_for_each_entry_safe(cde_ctx, cde_ctx_save, | 129 | nvgpu_list_for_each_entry_safe(cde_ctx, cde_ctx_save, |
130 | &cde_app->used_contexts, list) { | 130 | &cde_app->used_contexts, gk20a_cde_ctx, list) { |
131 | gk20a_cde_cancel_deleter(cde_ctx, true); | 131 | gk20a_cde_cancel_deleter(cde_ctx, true); |
132 | gk20a_cde_remove_ctx(cde_ctx); | 132 | gk20a_cde_remove_ctx(cde_ctx); |
133 | } | 133 | } |
@@ -172,13 +172,13 @@ __releases(&cde_app->mutex) | |||
172 | 172 | ||
173 | nvgpu_mutex_acquire(&cde_app->mutex); | 173 | nvgpu_mutex_acquire(&cde_app->mutex); |
174 | 174 | ||
175 | list_for_each_entry_safe(cde_ctx, cde_ctx_save, | 175 | nvgpu_list_for_each_entry_safe(cde_ctx, cde_ctx_save, |
176 | &cde_app->free_contexts, list) { | 176 | &cde_app->free_contexts, gk20a_cde_ctx, list) { |
177 | gk20a_cde_cancel_deleter(cde_ctx, false); | 177 | gk20a_cde_cancel_deleter(cde_ctx, false); |
178 | } | 178 | } |
179 | 179 | ||
180 | list_for_each_entry_safe(cde_ctx, cde_ctx_save, | 180 | nvgpu_list_for_each_entry_safe(cde_ctx, cde_ctx_save, |
181 | &cde_app->used_contexts, list) { | 181 | &cde_app->used_contexts, gk20a_cde_ctx, list) { |
182 | gk20a_cde_cancel_deleter(cde_ctx, false); | 182 | gk20a_cde_cancel_deleter(cde_ctx, false); |
183 | } | 183 | } |
184 | 184 | ||
@@ -196,7 +196,7 @@ __must_hold(&cde_app->mutex) | |||
196 | if (IS_ERR(cde_ctx)) | 196 | if (IS_ERR(cde_ctx)) |
197 | return PTR_ERR(cde_ctx); | 197 | return PTR_ERR(cde_ctx); |
198 | 198 | ||
199 | list_add(&cde_ctx->list, &cde_app->free_contexts); | 199 | nvgpu_list_add(&cde_ctx->list, &cde_app->free_contexts); |
200 | cde_app->ctx_count++; | 200 | cde_app->ctx_count++; |
201 | if (cde_app->ctx_count > cde_app->ctx_count_top) | 201 | if (cde_app->ctx_count > cde_app->ctx_count_top) |
202 | cde_app->ctx_count_top = cde_app->ctx_count; | 202 | cde_app->ctx_count_top = cde_app->ctx_count; |
@@ -747,7 +747,7 @@ __releases(&cde_app->mutex) | |||
747 | 747 | ||
748 | if (cde_ctx->in_use) { | 748 | if (cde_ctx->in_use) { |
749 | cde_ctx->in_use = false; | 749 | cde_ctx->in_use = false; |
750 | list_move(&cde_ctx->list, &cde_app->free_contexts); | 750 | nvgpu_list_move(&cde_ctx->list, &cde_app->free_contexts); |
751 | cde_app->ctx_usecount--; | 751 | cde_app->ctx_usecount--; |
752 | } else { | 752 | } else { |
753 | gk20a_dbg_info("double release cde context %p", cde_ctx); | 753 | gk20a_dbg_info("double release cde context %p", cde_ctx); |
@@ -819,9 +819,9 @@ __must_hold(&cde_app->mutex) | |||
819 | 819 | ||
820 | /* idle context available? */ | 820 | /* idle context available? */ |
821 | 821 | ||
822 | if (!list_empty(&cde_app->free_contexts)) { | 822 | if (!nvgpu_list_empty(&cde_app->free_contexts)) { |
823 | cde_ctx = list_first_entry(&cde_app->free_contexts, | 823 | cde_ctx = nvgpu_list_first_entry(&cde_app->free_contexts, |
824 | struct gk20a_cde_ctx, list); | 824 | gk20a_cde_ctx, list); |
825 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_cde_ctx, | 825 | gk20a_dbg(gpu_dbg_fn | gpu_dbg_cde_ctx, |
826 | "cde: got free %p count=%d use=%d max=%d", | 826 | "cde: got free %p count=%d use=%d max=%d", |
827 | cde_ctx, cde_app->ctx_count, | 827 | cde_ctx, cde_app->ctx_count, |
@@ -831,7 +831,7 @@ __must_hold(&cde_app->mutex) | |||
831 | 831 | ||
832 | /* deleter work may be scheduled, but in_use prevents it */ | 832 | /* deleter work may be scheduled, but in_use prevents it */ |
833 | cde_ctx->in_use = true; | 833 | cde_ctx->in_use = true; |
834 | list_move(&cde_ctx->list, &cde_app->used_contexts); | 834 | nvgpu_list_move(&cde_ctx->list, &cde_app->used_contexts); |
835 | cde_app->ctx_usecount++; | 835 | cde_app->ctx_usecount++; |
836 | 836 | ||
837 | /* cancel any deletions now that ctx is in use */ | 837 | /* cancel any deletions now that ctx is in use */ |
@@ -859,7 +859,7 @@ __must_hold(&cde_app->mutex) | |||
859 | cde_app->ctx_count++; | 859 | cde_app->ctx_count++; |
860 | if (cde_app->ctx_count > cde_app->ctx_count_top) | 860 | if (cde_app->ctx_count > cde_app->ctx_count_top) |
861 | cde_app->ctx_count_top = cde_app->ctx_count; | 861 | cde_app->ctx_count_top = cde_app->ctx_count; |
862 | list_add(&cde_ctx->list, &cde_app->used_contexts); | 862 | nvgpu_list_add(&cde_ctx->list, &cde_app->used_contexts); |
863 | 863 | ||
864 | return cde_ctx; | 864 | return cde_ctx; |
865 | } | 865 | } |
@@ -907,7 +907,7 @@ static struct gk20a_cde_ctx *gk20a_cde_allocate_context(struct gk20a *g) | |||
907 | return ERR_PTR(ret); | 907 | return ERR_PTR(ret); |
908 | } | 908 | } |
909 | 909 | ||
910 | INIT_LIST_HEAD(&cde_ctx->list); | 910 | nvgpu_init_list_node(&cde_ctx->list); |
911 | cde_ctx->is_temporary = false; | 911 | cde_ctx->is_temporary = false; |
912 | cde_ctx->in_use = false; | 912 | cde_ctx->in_use = false; |
913 | INIT_DELAYED_WORK(&cde_ctx->ctx_deleter_work, | 913 | INIT_DELAYED_WORK(&cde_ctx->ctx_deleter_work, |
@@ -1321,8 +1321,8 @@ __releases(&cde_app->mutex) | |||
1321 | 1321 | ||
1322 | nvgpu_mutex_acquire(&cde_app->mutex); | 1322 | nvgpu_mutex_acquire(&cde_app->mutex); |
1323 | 1323 | ||
1324 | INIT_LIST_HEAD(&cde_app->free_contexts); | 1324 | nvgpu_init_list_node(&cde_app->free_contexts); |
1325 | INIT_LIST_HEAD(&cde_app->used_contexts); | 1325 | nvgpu_init_list_node(&cde_app->used_contexts); |
1326 | cde_app->ctx_count = 0; | 1326 | cde_app->ctx_count = 0; |
1327 | cde_app->ctx_count_top = 0; | 1327 | cde_app->ctx_count_top = 0; |
1328 | cde_app->ctx_usecount = 0; | 1328 | cde_app->ctx_usecount = 0; |
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.h b/drivers/gpu/nvgpu/gk20a/cde_gk20a.h index 1136b0ad..a36f2401 100644 --- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.h | |||
@@ -254,18 +254,25 @@ struct gk20a_cde_ctx { | |||
254 | 254 | ||
255 | bool init_cmd_executed; | 255 | bool init_cmd_executed; |
256 | 256 | ||
257 | struct list_head list; | 257 | struct nvgpu_list_node list; |
258 | bool is_temporary; | 258 | bool is_temporary; |
259 | bool in_use; | 259 | bool in_use; |
260 | struct delayed_work ctx_deleter_work; | 260 | struct delayed_work ctx_deleter_work; |
261 | }; | 261 | }; |
262 | 262 | ||
263 | static inline struct gk20a_cde_ctx * | ||
264 | gk20a_cde_ctx_from_list(struct nvgpu_list_node *node) | ||
265 | { | ||
266 | return (struct gk20a_cde_ctx *) | ||
267 | ((uintptr_t)node - offsetof(struct gk20a_cde_ctx, list)); | ||
268 | }; | ||
269 | |||
263 | struct gk20a_cde_app { | 270 | struct gk20a_cde_app { |
264 | bool initialised; | 271 | bool initialised; |
265 | struct nvgpu_mutex mutex; | 272 | struct nvgpu_mutex mutex; |
266 | 273 | ||
267 | struct list_head free_contexts; | 274 | struct nvgpu_list_node free_contexts; |
268 | struct list_head used_contexts; | 275 | struct nvgpu_list_node used_contexts; |
269 | unsigned int ctx_count; | 276 | unsigned int ctx_count; |
270 | unsigned int ctx_usecount; | 277 | unsigned int ctx_usecount; |
271 | unsigned int ctx_count_top; | 278 | unsigned int ctx_count_top; |