diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gv11b')
-rw-r--r-- | drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 190 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv11b/gr_gv11b.h | 12 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gv11b/ltc_gv11b.c | 21 |
3 files changed, 147 insertions, 76 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 | ||
226 | static int gr_gv11b_add_zbc_color(struct gk20a *g, struct gr_gk20a *gr, | 226 | static 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 | |||
243 | static 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 | |||
282 | static 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 | ||
281 | static int gr_gv11b_add_zbc_depth(struct gk20a *g, struct gr_gk20a *gr, | 306 | static 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++; | 338 | static 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; |
diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h index fe5445d9..d31c92ca 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h | |||
@@ -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, |
@@ -16,6 +16,16 @@ | |||
16 | #ifndef _NVGPU_GR_GV11B_H_ | 16 | #ifndef _NVGPU_GR_GV11B_H_ |
17 | #define _NVGPU_GR_GV11B_H_ | 17 | #define _NVGPU_GR_GV11B_H_ |
18 | 18 | ||
19 | #define GV11B_ZBC_TYPE_STENCIL T19X_ZBC | ||
20 | #define ZBC_STENCIL_CLEAR_FMT_INVAILD 0 | ||
21 | #define ZBC_STENCIL_CLEAR_FMT_U8 1 | ||
22 | |||
23 | struct zbc_s_table { | ||
24 | u32 stencil; | ||
25 | u32 format; | ||
26 | u32 ref_cnt; | ||
27 | }; | ||
28 | |||
19 | struct gpu_ops; | 29 | struct gpu_ops; |
20 | 30 | ||
21 | enum { | 31 | enum { |
diff --git a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c index df2b0f68..c0e46be3 100644 --- a/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/ltc_gv11b.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * GV11B LTC | 2 | * GV11B LTC |
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, |
@@ -20,7 +20,26 @@ | |||
20 | #include "gv11b/ltc_gv11b.h" | 20 | #include "gv11b/ltc_gv11b.h" |
21 | #include "hw_ltc_gv11b.h" | 21 | #include "hw_ltc_gv11b.h" |
22 | 22 | ||
23 | /* | ||
24 | * Sets the ZBC stencil for the passed index. | ||
25 | */ | ||
26 | static void gv11b_ltc_set_zbc_stencil_entry(struct gk20a *g, | ||
27 | struct zbc_entry *stencil_val, | ||
28 | u32 index) | ||
29 | { | ||
30 | u32 real_index = index + GK20A_STARTOF_ZBC_TABLE; | ||
31 | |||
32 | gk20a_writel(g, ltc_ltcs_ltss_dstg_zbc_index_r(), | ||
33 | ltc_ltcs_ltss_dstg_zbc_index_address_f(real_index)); | ||
34 | |||
35 | gk20a_writel(g, ltc_ltcs_ltss_dstg_zbc_stencil_clear_value_r(), | ||
36 | stencil_val->depth); | ||
37 | |||
38 | gk20a_readl(g, ltc_ltcs_ltss_dstg_zbc_index_r()); | ||
39 | } | ||
40 | |||
23 | void gv11b_init_ltc(struct gpu_ops *gops) | 41 | void gv11b_init_ltc(struct gpu_ops *gops) |
24 | { | 42 | { |
25 | gp10b_init_ltc(gops); | 43 | gp10b_init_ltc(gops); |
44 | gops->ltc.set_zbc_s_entry = gv11b_ltc_set_zbc_stencil_entry; | ||
26 | } | 45 | } |