From 94eebcdd8cacc9a2dc20485e0d3d15fc51507c2c Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Fri, 10 Aug 2018 10:34:17 +0530 Subject: gpu: nvgpu: linux: move os ops to a common file Currently only cde uses nvgpu_os_linux_ops to set up linux specific ops. Move nvgpu_os_linux_ops of a gpu to a common file so that those can be reused for other os ops of that gpu. JIRA NVGPU-603 Change-Id: Icf1ff275d3832229137f730fe8183b8015e82673 Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/1797902 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/Makefile | 3 +++ drivers/gpu/nvgpu/os/linux/cde.c | 21 ---------------- drivers/gpu/nvgpu/os/linux/cde_gm20b.c | 16 ++++--------- drivers/gpu/nvgpu/os/linux/cde_gm20b.h | 9 +++---- drivers/gpu/nvgpu/os/linux/cde_gp10b.c | 8 ------- drivers/gpu/nvgpu/os/linux/cde_gp10b.h | 14 ++++++++--- drivers/gpu/nvgpu/os/linux/module.c | 12 +--------- drivers/gpu/nvgpu/os/linux/os_ops.c | 40 +++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/os_ops.h | 22 +++++++++++++++++ drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c | 34 ++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h | 22 +++++++++++++++++ drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c | 36 ++++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h | 22 +++++++++++++++++ 13 files changed, 201 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops.c create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops.h create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c create mode 100644 drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index a6f0f0ce..06762586 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -49,6 +49,9 @@ nvgpu-y += common/bus/bus_gk20a.o \ # Linux specific parts of nvgpu. nvgpu-y += \ + os/linux/os_ops.o \ + os/linux/os_ops_gm20b.o \ + os/linux/os_ops_gp10b.o \ os/linux/kmem.o \ os/linux/timers.o \ os/linux/ioctl.o \ diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c index 850f6deb..30cd0bff 100644 --- a/drivers/gpu/nvgpu/os/linux/cde.c +++ b/drivers/gpu/nvgpu/os/linux/cde.c @@ -1791,24 +1791,3 @@ int gk20a_mark_compressible_write(struct gk20a *g, u32 buffer_fd, dma_buf_put(dmabuf); return 0; } - -int nvgpu_cde_init_ops(struct nvgpu_os_linux *l) -{ - struct gk20a *g = &l->g; - u32 ver = g->params.gpu_arch + g->params.gpu_impl; - - switch (ver) { - case GK20A_GPUID_GM20B: - case GK20A_GPUID_GM20B_B: - l->ops.cde = gm20b_cde_ops.cde; - break; - case NVGPU_GPUID_GP10B: - l->ops.cde = gp10b_cde_ops.cde; - break; - default: - /* CDE is optional, so today ignoring unknown chip is fine */ - break; - } - - return 0; -} diff --git a/drivers/gpu/nvgpu/os/linux/cde_gm20b.c b/drivers/gpu/nvgpu/os/linux/cde_gm20b.c index 1cd15c54..7f71b740 100644 --- a/drivers/gpu/nvgpu/os/linux/cde_gm20b.c +++ b/drivers/gpu/nvgpu/os/linux/cde_gm20b.c @@ -1,7 +1,7 @@ /* * GM20B CDE * - * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-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"), @@ -35,10 +35,10 @@ enum programs { PROG_PASSTHROUGH = 6, }; -static void gm20b_cde_get_program_numbers(struct gk20a *g, - u32 block_height_log2, - u32 shader_parameter, - int *hprog_out, int *vprog_out) +void gm20b_cde_get_program_numbers(struct gk20a *g, + u32 block_height_log2, + u32 shader_parameter, + int *hprog_out, int *vprog_out) { int hprog = PROG_HPASS; int vprog = (block_height_log2 >= 2) ? @@ -56,9 +56,3 @@ static void gm20b_cde_get_program_numbers(struct gk20a *g, *hprog_out = hprog; *vprog_out = vprog; } - -struct nvgpu_os_linux_ops gm20b_cde_ops = { - .cde = { - .get_program_numbers = gm20b_cde_get_program_numbers, - }, -}; diff --git a/drivers/gpu/nvgpu/os/linux/cde_gm20b.h b/drivers/gpu/nvgpu/os/linux/cde_gm20b.h index 640d6ab6..fac8aaff 100644 --- a/drivers/gpu/nvgpu/os/linux/cde_gm20b.h +++ b/drivers/gpu/nvgpu/os/linux/cde_gm20b.h @@ -1,7 +1,7 @@ /* * GM20B CDE * - * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-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"), @@ -25,8 +25,9 @@ #ifndef _NVHOST_GM20B_CDE #define _NVHOST_GM20B_CDE -#include "os_linux.h" - -extern struct nvgpu_os_linux_ops gm20b_cde_ops; +void gm20b_cde_get_program_numbers(struct gk20a *g, + u32 block_height_log2, + u32 shader_parameter, + int *hprog_out, int *vprog_out); #endif diff --git a/drivers/gpu/nvgpu/os/linux/cde_gp10b.c b/drivers/gpu/nvgpu/os/linux/cde_gp10b.c index 5c0e79a7..f22f4b68 100644 --- a/drivers/gpu/nvgpu/os/linux/cde_gp10b.c +++ b/drivers/gpu/nvgpu/os/linux/cde_gp10b.c @@ -151,11 +151,3 @@ int gp10b_populate_scatter_buffer(struct gk20a *g, return 0; } - -struct nvgpu_os_linux_ops gp10b_cde_ops = { - .cde = { - .get_program_numbers = gp10b_cde_get_program_numbers, - .need_scatter_buffer = gp10b_need_scatter_buffer, - .populate_scatter_buffer = gp10b_populate_scatter_buffer, - }, -}; diff --git a/drivers/gpu/nvgpu/os/linux/cde_gp10b.h b/drivers/gpu/nvgpu/os/linux/cde_gp10b.h index 52e9f292..3ecca2ab 100644 --- a/drivers/gpu/nvgpu/os/linux/cde_gp10b.h +++ b/drivers/gpu/nvgpu/os/linux/cde_gp10b.h @@ -1,7 +1,7 @@ /* * GP10B CDE * - * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-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"), @@ -27,6 +27,14 @@ #include "os_linux.h" -extern struct nvgpu_os_linux_ops gp10b_cde_ops; - +void gp10b_cde_get_program_numbers(struct gk20a *g, + u32 block_height_log2, + u32 shader_parameter, + int *hprog_out, int *vprog_out); +bool gp10b_need_scatter_buffer(struct gk20a *g); +int gp10b_populate_scatter_buffer(struct gk20a *g, + struct sg_table *sgt, + size_t surface_size, + void *scatter_buffer_ptr, + size_t scatter_buffer_size); #endif diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index c07faf08..3be879be 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -56,6 +56,7 @@ #include "ioctl.h" #include "os_linux.h" +#include "os_ops.h" #include "ctxsw_trace.h" #include "driver_common.h" #include "channel.h" @@ -183,17 +184,6 @@ static int gk20a_restore_registers(struct gk20a *g) return 0; } -static int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l) -{ - int err = 0; - -#ifdef CONFIG_NVGPU_SUPPORT_CDE - err = nvgpu_cde_init_ops(l); -#endif - - return err; -} - int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l) { struct gk20a *g = &l->g; diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.c b/drivers/gpu/nvgpu/os/linux/os_ops.c new file mode 100644 index 00000000..14f92787 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018, 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 "os_linux.h" + +#include "os_ops_gm20b.h" +#include "os_ops_gp10b.h" + +int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l) +{ + struct gk20a *g = &l->g; + u32 ver = g->params.gpu_arch + g->params.gpu_impl; + + switch (ver) { + case GK20A_GPUID_GM20B: + case GK20A_GPUID_GM20B_B: + nvgpu_gm20b_init_os_ops(l); + break; + case NVGPU_GPUID_GP10B: + nvgpu_gp10b_init_os_ops(l); + break; + default: + break; + } + + return 0; +} diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.h b/drivers/gpu/nvgpu/os/linux/os_ops.h new file mode 100644 index 00000000..af3ce0a7 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018, 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 __LINUX_OS_OPS_H +#define __LINUX_OS_OPS_H + +int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l); + +#endif diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c new file mode 100644 index 00000000..7db004eb --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018, 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 "os_linux.h" + +#include "cde_gm20b.h" + +static struct nvgpu_os_linux_ops gm20b_os_linux_ops = { +#ifdef CONFIG_NVGPU_SUPPORT_CDE + .cde = { + .get_program_numbers = gm20b_cde_get_program_numbers, + }, +#endif +}; + +void nvgpu_gm20b_init_os_ops(struct nvgpu_os_linux *l) +{ +#ifdef CONFIG_NVGPU_SUPPORT_CDE + l->ops.cde = gm20b_os_linux_ops.cde; +#endif +} diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h new file mode 100644 index 00000000..7d27e401 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gm20b.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018, 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 __LINUX_OS_OPS_GM20B_H +#define __LINUX_OS_OPS_GM20B_H + +void nvgpu_gm20b_init_os_ops(struct nvgpu_os_linux *l); + +#endif diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c new file mode 100644 index 00000000..984dcdc0 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018, 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 "os_linux.h" + +#include "cde_gp10b.h" + +static struct nvgpu_os_linux_ops gp10b_os_linux_ops = { +#ifdef CONFIG_NVGPU_SUPPORT_CDE + .cde = { + .get_program_numbers = gp10b_cde_get_program_numbers, + .need_scatter_buffer = gp10b_need_scatter_buffer, + .populate_scatter_buffer = gp10b_populate_scatter_buffer, + }, +#endif +}; + +void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l) +{ +#ifdef CONFIG_NVGPU_SUPPORT_CDE + l->ops.cde = gp10b_os_linux_ops.cde; +#endif +} diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h new file mode 100644 index 00000000..0be1bca1 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp10b.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018, 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 __LINUX_OS_OPS_GP10B_H +#define __LINUX_OS_OPS_GP10B_H + +void nvgpu_gp10b_init_os_ops(struct nvgpu_os_linux *l); + +#endif -- cgit v1.2.2