diff --git a/drivers/gpu/nvgpu/common/linux/thread.c b/drivers/gpu/nvgpu/common/linux/thread.c index d37b2a10b..ef783bbe3 100644 --- a/drivers/gpu/nvgpu/common/linux/thread.c +++ b/drivers/gpu/nvgpu/common/linux/thread.c @@ -34,9 +34,15 @@ int nvgpu_thread_create(struct nvgpu_thread *thread, void nvgpu_thread_stop(struct nvgpu_thread *thread) { kthread_stop(thread->task); + thread->task = NULL; }; bool nvgpu_thread_should_stop(struct nvgpu_thread *thread) { return kthread_should_stop(); }; + +bool nvgpu_thread_is_running(struct nvgpu_thread *thread) +{ + return thread->task != NULL; +}; diff --git a/drivers/gpu/nvgpu/include/nvgpu/thread.h b/drivers/gpu/nvgpu/include/nvgpu/thread.h index 81dac7ca2..1e946119e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/thread.h +++ b/drivers/gpu/nvgpu/include/nvgpu/thread.h @@ -59,4 +59,13 @@ void nvgpu_thread_stop(struct nvgpu_thread *thread); */ bool nvgpu_thread_should_stop(struct nvgpu_thread *thread); +/** + * nvgpu_thread_is_running - Query if thread is running + * + * @thread + * + * Return true if thread is started. + */ +bool nvgpu_thread_is_running(struct nvgpu_thread *thread); + #endif /* __NVGPU_THREAD_H__ */