summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/nvgpu/Makefile1
-rw-r--r--drivers/gpu/nvgpu/common/linux/os_sched.c21
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/os_sched.h34
4 files changed, 58 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 8a95065f..47c7e7d7 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -49,6 +49,7 @@ nvgpu-y := \
49 common/linux/channel.o \ 49 common/linux/channel.o \
50 common/linux/ce2.o \ 50 common/linux/ce2.o \
51 common/linux/sim.o \ 51 common/linux/sim.o \
52 common/linux/os_sched.o \
52 common/mm/nvgpu_allocator.o \ 53 common/mm/nvgpu_allocator.o \
53 common/mm/bitmap_allocator.o \ 54 common/mm/bitmap_allocator.o \
54 common/mm/buddy_allocator.o \ 55 common/mm/buddy_allocator.o \
diff --git a/drivers/gpu/nvgpu/common/linux/os_sched.c b/drivers/gpu/nvgpu/common/linux/os_sched.c
new file mode 100644
index 00000000..ddaaad0f
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/os_sched.c
@@ -0,0 +1,21 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13
14#include <nvgpu/os_sched.h>
15
16#include <linux/sched.h>
17
18int nvgpu_current_pid(struct gk20a *g)
19{
20 return current->tgid;
21}
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
index 4efcfda8..64d521a0 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
@@ -22,6 +22,7 @@
22 22
23#include <nvgpu/kmem.h> 23#include <nvgpu/kmem.h>
24#include <nvgpu/log.h> 24#include <nvgpu/log.h>
25#include <nvgpu/os_sched.h>
25 26
26#include "gk20a.h" 27#include "gk20a.h"
27#include "tsg_gk20a.h" 28#include "tsg_gk20a.h"
@@ -286,7 +287,7 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g)
286 tsg->timeslice_timeout = 0; 287 tsg->timeslice_timeout = 0;
287 tsg->timeslice_scale = 0; 288 tsg->timeslice_scale = 0;
288 tsg->runlist_id = ~0; 289 tsg->runlist_id = ~0;
289 tsg->tgid = current->tgid; 290 tsg->tgid = nvgpu_current_pid(g);
290 291
291 if (g->ops.fifo.init_eng_method_buffers) 292 if (g->ops.fifo.init_eng_method_buffers)
292 g->ops.fifo.init_eng_method_buffers(g, tsg); 293 g->ops.fifo.init_eng_method_buffers(g, tsg);
diff --git a/drivers/gpu/nvgpu/include/nvgpu/os_sched.h b/drivers/gpu/nvgpu/include/nvgpu/os_sched.h
new file mode 100644
index 00000000..61cee4ad
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/os_sched.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __NVGPU_OS_SCHED_H__
24#define __NVGPU_OS_SCHED_H__
25
26struct gk20a;
27
28/**
29 * nvgpu_current_pid - Query the id of current process
30 *
31 */
32int nvgpu_current_pid(struct gk20a *g);
33
34#endif /* __NVGPU_OS_SCHED_H__ */