From 6d758eb81bcbff4e50df5c9fa67a369a4e1f2074 Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Thu, 29 Jun 2017 15:59:05 -0700 Subject: gpu: nvgpu: gv11b: support for full subcontext Changes to enable 64 subcontexts: 1 SYNC + 63 ASYNC Currently all subcontexts with in a tsg can have only single address space. Add support for NVGPU_TSG_IOCTL_BIND_CHANNEL_EX for selecting subctx id by client. Bug 1842197 Change-Id: Icf56a41303bd1ad7fc6f2a6fbc691bb7b4a01d22 Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master/r/1511145 Reviewed-by: Terje Bergstrom GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 87 +++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c new file mode 100644 index 00000000..bf6088ab --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -0,0 +1,87 @@ +/* + * GV11B TSG IOCTL Handler + * + * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include + +#include "gk20a/gk20a.h" + +#include "gv11b/fifo_gv11b.h" +#include "gv11b/subctx_gv11b.h" +#include "ioctl_tsg_t19x.h" + +static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, + struct tsg_gk20a *tsg, struct nvgpu_tsg_bind_channel_ex_args *arg) +{ + struct gk20a_sched_ctrl *sched = &g->sched_ctrl; + struct channel_gk20a *ch; + int err = 0; + + nvgpu_log(g, gpu_dbg_fn | gpu_dbg_sched, "tsgid=%u", tsg->tsgid); + + nvgpu_mutex_acquire(&sched->control_lock); + if (sched->control_locked) { + err = -EPERM; + goto done; + } + err = gk20a_busy(g); + if (err) { + nvgpu_err(g, "failed to power on gpu"); + goto done; + } + + ch = gk20a_get_channel_from_file(arg->channel_fd); + if (!ch) + return -EINVAL; + if (arg->subcontext_id < gv11b_get_max_subctx_count(g)) + ch->t19x.subctx_id = arg->subcontext_id; + else + return -EINVAL; + nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d", + ch->chid, ch->t19x.subctx_id); + + /* Use runqueue selector 1 for all ASYNC ids */ + if (ch->t19x.subctx_id > CHANNEL_INFO_VEID0) + ch->t19x.runqueue_sel = 1; + + err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch); + gk20a_idle(g); +done: + nvgpu_mutex_release(&sched->control_lock); + return err; +} + +int t19x_tsg_ioctl_handler(struct gk20a *g, struct tsg_gk20a *tsg, + unsigned int cmd, u8 *buf) +{ + int err = 0; + + nvgpu_log(g, gpu_dbg_fn, "t19x_tsg_ioctl_handler"); + + switch (cmd) { + case NVGPU_TSG_IOCTL_BIND_CHANNEL_EX: + { + err = gv11b_tsg_ioctl_bind_channel_ex(g, tsg, + (struct nvgpu_tsg_bind_channel_ex_args *)buf); + break; + } + + default: + nvgpu_err(g, "unrecognized tsg gpu ioctl cmd: 0x%x", + cmd); + err = -ENOTTY; + break; + } + return err; +} -- cgit v1.2.2 From 3197a918d5052c71ad854f6b22fdb35bfe7cebe2 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Thu, 10 Aug 2017 16:34:16 -0700 Subject: gpu: nvgpu: gv11b: add max_subctx_count to g->fifo.t19x - For better performance. It used to read register every time referencing max_subctx_count. - Avoid reading registers for vgpu. Jira VFND-3797 Change-Id: Id6e6b15a0d9a035795e8a9a2c6bb63524c5eb544 Signed-off-by: Richard Zhao Reviewed-on: https://git-master.nvidia.com/r/1537009 Reviewed-by: svccoveritychecker Reviewed-by: Seshendra Gadagottu GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index bf6088ab..b0b1f9c4 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -44,7 +44,7 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, ch = gk20a_get_channel_from_file(arg->channel_fd); if (!ch) return -EINVAL; - if (arg->subcontext_id < gv11b_get_max_subctx_count(g)) + if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) ch->t19x.subctx_id = arg->subcontext_id; else return -EINVAL; -- cgit v1.2.2 From 58018f0c1b6c1957598ba58168ba9303b5617f35 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Wed, 6 Sep 2017 13:27:17 +0300 Subject: gpu: nvgpu: gv11b: hold ch ref when getting ch from fd Add gk20a_channel_put() pair for gk20a_get_channel_from_file() that now returns the channel with a reference. Also fix resource leaks in gv11b_tsg_ioctl_bind_channel_ex's error paths. Change-Id: Ib348219defa67163657ca534826f504ebc59497e Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1553276 Reviewed-by: svccoveritychecker Reviewed-by: svc-mobile-coverity Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index b0b1f9c4..87fbf010 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -33,21 +33,26 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, nvgpu_mutex_acquire(&sched->control_lock); if (sched->control_locked) { err = -EPERM; - goto done; + goto mutex_release; } err = gk20a_busy(g); if (err) { nvgpu_err(g, "failed to power on gpu"); - goto done; + goto mutex_release; } ch = gk20a_get_channel_from_file(arg->channel_fd); - if (!ch) - return -EINVAL; - if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) + if (!ch) { + err = -EINVAL; + goto idle; + } + if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) { ch->t19x.subctx_id = arg->subcontext_id; - else - return -EINVAL; + } else { + err = -EINVAL; + goto ch_put; + } + nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d", ch->chid, ch->t19x.subctx_id); @@ -56,8 +61,11 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, ch->t19x.runqueue_sel = 1; err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch); +ch_put: + gk20a_channel_put(ch); +idle: gk20a_idle(g); -done: +mutex_release: nvgpu_mutex_release(&sched->control_lock); return err; } -- cgit v1.2.2 From 98b08b413bb5ef082719bf2907629ab00137ec81 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 17 Oct 2017 11:09:22 -0700 Subject: gpu: nvgpu: Use sched_ctrl from nvgpu_os_linux Sched has been moved to be part of Linux implementation, and at the same time sched_ctrl has been moved to be part of nvgpu_os_linux. JIRA NVGPU-259 Change-Id: I4c1869628ad716bcd903ba99db926a8f8723828d Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1580650 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index 87fbf010..797115ac 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -20,11 +20,13 @@ #include "gv11b/fifo_gv11b.h" #include "gv11b/subctx_gv11b.h" #include "ioctl_tsg_t19x.h" +#include "common/linux/os_linux.h" static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, struct tsg_gk20a *tsg, struct nvgpu_tsg_bind_channel_ex_args *arg) { - struct gk20a_sched_ctrl *sched = &g->sched_ctrl; + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + struct gk20a_sched_ctrl *sched = &l->sched_ctrl; struct channel_gk20a *ch; int err = 0; -- cgit v1.2.2 From 730ba218c1a57486f05e02cfaddf6a75e95ff498 Mon Sep 17 00:00:00 2001 From: Deepak Goyal Date: Fri, 27 Oct 2017 14:51:17 +0530 Subject: gpu: nvgpu: gv11b: Kernel iface for Dynamic TPC-PG This patch adds kernel interface for dynamic TPC-PG feature. User-space needs to send TPC-PG args to kernel via ioctl. Dynamic TPC-PG feature will allow every context to specify the number of TPC's it will use to run its workload. This way, graphics driver can power off non-required TPC's if a particular context has light to medium workload. JIRA GPUT19x-16 Change-Id: Id4846245a6414b719599d04784cbe2ca5282f4ad Signed-off-by: Deepak Goyal Reviewed-on: https://git-master.nvidia.com/r/1575848 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index 797115ac..ec7501ce 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -28,6 +28,7 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct gk20a_sched_ctrl *sched = &l->sched_ctrl; struct channel_gk20a *ch; + struct gr_gk20a *gr = &g->gr; int err = 0; nvgpu_log(g, gpu_dbg_fn | gpu_dbg_sched, "tsgid=%u", tsg->tsgid); @@ -48,6 +49,22 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, err = -EINVAL; goto idle; } + + if (arg->tpc_pg_enabled && (!tsg->t19x.tpc_num_initialized)) { + if ((arg->num_active_tpcs > gr->max_tpc_count) || + !(arg->num_active_tpcs)) { + nvgpu_err(g, "Invalid num of active TPCs"); + err = -EINVAL; + goto ch_put; + } + tsg->t19x.tpc_num_initialized = true; + tsg->t19x.num_active_tpcs = arg->num_active_tpcs; + tsg->t19x.tpc_pg_enabled = true; + } else { + tsg->t19x.tpc_pg_enabled = false; + nvgpu_log(g, gpu_dbg_info, "dynamic TPC-PG not enabled"); + } + if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) { ch->t19x.subctx_id = arg->subcontext_id; } else { -- cgit v1.2.2 From d64241cb5a0ca21ae2c88419d34ad79715a4588a Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 10 Nov 2017 11:41:17 -0800 Subject: gpu: nvgpu: Include UAPI explicitly Add explicit #includes for for source code files that depend on it. JIRA NVGPU-388 Change-Id: I5d834e6f3b413cee9b1e4e055d710fc9f2c8f7c2 Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1596246 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index ec7501ce..1c96db69 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -14,6 +14,7 @@ */ #include +#include #include "gk20a/gk20a.h" -- cgit v1.2.2