summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/linux/thread.h26
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/thread.h62
2 files changed, 88 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h b/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h
new file mode 100644
index 00000000..13f29515
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h
@@ -0,0 +1,26 @@
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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __NVGPU_THREAD_LINUX_H__
18#define __NVGPU_THREAD_LINUX_H__
19
20struct task_struct;
21
22struct nvgpu_thread {
23 struct task_struct *task;
24};
25
26#endif /* __NVGPU_THREAD_LINUX_H__ */
diff --git a/drivers/gpu/nvgpu/include/nvgpu/thread.h b/drivers/gpu/nvgpu/include/nvgpu/thread.h
new file mode 100644
index 00000000..81dac7ca
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/thread.h
@@ -0,0 +1,62 @@
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 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __NVGPU_THREAD_H__
18#define __NVGPU_THREAD_H__
19
20#ifdef __KERNEL__
21#include <nvgpu/linux/thread.h>
22#endif
23
24/**
25 * nvgpu_thread_create - Create and run a new thread.
26 *
27 * @thread - thread structure to use
28 * @data - data to pass to threadfn
29 * @threadfn - Thread function
30 * @name - name of the thread
31 *
32 * Create a thread and run threadfn in it. The thread stays alive as long as
33 * threadfn is running. As soon as threadfn returns the thread is destroyed.
34 *
35 * threadfn needs to continuously poll nvgpu_thread_should_stop() to determine
36 * if it should exit.
37 */
38int nvgpu_thread_create(struct nvgpu_thread *thread,
39 void *data,
40 int (*threadfn)(void *data), const char *name);
41
42/**
43 * nvgpu_thread_stop - Destroy or request to destroy a thread
44 *
45 * @thread - thread to stop
46 *
47 * Request a thread to stop by setting nvgpu_thread_should_stop() to
48 * true and wait for thread to exit.
49 */
50void nvgpu_thread_stop(struct nvgpu_thread *thread);
51
52/**
53 * nvgpu_thread_should_stop - Query if thread should stop
54 *
55 * @thread
56 *
57 * Return true if thread should exit. Can be run only in the thread's own
58 * context and with the thread as parameter.
59 */
60bool nvgpu_thread_should_stop(struct nvgpu_thread *thread);
61
62#endif /* __NVGPU_THREAD_H__ */