From 08f37cba39d846bc635098c4adae0c4a5629161a Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Mon, 17 Aug 2015 21:05:19 +0300 Subject: gpu: nvgpu: Prepare for per-GPU CDE program numbers Add gpu_ops for CDE, and add get_program_numbers function pointer for determining horizontal and vertical CDE swizzler programs. This allows different GPUs to have their own specific requirements for choosing the CDE firmware programs. Bug 1604102 Change-Id: Ib37c13abb017c8eb1c32adc8cbc6b5984488222e Signed-off-by: Sami Kiminki Reviewed-on: http://git-master/r/784899 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/Makefile | 3 ++- drivers/gpu/nvgpu/gk20a/cde_gk20a.c | 36 ++++++++++--------------- drivers/gpu/nvgpu/gk20a/gk20a.h | 5 ++++ drivers/gpu/nvgpu/gm20b/cde_gm20b.c | 53 +++++++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/gm20b/cde_gm20b.h | 23 ++++++++++++++++ drivers/gpu/nvgpu/gm20b/hal_gm20b.c | 2 ++ 6 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 drivers/gpu/nvgpu/gm20b/cde_gm20b.c create mode 100644 drivers/gpu/nvgpu/gm20b/cde_gm20b.h (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index ee2096d9..ee2117b9 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -61,7 +61,8 @@ nvgpu-y := \ gm20b/mm_gm20b.o \ gm20b/regops_gm20b.o \ gm20b/mc_gm20b.o \ - gm20b/debug_gm20b.o + gm20b/debug_gm20b.o \ + gm20b/cde_gm20b.o nvgpu-$(CONFIG_TEGRA_GK20A) += gk20a/platform_gk20a_tegra.o nvgpu-$(CONFIG_SYNC) += gk20a/sync_gk20a.o diff --git a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c index dc7e8be3..84b39b2d 100644 --- a/drivers/gpu/nvgpu/gk20a/cde_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/cde_gk20a.c @@ -1259,17 +1259,6 @@ enum cde_launch_patch_id { PATCH_V_QMD_REGISTER_COUNT_ID = 1056, }; -enum programs { - PROG_HPASS = 0, - PROG_VPASS_LARGE = 1, - PROG_VPASS_SMALL = 2, - PROG_HPASS_DEBUG = 3, - PROG_VPASS_LARGE_DEBUG = 4, - PROG_VPASS_SMALL_DEBUG = 5, - PROG_PASSTHROUGH = 6, - NUM_PROGRAMS = 7 -}; - /* maximum number of WRITE_PATCHes in the below function */ #define MAX_CDE_LAUNCH_PATCHES 32 @@ -1301,17 +1290,20 @@ static int gk20a_buffer_convert_gpu_to_cde_v1( const int xblocks = (xtiles + 1) >> 1; const int voffset = compbits_voffset - compbits_hoffset; - int hprog = PROG_HPASS; - int vprog = (block_height_log2 >= 2) ? - PROG_VPASS_LARGE : PROG_VPASS_SMALL; - if (g->cde_app.shader_parameter == 1) { - hprog = PROG_PASSTHROUGH; - vprog = PROG_PASSTHROUGH; - } else if (g->cde_app.shader_parameter == 2) { - hprog = PROG_HPASS_DEBUG; - vprog = (block_height_log2 >= 2) ? - PROG_VPASS_LARGE_DEBUG : - PROG_VPASS_SMALL_DEBUG; + int hprog = -1; + int vprog = -1; + + if (g->ops.cde.get_program_numbers) + g->ops.cde.get_program_numbers(g, block_height_log2, + &hprog, &vprog); + else { + gk20a_warn(&g->dev->dev, "cde: chip not supported"); + return -ENOSYS; + } + + if (hprog < 0 || vprog < 0) { + gk20a_warn(&g->dev->dev, "cde: could not determine programs"); + return -ENOSYS; } if (xtiles > 8192 / 8 || ytiles > 8192 / 8) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 25712a64..5caef6fe 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -432,6 +432,11 @@ struct gpu_ops { void (*show_dump)(struct gk20a *g, struct gk20a_debug_output *o); } debug; + struct { + void (*get_program_numbers)(struct gk20a *g, + u32 block_height_log2, + int *hprog, int *vprog); + } cde; }; struct gk20a { diff --git a/drivers/gpu/nvgpu/gm20b/cde_gm20b.c b/drivers/gpu/nvgpu/gm20b/cde_gm20b.c new file mode 100644 index 00000000..d23ba8c5 --- /dev/null +++ b/drivers/gpu/nvgpu/gm20b/cde_gm20b.c @@ -0,0 +1,53 @@ +/* + * GM20B CDE + * + * Copyright (c) 2015, 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 "gk20a/gk20a.h" +#include "cde_gm20b.h" + +enum programs { + PROG_HPASS = 0, + PROG_VPASS_LARGE = 1, + PROG_VPASS_SMALL = 2, + PROG_HPASS_DEBUG = 3, + PROG_VPASS_LARGE_DEBUG = 4, + PROG_VPASS_SMALL_DEBUG = 5, + PROG_PASSTHROUGH = 6, +}; + +static void gm20b_cde_get_program_numbers(struct gk20a *g, + u32 block_height_log2, + int *hprog_out, int *vprog_out) +{ + int hprog = PROG_HPASS; + int vprog = (block_height_log2 >= 2) ? + PROG_VPASS_LARGE : PROG_VPASS_SMALL; + if (g->cde_app.shader_parameter == 1) { + hprog = PROG_PASSTHROUGH; + vprog = PROG_PASSTHROUGH; + } else if (g->cde_app.shader_parameter == 2) { + hprog = PROG_HPASS_DEBUG; + vprog = (block_height_log2 >= 2) ? + PROG_VPASS_LARGE_DEBUG : + PROG_VPASS_SMALL_DEBUG; + } + + *hprog_out = hprog; + *vprog_out = vprog; +} + +void gm20b_init_cde_ops(struct gpu_ops *gops) +{ + gops->cde.get_program_numbers = gm20b_cde_get_program_numbers; +} diff --git a/drivers/gpu/nvgpu/gm20b/cde_gm20b.h b/drivers/gpu/nvgpu/gm20b/cde_gm20b.h new file mode 100644 index 00000000..66e303f5 --- /dev/null +++ b/drivers/gpu/nvgpu/gm20b/cde_gm20b.h @@ -0,0 +1,23 @@ +/* + * GM20B CDE + * + * Copyright (c) 2015, 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 _NVHOST_GM20B_CDE +#define _NVHOST_GM20B_CDE + +struct gpu_ops; + +void gm20b_init_cde_ops(struct gpu_ops *gops); + +#endif diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c index 1ab65836..e32f8943 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c @@ -32,6 +32,7 @@ #include #include "regops_gm20b.h" #include "debug_gm20b.h" +#include "cde_gm20b.h" #define FUSE_OPT_PRIV_SEC_DIS_0 0x264 #define PRIV_SECURITY_DISABLE 0x01 @@ -133,6 +134,7 @@ int gm20b_init_hal(struct gk20a *g) gm20b_init_clk_ops(gops); gm20b_init_regops(gops); gm20b_init_debug_ops(gops); + gm20b_init_cde_ops(gops); gops->name = "gm20b"; c->twod_class = FERMI_TWOD_A; -- cgit v1.2.2