From 32353ab744937add05253cea617f397ea3d13920 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Mon, 11 Dec 2017 11:33:48 -0800 Subject: gpu: nvgpu: Implement abstraction for finding TID Implement abstraction for finding the thread ID of thread currently being run. This is tracked for context switch tracing. In Linux kernel this is implemented by returning PID. Change-Id: Id46a318894f9a2ff3c85d2c8ef0b02c52783f122 Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1627239 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/os_sched.c | 5 +++++ drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 5 +++-- drivers/gpu/nvgpu/include/nvgpu/os_sched.h | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/os_sched.c b/drivers/gpu/nvgpu/common/linux/os_sched.c index ddaaad0f..586b35eb 100644 --- a/drivers/gpu/nvgpu/common/linux/os_sched.c +++ b/drivers/gpu/nvgpu/common/linux/os_sched.c @@ -15,6 +15,11 @@ #include +int nvgpu_current_tid(struct gk20a *g) +{ + return current->pid; +} + int nvgpu_current_pid(struct gk20a *g) { return current->tgid; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 07ae5a16..f4a49a4b 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "gk20a.h" #include "dbg_gpu_gk20a.h" @@ -726,8 +727,8 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, /* now the channel is in a limbo out of the free list but not marked as * alive and used (i.e. get-able) yet */ - ch->pid = current->pid; - ch->tgid = current->tgid; /* process granularity for FECS traces */ + ch->pid = nvgpu_current_tid(g); + ch->tgid = nvgpu_current_pid(g); /* process granularity for FECS traces */ /* By default, channel is regular (non-TSG) channel */ ch->tsgid = NVGPU_INVALID_TSG_ID; diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_sched.h b/drivers/gpu/nvgpu/include/nvgpu/os_sched.h index 61cee4ad..97dc9a57 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/os_sched.h +++ b/drivers/gpu/nvgpu/include/nvgpu/os_sched.h @@ -25,6 +25,12 @@ struct gk20a; +/** + * nvgpu_current_tid - Query the id of current thread + * + */ +int nvgpu_current_tid(struct gk20a *g); + /** * nvgpu_current_pid - Query the id of current process * -- cgit v1.2.2