summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2014-11-13 09:19:41 -0500
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:12:16 -0400
commit617541236b2dcf980f7c9e3c6441472f1cc7bf62 (patch)
tree0b9f44da1972d9eb6150a4d1e51c172c5447282d /drivers/gpu/nvgpu/gk20a/cde_gk20a.c
parentf73552baea1ed48758bfece039aaf0c02102e0e7 (diff)
gpu: nvgpu: cde: combine init and convert passes
CDE context needs to be initialized in the first run using a separate initialization gpfifo before the actual conversion. To prevent a race condition, include both of them in a single gpfifo whenever the initialization is performed. Bug 200052943 Change-Id: I7eb09a906c0374825df71eba969e4596b94e5ff2 Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/602888 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/cde_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/cde_gk20a.c72
1 files changed, 53 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
index 43e74c85..24c28029 100644
--- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c
@@ -62,11 +62,10 @@ static void gk20a_deinit_cde_img(struct gk20a_cde_ctx *cde_ctx)
62 &(struct nvgpu_free_obj_ctx_args) 62 &(struct nvgpu_free_obj_ctx_args)
63 { cde_ctx->obj_ids[i] }); 63 { cde_ctx->obj_ids[i] });
64 64
65 kfree(cde_ctx->init_cmd); 65 kfree(cde_ctx->init_convert_cmd);
66 kfree(cde_ctx->convert_cmd);
67 66
68 cde_ctx->convert_cmd = NULL; 67 cde_ctx->convert_cmd = NULL;
69 cde_ctx->init_cmd = NULL; 68 cde_ctx->init_convert_cmd = NULL;
70 cde_ctx->num_bufs = 0; 69 cde_ctx->num_bufs = 0;
71 cde_ctx->num_obj_ids = 0; 70 cde_ctx->num_obj_ids = 0;
72 cde_ctx->num_params = 0; 71 cde_ctx->num_params = 0;
@@ -554,7 +553,7 @@ static int gk20a_init_cde_command(struct gk20a_cde_ctx *cde_ctx,
554 553
555 /* check command type */ 554 /* check command type */
556 if (op == TYPE_BUF_COMMAND_INIT) { 555 if (op == TYPE_BUF_COMMAND_INIT) {
557 gpfifo = &cde_ctx->init_cmd; 556 gpfifo = &cde_ctx->init_convert_cmd;
558 num_entries = &cde_ctx->init_cmd_num_entries; 557 num_entries = &cde_ctx->init_cmd_num_entries;
559 } else if (op == TYPE_BUF_COMMAND_CONVERT) { 558 } else if (op == TYPE_BUF_COMMAND_CONVERT) {
560 gpfifo = &cde_ctx->convert_cmd; 559 gpfifo = &cde_ctx->convert_cmd;
@@ -609,6 +608,38 @@ static int gk20a_init_cde_command(struct gk20a_cde_ctx *cde_ctx,
609 return 0; 608 return 0;
610} 609}
611 610
611static int gk20a_cde_pack_cmdbufs(struct gk20a_cde_ctx *cde_ctx)
612{
613 unsigned long init_bytes = cde_ctx->init_cmd_num_entries *
614 sizeof(struct nvgpu_gpfifo);
615 unsigned long conv_bytes = cde_ctx->convert_cmd_num_entries *
616 sizeof(struct nvgpu_gpfifo);
617 unsigned long total_bytes = init_bytes + conv_bytes;
618 struct nvgpu_gpfifo *combined_cmd;
619
620 /* allocate buffer that has space for both */
621 combined_cmd = kzalloc(total_bytes, GFP_KERNEL);
622 if (!combined_cmd) {
623 gk20a_warn(&cde_ctx->pdev->dev,
624 "cde: could not allocate memory for gpfifo entries");
625 return -ENOMEM;
626 }
627
628 /* move the original init here and append convert */
629 memcpy(combined_cmd, cde_ctx->init_convert_cmd, init_bytes);
630 memcpy(combined_cmd + cde_ctx->init_cmd_num_entries,
631 cde_ctx->convert_cmd, conv_bytes);
632
633 kfree(cde_ctx->init_convert_cmd);
634 kfree(cde_ctx->convert_cmd);
635
636 cde_ctx->init_convert_cmd = combined_cmd;
637 cde_ctx->convert_cmd = combined_cmd
638 + cde_ctx->init_cmd_num_entries;
639
640 return 0;
641}
642
612static int gk20a_init_cde_img(struct gk20a_cde_ctx *cde_ctx, 643static int gk20a_init_cde_img(struct gk20a_cde_ctx *cde_ctx,
613 const struct firmware *img) 644 const struct firmware *img)
614{ 645{
@@ -678,7 +709,7 @@ static int gk20a_init_cde_img(struct gk20a_cde_ctx *cde_ctx,
678 elem++; 709 elem++;
679 } 710 }
680 711
681 if (!cde_ctx->init_cmd || !cde_ctx->init_cmd_num_entries) { 712 if (!cde_ctx->init_convert_cmd || !cde_ctx->init_cmd_num_entries) {
682 gk20a_warn(&cde_ctx->pdev->dev, "cde: convert command not defined"); 713 gk20a_warn(&cde_ctx->pdev->dev, "cde: convert command not defined");
683 err = -EINVAL; 714 err = -EINVAL;
684 goto deinit_image; 715 goto deinit_image;
@@ -690,6 +721,10 @@ static int gk20a_init_cde_img(struct gk20a_cde_ctx *cde_ctx,
690 goto deinit_image; 721 goto deinit_image;
691 } 722 }
692 723
724 err = gk20a_cde_pack_cmdbufs(cde_ctx);
725 if (err)
726 goto deinit_image;
727
693 return 0; 728 return 0;
694 729
695deinit_image: 730deinit_image:
@@ -706,8 +741,10 @@ static int gk20a_cde_execute_buffer(struct gk20a_cde_ctx *cde_ctx,
706 741
707 /* check command type */ 742 /* check command type */
708 if (op == TYPE_BUF_COMMAND_INIT) { 743 if (op == TYPE_BUF_COMMAND_INIT) {
709 gpfifo = cde_ctx->init_cmd; 744 /* both init and convert combined */
710 num_entries = cde_ctx->init_cmd_num_entries; 745 gpfifo = cde_ctx->init_convert_cmd;
746 num_entries = cde_ctx->init_cmd_num_entries
747 + cde_ctx->convert_cmd_num_entries;
711 } else if (op == TYPE_BUF_COMMAND_CONVERT) { 748 } else if (op == TYPE_BUF_COMMAND_CONVERT) {
712 gpfifo = cde_ctx->convert_cmd; 749 gpfifo = cde_ctx->convert_cmd;
713 num_entries = cde_ctx->convert_cmd_num_entries; 750 num_entries = cde_ctx->convert_cmd_num_entries;
@@ -1006,23 +1043,20 @@ __releases(&cde_app->mutex)
1006 gk20a_dbg(gpu_dbg_cde, "cde: buffer=compbits, size=%llu, gpuva=%llx\n", 1043 gk20a_dbg(gpu_dbg_cde, "cde: buffer=compbits, size=%llu, gpuva=%llx\n",
1007 cde_ctx->compbit_size, cde_ctx->compbit_vaddr); 1044 cde_ctx->compbit_size, cde_ctx->compbit_vaddr);
1008 1045
1009 /* execute the init push buffer */
1010 if (!cde_ctx->init_cmd_executed) {
1011 err = gk20a_cde_execute_buffer(cde_ctx, TYPE_BUF_COMMAND_INIT,
1012 NULL, 0, NULL);
1013 if (err)
1014 goto exit_unlock;
1015
1016 cde_ctx->init_cmd_executed = true;
1017 }
1018 1046
1019 /* take always the postfence as it is needed for protecting the 1047 /* take always the postfence as it is needed for protecting the
1020 * cde context */ 1048 * cde context */
1021 flags = __flags | NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET; 1049 flags = __flags | NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET;
1022 1050
1023 /* execute the conversion buffer */ 1051 /* execute the conversion buffer, combined with init first if it's the
1024 err = gk20a_cde_execute_buffer(cde_ctx, TYPE_BUF_COMMAND_CONVERT, 1052 * first time */
1025 fence, flags, fence_out); 1053 err = gk20a_cde_execute_buffer(cde_ctx,
1054 cde_ctx->init_cmd_executed
1055 ? TYPE_BUF_COMMAND_CONVERT
1056 : TYPE_BUF_COMMAND_INIT,
1057 fence, flags, fence_out);
1058
1059 cde_ctx->init_cmd_executed = true;
1026 1060
1027exit_unlock: 1061exit_unlock:
1028 1062