summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm')
-rw-r--r--drivers/gpu/nvgpu/common/mm/vm.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c
index be7e4207..7a451956 100644
--- a/drivers/gpu/nvgpu/common/mm/vm.c
+++ b/drivers/gpu/nvgpu/common/mm/vm.c
@@ -857,53 +857,39 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm,
857 struct gk20a_comptags comptags = { 0 }; 857 struct gk20a_comptags comptags = { 0 };
858 858
859 /* 859 /*
860 * Get the comptags state 860 * Get the comptags state, alloc if necessary
861 */ 861 */
862 gk20a_get_comptags(os_buf, &comptags); 862 err = gk20a_alloc_or_get_comptags(g, os_buf,
863 &g->gr.comp_tags,
864 binfo.ctag_lines, &comptags);
865 if (err) {
866 /*
867 * This is an irrecoverable failure and we need to
868 * abort. In particular, it is not safe to proceed with
869 * the incompressible fallback, since we cannot not mark
870 * our alloc failure anywere. Later we would retry
871 * allocation and break compressible map aliasing.
872 */
873 nvgpu_err(g, "Error %d setting up comptags", err);
874 goto clean_up;
875 }
863 876
864 /* 877 /*
865 * Allocate if not yet allocated 878 * Newly allocated comptags needs to be cleared
866 */ 879 */
867 if (!comptags.allocated) { 880 if (comptags.needs_clear) {
868 err = gk20a_alloc_comptags(g, os_buf, 881 if (g->ops.ltc.cbc_ctrl) {
869 &g->gr.comp_tags, 882 g->ops.ltc.cbc_ctrl(
870 binfo.ctag_lines); 883 g, gk20a_cbc_op_clear,
871 if (err) { 884 comptags.offset,
885 (comptags.offset +
886 comptags.lines - 1));
887 gk20a_mark_comptags_cleared(os_buf);
888 } else {
872 /* 889 /*
873 * This is an irrecoverable failure and we need 890 * Cleared as part of gmmu map
874 * to abort. In particular, it is not safe to
875 * proceed with incompressible fallback, since
876 * we could not mark our alloc failure
877 * anywere. Later we would retry allocation and
878 * break compressible map aliasing.
879 */ 891 */
880 nvgpu_err(g, 892 clear_ctags = true;
881 "Error %d setting up comptags", err);
882 goto clean_up;
883 }
884
885 /*
886 * Refresh comptags state after alloc. Field
887 * comptags.lines will be 0 if alloc failed.
888 */
889 gk20a_get_comptags(os_buf, &comptags);
890
891 /*
892 * Newly allocated comptags needs to be cleared
893 */
894 if (comptags.lines) {
895 if (g->ops.ltc.cbc_ctrl)
896 g->ops.ltc.cbc_ctrl(
897 g, gk20a_cbc_op_clear,
898 comptags.offset,
899 (comptags.offset +
900 comptags.lines - 1));
901 else
902 /*
903 * The comptags will be cleared as part
904 * of mapping (vgpu)
905 */
906 clear_ctags = true;
907 } 893 }
908 } 894 }
909 895
@@ -959,6 +945,9 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm,
959 goto clean_up; 945 goto clean_up;
960 } 946 }
961 947
948 if (clear_ctags)
949 gk20a_mark_comptags_cleared(os_buf);
950
962 nvgpu_init_list_node(&mapped_buffer->buffer_list); 951 nvgpu_init_list_node(&mapped_buffer->buffer_list);
963 nvgpu_ref_init(&mapped_buffer->ref); 952 nvgpu_ref_init(&mapped_buffer->ref);
964 mapped_buffer->addr = map_addr; 953 mapped_buffer->addr = map_addr;