From 5e85069f4f4f1f9849fcba02829c802cb1849618 Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Wed, 20 May 2015 18:38:10 +0300 Subject: gpu: nvgpu: Fix compbits mapping Commit e99aa2485f8992eabe3556f3ebcb57bdc8ad91ff broke compbits mapping. So, let's fix it. Bug 200077571 Change-Id: I02dc150fbcb4cd59660f510adde9f029290efdfb Signed-off-by: Sami Kiminki Reviewed-on: http://git-master/r/745001 (cherry picked from commit 86fc7ec9a05999bea8de320840b962db3ee11410) Reviewed-on: http://git-master/r/753281 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 47 ++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 342d3ace..e3ec3f10 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -271,7 +271,6 @@ static int gk20a_alloc_comptags(struct gk20a *g, if (ctaglines_to_allocate < lines) return -EINVAL; /* integer overflow */ - pr_info("user-mapped CTAGS: %u\n", ctaglines_to_allocate); } /* store the allocator so we can use it when we free the ctags */ @@ -282,9 +281,19 @@ static int gk20a_alloc_comptags(struct gk20a *g, priv->comptags.lines = lines; priv->comptags.real_offset = offset; + priv->comptags.allocated_lines = ctaglines_to_allocate; + + if (user_mappable) { + u64 win_size = + DIV_ROUND_UP(lines, g->gr.comptags_per_cacheline) * + aggregate_cacheline_sz; + win_size = roundup(win_size, small_pgsz); - if (user_mappable) offset = DIV_ROUND_UP(offset, ctagline_align) * ctagline_align; + *ctag_map_win_ctagline = offset; + *ctag_map_win_size = win_size; + } + priv->comptags.offset = offset; @@ -1458,14 +1467,32 @@ u64 gk20a_vm_map(struct vm_gk20a *vm, gk20a_get_comptags(d, dmabuf, &comptags); clear_ctags = true; - if (comptags.lines < comptags.allocated_lines) { - /* clear tail-padding comptags */ - u32 ctagmin = comptags.offset + comptags.lines; - u32 ctagmax = comptags.offset + - comptags.allocated_lines - 1; - - g->ops.ltc.cbc_ctrl(g, gk20a_cbc_op_clear, - ctagmin, ctagmax); + comptags.user_mappable = user_mappable; + + if (user_mappable) { + /* comptags for the buffer will be + cleared later, but we need to make + sure the whole comptags allocation + (which may be bigger) is cleared in + order not to leak compbits */ + + const u32 buffer_ctag_end = + comptags.offset + comptags.lines; + const u32 alloc_ctag_end = + comptags.real_offset + + comptags.allocated_lines; + + if (comptags.real_offset < comptags.offset) + g->ops.ltc.cbc_ctrl( + g, gk20a_cbc_op_clear, + comptags.real_offset, + comptags.offset - 1); + + if (buffer_ctag_end < alloc_ctag_end) + g->ops.ltc.cbc_ctrl( + g, gk20a_cbc_op_clear, + buffer_ctag_end, + alloc_ctag_end - 1); } } } -- cgit v1.2.2