From 0f8746130ba79ec82a4b0675bbe00ab1ba17d3f8 Mon Sep 17 00:00:00 2001 From: David Nieto Date: Mon, 23 Oct 2017 13:58:37 -0700 Subject: gpu: nvgpu: halify size of patch buffer Allow per chip calculation of gr patch buffer size and set default to match hw default of 512 data-address pair entries (4K) bug 200350539 Change-Id: I6010c9e0304332825cb02612d3f10523ef27d128 Signed-off-by: David Nieto Reviewed-on: https://git-master.nvidia.com/r/1584033 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/gr_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 71fe44a3..3c3ddc80 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -714,7 +714,8 @@ void gr_gk20a_ctx_patch_write(struct gk20a *g, if (patch) { u32 patch_slot = ch_ctx->patch_ctx.data_count * PATCH_CTX_SLOTS_REQUIRED_PER_ENTRY; - if (patch_slot > (PATCH_CTX_SLOTS_MAX - + if (patch_slot > (PATCH_CTX_ENTRIES_FROM_SIZE( + ch_ctx->patch_ctx.mem.size) - PATCH_CTX_SLOTS_REQUIRED_PER_ENTRY)) { nvgpu_err(g, "failed to access patch_slot %d", patch_slot); @@ -2813,17 +2814,29 @@ static void gr_gk20a_free_channel_gr_ctx(struct channel_gk20a *c) c->ch_ctx.gr_ctx = NULL; } +u32 gr_gk20a_get_patch_slots(struct gk20a *g) +{ + return PATCH_CTX_SLOTS_PER_PAGE; +} + static int gr_gk20a_alloc_channel_patch_ctx(struct gk20a *g, struct channel_gk20a *c) { struct patch_desc *patch_ctx = &c->ch_ctx.patch_ctx; struct vm_gk20a *ch_vm = c->vm; + u32 alloc_size; int err = 0; gk20a_dbg_fn(""); + alloc_size = g->ops.gr.get_patch_slots(g) * + PATCH_CTX_SLOTS_REQUIRED_PER_ENTRY; + + nvgpu_log(g, gpu_dbg_info, "patch buffer size in entries: %d", + alloc_size); + err = nvgpu_dma_alloc_map_flags_sys(ch_vm, NVGPU_DMA_NO_KERNEL_MAPPING, - PATCH_CTX_SLOTS_MAX * sizeof(u32), &patch_ctx->mem); + alloc_size * sizeof(u32), &patch_ctx->mem); if (err) return err; -- cgit v1.2.2