mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
Call nvgpu_dma_alloc_flags_sys without NVGPU_DMA_NO_KERNEL_MAPPING flags, since it makes CMA memory handling simple in t194 and fixes error during subcontext header free: [ 340.378910] trying to free invalid coherent area: ffffffc0135ba000^M [ 340.378921] ------------[ cut here ]------------^M [ 340.378933] WARNING: CPU: 0 PID: 1618 at /code/volta/kernel/kernel-4.9/arch/arm64/mm/dma-mapping.c:1442 __arm_dma_free.isra.4+0x160/0x168^M [ 340.378950] Modules linked in: nvgpu^M [ 340.378958] ^M [ 340.378966] CPU: 0 PID: 1618 Comm: nvogtest Tainted: G W 4.9.52-tegra-g170e0c4 #20^M [ 340.378979] Hardware name: t194pre_si (DT)^M [ 340.378988] task: ffffffc018930d80 task.stack: ffffffc017e08000^M [ 340.378999] PC is at __arm_dma_free.isra.4+0x160/0x168^M [ 340.379009] LR is at __arm_dma_free.isra.4+0x160/0x168^M [ 340.379020] pc : [<ffffff800809cfd0>] lr : [<ffffff800809cfd0>] pstate: 60400045^M [ 340.379032] sp : ffffffc017e0bbe0^M [ 340.379039] x29: ffffffc017e0bbe0 x28: 00000000935ba000 ^M [ 340.379051] x27: 0000000000001000 x26: ffffffc0135b9580 ^M [ 340.379063] x25: ffffff8009ced1b0 x24: 0000000000000010 ^M [ 340.379075] x23: ffffffc070746010 x22: 0000000080000000 ^M [ 340.379088] x21: ffffffbf004d6e80 x20: ffffffc0135ba000 ^M [ 340.379100] x19: 0000000000001000 x18: ffffffffffffffff ^M [ 340.379112] x17: 0000007fa4d8fc60 x16: ffffff800823e370 ^M [ 340.379124] x15: ffffff8009cd8690 x14: ffffff8089fb34bf ^M [ 340.379135] x13: ffffff8009fb34cd x12: 0000000000000007 ^M [ 340.379147] x11: 0000000000000325 x10: 0000000005f5e0ff ^M [ 340.379159] x9 : 0000000000000326 x8 : 3331306366666666 ^M [ 340.379172] x7 : 6666203a61657261 x6 : ffffff8009fb3505 ^M [ 340.379184] x5 : 0000000000000012 x4 : 0000000000000000 ^M [ 340.379196] x3 : 0000000000010000 x2 : 0000000000040934 ^M [ 340.379207] x1 : 0000000000000000 x0 : 0000000000000036 ^M [ 340.379219] ^M [ 340.379224] ---[ end trace 9e7ab41f55eb32d2 ]---^M [ 340.379232] Call trace:^M [ 340.379241] [<ffffff800809cfd0>] __arm_dma_free.isra.4+0x160/0x168^M [ 340.379254] [<ffffff800809e3a0>] arm_dma_free+0x48/0x60^M [ 340.379827] [<ffffff8000f01250>] nvgpu_dma_free+0x260/0x410 [nvgpu]^M [ 340.380403] [<ffffff8000fb2fac>] gv11b_free_subctx_header+0x5c/0x80 [nvgpu]^M [ 340.380980] [<ffffff8000f3ed2c>] gk20a_free_channel_ctx+0x3c/0x150 [nvgpu]^M After changing dma alloc flags to none, this issue got fixed. Bug 1930032 Change-Id: I002236373c6a3ae5d7ec80a35f166429821662b7 Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1598193 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
186 lines
5.6 KiB
C
186 lines
5.6 KiB
C
/*
|
|
* Volta GPU series Subcontext
|
|
*
|
|
* Copyright (c) 2016-2017, 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include "gk20a/gk20a.h"
|
|
|
|
#include "gv11b/subctx_gv11b.h"
|
|
|
|
#include <nvgpu/dma.h>
|
|
#include <nvgpu/log.h>
|
|
#include <nvgpu/gmmu.h>
|
|
|
|
#include <nvgpu/hw/gv11b/hw_ram_gv11b.h>
|
|
#include <nvgpu/hw/gv11b/hw_ctxsw_prog_gv11b.h>
|
|
|
|
static void gv11b_init_subcontext_pdb(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block);
|
|
|
|
static void gv11b_subctx_commit_valid_mask(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block);
|
|
static void gv11b_subctx_commit_pdb(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block);
|
|
|
|
void gv11b_free_subctx_header(struct channel_gk20a *c)
|
|
{
|
|
struct ctx_header_desc *ctx = &c->ch_ctx.ctx_header;
|
|
struct gk20a *g = c->g;
|
|
|
|
nvgpu_log(g, gpu_dbg_fn, "gv11b_free_subctx_header");
|
|
|
|
if (ctx->mem.gpu_va) {
|
|
nvgpu_gmmu_unmap(c->vm, &ctx->mem, ctx->mem.gpu_va);
|
|
|
|
nvgpu_dma_free(g, &ctx->mem);
|
|
}
|
|
}
|
|
|
|
int gv11b_alloc_subctx_header(struct channel_gk20a *c)
|
|
{
|
|
struct ctx_header_desc *ctx = &c->ch_ctx.ctx_header;
|
|
struct gk20a *g = c->g;
|
|
int ret = 0;
|
|
|
|
nvgpu_log(g, gpu_dbg_fn, "gv11b_alloc_subctx_header");
|
|
|
|
if (ctx->mem.gpu_va == 0) {
|
|
ret = nvgpu_dma_alloc_flags_sys(g,
|
|
0, /* No Special flags */
|
|
ctxsw_prog_fecs_header_v(),
|
|
&ctx->mem);
|
|
if (ret) {
|
|
nvgpu_err(g, "failed to allocate sub ctx header");
|
|
return ret;
|
|
}
|
|
ctx->mem.gpu_va = nvgpu_gmmu_map(c->vm,
|
|
&ctx->mem,
|
|
ctx->mem.size,
|
|
0, /* not GPU-cacheable */
|
|
gk20a_mem_flag_none, true,
|
|
ctx->mem.aperture);
|
|
if (!ctx->mem.gpu_va) {
|
|
nvgpu_err(g, "failed to map ctx header");
|
|
nvgpu_dma_free(g, &ctx->mem);
|
|
return -ENOMEM;
|
|
}
|
|
/* Now clear the buffer */
|
|
if (nvgpu_mem_begin(g, &ctx->mem))
|
|
return -ENOMEM;
|
|
|
|
nvgpu_memset(g, &ctx->mem, 0, 0, ctx->mem.size);
|
|
nvgpu_mem_end(g, &ctx->mem);
|
|
|
|
gv11b_init_subcontext_pdb(c, &c->inst_block);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static void gv11b_init_subcontext_pdb(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block)
|
|
{
|
|
struct gk20a *g = c->g;
|
|
|
|
gv11b_subctx_commit_pdb(c, inst_block);
|
|
gv11b_subctx_commit_valid_mask(c, inst_block);
|
|
|
|
nvgpu_log(g, gpu_dbg_info, " subctx %d instblk set", c->t19x.subctx_id);
|
|
nvgpu_mem_wr32(g, inst_block, ram_in_engine_wfi_veid_w(),
|
|
ram_in_engine_wfi_veid_f(c->t19x.subctx_id));
|
|
|
|
}
|
|
|
|
int gv11b_update_subctx_header(struct channel_gk20a *c, u64 gpu_va)
|
|
{
|
|
struct ctx_header_desc *ctx = &c->ch_ctx.ctx_header;
|
|
struct nvgpu_mem *gr_mem;
|
|
struct gk20a *g = c->g;
|
|
int ret = 0;
|
|
u32 addr_lo, addr_hi;
|
|
|
|
addr_lo = u64_lo32(gpu_va);
|
|
addr_hi = u64_hi32(gpu_va);
|
|
|
|
gr_mem = &ctx->mem;
|
|
g->ops.mm.l2_flush(g, true);
|
|
if (nvgpu_mem_begin(g, gr_mem))
|
|
return -ENOMEM;
|
|
|
|
nvgpu_mem_wr(g, gr_mem,
|
|
ctxsw_prog_main_image_context_buffer_ptr_hi_o(), addr_hi);
|
|
nvgpu_mem_wr(g, gr_mem,
|
|
ctxsw_prog_main_image_context_buffer_ptr_o(), addr_lo);
|
|
|
|
nvgpu_mem_wr(g, gr_mem,
|
|
ctxsw_prog_main_image_ctl_o(),
|
|
ctxsw_prog_main_image_ctl_type_per_veid_header_v());
|
|
nvgpu_mem_end(g, gr_mem);
|
|
return ret;
|
|
}
|
|
|
|
void gv11b_subctx_commit_valid_mask(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block)
|
|
{
|
|
struct gk20a *g = c->g;
|
|
|
|
/* Make all subctx pdbs valid */
|
|
nvgpu_mem_wr32(g, inst_block, 166, 0xffffffff);
|
|
nvgpu_mem_wr32(g, inst_block, 167, 0xffffffff);
|
|
}
|
|
|
|
void gv11b_subctx_commit_pdb(struct channel_gk20a *c,
|
|
struct nvgpu_mem *inst_block)
|
|
{
|
|
struct gk20a *g = c->g;
|
|
struct fifo_gk20a *f = &g->fifo;
|
|
struct vm_gk20a *vm = c->vm;
|
|
u32 lo, hi;
|
|
u32 subctx_id = 0;
|
|
u32 format_word;
|
|
u32 pdb_addr_lo, pdb_addr_hi;
|
|
u64 pdb_addr;
|
|
u32 aperture = nvgpu_aperture_mask(g, vm->pdb.mem,
|
|
ram_in_sc_page_dir_base_target_sys_mem_ncoh_v(),
|
|
ram_in_sc_page_dir_base_target_vid_mem_v());
|
|
|
|
pdb_addr = nvgpu_mem_get_addr(g, vm->pdb.mem);
|
|
pdb_addr_lo = u64_lo32(pdb_addr >> ram_in_base_shift_v());
|
|
pdb_addr_hi = u64_hi32(pdb_addr);
|
|
format_word = ram_in_sc_page_dir_base_target_f(
|
|
aperture, 0) |
|
|
ram_in_sc_page_dir_base_vol_f(
|
|
ram_in_sc_page_dir_base_vol_true_v(), 0) |
|
|
ram_in_sc_page_dir_base_fault_replay_tex_f(1, 0) |
|
|
ram_in_sc_page_dir_base_fault_replay_gcc_f(1, 0) |
|
|
ram_in_sc_use_ver2_pt_format_f(1, 0) |
|
|
ram_in_sc_big_page_size_f(1, 0) |
|
|
ram_in_sc_page_dir_base_lo_0_f(pdb_addr_lo);
|
|
nvgpu_log(g, gpu_dbg_info, " pdb info lo %x hi %x",
|
|
format_word, pdb_addr_hi);
|
|
for (subctx_id = 0; subctx_id < f->t19x.max_subctx_count; subctx_id++) {
|
|
lo = ram_in_sc_page_dir_base_vol_0_w() + (4 * subctx_id);
|
|
hi = ram_in_sc_page_dir_base_hi_0_w() + (4 * subctx_id);
|
|
nvgpu_mem_wr32(g, inst_block, lo, format_word);
|
|
nvgpu_mem_wr32(g, inst_block, hi, pdb_addr_hi);
|
|
}
|
|
}
|