From d39781054f63a510b0eaccee5e1099d7ae6ce132 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Fri, 25 Jan 2019 15:06:46 -0800 Subject: gpu: nvgpu: allocate ctxsw buffers once only In *_set_ctxsw_preemption_mode, only allocate buffers the first time through. Bug 200418468 Change-Id: I22d06463416615b9a9d671c32b6fe76b602a2623 Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/2004301 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: Satish Arora Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gp10b/gr_gp10b.c | 43 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'drivers/gpu/nvgpu/gp10b') diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c index be1e2038..f70a5a00 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c @@ -1,7 +1,7 @@ /* * GP10B GPU GR * - * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -1013,36 +1013,39 @@ int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g, nvgpu_log_info(g, "gfxp context attrib_cb_size=%d", attrib_cb_size); - err = gr_gp10b_alloc_buffer(vm, + /* Only allocate buffers the first time through */ + if (!nvgpu_mem_is_valid(&gr_ctx->preempt_ctxsw_buffer)) { + err = gr_gp10b_alloc_buffer(vm, g->gr.ctx_vars.preempt_image_size, &gr_ctx->preempt_ctxsw_buffer); - if (err) { - nvgpu_err(g, "cannot allocate preempt buffer"); - goto fail; - } + if (err) { + nvgpu_err(g, "cannot allocate preempt buffer"); + goto fail; + } - err = gr_gp10b_alloc_buffer(vm, + err = gr_gp10b_alloc_buffer(vm, spill_size, &gr_ctx->spill_ctxsw_buffer); - if (err) { - nvgpu_err(g, "cannot allocate spill buffer"); - goto fail_free_preempt; - } + if (err) { + nvgpu_err(g, "cannot allocate spill buffer"); + goto fail_free_preempt; + } - err = gr_gp10b_alloc_buffer(vm, + err = gr_gp10b_alloc_buffer(vm, attrib_cb_size, &gr_ctx->betacb_ctxsw_buffer); - if (err) { - nvgpu_err(g, "cannot allocate beta buffer"); - goto fail_free_spill; - } + if (err) { + nvgpu_err(g, "cannot allocate beta buffer"); + goto fail_free_spill; + } - err = gr_gp10b_alloc_buffer(vm, + err = gr_gp10b_alloc_buffer(vm, pagepool_size, &gr_ctx->pagepool_ctxsw_buffer); - if (err) { - nvgpu_err(g, "cannot allocate page pool"); - goto fail_free_betacb; + if (err) { + nvgpu_err(g, "cannot allocate page pool"); + goto fail_free_betacb; + } } gr_ctx->graphics_preempt_mode = graphics_preempt_mode; -- cgit v1.2.2