mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: vgpu: unify fecs trace
move fecs_trace_vgpu.c to be common, leaving only few functions os specific. struct gk20a_fecs_trace_header was moved to header, to share with os specific code. Jira EVLR-3275 Change-Id: I372aeb539cbca3abb87e997c9e35e6d682f9cb96 Signed-off-by: Richard Zhao <rizhao@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1831991 GVS: Gerrit_Virtual_Submit Reviewed-by: Aparna Das <aparnad@nvidia.com> Reviewed-by: Nirav Patel <nipatel@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
a053d3b12f
commit
f2cb8c5d2e
@@ -186,11 +186,11 @@ nvgpu-$(CONFIG_TEGRA_GK20A_NVHOST) += \
|
||||
|
||||
nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \
|
||||
os/linux/vgpu/platform_vgpu_tegra.o \
|
||||
os/linux/vgpu/fecs_trace_vgpu.o \
|
||||
os/linux/vgpu/sysfs_vgpu.o \
|
||||
os/linux/vgpu/vgpu_ivc.o \
|
||||
os/linux/vgpu/vgpu_ivm.o \
|
||||
os/linux/vgpu/vgpu_linux.o \
|
||||
os/linux/vgpu/fecs_trace_vgpu_linux.o \
|
||||
os/linux/vgpu/gv11b/platform_gv11b_vgpu_tegra.o
|
||||
|
||||
nvgpu-$(CONFIG_COMMON_CLK) += \
|
||||
@@ -297,6 +297,7 @@ nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \
|
||||
vgpu/css_vgpu.o \
|
||||
vgpu/ecc_vgpu.o \
|
||||
vgpu/clk_vgpu.o \
|
||||
vgpu/fecs_trace_vgpu.o \
|
||||
vgpu/gm20b/vgpu_gr_gm20b.o \
|
||||
vgpu/gp10b/vgpu_hal_gp10b.o \
|
||||
vgpu/gp10b/vgpu_gr_gp10b.o \
|
||||
|
||||
@@ -53,6 +53,18 @@ struct nvgpu_gpu_ctxsw_trace_filter {
|
||||
u64 tag_bits[(NVGPU_GPU_CTXSW_FILTER_SIZE + 63) / 64];
|
||||
};
|
||||
|
||||
/* must be consistent with nvgpu_ctxsw_ring_header */
|
||||
struct nvgpu_ctxsw_ring_header_internal {
|
||||
u32 magic;
|
||||
u32 version;
|
||||
u32 num_ents;
|
||||
u32 ent_size;
|
||||
u32 drop_count; /* excluding filtered out events */
|
||||
u32 write_seqno;
|
||||
u32 write_idx;
|
||||
u32 read_idx;
|
||||
};
|
||||
|
||||
/*
|
||||
* The binary format of 'struct nvgpu_gpu_ctxsw_trace_entry' introduced here
|
||||
* should match that of 'struct nvgpu_ctxsw_trace_entry' defined in uapi
|
||||
|
||||
53
drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu_linux.c
Normal file
53
drivers/gpu/nvgpu/os/linux/vgpu/fecs_trace_vgpu_linux.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <nvgpu/ctxsw_trace.h>
|
||||
#include <nvgpu/vgpu/tegra_vgpu.h>
|
||||
#include <nvgpu/vgpu/vgpu_ivm.h>
|
||||
#include <nvgpu/gk20a.h>
|
||||
|
||||
#include <linux/mm.h>
|
||||
|
||||
#include "vgpu/fecs_trace_vgpu.h"
|
||||
|
||||
void vgpu_fecs_trace_data_update(struct gk20a *g)
|
||||
{
|
||||
gk20a_ctxsw_trace_wake_up(g, 0);
|
||||
}
|
||||
|
||||
int vgpu_alloc_user_buffer(struct gk20a *g, void **buf, size_t *size)
|
||||
{
|
||||
struct vgpu_fecs_trace *vcst = (struct vgpu_fecs_trace *)g->fecs_trace;
|
||||
|
||||
*buf = vcst->buf;
|
||||
*size = vgpu_ivm_get_size(vcst->cookie);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vgpu_mmap_user_buffer(struct gk20a *g, struct vm_area_struct *vma)
|
||||
{
|
||||
struct vgpu_fecs_trace *vcst = (struct vgpu_fecs_trace *)g->fecs_trace;
|
||||
unsigned long size = vgpu_ivm_get_size(vcst->cookie);
|
||||
unsigned long vsize = vma->vm_end - vma->vm_start;
|
||||
|
||||
size = min(size, vsize);
|
||||
size = round_up(size, PAGE_SIZE);
|
||||
|
||||
return remap_pfn_range(vma, vma->vm_start,
|
||||
vgpu_ivm_get_ipa(vcst->cookie) >> PAGE_SHIFT,
|
||||
size,
|
||||
vma->vm_page_prot);
|
||||
}
|
||||
@@ -14,54 +14,43 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <uapi/linux/nvgpu.h>
|
||||
|
||||
#include <nvgpu/kmem.h>
|
||||
#include <nvgpu/bug.h>
|
||||
#include <nvgpu/enabled.h>
|
||||
#include <nvgpu/ctxsw_trace.h>
|
||||
#include <nvgpu/fecs_trace.h>
|
||||
#include <nvgpu/dt.h>
|
||||
#include <nvgpu/vgpu/vgpu_ivm.h>
|
||||
#include <nvgpu/vgpu/tegra_vgpu.h>
|
||||
#include <nvgpu/vgpu/vgpu.h>
|
||||
#include <nvgpu/gk20a.h>
|
||||
|
||||
#include "os/linux/os_linux.h"
|
||||
#include "gk20a/fecs_trace_gk20a.h"
|
||||
#include "vgpu/fecs_trace_vgpu.h"
|
||||
|
||||
struct vgpu_fecs_trace {
|
||||
struct tegra_hv_ivm_cookie *cookie;
|
||||
struct nvgpu_ctxsw_ring_header *header;
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entries;
|
||||
int num_entries;
|
||||
bool enabled;
|
||||
void *buf;
|
||||
};
|
||||
|
||||
int vgpu_fecs_trace_init(struct gk20a *g)
|
||||
{
|
||||
struct device *dev = dev_from_gk20a(g);
|
||||
struct device_node *np = dev->of_node;
|
||||
struct of_phandle_args args;
|
||||
struct vgpu_fecs_trace *vcst;
|
||||
u32 mempool;
|
||||
int err;
|
||||
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
if (g->fecs_trace)
|
||||
return 0;
|
||||
|
||||
vcst = nvgpu_kzalloc(g, sizeof(*vcst));
|
||||
if (!vcst)
|
||||
return -ENOMEM;
|
||||
|
||||
err = of_parse_phandle_with_fixed_args(np,
|
||||
"mempool-fecs-trace", 1, 0, &args);
|
||||
err = nvgpu_dt_read_u32_index(g, "mempool-fecs-trace", 1, &mempool);
|
||||
if (err) {
|
||||
nvgpu_info(g, "does not support fecs trace");
|
||||
goto fail;
|
||||
}
|
||||
__nvgpu_set_enabled(g, NVGPU_SUPPORT_FECS_CTXSW_TRACE, true);
|
||||
|
||||
mempool = args.args[0];
|
||||
vcst->cookie = vgpu_ivm_mempool_reserve(mempool);
|
||||
if (IS_ERR(vcst->cookie)) {
|
||||
nvgpu_info(g,
|
||||
@@ -71,8 +60,7 @@ int vgpu_fecs_trace_init(struct gk20a *g)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vcst->buf = ioremap_cache(vgpu_ivm_get_ipa(vcst->cookie),
|
||||
vgpu_ivm_get_size(vcst->cookie));
|
||||
vcst->buf = vgpu_ivm_mempool_map(vcst->cookie);
|
||||
if (!vcst->buf) {
|
||||
nvgpu_info(g, "ioremap_cache failed");
|
||||
err = -EINVAL;
|
||||
@@ -84,12 +72,15 @@ int vgpu_fecs_trace_init(struct gk20a *g)
|
||||
nvgpu_err(g, "entry size mismatch");
|
||||
goto fail;
|
||||
}
|
||||
vcst->entries = vcst->buf + sizeof(*vcst->header);
|
||||
vcst->entries = (struct nvgpu_gpu_ctxsw_trace_entry *)(
|
||||
(char *)vcst->buf + sizeof(*vcst->header));
|
||||
g->fecs_trace = (struct gk20a_fecs_trace *)vcst;
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
iounmap(vcst->buf);
|
||||
if (vcst->cookie != NULL && vcst->buf != NULL) {
|
||||
vgpu_ivm_mempool_unmap(vcst->cookie, vcst->buf);
|
||||
}
|
||||
if (vcst->cookie)
|
||||
vgpu_ivm_mempool_unreserve(vcst->cookie);
|
||||
nvgpu_kfree(g, vcst);
|
||||
@@ -100,7 +91,7 @@ int vgpu_fecs_trace_deinit(struct gk20a *g)
|
||||
{
|
||||
struct vgpu_fecs_trace *vcst = (struct vgpu_fecs_trace *)g->fecs_trace;
|
||||
|
||||
iounmap(vcst->buf);
|
||||
vgpu_ivm_mempool_unmap(vcst->cookie, vcst->buf);
|
||||
vgpu_ivm_mempool_unreserve(vcst->cookie);
|
||||
nvgpu_kfree(g, vcst);
|
||||
return 0;
|
||||
@@ -159,34 +150,11 @@ int vgpu_fecs_trace_poll(struct gk20a *g)
|
||||
return err;
|
||||
}
|
||||
|
||||
int vgpu_alloc_user_buffer(struct gk20a *g, void **buf, size_t *size)
|
||||
{
|
||||
struct vgpu_fecs_trace *vcst = (struct vgpu_fecs_trace *)g->fecs_trace;
|
||||
|
||||
*buf = vcst->buf;
|
||||
*size = vgpu_ivm_get_size(vcst->cookie);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vgpu_free_user_buffer(struct gk20a *g)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vgpu_mmap_user_buffer(struct gk20a *g, struct vm_area_struct *vma)
|
||||
{
|
||||
struct vgpu_fecs_trace *vcst = (struct vgpu_fecs_trace *)g->fecs_trace;
|
||||
unsigned long size = vgpu_ivm_get_size(vcst->cookie);
|
||||
unsigned long vsize = vma->vm_end - vma->vm_start;
|
||||
|
||||
size = min(size, vsize);
|
||||
size = round_up(size, PAGE_SIZE);
|
||||
|
||||
return remap_pfn_range(vma, vma->vm_start,
|
||||
vgpu_ivm_get_ipa(vcst->cookie) >> PAGE_SHIFT,
|
||||
size,
|
||||
vma->vm_page_prot);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GK20A_CTXSW_TRACE
|
||||
int vgpu_fecs_trace_max_entries(struct gk20a *g,
|
||||
@@ -197,10 +165,6 @@ int vgpu_fecs_trace_max_entries(struct gk20a *g,
|
||||
return vcst->header->num_ents;
|
||||
}
|
||||
|
||||
#if NVGPU_CTXSW_FILTER_SIZE != TEGRA_VGPU_FECS_TRACE_FILTER_SIZE
|
||||
#error "FECS trace filter size mismatch!"
|
||||
#endif
|
||||
|
||||
int vgpu_fecs_trace_set_filter(struct gk20a *g,
|
||||
struct nvgpu_gpu_ctxsw_trace_filter *filter)
|
||||
{
|
||||
@@ -218,8 +182,4 @@ int vgpu_fecs_trace_set_filter(struct gk20a *g,
|
||||
return err;
|
||||
}
|
||||
|
||||
void vgpu_fecs_trace_data_update(struct gk20a *g)
|
||||
{
|
||||
gk20a_ctxsw_trace_wake_up(g, 0);
|
||||
}
|
||||
#endif /* CONFIG_GK20A_CTXSW_TRACE */
|
||||
@@ -28,6 +28,18 @@
|
||||
struct gk20a;
|
||||
struct vm_area_struct;
|
||||
struct nvgpu_gpu_ctxsw_trace_filter;
|
||||
struct tegra_hv_ivm_cookie;
|
||||
struct nvgpu_gpu_ctxsw_trace_entry;
|
||||
struct nvgpu_ctxsw_ring_header_internal;
|
||||
|
||||
struct vgpu_fecs_trace {
|
||||
struct tegra_hv_ivm_cookie *cookie;
|
||||
struct nvgpu_ctxsw_ring_header_internal *header;
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entries;
|
||||
int num_entries;
|
||||
bool enabled;
|
||||
void *buf;
|
||||
};
|
||||
|
||||
void vgpu_fecs_trace_data_update(struct gk20a *g);
|
||||
int vgpu_fecs_trace_init(struct gk20a *g);
|
||||
@@ -43,5 +55,6 @@ int vgpu_fecs_trace_max_entries(struct gk20a *g,
|
||||
struct nvgpu_gpu_ctxsw_trace_filter *filter);
|
||||
int vgpu_fecs_trace_set_filter(struct gk20a *g,
|
||||
struct nvgpu_gpu_ctxsw_trace_filter *filter);
|
||||
struct tegra_hv_ivm_cookie *vgpu_fecs_trace_get_ivm(struct gk20a *g);
|
||||
|
||||
#endif /* __FECS_TRACE_VGPU_H */
|
||||
|
||||
Reference in New Issue
Block a user