gpu: nvgpu: Use nvgpu_thread in FECS trace

Use nvgpu_thread for launching the FECS trace periodic poller thread.

JIRA NVGPU-14

Change-Id: Idc53d85b96ae72a367dd1447bf18a8207b9886d6
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1469649
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Terje Bergstrom
2017-04-25 09:38:40 -07:00
committed by mobile promotions
parent a7e6a8cf51
commit 7d6d8a7ec3
2 changed files with 14 additions and 16 deletions

View File

@@ -12,7 +12,6 @@
*/
#include <asm/barrier.h>
#include <linux/kthread.h>
#include <linux/wait.h>
#include <linux/ktime.h>
#include <linux/uaccess.h>

View File

@@ -12,7 +12,6 @@
*/
#include <asm/barrier.h>
#include <linux/kthread.h>
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
#endif
@@ -22,6 +21,7 @@
#include <nvgpu/bug.h>
#include <nvgpu/hashtable.h>
#include <nvgpu/circ_buf.h>
#include <nvgpu/thread.h>
#include "ctxsw_trace_gk20a.h"
#include "fecs_trace_gk20a.h"
@@ -65,7 +65,7 @@ struct gk20a_fecs_trace {
DECLARE_HASHTABLE(pid_hash_table, GK20A_FECS_TRACE_HASH_BITS);
struct nvgpu_mutex hash_lock;
struct nvgpu_mutex poll_lock;
struct task_struct *poll_task;
struct nvgpu_thread poll_task;
};
#ifdef CONFIG_GK20A_CTXSW_TRACE
@@ -382,10 +382,11 @@ done:
static int gk20a_fecs_trace_periodic_polling(void *arg)
{
struct gk20a *g = (struct gk20a *)arg;
struct gk20a_fecs_trace *trace = g->fecs_trace;
pr_info("%s: running\n", __func__);
while (!kthread_should_stop()) {
while (!nvgpu_thread_should_stop(&trace->poll_task)) {
nvgpu_usleep_range(GK20A_FECS_TRACE_FRAME_PERIOD_US,
GK20A_FECS_TRACE_FRAME_PERIOD_US * 2);
@@ -708,7 +709,7 @@ static int gk20a_fecs_trace_deinit(struct gk20a *g)
struct gk20a_fecs_trace *trace = g->fecs_trace;
gk20a_fecs_trace_debugfs_cleanup(g);
kthread_stop(trace->poll_task);
nvgpu_thread_stop(&trace->poll_task);
gk20a_fecs_trace_free_ring(g);
gk20a_fecs_trace_free_hash_table(g);
@@ -737,13 +738,13 @@ static int gk20a_gr_max_entries(struct gk20a *g,
static int gk20a_fecs_trace_enable(struct gk20a *g)
{
struct gk20a_fecs_trace *trace = g->fecs_trace;
struct task_struct *task;
int write;
int err = 0;
if (!trace)
return -EINVAL;
if (trace->poll_task)
if (nvgpu_thread_is_running(&trace->poll_task))
return 0;
/* drop data in hw buffer */
@@ -752,13 +753,13 @@ static int gk20a_fecs_trace_enable(struct gk20a *g)
write = gk20a_fecs_trace_get_write_index(g);
gk20a_fecs_trace_set_read_index(g, write);
task = kthread_run(gk20a_fecs_trace_periodic_polling, g, __func__);
if (unlikely(IS_ERR(task))) {
err = nvgpu_thread_create(&trace->poll_task, g,
gk20a_fecs_trace_periodic_polling, __func__);
if (err) {
nvgpu_warn(g,
"failed to create FECS polling task");
return PTR_ERR(task);
return err;
}
trace->poll_task = task;
return 0;
}
@@ -767,10 +768,8 @@ static int gk20a_fecs_trace_disable(struct gk20a *g)
{
struct gk20a_fecs_trace *trace = g->fecs_trace;
if (trace->poll_task) {
kthread_stop(trace->poll_task);
trace->poll_task = NULL;
}
if (nvgpu_thread_is_running(&trace->poll_task))
nvgpu_thread_stop(&trace->poll_task);
return -EPERM;
}
@@ -779,7 +778,7 @@ static bool gk20a_fecs_trace_is_enabled(struct gk20a *g)
{
struct gk20a_fecs_trace *trace = g->fecs_trace;
return (trace && trace->poll_task);
return (trace && nvgpu_thread_is_running(&trace->poll_task));
}