summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gv11b/gr_gv11b.c
diff options
context:
space:
mode:
authorSeema Khowala <seemaj@nvidia.com>2017-01-13 17:24:36 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-01-18 19:46:10 -0500
commita674eeee419a68e27bec63e46200036f5f33c8ff (patch)
treeb1af36cb70b39f66cbe0ff0f399fa54806f7109b /drivers/gpu/nvgpu/gv11b/gr_gv11b.c
parent4ad2d3aebc4137d350efaff8072d60441572bcf2 (diff)
gpu: nvgpu: gv11b: Support Stencil ZBC
Pre-GP10X All chips prior to GP10X do not support ZBC (Zero Bandwidth Clear) to stencil part of the packed kinds (packed kinds refer to Z24S8 and Z32_X24S8 kinds). Clears for these kinds typically happen in two phases, depth phase and stencil phase. The depth clears can be compressed or ZBC-ed, whereas the stencil part is always uncompressed. Stencil ZBC in GP10X For GP10X both the depth and the stencil data for these packed kinds can be ZBC cleared. A given tile will be a cross product of the following states for depth and stencil. Depth: Uncompressed, 1-2 plane compressed, 3-4 plane compressed, ZBC index 0, ZBC index 1 Stencil: Uncompressed, ZBC index 0, ZBC index 1, ZBC index 2 JIRA GV11B-9 Change-Id: I3381fd6305a4fada64211176b8ef98f27b04089f Signed-off-by: Seema Khowala <seemaj@nvidia.com> Reviewed-on: http://git-master/r/1235520 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gv11b/gr_gv11b.c')
-rw-r--r--drivers/gpu/nvgpu/gv11b/gr_gv11b.c190
1 files changed, 116 insertions, 74 deletions
diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c
index bdb96329..4c23455d 100644
--- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * GV11b GPU GR 2 * GV11b GPU GR
3 * 3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -223,96 +223,135 @@ static void gr_gv11b_commit_global_pagepool(struct gk20a *g,
223 gr_gpcs_gcc_pagepool_total_pages_f(size), patch); 223 gr_gpcs_gcc_pagepool_total_pages_f(size), patch);
224} 224}
225 225
226static int gr_gv11b_add_zbc_color(struct gk20a *g, struct gr_gk20a *gr, 226static int gr_gv11b_zbc_s_query_table(struct gk20a *g, struct gr_gk20a *gr,
227 struct zbc_entry *color_val, u32 index) 227 struct zbc_query_params *query_params)
228{ 228{
229 u32 index = query_params->index_size;
230
231 if (index >= GK20A_ZBC_TABLE_SIZE) {
232 gk20a_err(dev_from_gk20a(g),
233 "invalid zbc stencil table index\n");
234 return -EINVAL;
235 }
236 query_params->depth = gr->zbc_s_tbl[index].stencil;
237 query_params->format = gr->zbc_s_tbl[index].format;
238 query_params->ref_cnt = gr->zbc_s_tbl[index].ref_cnt;
239
240 return 0;
241}
242
243static bool gr_gv11b_add_zbc_type_s(struct gk20a *g, struct gr_gk20a *gr,
244 struct zbc_entry *zbc_val, int *ret_val)
245{
246 struct zbc_s_table *s_tbl;
229 u32 i; 247 u32 i;
230 u32 zbc_c; 248 bool added = false;
249
250 *ret_val = -ENOMEM;
251
252 /* search existing tables */
253 for (i = 0; i < gr->max_used_s_index; i++) {
254
255 s_tbl = &gr->zbc_s_tbl[i];
256
257 if (s_tbl->ref_cnt &&
258 s_tbl->stencil == zbc_val->depth &&
259 s_tbl->format == zbc_val->format) {
260 added = true;
261 s_tbl->ref_cnt++;
262 *ret_val = 0;
263 break;
264 }
265 }
266 /* add new table */
267 if (!added &&
268 gr->max_used_s_index < GK20A_ZBC_TABLE_SIZE) {
269
270 s_tbl = &gr->zbc_s_tbl[gr->max_used_s_index];
271 WARN_ON(s_tbl->ref_cnt != 0);
272
273 *ret_val = g->ops.gr.add_zbc_s(g, gr,
274 zbc_val, gr->max_used_s_index);
275
276 if (!(*ret_val))
277 gr->max_used_s_index++;
278 }
279 return added;
280}
281
282static int gr_gv11b_add_zbc_stencil(struct gk20a *g, struct gr_gk20a *gr,
283 struct zbc_entry *stencil_val, u32 index)
284{
285 u32 zbc_s;
231 286
232 /* update l2 table */ 287 /* update l2 table */
233 g->ops.ltc.set_zbc_color_entry(g, color_val, index); 288 g->ops.ltc.set_zbc_s_entry(g, stencil_val, index);
234
235 /* update ds table */
236 gk20a_writel(g, gr_ds_zbc_color_r_r(),
237 gr_ds_zbc_color_r_val_f(color_val->color_ds[0]));
238 gk20a_writel(g, gr_ds_zbc_color_g_r(),
239 gr_ds_zbc_color_g_val_f(color_val->color_ds[1]));
240 gk20a_writel(g, gr_ds_zbc_color_b_r(),
241 gr_ds_zbc_color_b_val_f(color_val->color_ds[2]));
242 gk20a_writel(g, gr_ds_zbc_color_a_r(),
243 gr_ds_zbc_color_a_val_f(color_val->color_ds[3]));
244
245 gk20a_writel(g, gr_ds_zbc_color_fmt_r(),
246 gr_ds_zbc_color_fmt_val_f(color_val->format));
247
248 gk20a_writel(g, gr_ds_zbc_tbl_index_r(),
249 gr_ds_zbc_tbl_index_val_f(index + GK20A_STARTOF_ZBC_TABLE));
250
251 /* trigger the write */
252 gk20a_writel(g, gr_ds_zbc_tbl_ld_r(),
253 gr_ds_zbc_tbl_ld_select_c_f() |
254 gr_ds_zbc_tbl_ld_action_write_f() |
255 gr_ds_zbc_tbl_ld_trigger_active_f());
256 289
257 /* update local copy */ 290 /* update local copy */
258 for (i = 0; i < GK20A_ZBC_COLOR_VALUE_SIZE; i++) { 291 gr->zbc_s_tbl[index].stencil = stencil_val->depth;
259 gr->zbc_col_tbl[index].color_l2[i] = color_val->color_l2[i]; 292 gr->zbc_s_tbl[index].format = stencil_val->format;
260 gr->zbc_col_tbl[index].color_ds[i] = color_val->color_ds[i]; 293 gr->zbc_s_tbl[index].ref_cnt++;
261 } 294
262 gr->zbc_col_tbl[index].format = color_val->format; 295 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_s_r(index), stencil_val->depth);
263 gr->zbc_col_tbl[index].ref_cnt++; 296 zbc_s = gk20a_readl(g, gr_gpcs_swdx_dss_zbc_s_01_to_04_format_r() +
264 297 (index & ~3));
265 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_r_r(index), 298 zbc_s &= ~(0x7f << (index % 4) * 7);
266 color_val->color_ds[0]); 299 zbc_s |= stencil_val->format << (index % 4) * 7;
267 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_g_r(index), 300 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_s_01_to_04_format_r() +
268 color_val->color_ds[1]); 301 (index & ~3), zbc_s);
269 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_b_r(index),
270 color_val->color_ds[2]);
271 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_a_r(index),
272 color_val->color_ds[3]);
273 zbc_c = gk20a_readl(g, gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r() + (index & ~3));
274 zbc_c &= ~(0x7f << ((index % 4) * 7));
275 zbc_c |= color_val->format << ((index % 4) * 7);
276 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r() + (index & ~3), zbc_c);
277 302
278 return 0; 303 return 0;
279} 304}
280 305
281static int gr_gv11b_add_zbc_depth(struct gk20a *g, struct gr_gk20a *gr, 306static int gr_gv11b_load_stencil_default_tbl(struct gk20a *g,
282 struct zbc_entry *depth_val, u32 index) 307 struct gr_gk20a *gr)
283{ 308{
284 u32 zbc_z; 309 struct zbc_entry zbc_val;
310 u32 err;
285 311
286 /* update l2 table */ 312 /* load default stencil table */
287 g->ops.ltc.set_zbc_depth_entry(g, depth_val, index); 313 zbc_val.type = GV11B_ZBC_TYPE_STENCIL;
288 314
289 /* update ds table */ 315 zbc_val.depth = 0x0;
290 gk20a_writel(g, gr_ds_zbc_z_r(), 316 zbc_val.format = ZBC_STENCIL_CLEAR_FMT_U8;
291 gr_ds_zbc_z_val_f(depth_val->depth)); 317 err = gr_gk20a_add_zbc(g, gr, &zbc_val);
292 318
293 gk20a_writel(g, gr_ds_zbc_z_fmt_r(), 319 zbc_val.depth = 0x1;
294 gr_ds_zbc_z_fmt_val_f(depth_val->format)); 320 zbc_val.format = ZBC_STENCIL_CLEAR_FMT_U8;
321 err |= gr_gk20a_add_zbc(g, gr, &zbc_val);
295 322
296 gk20a_writel(g, gr_ds_zbc_tbl_index_r(), 323 zbc_val.depth = 0xff;
297 gr_ds_zbc_tbl_index_val_f(index + GK20A_STARTOF_ZBC_TABLE)); 324 zbc_val.format = ZBC_STENCIL_CLEAR_FMT_U8;
325 err |= gr_gk20a_add_zbc(g, gr, &zbc_val);
298 326
299 /* trigger the write */ 327 if (!err) {
300 gk20a_writel(g, gr_ds_zbc_tbl_ld_r(), 328 gr->max_default_s_index = 3;
301 gr_ds_zbc_tbl_ld_select_z_f() | 329 } else {
302 gr_ds_zbc_tbl_ld_action_write_f() | 330 gk20a_err(dev_from_gk20a(g),
303 gr_ds_zbc_tbl_ld_trigger_active_f()); 331 "fail to load default zbc stencil table\n");
332 return err;
333 }
304 334
305 /* update local copy */ 335 return 0;
306 gr->zbc_dep_tbl[index].depth = depth_val->depth; 336}
307 gr->zbc_dep_tbl[index].format = depth_val->format; 337
308 gr->zbc_dep_tbl[index].ref_cnt++; 338static int gr_gv11b_load_stencil_tbl(struct gk20a *g, struct gr_gk20a *gr)
339{
340 int ret;
341 u32 i;
342
343 for (i = 0; i < gr->max_used_s_index; i++) {
344 struct zbc_s_table *s_tbl = &gr->zbc_s_tbl[i];
345 struct zbc_entry zbc_val;
309 346
310 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_z_r(index), depth_val->depth); 347 zbc_val.type = GV11B_ZBC_TYPE_STENCIL;
311 zbc_z = gk20a_readl(g, gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r() + (index & ~3)); 348 zbc_val.depth = s_tbl->stencil;
312 zbc_z &= ~(0x7f << (index % 4) * 7); 349 zbc_val.format = s_tbl->format;
313 zbc_z |= depth_val->format << (index % 4) * 7;
314 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r() + (index & ~3), zbc_z);
315 350
351 ret = g->ops.gr.add_zbc_s(g, gr, &zbc_val, i);
352 if (ret)
353 return ret;
354 }
316 return 0; 355 return 0;
317} 356}
318 357
@@ -1869,8 +1908,11 @@ void gv11b_init_gr(struct gpu_ops *gops)
1869 gops->gr.is_valid_class = gr_gv11b_is_valid_class; 1908 gops->gr.is_valid_class = gr_gv11b_is_valid_class;
1870 gops->gr.commit_global_cb_manager = gr_gv11b_commit_global_cb_manager; 1909 gops->gr.commit_global_cb_manager = gr_gv11b_commit_global_cb_manager;
1871 gops->gr.commit_global_pagepool = gr_gv11b_commit_global_pagepool; 1910 gops->gr.commit_global_pagepool = gr_gv11b_commit_global_pagepool;
1872 gops->gr.add_zbc_color = gr_gv11b_add_zbc_color; 1911 gops->gr.add_zbc_s = gr_gv11b_add_zbc_stencil;
1873 gops->gr.add_zbc_depth = gr_gv11b_add_zbc_depth; 1912 gops->gr.load_zbc_s_default_tbl = gr_gv11b_load_stencil_default_tbl;
1913 gops->gr.load_zbc_s_tbl = gr_gv11b_load_stencil_tbl;
1914 gops->gr.zbc_s_query_table = gr_gv11b_zbc_s_query_table;
1915 gops->gr.add_zbc_type_s = gr_gv11b_add_zbc_type_s;
1874 gops->gr.pagepool_default_size = gr_gv11b_pagepool_default_size; 1916 gops->gr.pagepool_default_size = gr_gv11b_pagepool_default_size;
1875 gops->gr.calc_global_ctx_buffer_size = 1917 gops->gr.calc_global_ctx_buffer_size =
1876 gr_gv11b_calc_global_ctx_buffer_size; 1918 gr_gv11b_calc_global_ctx_buffer_size;