From 21c7a00f18c53f01d18d8564567f1bea46e23703 Mon Sep 17 00:00:00 2001 From: Aparna Das Date: Tue, 18 Jun 2019 14:41:57 -0700 Subject: [PATCH] gpu: nvgpu: vgpu: create hal vgpu unit File vgpu_fifo_gv11b.c contained syncpoint related implementation specific to gv11b. Move the implementations to a new file in hal directory for vgpu hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c. Also move function vgpu_gv11b_init_fifo_setup_hw() to a new file in hal directory for vgpu hal/vgpu/fifo/fifo_gv11b_vgpu.c. Add a new yaml file nvgpu-hal-vgpu.yaml that contains vgpu specific hal files. Update arch yaml to reflect the above changes. Jira GVSCI-994 Change-Id: Ie33614473d5fd3fcd624c70709b109c4e45725ef Signed-off-by: Aparna Das Reviewed-on: https://git-master.nvidia.com/r/2138390 Reviewed-by: Thomas Fleury Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Nirav Patel Reviewed-by: mobile promotions Tested-by: mobile promotions --- arch/nvgpu-hal-vgpu.yaml | 21 +++++++++++ arch/nvgpu-vgpu.yaml | 2 -- arch/nvgpu.yaml | 8 ++++- drivers/gpu/nvgpu/Makefile | 5 +-- drivers/gpu/nvgpu/Makefile.sources | 5 +-- .../nvgpu/common/vgpu/gv11b/vgpu_hal_gv11b.c | 12 ++++--- .../gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.c | 36 +++++++++++++++++++ .../gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.h | 30 ++++++++++++++++ .../vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c} | 18 +++------- .../vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h} | 18 ++++++---- 10 files changed, 122 insertions(+), 33 deletions(-) create mode 100644 arch/nvgpu-hal-vgpu.yaml create mode 100644 drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.c create mode 100644 drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.h rename drivers/gpu/nvgpu/{common/vgpu/fifo/vgpu_fifo_gv11b.c => hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c} (90%) rename drivers/gpu/nvgpu/{common/vgpu/fifo/vgpu_fifo_gv11b.h => hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h} (77%) diff --git a/arch/nvgpu-hal-vgpu.yaml b/arch/nvgpu-hal-vgpu.yaml new file mode 100644 index 000000000..97ea99780 --- /dev/null +++ b/arch/nvgpu-hal-vgpu.yaml @@ -0,0 +1,21 @@ +# Copyright (c) 2019, NVIDIA CORPORATION. All Rights Reserved. +# +# VGPU HAL units. +# + +fifo: + safe : no + owner: Aparna D + children: + fifo: + safe: no + sources: [ hal/vgpu/fifo/fifo_gv11b_vgpu.c, + hal/vgpu/fifo/fifo_gv11b_vgpu.h ] + +sync: + safe: no + owner: Aparna D + children: + syncpt: + sources: [ hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c, + hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h ] diff --git a/arch/nvgpu-vgpu.yaml b/arch/nvgpu-vgpu.yaml index c4f29ad94..45acdb4b6 100644 --- a/arch/nvgpu-vgpu.yaml +++ b/arch/nvgpu-vgpu.yaml @@ -36,8 +36,6 @@ all: common/vgpu/fifo/runlist_vgpu.h, common/vgpu/fifo/userd_vgpu.c, common/vgpu/fifo/userd_vgpu.h, - common/vgpu/fifo/vgpu_fifo_gv11b.c, - common/vgpu/fifo/vgpu_fifo_gv11b.h, common/vgpu/gp10b/vgpu_hal_gp10b.c, common/vgpu/gr/ctx_vgpu.c, common/vgpu/gr/ctx_vgpu.h, diff --git a/arch/nvgpu.yaml b/arch/nvgpu.yaml index 0b396c4c9..0778506d3 100644 --- a/arch/nvgpu.yaml +++ b/arch/nvgpu.yaml @@ -47,12 +47,18 @@ nvgpu: children: !include nvgpu-interface.yaml - # Virtualizatikon code. + # Virtualization code. vgpu: safe: yes children: !include nvgpu-vgpu.yaml + # Virtualization HAL code. + hal-vgpu: + safe: yes + children: + !include nvgpu-hal-vgpu.yaml + # A meta-element for the GPU HW. A good example of this is the HW headers. # This is not code we write in nvgpu, but we import it from the GPU HW # tree (with a little tranformation - the gen reg scrip). diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index ccc833741..17e11196e 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -597,7 +597,6 @@ nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \ common/vgpu/fifo/engines_vgpu.o \ common/vgpu/fifo/preempt_vgpu.o \ common/vgpu/fifo/runlist_vgpu.o \ - common/vgpu/fifo/vgpu_fifo_gv11b.o \ common/vgpu/fifo/ramfc_vgpu.o \ common/vgpu/fifo/userd_vgpu.o \ common/vgpu/ce_vgpu.o \ @@ -615,7 +614,9 @@ nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \ common/vgpu/gr/fecs_trace_vgpu.o \ common/vgpu/gp10b/vgpu_hal_gp10b.o \ common/vgpu/gv11b/vgpu_gv11b.o \ - common/vgpu/gv11b/vgpu_hal_gv11b.o + common/vgpu/gv11b/vgpu_hal_gv11b.o \ + hal/vgpu/fifo/fifo_gv11b_vgpu.o \ + hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.o nvgpu-$(CONFIG_NVGPU_CYCLESTATS) += \ common/perf/cyclestats_snapshot.o \ diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index 68eb18a92..f12be3af7 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources @@ -438,7 +438,6 @@ srcs += common/vgpu/init/init_vgpu.c \ common/vgpu/fifo/engines_vgpu.c \ common/vgpu/fifo/preempt_vgpu.c \ common/vgpu/fifo/runlist_vgpu.c \ - common/vgpu/fifo/vgpu_fifo_gv11b.c \ common/vgpu/fifo/ramfc_vgpu.c \ common/vgpu/fifo/userd_vgpu.c \ common/vgpu/perf/perf_vgpu.c \ @@ -454,7 +453,9 @@ srcs += common/vgpu/init/init_vgpu.c \ common/vgpu/ce_vgpu.c \ common/vgpu/gv11b/vgpu_gv11b.c \ common/vgpu/gv11b/vgpu_hal_gv11b.c \ - common/vgpu/gp10b/vgpu_hal_gp10b.c + common/vgpu/gp10b/vgpu_hal_gp10b.c \ + hal/vgpu/fifo/fifo_gv11b_vgpu.c \ + hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c ifeq ($(CONFIG_NVGPU_COMPRESSION),1) srcs += common/vgpu/cbc/cbc_vgpu.c diff --git a/drivers/gpu/nvgpu/common/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/common/vgpu/gv11b/vgpu_hal_gv11b.c index befe45dff..de847a70d 100644 --- a/drivers/gpu/nvgpu/common/vgpu/gv11b/vgpu_hal_gv11b.c +++ b/drivers/gpu/nvgpu/common/vgpu/gv11b/vgpu_hal_gv11b.c @@ -84,8 +84,11 @@ #include "hal/sync/sema_cmdbuf_gv11b.h" #include "hal/init/hal_gv11b.h" #include "hal/init/hal_gv11b_litter.h" - #include "hal/fifo/channel_gv11b.h" + +#include "hal/vgpu/fifo/fifo_gv11b_vgpu.h" +#include "hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h" + #include "common/clk_arb/clk_arb_gp10b.h" #include @@ -112,7 +115,6 @@ #include "common/vgpu/perf/perf_vgpu.h" #include "common/vgpu/gr/fecs_trace_vgpu.h" #include "common/vgpu/perf/cyclestats_snapshot_vgpu.h" -#include "common/vgpu/fifo/vgpu_fifo_gv11b.h" #include "common/vgpu/ptimer/ptimer_vgpu.h" #include "vgpu_hal_gv11b.h" @@ -567,8 +569,8 @@ static const struct gpu_ops vgpu_gv11b_ops = { .sync = { #ifdef CONFIG_TEGRA_GK20A_NVHOST .syncpt = { - .alloc_buf = vgpu_gv11b_fifo_alloc_buf, - .free_buf = vgpu_gv11b_fifo_free_buf, + .alloc_buf = vgpu_gv11b_syncpt_alloc_buf, + .free_buf = vgpu_gv11b_syncpt_free_buf, .add_wait_cmd = gv11b_syncpt_add_wait_cmd, .get_wait_cmd_size = gv11b_syncpt_get_wait_cmd_size, @@ -577,7 +579,7 @@ static const struct gpu_ops vgpu_gv11b_ops = { .add_incr_cmd = gv11b_syncpt_add_incr_cmd, .get_incr_cmd_size = gv11b_syncpt_get_incr_cmd_size, - .get_sync_ro_map = vgpu_gv11b_fifo_get_sync_ro_map, + .get_sync_ro_map = vgpu_gv11b_syncpt_get_sync_ro_map, }, #endif .sema = { diff --git a/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.c b/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.c new file mode 100644 index 000000000..803f041c0 --- /dev/null +++ b/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.c @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#include +#include + +#include "fifo_gv11b_vgpu.h" + +int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g) +{ + struct nvgpu_fifo *f = &g->fifo; + struct vgpu_priv_data *priv = vgpu_get_priv_data(g); + + f->max_subctx_count = priv->constants.max_subctx_count; + + return 0; +} diff --git a/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.h b/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.h new file mode 100644 index 000000000..8ca638998 --- /dev/null +++ b/drivers/gpu/nvgpu/hal/vgpu/fifo/fifo_gv11b_vgpu.h @@ -0,0 +1,30 @@ +/* + * 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_FIFO_GV11B_VGPU_H +#define NVGPU_FIFO_GV11B_VGPU_H + +struct gk20a; + +int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g); + +#endif diff --git a/drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.c b/drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c similarity index 90% rename from drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.c rename to drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c index d383b6ae5..046fd4a82 100644 --- a/drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.c +++ b/drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.c @@ -27,7 +27,7 @@ #include #include -#include "common/vgpu/fifo/vgpu_fifo_gv11b.h" +#include "syncpt_cmdbuf_gv11b_vgpu.h" #include "common/vgpu/ivc/comm_vgpu.h" #ifdef CONFIG_TEGRA_GK20A_NVHOST @@ -73,7 +73,7 @@ static int set_syncpt_ro_map_gpu_va_locked(struct vm_gk20a *vm) return 0; } -int vgpu_gv11b_fifo_alloc_buf(struct nvgpu_channel *c, +int vgpu_gv11b_syncpt_alloc_buf(struct nvgpu_channel *c, u32 syncpt_id, struct nvgpu_mem *syncpt_buf) { int err; @@ -120,7 +120,7 @@ int vgpu_gv11b_fifo_alloc_buf(struct nvgpu_channel *c, return 0; } -void vgpu_gv11b_fifo_free_buf(struct nvgpu_channel *c, +void vgpu_gv11b_syncpt_free_buf(struct nvgpu_channel *c, struct nvgpu_mem *syncpt_buf) { nvgpu_gmmu_unmap(c->vm, syncpt_buf, syncpt_buf->gpu_va); @@ -128,7 +128,7 @@ void vgpu_gv11b_fifo_free_buf(struct nvgpu_channel *c, nvgpu_dma_free(c->g, syncpt_buf); } -int vgpu_gv11b_fifo_get_sync_ro_map(struct vm_gk20a *vm, +int vgpu_gv11b_syncpt_get_sync_ro_map(struct vm_gk20a *vm, u64 *base_gpuva, u32 *sync_size) { struct gk20a *g = gk20a_from_vm(vm); @@ -147,13 +147,3 @@ int vgpu_gv11b_fifo_get_sync_ro_map(struct vm_gk20a *vm, return 0; } #endif /* CONFIG_TEGRA_GK20A_NVHOST */ - -int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g) -{ - struct nvgpu_fifo *f = &g->fifo; - struct vgpu_priv_data *priv = vgpu_get_priv_data(g); - - f->max_subctx_count = priv->constants.max_subctx_count; - - return 0; -} diff --git a/drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.h b/drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h similarity index 77% rename from drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.h rename to drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h index 56507ade1..aca50818f 100644 --- a/drivers/gpu/nvgpu/common/vgpu/fifo/vgpu_fifo_gv11b.h +++ b/drivers/gpu/nvgpu/hal/vgpu/sync/syncpt_cmdbuf_gv11b_vgpu.h @@ -20,16 +20,20 @@ * DEALINGS IN THE SOFTWARE. */ -#ifndef NVGPU_VGPU_FIFO_GV11B_H -#define NVGPU_VGPU_FIFO_GV11B_H +#ifndef NVGPU_SYNCPT_CMDBUF_GV11B_VGPU_H +#define NVGPU_SYNCPT_CMDBUF_GV11B_VGPU_H + +#include struct gk20a; +struct nvgpu_channel; +struct nvgpu_mem; +struct vm_gk20a; -int vgpu_gv11b_init_fifo_setup_hw(struct gk20a *g); -int vgpu_gv11b_fifo_alloc_buf(struct nvgpu_channel *c, +int vgpu_gv11b_syncpt_alloc_buf(struct nvgpu_channel *c, u32 syncpt_id, struct nvgpu_mem *syncpt_buf); -void vgpu_gv11b_fifo_free_buf(struct nvgpu_channel *c, +void vgpu_gv11b_syncpt_free_buf(struct nvgpu_channel *c, struct nvgpu_mem *syncpt_buf); -int vgpu_gv11b_fifo_get_sync_ro_map(struct vm_gk20a *vm, +int vgpu_gv11b_syncpt_get_sync_ro_map(struct vm_gk20a *vm, u64 *base_gpuva, u32 *sync_size); -#endif /* NVGPU_VGPU_FIFO_GV11B_H */ +#endif /* NVGPU_SYNCPT_CMDBUF_GV11B_VGPU_H */