diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/thread.c | 17 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/linux/thread.h | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/thread.c b/drivers/gpu/nvgpu/common/linux/thread.c index ef783bbe..fe3906eb 100644 --- a/drivers/gpu/nvgpu/common/linux/thread.c +++ b/drivers/gpu/nvgpu/common/linux/thread.c | |||
@@ -18,15 +18,28 @@ | |||
18 | 18 | ||
19 | #include <nvgpu/thread.h> | 19 | #include <nvgpu/thread.h> |
20 | 20 | ||
21 | int nvgpu_thread_proxy(void *threaddata) | ||
22 | { | ||
23 | struct nvgpu_thread *thread = threaddata; | ||
24 | int ret = thread->fn(thread->data); | ||
25 | |||
26 | thread->running = false; | ||
27 | return ret; | ||
28 | } | ||
29 | |||
21 | int nvgpu_thread_create(struct nvgpu_thread *thread, | 30 | int nvgpu_thread_create(struct nvgpu_thread *thread, |
22 | void *data, | 31 | void *data, |
23 | int (*threadfn)(void *data), const char *name) | 32 | int (*threadfn)(void *data), const char *name) |
24 | { | 33 | { |
25 | struct task_struct *task = kthread_create(threadfn, data, name); | 34 | struct task_struct *task = kthread_create(nvgpu_thread_proxy, |
35 | thread, name); | ||
26 | if (IS_ERR(task)) | 36 | if (IS_ERR(task)) |
27 | return PTR_ERR(task); | 37 | return PTR_ERR(task); |
28 | 38 | ||
29 | thread->task = task; | 39 | thread->task = task; |
40 | thread->fn = threadfn; | ||
41 | thread->data = data; | ||
42 | thread->running = true; | ||
30 | wake_up_process(task); | 43 | wake_up_process(task); |
31 | return 0; | 44 | return 0; |
32 | }; | 45 | }; |
@@ -44,5 +57,5 @@ bool nvgpu_thread_should_stop(struct nvgpu_thread *thread) | |||
44 | 57 | ||
45 | bool nvgpu_thread_is_running(struct nvgpu_thread *thread) | 58 | bool nvgpu_thread_is_running(struct nvgpu_thread *thread) |
46 | { | 59 | { |
47 | return thread->task != NULL; | 60 | return ACCESS_ONCE(thread->running); |
48 | }; | 61 | }; |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h b/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h index 13f29515..1355319c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h +++ b/drivers/gpu/nvgpu/include/nvgpu/linux/thread.h | |||
@@ -21,6 +21,9 @@ struct task_struct; | |||
21 | 21 | ||
22 | struct nvgpu_thread { | 22 | struct nvgpu_thread { |
23 | struct task_struct *task; | 23 | struct task_struct *task; |
24 | bool running; | ||
25 | int (*fn)(void *); | ||
26 | void *data; | ||
24 | }; | 27 | }; |
25 | 28 | ||
26 | #endif /* __NVGPU_THREAD_LINUX_H__ */ | 29 | #endif /* __NVGPU_THREAD_LINUX_H__ */ |