mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: remove use of nvgpu_ctxsw_trace_entry
- Remove the usage of nvgpu_ctxsw_trace_entry splattered across nvgpu, and replace with a struct defined in common code. The usage is still inside Linux, but this helps the subsequent unification efforts, e.g. to unify the fecs trace path. - Remove "asm/barrier.h" as "nvgpu/barrier.h" is already included. EVLR-3078 Change-Id: Iabfb105b891b0078ed326a8047ef14ebe1888cf2 Signed-off-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1803208 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
8c8cdacf7a
commit
eb97fc52a9
@@ -20,7 +20,6 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <asm/barrier.h>
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#include <linux/debugfs.h>
|
||||
#endif
|
||||
@@ -259,7 +258,7 @@ static pid_t gk20a_fecs_trace_find_pid(struct gk20a *g, u32 context_ptr)
|
||||
static int gk20a_fecs_trace_ring_read(struct gk20a *g, int index)
|
||||
{
|
||||
int i;
|
||||
struct nvgpu_ctxsw_trace_entry entry = { };
|
||||
struct nvgpu_gpu_ctxsw_trace_entry entry = { };
|
||||
struct gk20a_fecs_trace *trace = g->fecs_trace;
|
||||
pid_t cur_pid;
|
||||
pid_t new_pid;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2017-2018, 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"),
|
||||
@@ -28,7 +28,21 @@
|
||||
struct gk20a;
|
||||
struct tsg_gk20a;
|
||||
struct channel_gk20a;
|
||||
struct nvgpu_ctxsw_trace_entry;
|
||||
|
||||
/*
|
||||
* The binary format of 'struct nvgpu_gpu_ctxsw_trace_entry' introduced here
|
||||
* should match that of 'struct nvgpu_ctxsw_trace_entry' defined in uapi
|
||||
* header, since this struct is intended to be a mirror copy of the uapi
|
||||
* struct.
|
||||
*/
|
||||
struct nvgpu_gpu_ctxsw_trace_entry {
|
||||
u8 tag;
|
||||
u8 vmid;
|
||||
u16 seqno; /* sequence number to detect drops */
|
||||
u32 context_id; /* context_id as allocated by FECS */
|
||||
u64 pid; /* 64-bit is max bits of different OS pid */
|
||||
u64 timestamp; /* 64-bit time */
|
||||
};
|
||||
|
||||
int gk20a_ctxsw_trace_init(struct gk20a *g);
|
||||
|
||||
@@ -37,7 +51,7 @@ void gk20a_ctxsw_trace_tsg_reset(struct gk20a *g, struct tsg_gk20a *tsg);
|
||||
|
||||
void gk20a_ctxsw_trace_cleanup(struct gk20a *g);
|
||||
int gk20a_ctxsw_trace_write(struct gk20a *g,
|
||||
struct nvgpu_ctxsw_trace_entry *entry);
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entry);
|
||||
void gk20a_ctxsw_trace_wake_up(struct gk20a *g, int vmid);
|
||||
|
||||
#ifdef CONFIG_GK20A_CTXSW_TRACE
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
#include <linux/poll.h>
|
||||
#include <trace/events/gk20a.h>
|
||||
#include <uapi/linux/nvgpu.h>
|
||||
#include <nvgpu/ctxsw_trace.h>
|
||||
|
||||
#include "gk20a/gk20a.h"
|
||||
#include "gk20a/gr_gk20a.h"
|
||||
#include "gk20a/fecs_trace_gk20a.h"
|
||||
|
||||
#include <nvgpu/kmem.h>
|
||||
#include <nvgpu/log.h>
|
||||
@@ -43,7 +45,7 @@ struct gk20a_ctxsw_dev {
|
||||
struct gk20a *g;
|
||||
|
||||
struct nvgpu_ctxsw_ring_header *hdr;
|
||||
struct nvgpu_ctxsw_trace_entry *ents;
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *ents;
|
||||
struct nvgpu_ctxsw_trace_filter filter;
|
||||
bool write_enabled;
|
||||
struct nvgpu_cond readout_wq;
|
||||
@@ -75,6 +77,17 @@ static inline int ring_len(struct nvgpu_ctxsw_ring_header *hdr)
|
||||
return (hdr->write_idx - hdr->read_idx) % hdr->num_ents;
|
||||
}
|
||||
|
||||
static void nvgpu_set_ctxsw_trace_entry(struct nvgpu_ctxsw_trace_entry *entry_dst,
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entry_src)
|
||||
{
|
||||
entry_dst->tag = entry_src->tag;
|
||||
entry_dst->vmid = entry_src->vmid;
|
||||
entry_dst->seqno = entry_src->seqno;
|
||||
entry_dst->context_id = entry_src->context_id;
|
||||
entry_dst->pid = entry_src->pid;
|
||||
entry_dst->timestamp = entry_src->timestamp;
|
||||
}
|
||||
|
||||
ssize_t gk20a_ctxsw_dev_read(struct file *filp, char __user *buf, size_t size,
|
||||
loff_t *off)
|
||||
{
|
||||
@@ -83,6 +96,7 @@ ssize_t gk20a_ctxsw_dev_read(struct file *filp, char __user *buf, size_t size,
|
||||
struct nvgpu_ctxsw_ring_header *hdr = dev->hdr;
|
||||
struct nvgpu_ctxsw_trace_entry __user *entry =
|
||||
(struct nvgpu_ctxsw_trace_entry *) buf;
|
||||
struct nvgpu_ctxsw_trace_entry user_entry;
|
||||
size_t copied = 0;
|
||||
int err;
|
||||
|
||||
@@ -101,11 +115,12 @@ ssize_t gk20a_ctxsw_dev_read(struct file *filp, char __user *buf, size_t size,
|
||||
nvgpu_mutex_acquire(&dev->write_lock);
|
||||
}
|
||||
|
||||
while (size >= sizeof(struct nvgpu_ctxsw_trace_entry)) {
|
||||
while (size >= sizeof(struct nvgpu_gpu_ctxsw_trace_entry)) {
|
||||
if (ring_is_empty(hdr))
|
||||
break;
|
||||
|
||||
if (copy_to_user(entry, &dev->ents[hdr->read_idx],
|
||||
nvgpu_set_ctxsw_trace_entry(&user_entry, &dev->ents[hdr->read_idx]);
|
||||
if (copy_to_user(entry, &user_entry,
|
||||
sizeof(*entry))) {
|
||||
nvgpu_mutex_release(&dev->write_lock);
|
||||
return -EFAULT;
|
||||
@@ -169,7 +184,7 @@ static int gk20a_ctxsw_dev_alloc_buffer(struct gk20a_ctxsw_dev *dev,
|
||||
|
||||
|
||||
dev->hdr = buf;
|
||||
dev->ents = (struct nvgpu_ctxsw_trace_entry *) (dev->hdr + 1);
|
||||
dev->ents = (struct nvgpu_gpu_ctxsw_trace_entry *) (dev->hdr + 1);
|
||||
dev->size = size;
|
||||
dev->num_ents = dev->hdr->num_ents;
|
||||
|
||||
@@ -191,8 +206,8 @@ int gk20a_ctxsw_dev_ring_alloc(struct gk20a *g,
|
||||
hdr->magic = NVGPU_CTXSW_RING_HEADER_MAGIC;
|
||||
hdr->version = NVGPU_CTXSW_RING_HEADER_VERSION;
|
||||
hdr->num_ents = (*size - sizeof(struct nvgpu_ctxsw_ring_header))
|
||||
/ sizeof(struct nvgpu_ctxsw_trace_entry);
|
||||
hdr->ent_size = sizeof(struct nvgpu_ctxsw_trace_entry);
|
||||
/ sizeof(struct nvgpu_gpu_ctxsw_trace_entry);
|
||||
hdr->ent_size = sizeof(struct nvgpu_gpu_ctxsw_trace_entry);
|
||||
hdr->drop_count = 0;
|
||||
hdr->read_idx = 0;
|
||||
hdr->write_idx = 0;
|
||||
@@ -327,9 +342,9 @@ int gk20a_ctxsw_dev_open(struct inode *inode, struct file *filp)
|
||||
n = g->ops.fecs_trace.max_entries(g, &dev->filter);
|
||||
|
||||
size = sizeof(struct nvgpu_ctxsw_ring_header) +
|
||||
n * sizeof(struct nvgpu_ctxsw_trace_entry);
|
||||
n * sizeof(struct nvgpu_gpu_ctxsw_trace_entry);
|
||||
nvgpu_log(g, gpu_dbg_ctxsw, "size=%zu entries=%d ent_size=%zu",
|
||||
size, n, sizeof(struct nvgpu_ctxsw_trace_entry));
|
||||
size, n, sizeof(struct nvgpu_gpu_ctxsw_trace_entry));
|
||||
|
||||
err = gk20a_ctxsw_dev_alloc_buffer(dev, size);
|
||||
if (!err) {
|
||||
@@ -583,7 +598,7 @@ void gk20a_ctxsw_trace_cleanup(struct gk20a *g)
|
||||
}
|
||||
|
||||
int gk20a_ctxsw_trace_write(struct gk20a *g,
|
||||
struct nvgpu_ctxsw_trace_entry *entry)
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entry)
|
||||
{
|
||||
struct nvgpu_ctxsw_ring_header *hdr;
|
||||
struct gk20a_ctxsw_dev *dev;
|
||||
@@ -692,7 +707,7 @@ void gk20a_ctxsw_trace_wake_up(struct gk20a *g, int vmid)
|
||||
void gk20a_ctxsw_trace_channel_reset(struct gk20a *g, struct channel_gk20a *ch)
|
||||
{
|
||||
#ifdef CONFIG_GK20A_CTXSW_TRACE
|
||||
struct nvgpu_ctxsw_trace_entry entry = {
|
||||
struct nvgpu_gpu_ctxsw_trace_entry entry = {
|
||||
.vmid = 0,
|
||||
.tag = NVGPU_CTXSW_TAG_ENGINE_RESET,
|
||||
.context_id = 0,
|
||||
@@ -712,7 +727,7 @@ void gk20a_ctxsw_trace_channel_reset(struct gk20a *g, struct channel_gk20a *ch)
|
||||
void gk20a_ctxsw_trace_tsg_reset(struct gk20a *g, struct tsg_gk20a *tsg)
|
||||
{
|
||||
#ifdef CONFIG_GK20A_CTXSW_TRACE
|
||||
struct nvgpu_ctxsw_trace_entry entry = {
|
||||
struct nvgpu_gpu_ctxsw_trace_entry entry = {
|
||||
.vmid = 0,
|
||||
.tag = NVGPU_CTXSW_TAG_ENGINE_RESET,
|
||||
.context_id = 0,
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
|
||||
#include "gk20a/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_ctxsw_trace_entry *entries;
|
||||
struct nvgpu_gpu_ctxsw_trace_entry *entries;
|
||||
int num_entries;
|
||||
bool enabled;
|
||||
void *buf;
|
||||
|
||||
Reference in New Issue
Block a user