From 23396c58db7e9d9c974bb3334a159aad960afc3e Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Mon, 13 Nov 2017 13:52:29 +0200 Subject: gpu: nvgpu: Simplify compbits alloc and add needs_clear Simplify compbits alloc by making the alloc function re-callable for the buffer, and making it return the comptags info. This simplifies the calling code: alloc_or_get vs. get + alloc + get again. Add tracking whether the allocated compbits need clearing before they can be used in PTEs. We do this, since clearing is part of the gmmu map call on vgpu, which can fail. Bug 1902982 Change-Id: Ic4ab8d326910443b128e82491d302a1f49120f5b Signed-off-by: Sami Kiminki Reviewed-on: https://git-master.nvidia.com/r/1597130 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: svc-mobile-coverity Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/vm.c | 71 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 41 deletions(-) (limited to 'drivers/gpu/nvgpu/common/mm') 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, struct gk20a_comptags comptags = { 0 }; /* - * Get the comptags state + * Get the comptags state, alloc if necessary */ - gk20a_get_comptags(os_buf, &comptags); + err = gk20a_alloc_or_get_comptags(g, os_buf, + &g->gr.comp_tags, + binfo.ctag_lines, &comptags); + if (err) { + /* + * This is an irrecoverable failure and we need to + * abort. In particular, it is not safe to proceed with + * the incompressible fallback, since we cannot not mark + * our alloc failure anywere. Later we would retry + * allocation and break compressible map aliasing. + */ + nvgpu_err(g, "Error %d setting up comptags", err); + goto clean_up; + } /* - * Allocate if not yet allocated + * Newly allocated comptags needs to be cleared */ - if (!comptags.allocated) { - err = gk20a_alloc_comptags(g, os_buf, - &g->gr.comp_tags, - binfo.ctag_lines); - if (err) { + if (comptags.needs_clear) { + if (g->ops.ltc.cbc_ctrl) { + g->ops.ltc.cbc_ctrl( + g, gk20a_cbc_op_clear, + comptags.offset, + (comptags.offset + + comptags.lines - 1)); + gk20a_mark_comptags_cleared(os_buf); + } else { /* - * This is an irrecoverable failure and we need - * to abort. In particular, it is not safe to - * proceed with incompressible fallback, since - * we could not mark our alloc failure - * anywere. Later we would retry allocation and - * break compressible map aliasing. + * Cleared as part of gmmu map */ - nvgpu_err(g, - "Error %d setting up comptags", err); - goto clean_up; - } - - /* - * Refresh comptags state after alloc. Field - * comptags.lines will be 0 if alloc failed. - */ - gk20a_get_comptags(os_buf, &comptags); - - /* - * Newly allocated comptags needs to be cleared - */ - if (comptags.lines) { - if (g->ops.ltc.cbc_ctrl) - g->ops.ltc.cbc_ctrl( - g, gk20a_cbc_op_clear, - comptags.offset, - (comptags.offset + - comptags.lines - 1)); - else - /* - * The comptags will be cleared as part - * of mapping (vgpu) - */ - clear_ctags = true; + clear_ctags = true; } } @@ -959,6 +945,9 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, goto clean_up; } + if (clear_ctags) + gk20a_mark_comptags_cleared(os_buf); + nvgpu_init_list_node(&mapped_buffer->buffer_list); nvgpu_ref_init(&mapped_buffer->ref); mapped_buffer->addr = map_addr; -- cgit v1.2.2