From cc9f3d80e32c63ae003a8dc66016a035100a6359 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Thu, 12 Apr 2018 16:06:02 -0700 Subject: gpu: nvgpu: pass pid/tid from os specific code to common code linux driver runs in user's process but qnx driver has dedicate driver process, so they have different way to get user pid. nvgpu common code expect calls from os specific code pass pid/tid. ce/cde open channel for internal use, we use driver pid. Jira VQRM-3534 Change-Id: I892372ac5f1dc4d25f9928d16992bcc659d12a56 Signed-off-by: Richard Zhao Reviewed-on: https://git-master.nvidia.com/r/1694145 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/ce2_gk20a.c | 8 +++++--- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 7 ++++--- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 3 ++- drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 4 ++-- drivers/gpu/nvgpu/gk20a/tsg_gk20a.h | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c index 87eff813..6da65abd 100644 --- a/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ce2_gk20a.c @@ -1,7 +1,7 @@ /* * GK20A Graphics Copy Engine (gr host) * - * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,6 +24,7 @@ #include #include +#include #include "gk20a.h" @@ -430,7 +431,7 @@ u32 gk20a_ce_create_context(struct gk20a *g, ce_ctx->vm = g->mm.ce.vm; /* allocate a tsg if needed */ - ce_ctx->tsg = gk20a_tsg_open(g); + ce_ctx->tsg = gk20a_tsg_open(g, nvgpu_current_pid(g)); if (!ce_ctx->tsg) { nvgpu_err(g, "ce: gk20a tsg not available"); err = -ENOMEM; @@ -438,7 +439,8 @@ u32 gk20a_ce_create_context(struct gk20a *g, } /* always kernel client needs privileged channel */ - ce_ctx->ch = gk20a_open_new_channel(g, runlist_id, true); + ce_ctx->ch = gk20a_open_new_channel(g, runlist_id, true, + nvgpu_current_pid(g), nvgpu_current_tid(g)); if (!ce_ctx->ch) { nvgpu_err(g, "ce: gk20a channel not available"); err = -ENOMEM; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index f50c37a7..2f5514a8 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -615,7 +615,8 @@ void __gk20a_channel_kill(struct channel_gk20a *ch) struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, s32 runlist_id, - bool is_privileged_channel) + bool is_privileged_channel, + pid_t pid, pid_t tid) { struct fifo_gk20a *f = &g->fifo; struct channel_gk20a *ch; @@ -645,8 +646,8 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, /* Channel privilege level */ ch->is_privileged_channel = is_privileged_channel; - ch->pid = nvgpu_current_tid(g); - ch->tgid = nvgpu_current_pid(g); /* process granularity for FECS traces */ + ch->pid = tid; + ch->tgid = pid; /* process granularity for FECS traces */ if (g->ops.fifo.alloc_inst(g, ch)) { ch->g = NULL; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 7fcc54cc..2b8be069 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -367,7 +367,8 @@ int gk20a_wait_channel_idle(struct channel_gk20a *ch); /* runlist_id -1 is synonym for ENGINE_GR_GK20A runlist id */ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, s32 runlist_id, - bool is_privileged_channel); + bool is_privileged_channel, + pid_t pid, pid_t tid); int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, struct nvgpu_gpfifo_args *gpfifo_args); diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index ccb456cf..05b8fc61 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -267,7 +267,7 @@ static struct tsg_gk20a *gk20a_tsg_acquire_unused_tsg(struct fifo_gk20a *f) return tsg; } -struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g) +struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid) { struct tsg_gk20a *tsg; int err; @@ -286,7 +286,7 @@ struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g) tsg->timeslice_timeout = 0; tsg->timeslice_scale = 0; tsg->runlist_id = ~0; - tsg->tgid = nvgpu_current_pid(g); + tsg->tgid = pid; if (g->ops.fifo.init_eng_method_buffers) g->ops.fifo.init_eng_method_buffers(g, tsg); diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h index f97dbb26..2f76477f 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h @@ -33,7 +33,7 @@ struct channel_gk20a; bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch); -struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g); +struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid); void gk20a_tsg_release(struct nvgpu_ref *ref); int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid); -- cgit v1.2.2