From f0a5f97ebba43b53cc64ce82922db6b0982766c0 Mon Sep 17 00:00:00 2001 From: Vaibhav Kachore Date: Tue, 26 Mar 2019 16:09:22 +0530 Subject: [PATCH] gpu: nvgpu: vgpu: initialize tgid for FECS trace - "tsg->tgid" is used for getting "pid" of contexts in FECS trace support. - "tsg->tgid" was unitialized for virtualized platforms which was resulting in "pid" to be "0" for all contexts. - This patch initializes tgid to fix this issue. Jira NVGPU-1880 Change-Id: I59c30aca4609d61d09c465b7ec39983095af669b Signed-off-by: Vaibhav Kachore Reviewed-on: https://git-master.nvidia.com/r/2081759 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/tsg.c | 7 +++---- drivers/gpu/nvgpu/common/vgpu/tsg_vgpu.c | 1 + drivers/gpu/nvgpu/include/nvgpu/tsg.h | 2 +- drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index e8a0dc688..b92331fce 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -558,7 +558,7 @@ static struct tsg_gk20a *gk20a_tsg_acquire_unused_tsg(struct fifo_gk20a *f) return tsg; } -int gk20a_tsg_open_common(struct gk20a *g, struct tsg_gk20a *tsg) +int gk20a_tsg_open_common(struct gk20a *g, struct tsg_gk20a *tsg, pid_t pid) { u32 no_of_sm = nvgpu_gr_config_get_no_of_sm(g->gr.config); int err; @@ -576,6 +576,7 @@ int gk20a_tsg_open_common(struct gk20a *g, struct tsg_gk20a *tsg) return err; } + tsg->tgid = pid; tsg->g = g; tsg->num_active_channels = 0U; nvgpu_ref_init(&tsg->refcount); @@ -625,15 +626,13 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid) return NULL; } - err = gk20a_tsg_open_common(g, tsg); + err = gk20a_tsg_open_common(g, tsg, pid); if (err != 0) { release_used_tsg(&g->fifo, tsg); nvgpu_err(g, "tsg %d open failed %d", tsg->tsgid, err); return NULL; } - tsg->tgid = pid; - nvgpu_log(g, gpu_dbg_fn, "tsg opened %d\n", tsg->tsgid); return tsg; diff --git a/drivers/gpu/nvgpu/common/vgpu/tsg_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/tsg_vgpu.c index a777c8041..b3df95169 100644 --- a/drivers/gpu/nvgpu/common/vgpu/tsg_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/tsg_vgpu.c @@ -43,6 +43,7 @@ int vgpu_tsg_open(struct tsg_gk20a *tsg) msg.cmd = TEGRA_VGPU_CMD_TSG_OPEN; msg.handle = vgpu_get_handle(tsg->g); p->tsg_id = tsg->tsgid; + p->pid = tsg->tgid; err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); err = err ? err : msg.ret; if (err) { diff --git a/drivers/gpu/nvgpu/include/nvgpu/tsg.h b/drivers/gpu/nvgpu/include/nvgpu/tsg.h index 21491db57..191839607 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/tsg.h +++ b/drivers/gpu/nvgpu/include/nvgpu/tsg.h @@ -81,7 +81,7 @@ struct tsg_gk20a { struct nvgpu_mutex sm_exception_mask_lock; }; -int gk20a_tsg_open_common(struct gk20a *g, struct tsg_gk20a *tsg); +int gk20a_tsg_open_common(struct gk20a *g, struct tsg_gk20a *tsg, pid_t pid); struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid); void gk20a_tsg_release_common(struct gk20a *g, struct tsg_gk20a *tsg); void gk20a_tsg_release(struct nvgpu_ref *ref); diff --git a/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h b/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h index 011555e0b..d75862dfe 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h @@ -418,6 +418,7 @@ struct tegra_vgpu_tsg_timeslice_params { struct tegra_vgpu_tsg_open_rel_params { u32 tsg_id; + pid_t pid; }; /* level follows nvgpu.h definitions */