From 99a664bda0c239e04003522c5f1f2681cea6b6f3 Mon Sep 17 00:00:00 2001 From: Pyarelal Knowles Date: Fri, 4 Jun 2021 13:26:28 -0700 Subject: [PATCH] gpu: nvgpu: enable stencil zbc The implementation already exists. This change adds NVGPU_GR_ZBC_TYPE_STENCIL and plumbs through the stencil value from NvRmGpuDeviceZbcAddStencil through NVGPU_GPU_IOCTL_ZBC_SET_TABLE. Adds cases for querying the stencil values, enabling NvRmGpuDeviceZbcGetStencilTableEntry. Bug 3403523 Bug 3395601 Change-Id: I42c9a2967d0433e0bb08343aabeff0fe465f231e Signed-off-by: Pyarelal Knowles Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2554963 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c | 6 ++++++ drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h | 7 +++++-- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 7 +++++++ include/uapi/linux/nvgpu-ctrl.h | 7 +++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c index 6c0d31b36..3cb63f768 100644 --- a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c @@ -538,6 +538,9 @@ int vgpu_gr_add_zbc(struct gk20a *g, struct nvgpu_gr_zbc *zbc, case NVGPU_GR_ZBC_TYPE_DEPTH: p->depth = zbc_val->depth; break; + case NVGPU_GR_ZBC_TYPE_STENCIL: + p->stencil = zbc_val->stencil; + break; default: return -EINVAL; } @@ -578,6 +581,9 @@ int vgpu_gr_query_zbc(struct gk20a *g, struct nvgpu_gr_zbc *zbc, case NVGPU_GR_ZBC_TYPE_DEPTH: query_params->depth = p->depth; break; + case NVGPU_GR_ZBC_TYPE_STENCIL: + query_params->stencil = p->stencil; + break; case NVGPU_GR_ZBC_TYPE_INVALID: query_params->index_size = p->index_size; break; diff --git a/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h b/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h index ccdae5bbd..bcd804095 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/vgpu/tegra_vgpu.h @@ -254,22 +254,25 @@ struct tegra_vgpu_zcull_info_params { #define TEGRA_VGPU_ZBC_TYPE_INVALID 0 #define TEGRA_VGPU_ZBC_TYPE_COLOR 1 #define TEGRA_VGPU_ZBC_TYPE_DEPTH 2 +#define TEGRA_VGPU_ZBC_TYPE_STENCIL 3 struct tegra_vgpu_zbc_set_table_params { u32 color_ds[TEGRA_VGPU_ZBC_COLOR_VALUE_SIZE]; u32 color_l2[TEGRA_VGPU_ZBC_COLOR_VALUE_SIZE]; u32 depth; + u32 stencil; u32 format; - u32 type; /* color or depth */ + u32 type; /* color, depth or stencil */ }; struct tegra_vgpu_zbc_query_table_params { u32 color_ds[TEGRA_VGPU_ZBC_COLOR_VALUE_SIZE]; u32 color_l2[TEGRA_VGPU_ZBC_COLOR_VALUE_SIZE]; u32 depth; + u32 stencil; u32 ref_cnt; u32 format; - u32 type; /* color or depth */ + u32 type; /* color, depth or stencil */ u32 index_size; /* [out] size, [in] index */ }; #endif diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 9a74007a5..793a266b6 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -2307,6 +2307,10 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg nvgpu_gr_zbc_set_entry_depth(zbc_val, set_table_args->depth); break; + case NVGPU_GR_ZBC_TYPE_STENCIL: + nvgpu_gr_zbc_set_entry_stencil(zbc_val, + set_table_args->stencil); + break; default: err = -EINVAL; } @@ -2349,6 +2353,9 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg case NVGPU_GR_ZBC_TYPE_DEPTH: query_table_args->depth = zbc_tbl->depth; break; + case NVGPU_GR_ZBC_TYPE_STENCIL: + query_table_args->stencil = zbc_tbl->stencil; + break; case NVGPU_GR_ZBC_TYPE_INVALID: query_table_args->index_size = zbc_tbl->index_size; break; diff --git a/include/uapi/linux/nvgpu-ctrl.h b/include/uapi/linux/nvgpu-ctrl.h index 910aab2b8..efb4d437b 100644 --- a/include/uapi/linux/nvgpu-ctrl.h +++ b/include/uapi/linux/nvgpu-ctrl.h @@ -49,22 +49,25 @@ struct nvgpu_gpu_zcull_get_info_args { #define NVGPU_ZBC_TYPE_INVALID 0 #define NVGPU_ZBC_TYPE_COLOR 1 #define NVGPU_ZBC_TYPE_DEPTH 2 +#define NVGPU_ZBC_TYPE_STENCIL 3 struct nvgpu_gpu_zbc_set_table_args { __u32 color_ds[NVGPU_ZBC_COLOR_VALUE_SIZE]; __u32 color_l2[NVGPU_ZBC_COLOR_VALUE_SIZE]; __u32 depth; + __u32 stencil; __u32 format; - __u32 type; /* color or depth */ + __u32 type; /* color, depth or stencil */ }; struct nvgpu_gpu_zbc_query_table_args { __u32 color_ds[NVGPU_ZBC_COLOR_VALUE_SIZE]; __u32 color_l2[NVGPU_ZBC_COLOR_VALUE_SIZE]; __u32 depth; + __u32 stencil; __u32 ref_cnt; __u32 format; - __u32 type; /* color or depth */ + __u32 type; /* color, depth or stencil */ __u32 index_size; /* [out] size, [in] index */ };