From 82b5f356d00faad3393b7252ae5592ac82b84df4 Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Wed, 3 Apr 2019 13:40:47 +0530 Subject: [PATCH] gpu: nvgpu: make nvgpu_gr_subctx a priv struct Make struct nvgpu_gr_subctx a private struct and add an api to access subctx header. JIRA NVGPU-3060 Change-Id: Ia1f0471084f90eddd31ddc6869bd767866f9b4e2 Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/2088531 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/fecs_trace.c | 2 +- drivers/gpu/nvgpu/common/gr/subctx.c | 8 +++++ drivers/gpu/nvgpu/common/gr/subctx_priv.h | 32 +++++++++++++++++++ .../gpu/nvgpu/common/vgpu/gr/subctx_vgpu.c | 2 ++ drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 2 +- drivers/gpu/nvgpu/include/nvgpu/gr/subctx.h | 10 +++--- 6 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/nvgpu/common/gr/subctx_priv.h diff --git a/drivers/gpu/nvgpu/common/gr/fecs_trace.c b/drivers/gpu/nvgpu/common/gr/fecs_trace.c index fdfa10321..b22ebae84 100644 --- a/drivers/gpu/nvgpu/common/gr/fecs_trace.c +++ b/drivers/gpu/nvgpu/common/gr/fecs_trace.c @@ -608,7 +608,7 @@ int nvgpu_gr_fecs_trace_bind_channel(struct gk20a *g, GK20A_FECS_TRACE_NUM_RECORDS); if (nvgpu_is_enabled(g, NVGPU_FECS_TRACE_VA) && subctx != NULL) { - mem = &subctx->ctx_header; + mem = nvgpu_gr_subctx_get_ctx_header(g, subctx); } g->ops.gr.ctxsw_prog.set_ts_buffer_ptr(g, mem, addr, aperture_mask); diff --git a/drivers/gpu/nvgpu/common/gr/subctx.c b/drivers/gpu/nvgpu/common/gr/subctx.c index 30bf87b25..42b7d84d8 100644 --- a/drivers/gpu/nvgpu/common/gr/subctx.c +++ b/drivers/gpu/nvgpu/common/gr/subctx.c @@ -25,6 +25,8 @@ #include #include +#include "common/gr/subctx_priv.h" + struct nvgpu_gr_subctx *nvgpu_gr_subctx_alloc(struct gk20a *g, struct vm_gk20a *vm) { @@ -145,3 +147,9 @@ void nvgpu_gr_subctx_set_preemption_buffer_va(struct gk20a *g, } } +struct nvgpu_mem *nvgpu_gr_subctx_get_ctx_header(struct gk20a *g, + struct nvgpu_gr_subctx *subctx) +{ + return &subctx->ctx_header; +} + diff --git a/drivers/gpu/nvgpu/common/gr/subctx_priv.h b/drivers/gpu/nvgpu/common/gr/subctx_priv.h new file mode 100644 index 000000000..59b0af7f1 --- /dev/null +++ b/drivers/gpu/nvgpu/common/gr/subctx_priv.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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"), + * 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. + */ + +#ifndef NVGPU_GR_SUBCTX_PRIV_H +#define NVGPU_GR_SUBCTX_PRIV_H + +struct nvgpu_mem; + +struct nvgpu_gr_subctx { + struct nvgpu_mem ctx_header; +}; + +#endif /* NVGPU_GR_SUBCTX_PRIV_H */ diff --git a/drivers/gpu/nvgpu/common/vgpu/gr/subctx_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/gr/subctx_vgpu.c index 4e0ac4cc8..0ece097bd 100644 --- a/drivers/gpu/nvgpu/common/vgpu/gr/subctx_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/gr/subctx_vgpu.c @@ -25,6 +25,8 @@ #include #include +#include "common/gr/subctx_priv.h" + #include "subctx_vgpu.h" #include "common/vgpu/ivc/comm_vgpu.h" diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c index c196c9636..b7f1d688b 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c @@ -1769,7 +1769,7 @@ int gr_gv11b_commit_inst(struct channel_gk20a *c, u64 gpu_va) nvgpu_gr_subctx_load_ctx_header(g, c->subctx, tsg->gr_ctx, gpu_va); - ctxheader = &c->subctx->ctx_header; + ctxheader = nvgpu_gr_subctx_get_ctx_header(g, c->subctx); g->ops.ramin.set_gr_ptr(g, &c->inst_block, ctxheader->gpu_va); return 0; diff --git a/drivers/gpu/nvgpu/include/nvgpu/gr/subctx.h b/drivers/gpu/nvgpu/include/nvgpu/gr/subctx.h index 62dbde280..5610995cd 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gr/subctx.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gr/subctx.h @@ -24,14 +24,11 @@ #define NVGPU_GR_SUBCTX_H #include -#include struct gk20a; struct vm_gk20a; - -struct nvgpu_gr_subctx { - struct nvgpu_mem ctx_header; -}; +struct nvgpu_gr_subctx; +struct nvgpu_mem; struct nvgpu_gr_subctx *nvgpu_gr_subctx_alloc(struct gk20a *g, struct vm_gk20a *vm); @@ -55,4 +52,7 @@ void nvgpu_gr_subctx_set_patch_ctx(struct gk20a *g, void nvgpu_gr_subctx_set_preemption_buffer_va(struct gk20a *g, struct nvgpu_gr_subctx *subctx, struct nvgpu_gr_ctx *gr_ctx); +struct nvgpu_mem *nvgpu_gr_subctx_get_ctx_header(struct gk20a *g, + struct nvgpu_gr_subctx *subctx); + #endif /* NVGPU_GR_SUBCTX_H */