diff --git a/drivers/gpu/nvgpu/common/linux/cde.c b/drivers/gpu/nvgpu/common/linux/cde.c index 4911afa19..f3895d5cb 100644 --- a/drivers/gpu/nvgpu/common/linux/cde.c +++ b/drivers/gpu/nvgpu/common/linux/cde.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -1287,7 +1288,7 @@ static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx) return -ENOSYS; } - tsg = gk20a_tsg_open(g); + tsg = gk20a_tsg_open(g, nvgpu_current_pid(g)); if (!tsg) { nvgpu_err(g, "cde: could not create TSG"); err = -ENOMEM; diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index 70baeb2d8..a360d0dfe 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2017-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, @@ -18,6 +18,7 @@ #include #include #include +#include /* * This is required for nvgpu_vm_find_buf() which is used in the tracing @@ -251,7 +252,8 @@ struct channel_gk20a *gk20a_open_new_channel_with_cb(struct gk20a *g, struct channel_gk20a *ch; struct nvgpu_channel_linux *priv; - ch = gk20a_open_new_channel(g, runlist_id, is_privileged_channel); + ch = gk20a_open_new_channel(g, runlist_id, is_privileged_channel, + nvgpu_current_pid(g), nvgpu_current_tid(g)); if (ch) { priv = ch->os_priv; diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 5b4dda6ce..b4d7d5018 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -1,7 +1,7 @@ /* * GK20A Graphics channel * - * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-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, @@ -33,6 +33,7 @@ #include #include #include +#include #include "gk20a/gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" @@ -495,7 +496,8 @@ static int __gk20a_channel_open(struct gk20a *g, goto fail_busy; } /* All the user space channel should be non privilege */ - ch = gk20a_open_new_channel(g, runlist_id, false); + ch = gk20a_open_new_channel(g, runlist_id, false, + nvgpu_current_pid(g), nvgpu_current_tid(g)); gk20a_idle(g); if (!ch) { nvgpu_err(g, diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c index 60aca5ec7..be2315bd2 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c @@ -24,6 +24,7 @@ #include #include +#include #include "gk20a/gk20a.h" #include "gk20a/tsg_gk20a.h" @@ -370,7 +371,7 @@ int nvgpu_ioctl_tsg_open(struct gk20a *g, struct file *filp) goto free_ref; } - tsg = gk20a_tsg_open(g); + tsg = gk20a_tsg_open(g, nvgpu_current_pid(g)); if (!tsg) { nvgpu_kfree(g, priv); err = -ENOMEM; diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index 87eff8138..6da65abd3 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c @@ -1,7 +1,7 @@ /* * GK20A Graphics Copy Engine (gr host) * - * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-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"), @@ -24,6 +24,7 @@ #include #include +#include #include "gk20a.h" @@ -430,7 +431,7 @@ u32 gk20a_ce_create_context(struct gk20a *g, ce_ctx->vm = g->mm.ce.vm; /* allocate a tsg if needed */ - ce_ctx->tsg = gk20a_tsg_open(g); + ce_ctx->tsg = gk20a_tsg_open(g, nvgpu_current_pid(g)); if (!ce_ctx->tsg) { nvgpu_err(g, "ce: gk20a tsg not available"); err = -ENOMEM; @@ -438,7 +439,8 @@ u32 gk20a_ce_create_context(struct gk20a *g, } /* always kernel client needs privileged channel */ - ce_ctx->ch = gk20a_open_new_channel(g, runlist_id, true); + ce_ctx->ch = gk20a_open_new_channel(g, runlist_id, true, + nvgpu_current_pid(g), nvgpu_current_tid(g)); if (!ce_ctx->ch) { nvgpu_err(g, "ce: gk20a channel not available"); err = -ENOMEM; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index f50c37a75..2f5514a8f 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -615,7 +615,8 @@ void __gk20a_channel_kill(struct channel_gk20a *ch) struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, s32 runlist_id, - bool is_privileged_channel) + bool is_privileged_channel, + pid_t pid, pid_t tid) { struct fifo_gk20a *f = &g->fifo; struct channel_gk20a *ch; @@ -645,8 +646,8 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, /* Channel privilege level */ ch->is_privileged_channel = is_privileged_channel; - ch->pid = nvgpu_current_tid(g); - ch->tgid = nvgpu_current_pid(g); /* process granularity for FECS traces */ + ch->pid = tid; + ch->tgid = pid; /* process granularity for FECS traces */ if (g->ops.fifo.alloc_inst(g, ch)) { ch->g = NULL; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 7fcc54cc7..2b8be0690 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -367,7 +367,8 @@ int gk20a_wait_channel_idle(struct channel_gk20a *ch); /* runlist_id -1 is synonym for ENGINE_GR_GK20A runlist id */ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, s32 runlist_id, - bool is_privileged_channel); + bool is_privileged_channel, + pid_t pid, pid_t tid); int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, struct nvgpu_gpfifo_args *gpfifo_args); diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index ccb456cfa..05b8fc612 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -267,7 +267,7 @@ static struct tsg_gk20a *gk20a_tsg_acquire_unused_tsg(struct fifo_gk20a *f) return tsg; } -struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g) +struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid) { struct tsg_gk20a *tsg; int err; @@ -286,7 +286,7 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g) tsg->timeslice_timeout = 0; tsg->timeslice_scale = 0; tsg->runlist_id = ~0; - tsg->tgid = nvgpu_current_pid(g); + tsg->tgid = pid; if (g->ops.fifo.init_eng_method_buffers) g->ops.fifo.init_eng_method_buffers(g, tsg); diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h index f97dbb265..2f76477f9 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h @@ -33,7 +33,7 @@ struct channel_gk20a; bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch); -struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g); +struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid); void gk20a_tsg_release(struct nvgpu_ref *ref); int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid);