From 366386d1898af61eb425aa8b37cfb656ff898c1a Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 2 Jun 2017 14:47:20 +0530 Subject: gpu: nvgpu: add t19x specific nvhost abstraction files Add new abstraction file common/linux/nvhost_t19x.c for all nvhost APIs exported from linux/nvhost_t194.h This file will be compiled only if config CONFIG_TEGRA_GK20A_NVHOST is set Export the new headers from file Also add dummy private header file nvhost_priv_t19x.h to store definition of private structure nvgpu_nvhost_dev This file should be deleted when nvgpu-t19x repo is merged into common nvhost repo Jira NVGPU-29 Change-Id: I8c08c9242b08cc45f7c99cc400b3e1a720f9439c Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1493792 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani --- drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h | 29 ++++++++++++++++++ drivers/gpu/nvgpu/common/linux/nvhost_t19x.c | 36 +++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h create mode 100644 drivers/gpu/nvgpu/common/linux/nvhost_t19x.c (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h b/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h new file mode 100644 index 00000000..7ff6184d --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h @@ -0,0 +1,29 @@ +/* + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __NVGPU_NVHOST_PRIV_T19X_H__ +#define __NVGPU_NVHOST_PRIV_T19X_H__ + +/* + * This file is copy of common/linux/nvhost_priv.h in nvgpu repo + * This file should be removed when nvgpu-t19x repo is merged + * into common nvgpu repo + */ +struct nvgpu_nvhost_dev { + struct platform_device *host1x_pdev; +}; + +#endif /* __NVGPU_NVHOST_PRIV_T19X_H__ */ diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c new file mode 100644 index 00000000..0bbb3d72 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c @@ -0,0 +1,36 @@ +/* + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include + +#include "nvhost_priv_t19x.h" + +int nvgpu_nvhost_syncpt_unit_interface_get_aperture( + struct nvgpu_nvhost_dev *nvhost_dev, + phys_addr_t *base, + size_t *size) +{ + return nvhost_syncpt_unit_interface_get_aperture( + nvhost_dev->host1x_pdev, base, size); +} + +u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id) +{ + return nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id); +} -- cgit v1.2.2 From 9cb4cc5d07e8a894f7d0c3ea5ea932291df32c36 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Thu, 8 Jun 2017 12:55:51 +0530 Subject: gpu: nvgpu: remove duplicate nvhost_priv_t19x.h We added duplicate common/linux/nvhost_priv_t19x.h so that the definition of struct nvgpu_nvhost_dev is available in nvgpu-t19x repo But instead of duplicating the file, directly include original file with path #include "common/linux/nvhost_priv.h Jira NVGPU-29 Change-Id: I5d373227f0f6b2b4670d2fd3ad433a4655df8e4f Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1499167 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h | 29 ----------------------- drivers/gpu/nvgpu/common/linux/nvhost_t19x.c | 2 +- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h b/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h deleted file mode 100644 index 7ff6184d..00000000 --- a/drivers/gpu/nvgpu/common/linux/nvhost_priv_t19x.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __NVGPU_NVHOST_PRIV_T19X_H__ -#define __NVGPU_NVHOST_PRIV_T19X_H__ - -/* - * This file is copy of common/linux/nvhost_priv.h in nvgpu repo - * This file should be removed when nvgpu-t19x repo is merged - * into common nvgpu repo - */ -struct nvgpu_nvhost_dev { - struct platform_device *host1x_pdev; -}; - -#endif /* __NVGPU_NVHOST_PRIV_T19X_H__ */ diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c index 0bbb3d72..0b2ae08c 100644 --- a/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c @@ -19,7 +19,7 @@ #include -#include "nvhost_priv_t19x.h" +#include "common/linux/nvhost_priv.h" int nvgpu_nvhost_syncpt_unit_interface_get_aperture( struct nvgpu_nvhost_dev *nvhost_dev, -- cgit v1.2.2 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 +++++++++++++++++++++++++ drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h | 21 ++++++ 2 files changed, 108 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h (limited to 'drivers/gpu/nvgpu/common/linux') 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; +} diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h new file mode 100644 index 00000000..3376ffce --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#ifndef _NVGPU_IOCTL_TSG_T19X +#define _NVGPU_IOCTL_TSG_T19X + +int t19x_tsg_ioctl_handler(struct gk20a *g, struct tsg_gk20a *tsg, + unsigned int cmd, u8 *arg); +#endif -- 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') 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') 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 ade9f5e03f1d0fd4987fc3f9fafb12e4118ac570 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 10 Oct 2017 13:18:02 -0700 Subject: gpu: nvgpu: Remove phys_addr_t from common code Remove phys_addr_t change for corresponding change in the nvgpu main repo. JIRA NVGPU-30 JIRA NVGPU-226 Change-Id: I05a19bc51e949279edef6e9ad7161226cbca51a7 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1576466 Reviewed-by: svc-mobile-coverity Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/nvhost_t19x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c index 0b2ae08c..21cf62ec 100644 --- a/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/nvhost_t19x.c @@ -23,11 +23,10 @@ int nvgpu_nvhost_syncpt_unit_interface_get_aperture( struct nvgpu_nvhost_dev *nvhost_dev, - phys_addr_t *base, - size_t *size) + u64 *base, size_t *size) { return nvhost_syncpt_unit_interface_get_aperture( - nvhost_dev->host1x_pdev, base, size); + nvhost_dev->host1x_pdev, (phys_addr_t *)base, size); } u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id) -- cgit v1.2.2 From b0092ea95c6e1f695912cdb0b13767f3881cb22f Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Wed, 27 Sep 2017 15:05:50 -0700 Subject: gpu: nvgpu: gv11b: Abstract IO aperture accessors Implement T19x specific usermode aperture initialization functions. Move usermode_regs field to nvgpu_os_linux_t19x, because it is Linux specific. JIRA NVGPU-259 Change-Id: I9d6ce243a692ab48209d468288ed85f89fb26770 Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1569699 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/io_t19x.c | 29 +++++++++++++ drivers/gpu/nvgpu/common/linux/module_t19x.c | 62 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/io_t19x.c create mode 100644 drivers/gpu/nvgpu/common/linux/module_t19x.c (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/io_t19x.c b/drivers/gpu/nvgpu/common/linux/io_t19x.c new file mode 100644 index 00000000..5c6b76ba --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/io_t19x.c @@ -0,0 +1,29 @@ +/* + * 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 + +#include "common/linux/os_linux.h" +#include "gk20a/gk20a.h" + +#include + +void gv11b_usermode_writel(struct gk20a *g, u32 r, u32 v) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + void __iomem *reg = l->t19x.usermode_regs + (r - usermode_cfg0_r()); + + writel_relaxed(v, reg); + gk20a_dbg(gpu_dbg_reg, "usermode r=0x%x v=0x%x", r, v); +} diff --git a/drivers/gpu/nvgpu/common/linux/module_t19x.c b/drivers/gpu/nvgpu/common/linux/module_t19x.c new file mode 100644 index 00000000..f0e3d438 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/module_t19x.c @@ -0,0 +1,62 @@ +/* + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include + +#include "common/linux/os_linux.h" + +/* + * Locks out the driver from accessing GPU registers. This prevents access to + * thse registers after the GPU has been clock or power gated. This should help + * find annoying bugs where register reads and writes are silently dropped + * after the GPU has been turned off. On older chips these reads and writes can + * also lock the entire CPU up. + */ +void t19x_lockout_registers(struct gk20a *g) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + + l->t19x.usermode_regs = NULL; +} + +/* + * Undoes t19x_lockout_registers(). + */ +void t19x_restore_registers(struct gk20a *g) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + + l->t19x.usermode_regs = l->t19x.usermode_regs_saved; +} + +void t19x_remove_support(struct gk20a *g) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + + if (l->t19x.usermode_regs) { + l->t19x.usermode_regs = NULL; + } +} + +void t19x_init_support(struct gk20a *g) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + + l->t19x.usermode_regs = l->regs + usermode_cfg0_r(); + l->t19x.usermode_regs_saved = l->t19x.usermode_regs; +} -- cgit v1.2.2 From 0c40a3e034cd9450859dfe713c4d1ca134b77b7e Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Sat, 14 Oct 2017 07:53:06 -0700 Subject: gpu: nvgpu: Initialize usermode regs for Volta dGPU Initialize usermode registers also for Volta GPU behind PCIe. Change-Id: Id621a74838839e4d98dfd0828c1ea5a0d54baa2d Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1579121 Reviewed-by: David Martinez Nieto Tested-by: David Martinez Nieto GVS: Gerrit_Virtual_Submit Reviewed-by: Seshendra Gadagottu --- drivers/gpu/nvgpu/common/linux/pci_t19x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/pci_t19x.c (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/pci_t19x.c b/drivers/gpu/nvgpu/common/linux/pci_t19x.c new file mode 100644 index 00000000..54efd68e --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/pci_t19x.c @@ -0,0 +1,24 @@ +/* + * 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 + +#include "common/linux/os_linux.h" + +void t19x_nvgpu_pci_init_support(struct nvgpu_os_linux *l) +{ + l->t19x.usermode_regs = l->regs + usermode_cfg0_r(); + l->t19x.usermode_regs_saved = l->t19x.usermode_regs; +} -- 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') 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 938785f1525ce0ae654c2be0911e15816617995d Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Mon, 23 Oct 2017 08:45:13 -0700 Subject: gpu: nvgpu: Linux specific GPU characteristics flags Make GPU characteristics flags specific to Linux code only. The rest of driver is moved to using nvgpu_is_enabled() API. JIRA NVGPU-259 Change-Id: I46a5a90bb34f170e9e755e7683be142ed6b18cce Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1583992 GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c | 31 ++++++++++++++++++++++++ drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h | 23 ++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c new file mode 100644 index 00000000..56756ac9 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c @@ -0,0 +1,31 @@ +/* + * 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 +#include + +#include "ioctl_ctrl_t19x.h" +#include "common/linux/os_linux.h" +#include "gk20a/gk20a.h" + +u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags_t19x(struct gk20a *g) +{ + u64 ioctl_flags = 0; + + if (nvgpu_is_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS)) + ioctl_flags |= NVGPU_GPU_FLAGS_SUPPORT_TSG_SUBCONTEXTS; + + return ioctl_flags; +} + diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h new file mode 100644 index 00000000..64141223 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + +#ifndef _NVGPU_IOCTL_CTRL_T19X +#define _NVGPU_IOCTL_CTRL_T19X + +#include + +struct gk20a; + +u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags_t19x(struct gk20a *g); + +#endif -- 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') 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_ctrl_t19x.c | 2 ++ drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 1 + 2 files changed, 3 insertions(+) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c index 56756ac9..a04fb5c9 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c @@ -11,6 +11,8 @@ * more details. */ +#include + #include #include #include 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