diff --git a/drivers/gpu/nvgpu/common/ecc.c b/drivers/gpu/nvgpu/common/ecc.c index 6dd41a467..f33f8837b 100644 --- a/drivers/gpu/nvgpu/common/ecc.c +++ b/drivers/gpu/nvgpu/common/ecc.c @@ -344,12 +344,18 @@ void nvgpu_ecc_free(struct gk20a *g) nvgpu_kfree(g, ecc->fbpa.fbpa_ecc_ded_err_count); (void)memset(ecc, 0, sizeof(*ecc)); + + ecc->initialized = false; } int nvgpu_ecc_init_support(struct gk20a *g) { int err; + if (g->ecc.initialized) { + return 0; + } + if (g->ops.gr.ecc.init == NULL) { return 0; } @@ -366,6 +372,8 @@ int nvgpu_ecc_init_support(struct gk20a *g) return err; } + g->ecc.initialized = true; + return 0; } diff --git a/drivers/gpu/nvgpu/common/gr/gr.c b/drivers/gpu/nvgpu/common/gr/gr.c index 2d40002be..b991fd579 100644 --- a/drivers/gpu/nvgpu/common/gr/gr.c +++ b/drivers/gpu/nvgpu/common/gr/gr.c @@ -274,7 +274,6 @@ static void gr_remove_support(struct gk20a *g) nvgpu_gr_falcon_remove_support(g, gr->falcon); gr->falcon = NULL; - nvgpu_ecc_remove_support(g); nvgpu_gr_zbc_deinit(g, gr->zbc); nvgpu_gr_zcull_deinit(g, gr->zcull); nvgpu_gr_obj_ctx_deinit(g, gr->golden_image); @@ -459,11 +458,6 @@ static int gr_init_setup_sw(struct gk20a *g) gr->remove_support = gr_remove_support; gr->sw_ready = true; - err = nvgpu_ecc_init_support(g); - if (err != 0) { - goto clean_up; - } - nvgpu_log_fn(g, "done"); return 0; diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index c47282202..dee1b7000 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -377,6 +378,13 @@ int gk20a_finalize_poweron(struct gk20a *g) goto done; } + err = nvgpu_ecc_init_support(g); + if (err != 0) { + nvgpu_err(g, "failed to init ecc"); + nvgpu_mutex_release(&g->tpc_pg_lock); + goto done; + } + nvgpu_mutex_release(&g->tpc_pg_lock); if (nvgpu_is_enabled(g, NVGPU_PMU_PSTATE)) { @@ -582,6 +590,8 @@ static void gk20a_free_cb(struct nvgpu_ref *refcount) nvgpu_cbc_remove_support(g); + nvgpu_ecc_remove_support(g); + if (g->remove_support != NULL) { g->remove_support(g); } diff --git a/drivers/gpu/nvgpu/include/nvgpu/ecc.h b/drivers/gpu/nvgpu/include/nvgpu/ecc.h index 9b211ef74..3d2727397 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/ecc.h +++ b/drivers/gpu/nvgpu/include/nvgpu/ecc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-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"), @@ -118,6 +118,7 @@ struct nvgpu_ecc { struct nvgpu_list_node stats_list; int stats_count; + bool initialized; }; int nvgpu_ecc_counter_init_per_tpc(struct gk20a *g,