mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
Use nvgpu_writel() instead of nvgpu_writel_check() for writing the zbc color, depth and stencil values in L2 ZBC registers. Checking that the read value equals is not sensible for broadcast registers, and in these cases it's not necessary to read back the regs to synchronize memory. Bug 2976632 Change-Id: Id40e7d0f435bae5a395b5553c186fc50302f7dea Signed-off-by: Konsta Hölttä <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2345877 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
175 lines
4.9 KiB
C
175 lines
4.9 KiB
C
/*
|
|
* GM20B L2
|
|
*
|
|
* Copyright (c) 2014-2020 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <nvgpu/trace.h>
|
|
#include <nvgpu/timers.h>
|
|
#include <nvgpu/enabled.h>
|
|
#include <nvgpu/bug.h>
|
|
#include <nvgpu/ltc.h>
|
|
#include <nvgpu/fbp.h>
|
|
#include <nvgpu/io.h>
|
|
#include <nvgpu/utils.h>
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/static_analysis.h>
|
|
#include <nvgpu/mc.h>
|
|
#include <nvgpu/gr/zbc.h>
|
|
|
|
#include <nvgpu/hw/gm20b/hw_ltc_gm20b.h>
|
|
|
|
#include "ltc_gm20b.h"
|
|
|
|
void gm20b_ltc_init_fs_state(struct gk20a *g)
|
|
{
|
|
u32 reg;
|
|
u32 line_size = 512U;
|
|
|
|
nvgpu_log_info(g, "initialize gm20b l2");
|
|
|
|
g->ltc->max_ltc_count = g->ops.top.get_num_ltcs(g);
|
|
g->ltc->ltc_count = g->ops.priv_ring.enum_ltc(g);
|
|
nvgpu_log_info(g, "%d ltcs out of %d", g->ltc->ltc_count,
|
|
g->ltc->max_ltc_count);
|
|
|
|
reg = gk20a_readl(g, ltc_ltcs_ltss_cbc_param_r());
|
|
g->ltc->slices_per_ltc = ltc_ltcs_ltss_cbc_param_slices_per_ltc_v(reg);
|
|
g->ltc->cacheline_size =
|
|
line_size << ltc_ltcs_ltss_cbc_param_cache_line_size_v(reg);
|
|
|
|
gk20a_writel(g, ltc_ltcs_ltss_cbc_num_active_ltcs_r(),
|
|
g->ltc->ltc_count);
|
|
gk20a_writel(g, ltc_ltcs_misc_ltc_num_active_ltcs_r(),
|
|
g->ltc->ltc_count);
|
|
|
|
gk20a_writel(g, ltc_ltcs_ltss_dstg_cfg0_r(),
|
|
gk20a_readl(g, ltc_ltc0_lts0_dstg_cfg0_r()) |
|
|
ltc_ltcs_ltss_dstg_cfg0_vdc_4to2_disable_m());
|
|
}
|
|
|
|
/*
|
|
* Performs a full flush of the L2 cache.
|
|
*/
|
|
|
|
u64 gm20b_determine_L2_size_bytes(struct gk20a *g)
|
|
{
|
|
u32 lts_per_ltc;
|
|
u32 ways;
|
|
u32 sets;
|
|
u32 bytes_per_line;
|
|
u32 active_ltcs;
|
|
u64 cache_size;
|
|
|
|
u32 tmp;
|
|
u32 active_sets_value;
|
|
|
|
tmp = gk20a_readl(g, ltc_ltc0_lts0_tstg_cfg1_r());
|
|
ways = (u32)hweight32(ltc_ltc0_lts0_tstg_cfg1_active_ways_v(tmp));
|
|
|
|
active_sets_value = ltc_ltc0_lts0_tstg_cfg1_active_sets_v(tmp);
|
|
if (active_sets_value == ltc_ltc0_lts0_tstg_cfg1_active_sets_all_v()) {
|
|
sets = 64U;
|
|
} else if (active_sets_value ==
|
|
ltc_ltc0_lts0_tstg_cfg1_active_sets_half_v()) {
|
|
sets = 32U;
|
|
} else if (active_sets_value ==
|
|
ltc_ltc0_lts0_tstg_cfg1_active_sets_quarter_v()) {
|
|
sets = 16U;
|
|
} else {
|
|
nvgpu_err(g, "Unknown constant %d for active sets",
|
|
active_sets_value);
|
|
sets = 0U;
|
|
}
|
|
|
|
active_ltcs = nvgpu_fbp_get_num_fbps(g->fbp);
|
|
|
|
/* chip-specific values */
|
|
lts_per_ltc = 2U;
|
|
bytes_per_line = 128U;
|
|
cache_size = nvgpu_safe_mult_u64(nvgpu_safe_mult_u64(
|
|
nvgpu_safe_mult_u64(active_ltcs, lts_per_ltc), ways),
|
|
nvgpu_safe_mult_u64(sets, bytes_per_line));
|
|
|
|
return cache_size;
|
|
}
|
|
|
|
#ifdef CONFIG_NVGPU_GRAPHICS
|
|
/*
|
|
* Sets the ZBC color for the passed index.
|
|
*/
|
|
void gm20b_ltc_set_zbc_color_entry(struct gk20a *g,
|
|
u32 *color_l2,
|
|
u32 index)
|
|
{
|
|
u32 i;
|
|
|
|
nvgpu_writel(g, ltc_ltcs_ltss_dstg_zbc_index_r(),
|
|
ltc_ltcs_ltss_dstg_zbc_index_address_f(
|
|
nvgpu_safe_add_u32(index, NVGPU_GR_ZBC_STARTOF_TABLE)));
|
|
|
|
for (i = 0;
|
|
i < ltc_ltcs_ltss_dstg_zbc_color_clear_value__size_1_v(); i++) {
|
|
nvgpu_writel(g, ltc_ltcs_ltss_dstg_zbc_color_clear_value_r(i),
|
|
color_l2[i]);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Sets the ZBC depth for the passed index.
|
|
*/
|
|
void gm20b_ltc_set_zbc_depth_entry(struct gk20a *g,
|
|
u32 depth_val,
|
|
u32 index)
|
|
{
|
|
nvgpu_writel(g, ltc_ltcs_ltss_dstg_zbc_index_r(),
|
|
ltc_ltcs_ltss_dstg_zbc_index_address_f(
|
|
nvgpu_safe_add_u32(index, NVGPU_GR_ZBC_STARTOF_TABLE)));
|
|
|
|
nvgpu_writel(g, ltc_ltcs_ltss_dstg_zbc_depth_clear_value_r(),
|
|
depth_val);
|
|
}
|
|
|
|
u32 gm20b_ltc_zbc_table_size(struct gk20a *g)
|
|
{
|
|
u32 address_max_bits = ltc_ltcs_ltss_dstg_zbc_index_address_s();
|
|
|
|
return nvgpu_safe_sub_u32((U32(0x1U) << address_max_bits),
|
|
NVGPU_GR_ZBC_STARTOF_TABLE);
|
|
}
|
|
#endif /* CONFIG_NVGPU_GRAPHICS */
|
|
|
|
void gm20b_ltc_set_enabled(struct gk20a *g, bool enabled)
|
|
{
|
|
u32 reg_f = ltc_ltcs_ltss_tstg_set_mgmt_2_l2_bypass_mode_enabled_f();
|
|
u32 reg = gk20a_readl(g, ltc_ltcs_ltss_tstg_set_mgmt_2_r());
|
|
|
|
if (enabled) {
|
|
/* bypass disabled (normal caching ops) */
|
|
reg &= ~reg_f;
|
|
} else {
|
|
/* bypass enabled (no caching) */
|
|
reg |= reg_f;
|
|
}
|
|
|
|
gk20a_writel(g, ltc_ltcs_ltss_tstg_set_mgmt_2_r(), reg);
|
|
}
|