diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2017-04-25 12:00:47 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-05-04 12:14:39 -0400 |
commit | fc95237cf08975983634fd6d3ad85634f80a8a55 (patch) | |
tree | 34d89a0301552fd4e0830e16f455d5c5514f0a81 /drivers/gpu/nvgpu/common/linux | |
parent | aeb14da4a0432eb852cd99f733524fd7633529f5 (diff) |
gpu: nvgpu: Abstract threads
Add abstraction for threads. Implement them using kthreads in Linux kernel.
JIRA NVGPU-14
Change-Id: I26996d844db6bdc4b5e6f3230514a1dadb3fb07c
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1469636
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/thread.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/thread.c b/drivers/gpu/nvgpu/common/linux/thread.c new file mode 100644 index 00000000..d37b2a10 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/thread.c | |||
@@ -0,0 +1,42 @@ | |||
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 | #include <linux/kthread.h> | ||
18 | |||
19 | #include <nvgpu/thread.h> | ||
20 | |||
21 | int nvgpu_thread_create(struct nvgpu_thread *thread, | ||
22 | void *data, | ||
23 | int (*threadfn)(void *data), const char *name) | ||
24 | { | ||
25 | struct task_struct *task = kthread_create(threadfn, data, name); | ||
26 | if (IS_ERR(task)) | ||
27 | return PTR_ERR(task); | ||
28 | |||
29 | thread->task = task; | ||
30 | wake_up_process(task); | ||
31 | return 0; | ||
32 | }; | ||
33 | |||
34 | void nvgpu_thread_stop(struct nvgpu_thread *thread) | ||
35 | { | ||
36 | kthread_stop(thread->task); | ||
37 | }; | ||
38 | |||
39 | bool nvgpu_thread_should_stop(struct nvgpu_thread *thread) | ||
40 | { | ||
41 | return kthread_should_stop(); | ||
42 | }; | ||