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/Makefile | 1 + drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c | 31 ++++++++++++++++++++++++ drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h | 23 ++++++++++++++++++ drivers/gpu/nvgpu/gv100/hal_gv100.c | 6 ++--- drivers/gpu/nvgpu/gv11b/gv11b.c | 8 +++--- drivers/gpu/nvgpu/include/nvgpu/enabled_t19x.h | 29 ++++++++++++++++++++++ 6 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.c create mode 100644 drivers/gpu/nvgpu/common/linux/ioctl_ctrl_t19x.h create mode 100644 drivers/gpu/nvgpu/include/nvgpu/enabled_t19x.h (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 0909a010..2edfa1bb 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -3,6 +3,7 @@ nvgpu-t19x := ../../../../nvgpu-t19x/drivers/gpu/nvgpu nvgpu-y += \ $(nvgpu-t19x)/common/mm/gmmu_t19x.o \ $(nvgpu-t19x)/common/linux/ioctl_tsg_t19x.o \ + $(nvgpu-t19x)/common/linux/ioctl_ctrl_t19x.o \ $(nvgpu-t19x)/common/linux/io_t19x.o \ $(nvgpu-t19x)/common/linux/module_t19x.o \ $(nvgpu-t19x)/common/linux/pci_t19x.o \ 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 diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index e8be1a43..e51b4446 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -107,6 +107,7 @@ #include #include #include +#include #include #include @@ -221,16 +222,13 @@ static int gv100_get_litter_value(struct gk20a *g, int value) int gv100_init_gpu_characteristics(struct gk20a *g) { - struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; - int err; err = gk20a_init_gpu_characteristics(g); if (err) return err; - gpu->flags |= - NVGPU_GPU_FLAGS_SUPPORT_TSG_SUBCONTEXTS; + __nvgpu_set_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS, true); return 0; } diff --git a/drivers/gpu/nvgpu/gv11b/gv11b.c b/drivers/gpu/nvgpu/gv11b/gv11b.c index c8691ad5..211755e5 100644 --- a/drivers/gpu/nvgpu/gv11b/gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gv11b.c @@ -22,6 +22,9 @@ * DEALINGS IN THE SOFTWARE. */ +#include +#include + #include "gk20a/gk20a.h" #include "gv11b/gv11b.h" @@ -29,8 +32,7 @@ int gv11b_init_gpu_characteristics(struct gk20a *g) { gk20a_init_gpu_characteristics(g); - g->gpu_characteristics.flags |= - NVGPU_GPU_FLAGS_SUPPORT_TSG_SUBCONTEXTS | - NVGPU_GPU_FLAGS_SUPPORT_IO_COHERENCE; + __nvgpu_set_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS, true); + __nvgpu_set_enabled(g, NVGPU_SUPPORT_IO_COHERENCE, true); return 0; } diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled_t19x.h b/drivers/gpu/nvgpu/include/nvgpu/enabled_t19x.h new file mode 100644 index 00000000..9ef1dc30 --- /dev/null +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled_t19x.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __NVGPU_ENABLED_T19X_H__ +#define __NVGPU_ENABLED_T19X_H__ + +/* subcontexts are available */ +#define NVGPU_SUPPORT_TSG_SUBCONTEXTS 63 + +#endif -- cgit v1.2.2