mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
Previously, unit interrupt enabling/disabling and corresponding MC level interrupt enabling/disabling was not done at the same time. With this change, stall and nonstall interrupt for units are programmed at MC level along with individual unit interrupts. Kept access to MC interrupt registers through mc.intr_lock spinlock. For doing this separated CE and GR interrupt mask functions. mc.intr_enable is only used when there is global interrupt control to be set. Removed mc_gp10b.c as mc_gp10b_intr_enable is now removed. Removed following functions - mc_gv100_intr_enable, mc_gv11b_intr_enable & intr_tu104_enable. Removed intr_pmu_unit_config as we can use the generic unit interrupt control function. JIRA NVGPU-4336 Change-Id: Ibd296d4a60fda6ba930f18f518ee56ab3f9dacad Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2196178 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
201 lines
5.0 KiB
C
201 lines
5.0 KiB
C
/*
|
|
* Copyright (c) 2017-2019, 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/ltc.h>
|
|
#include <nvgpu/dma.h>
|
|
#include <nvgpu/nvgpu_mem.h>
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/string.h>
|
|
|
|
void nvgpu_ltc_remove_support(struct gk20a *g)
|
|
{
|
|
struct nvgpu_ltc *ltc = g->ltc;
|
|
|
|
nvgpu_log_fn(g, " ");
|
|
|
|
if (ltc == NULL) {
|
|
return;
|
|
}
|
|
|
|
nvgpu_kfree(g, ltc);
|
|
g->ltc = NULL;
|
|
}
|
|
|
|
|
|
int nvgpu_init_ltc_support(struct gk20a *g)
|
|
{
|
|
struct nvgpu_ltc *ltc = g->ltc;
|
|
int err;
|
|
|
|
nvgpu_log_fn(g, " ");
|
|
|
|
g->mm.ltc_enabled_current = true;
|
|
g->mm.ltc_enabled_target = true;
|
|
|
|
if (ltc == NULL) {
|
|
ltc = nvgpu_kzalloc(g, sizeof(*ltc));
|
|
if (ltc == NULL) {
|
|
return -ENOMEM;
|
|
}
|
|
g->ltc = ltc;
|
|
nvgpu_spinlock_init(&g->ltc->ltc_enabled_lock);
|
|
}
|
|
|
|
if (g->ops.ltc.init_fs_state != NULL) {
|
|
g->ops.ltc.init_fs_state(g);
|
|
}
|
|
|
|
if (g->ops.ltc.ecc_init != NULL && !g->ecc.initialized) {
|
|
err = g->ops.ltc.ecc_init(g);
|
|
if (err != 0) {
|
|
nvgpu_kfree(g, ltc);
|
|
g->ltc = NULL;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
if (g->ops.ltc.intr.configure != NULL) {
|
|
nvgpu_mc_intr_stall_unit_config(g, MC_INTR_UNIT_LTC,
|
|
MC_INTR_ENABLE);
|
|
g->ops.ltc.intr.configure(g);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void nvgpu_ltc_sync_enabled(struct gk20a *g)
|
|
{
|
|
if (g->ops.ltc.set_enabled == NULL) {
|
|
return;
|
|
}
|
|
|
|
nvgpu_spinlock_acquire(&g->ltc->ltc_enabled_lock);
|
|
if (g->mm.ltc_enabled_current != g->mm.ltc_enabled_target) {
|
|
g->ops.ltc.set_enabled(g, g->mm.ltc_enabled_target);
|
|
g->mm.ltc_enabled_current = g->mm.ltc_enabled_target;
|
|
}
|
|
nvgpu_spinlock_release(&g->ltc->ltc_enabled_lock);
|
|
}
|
|
|
|
u32 nvgpu_ltc_get_ltc_count(struct gk20a *g)
|
|
{
|
|
return g->ltc->ltc_count;
|
|
}
|
|
|
|
u32 nvgpu_ltc_get_slices_per_ltc(struct gk20a *g)
|
|
{
|
|
return g->ltc->slices_per_ltc;
|
|
}
|
|
|
|
u32 nvgpu_ltc_get_cacheline_size(struct gk20a *g)
|
|
{
|
|
return g->ltc->cacheline_size;
|
|
}
|
|
|
|
int nvgpu_ecc_counter_init_per_lts(struct gk20a *g,
|
|
struct nvgpu_ecc_stat ***stat, const char *name)
|
|
{
|
|
struct nvgpu_ecc_stat **stats;
|
|
u32 ltc, lts;
|
|
char ltc_str[10] = {0}, lts_str[10] = {0};
|
|
int err = 0;
|
|
u32 ltc_count = nvgpu_ltc_get_ltc_count(g);
|
|
u32 slices_per_ltc = nvgpu_ltc_get_slices_per_ltc(g);
|
|
|
|
stats = nvgpu_kzalloc(g, nvgpu_safe_mult_u64(sizeof(*stats),
|
|
ltc_count));
|
|
if (stats == NULL) {
|
|
return -ENOMEM;
|
|
}
|
|
for (ltc = 0; ltc < ltc_count; ltc++) {
|
|
stats[ltc] = nvgpu_kzalloc(g,
|
|
nvgpu_safe_mult_u64(sizeof(*stats[ltc]),
|
|
slices_per_ltc));
|
|
if (stats[ltc] == NULL) {
|
|
err = -ENOMEM;
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
for (ltc = 0; ltc < ltc_count; ltc++) {
|
|
for (lts = 0; lts < slices_per_ltc; lts++) {
|
|
/**
|
|
* Store stats name as below:
|
|
* ltc<ltc_value>_lts<lts_value>_<name_string>
|
|
*/
|
|
(void)strcpy(stats[ltc][lts].name, "ltc");
|
|
(void)nvgpu_strnadd_u32(ltc_str, ltc,
|
|
sizeof(ltc_str), 10U);
|
|
(void)strncat(stats[ltc][lts].name, ltc_str,
|
|
NVGPU_ECC_STAT_NAME_MAX_SIZE -
|
|
strlen(stats[ltc][lts].name));
|
|
(void)strncat(stats[ltc][lts].name, "_lts",
|
|
NVGPU_ECC_STAT_NAME_MAX_SIZE -
|
|
strlen(stats[ltc][lts].name));
|
|
(void)nvgpu_strnadd_u32(lts_str, lts,
|
|
sizeof(lts_str), 10U);
|
|
(void)strncat(stats[ltc][lts].name, lts_str,
|
|
NVGPU_ECC_STAT_NAME_MAX_SIZE -
|
|
strlen(stats[ltc][lts].name));
|
|
(void)strncat(stats[ltc][lts].name, "_",
|
|
NVGPU_ECC_STAT_NAME_MAX_SIZE -
|
|
strlen(stats[ltc][lts].name));
|
|
(void)strncat(stats[ltc][lts].name, name,
|
|
NVGPU_ECC_STAT_NAME_MAX_SIZE -
|
|
strlen(stats[ltc][lts].name));
|
|
|
|
nvgpu_ecc_stat_add(g, &stats[ltc][lts]);
|
|
}
|
|
}
|
|
|
|
*stat = stats;
|
|
|
|
fail:
|
|
if (err != 0) {
|
|
while (ltc-- > 0u) {
|
|
nvgpu_kfree(g, stats[ltc]);
|
|
}
|
|
|
|
nvgpu_kfree(g, stats);
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
void nvgpu_ltc_ecc_free(struct gk20a *g)
|
|
{
|
|
struct nvgpu_ecc *ecc = &g->ecc;
|
|
u32 i;
|
|
|
|
for (i = 0; i < nvgpu_ltc_get_ltc_count(g); i++) {
|
|
if (ecc->ltc.ecc_sec_count != NULL) {
|
|
nvgpu_kfree(g, ecc->ltc.ecc_sec_count[i]);
|
|
}
|
|
|
|
if (ecc->ltc.ecc_ded_count != NULL) {
|
|
nvgpu_kfree(g, ecc->ltc.ecc_ded_count[i]);
|
|
}
|
|
}
|
|
nvgpu_kfree(g, ecc->ltc.ecc_sec_count);
|
|
nvgpu_kfree(g, ecc->ltc.ecc_ded_count);
|
|
}
|