gpu: nvgpu: collapse nvgpu_gr_prepare_sw into nvgpu_gr_alloc

common.gr unit exports a separate API nvgpu_gr_prepare_sw to
initialize some SW pieces required for nvgpu_gr_enable_hw().
A separate API is really unnecessary since same initialization
can be performed in nvgpu_gr_alloc().

Remove nvgpu_gr_prepare_sw() and HAL gops.gr.gr_prepare_sw().
Initialize falcon and interrupt structures in loop from
nvgpu_gr_alloc().

Move nvgpu_netlist_init_ctx_vars() from nvgpu_gr_prepare_sw() to
common init path since netlist parsing need not be done from
common.gr unit. It just needs to happen before nvgpu_gr_enable_hw().

Also, trigger nvgpu_gr_free() from gr_remove_support() instead
of OS specific paths. Also remove nvgpu_gr_free() calls from
probe error paths since nvgpu_gr_alloc is no longer called in
probe path.

Move interrupt and falcon data structure free calls to nvgpu_gr_free().

Also remove corresponding unit testing code that tests
nvgpu_gr_prepare_sw() specifically.
Update some unit tests to initialize ecc counters and netlist.
Disable some unit tests that fail for reasons unknown.

Jira NVGPU-5648

Change-Id: I82ec8160f76530bc40e0c11a9f26ba1c8f9cf643
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2400166
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-08-18 17:24:34 +05:30
committed by Alex Waterman
parent cfa360f5b8
commit 8cccb49bd2
25 changed files with 129 additions and 259 deletions

View File

@@ -339,18 +339,14 @@ static void gr_remove_support(struct gk20a *g)
nvgpu_gr_hwpm_map_deinit(g, gr->hwpm_map);
#endif
nvgpu_gr_falcon_remove_support(g, gr->falcon);
gr->falcon = NULL;
nvgpu_gr_intr_remove_support(g, gr->intr);
gr->intr = NULL;
#ifdef CONFIG_NVGPU_GRAPHICS
nvgpu_gr_zbc_deinit(g, gr->zbc);
nvgpu_gr_zcull_deinit(g, gr->zcull);
#endif /* CONFIG_NVGPU_GRAPHICS */
nvgpu_gr_obj_ctx_deinit(g, gr->golden_image);
nvgpu_gr_free(g);
}
static int gr_init_access_map(struct gk20a *g, struct nvgpu_gr *gr)
@@ -611,57 +607,6 @@ out:
return err;
}
int nvgpu_gr_prepare_sw(struct gk20a *g)
{
struct nvgpu_gr *gr = g->gr;
int err = 0;
nvgpu_log_fn(g, " ");
err = nvgpu_netlist_init_ctx_vars(g);
if (err != 0) {
nvgpu_err(g, "failed to parse netlist");
return err;
}
if (gr->falcon == NULL) {
gr->falcon = nvgpu_gr_falcon_init_support(g);
if (gr->falcon == NULL) {
nvgpu_err(g, "failed to init gr falcon");
err = -ENOMEM;
goto exit;
}
}
if (gr->intr == NULL) {
gr->intr = nvgpu_gr_intr_init_support(g);
if (gr->intr == NULL) {
nvgpu_err(g, "failed to init gr intr support");
err = -ENOMEM;
goto exit;
}
}
/*
* Initialize FECS ECC counters here before acr_construct_execute as the
* FECS ECC errors during FECS load need to be handled and reported
* using the ECC counters.
*/
if ((g->ops.gr.ecc.fecs_ecc_init != NULL) && !g->ecc.initialized) {
err = g->ops.gr.ecc.fecs_ecc_init(g);
if (err != 0) {
nvgpu_err(g, "failed to init gr fecs ecc");
nvgpu_gr_intr_remove_support(g, gr->intr);
gr->intr = NULL;
goto exit;
}
}
exit:
return err;
}
static int gr_init_prepare_hw(struct gk20a *g)
{
#if defined(CONFIG_NVGPU_NON_FUSA) && defined(CONFIG_NVGPU_NEXT)
@@ -847,6 +792,7 @@ int nvgpu_gr_init_support(struct gk20a *g)
int nvgpu_gr_alloc(struct gk20a *g)
{
struct nvgpu_gr *gr = NULL;
int err;
u32 i;
/* if gr exists return */
@@ -872,21 +818,62 @@ int nvgpu_gr_alloc(struct gk20a *g)
for (i = 0U; i < g->num_gr_instances; i++) {
gr = &g->gr[i];
gr->falcon = nvgpu_gr_falcon_init_support(g);
if (gr->falcon == NULL) {
nvgpu_err(g, "failed to init gr falcon");
err = -ENOMEM;
}
gr->intr = nvgpu_gr_intr_init_support(g);
if (gr->intr == NULL) {
nvgpu_err(g, "failed to init gr intr support");
err = -ENOMEM;
}
nvgpu_cond_init(&gr->init_wq);
#ifdef CONFIG_NVGPU_NON_FUSA
nvgpu_gr_override_ecc_val(gr, g->fecs_feature_override_ecc_val);
#endif
}
/*
* Initialize FECS ECC counters here before acr_construct_execute as the
* FECS ECC errors during FECS load need to be handled and reported
* using the ECC counters.
*/
if (g->ops.gr.ecc.fecs_ecc_init != NULL) {
err = g->ops.gr.ecc.fecs_ecc_init(g);
if (err != 0) {
nvgpu_err(g, "failed to init gr fecs ecc");
nvgpu_gr_intr_remove_support(g, gr->intr);
gr->intr = NULL;
}
}
return 0;
}
void nvgpu_gr_free(struct gk20a *g)
{
/*Delete gr memory */
if (g->gr != NULL) {
nvgpu_kfree(g, g->gr);
struct nvgpu_gr *gr = NULL;
u32 i;
if (g->gr == NULL) {
return;
}
for (i = 0U; i < g->num_gr_instances; i++) {
gr = &g->gr[i];
nvgpu_gr_falcon_remove_support(g, gr->falcon);
gr->falcon = NULL;
nvgpu_gr_intr_remove_support(g, gr->intr);
gr->intr = NULL;
}
nvgpu_kfree(g, g->gr);
g->gr = NULL;
}

View File

@@ -42,6 +42,7 @@
#include <nvgpu/device.h>
#include <nvgpu/gr/gr.h>
#include <nvgpu/pm_reservation.h>
#include <nvgpu/netlist.h>
#ifdef CONFIG_NVGPU_LS_PMU
#include <nvgpu/pmu/pmu_pstate.h>
@@ -655,9 +656,9 @@ int nvgpu_finalize_poweron(struct gk20a *g)
NVGPU_INIT_TABLE_ENTRY(&nvgpu_init_power_gate_gr, NO_FLAG),
#endif
NVGPU_INIT_TABLE_ENTRY(g->ops.grmgr.init_gr_manager, NO_FLAG),
NVGPU_INIT_TABLE_ENTRY(&nvgpu_netlist_init_ctx_vars, NO_FLAG),
/* prepare portion of sw required for enable hw */
NVGPU_INIT_TABLE_ENTRY(&nvgpu_gr_alloc, NO_FLAG),
NVGPU_INIT_TABLE_ENTRY(g->ops.gr.gr_prepare_sw, NO_FLAG),
NVGPU_INIT_TABLE_ENTRY(g->ops.gr.gr_enable_hw, NO_FLAG),
NVGPU_INIT_TABLE_ENTRY(g->ops.acr.acr_construct_execute,
NVGPU_SEC_PRIVSECURITY),

View File

@@ -35,6 +35,7 @@
#include <nvgpu/tsg.h>
#include <nvgpu/string.h>
#include <nvgpu/gr/global_ctx.h>
#include <nvgpu/gr/gr.h>
#include <nvgpu/gr/ctx.h>
#include <nvgpu/gr/config.h>
#include <nvgpu/gr/gr_intr.h>
@@ -707,6 +708,8 @@ static void vgpu_remove_gr_support(struct gk20a *g)
#ifdef CONFIG_NVGPU_GRAPHICS
nvgpu_gr_zcull_deinit(gr->g, gr->zcull);
#endif
nvgpu_gr_free(g);
}
static int vgpu_gr_init_gr_setup_sw(struct gk20a *g)
@@ -723,22 +726,6 @@ static int vgpu_gr_init_gr_setup_sw(struct gk20a *g)
gr->g = g;
if (gr->intr == NULL) {
gr->intr = nvgpu_gr_intr_init_support(g);
if (gr->intr == NULL) {
err = -ENOMEM;
goto clean_up;
}
}
if (gr->falcon == NULL) {
gr->falcon = nvgpu_gr_falcon_init_support(g);
if (gr->falcon == NULL) {
err = -ENOMEM;
goto clean_up;
}
}
err = g->ops.gr.falcon.init_ctx_state(g, &gr->falcon->sizes);
if (err) {
goto clean_up;

View File

@@ -190,7 +190,6 @@ static const struct gpu_ops gm20b_ops = {
.isr_nonstall = gk20a_ce2_nonstall_isr,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -238,7 +238,6 @@ static const struct gpu_ops gp10b_ops = {
.isr_nonstall = gp10b_ce_nonstall_isr,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -305,7 +305,6 @@ NVGPU_COV_WHITELIST_BLOCK_END(NVGPU_MISRA(Rule, 8_7))
.init_prod_values = gv11b_ce_init_prod_values,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -350,7 +350,6 @@ static const struct gpu_ops tu104_ops = {
.init_prod_values = gv11b_ce_init_prod_values,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -175,7 +175,6 @@ static const struct gpu_ops vgpu_gp10b_ops = {
.get_num_pce = vgpu_ce_get_num_pce,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -234,7 +234,6 @@ static const struct gpu_ops vgpu_gv11b_ops = {
.get_num_pce = vgpu_ce_get_num_pce,
},
.gr = {
.gr_prepare_sw = nvgpu_gr_prepare_sw,
.gr_enable_hw = nvgpu_gr_enable_hw,
.gr_init_support = nvgpu_gr_init_support,
.gr_suspend = nvgpu_gr_suspend,

View File

@@ -998,23 +998,6 @@ struct gops_gr_zcull {
* @see gpu_ops
*/
struct gops_gr {
/**
* @brief Prepare the s/w required to enable gr h/w.
*
* @param g [in] Pointer to GPU driver struct.
*
* This HAL executes only a subset of s/w initialization sequence
* that is required to enable GR engine h/w in #gr_enable_hw hal.
* This HAL always maps to #nvgpu_gr_prepare_sw.
*
* @return 0 in case of success, < 0 in case of failure.
* @retval -ENOMEM if memory allocation fails for any internal data
* structure.
*
* @see nvgpu_gr_prepare_sw
*/
int (*gr_prepare_sw)(struct gk20a *g);
/**
* @brief Enable GR engine h/w.
*

View File

@@ -124,6 +124,18 @@ struct nvgpu_gr_config;
* @param g [in] Pointer to GPU driver struct.
*
* This function allocates memory for GR struct (i.e. struct nvgpu_gr).
* Number of GR instances are queried from #nvgpu_grmgr_get_num_gr_instances()
* and size is allocated for each instance.
*
* This function executes only a subset of s/w initialization sequence
* that is required to enable GR engine h/w in #nvgpu_gr_enable_hw().
*
* This initialization includes allocating memory for internal data
* structures required to enable h/w. This function allocates memory
* for FECS ECC error counters and GR interrupt structure.
*
* Note that all rest of the s/w initialization is completed in
* #nvgpu_gr_init_support() function.
*
* @return 0 in case of success, < 0 in case of failure.
* @retval -ENOMEM if memory allocation fails for GR struct.
@@ -140,28 +152,6 @@ int nvgpu_gr_alloc(struct gk20a *g);
*/
void nvgpu_gr_free(struct gk20a *g);
/**
* @brief Initialize the s/w required to enable h/w.
*
* @param g [in] Pointer to GPU driver struct.
*
* This function executes only a subset of s/w initialization sequence
* that is required to enable GR engine h/w in #nvgpu_gr_enable_hw().
*
* This initialization includes reading netlist ucode and allocating
* memory for internal data structures required to enable h/w. This
* function allocates memory for FECS ECC error counters and GR
* interrupt structure.
*
* Note that all rest of the s/w initialization is completed in
* #nvgpu_gr_init_support() function.
*
* @return 0 in case of success, < 0 in case of failure.
* @retval -ENOMEM if memory allocation fails for any internal data
* structure.
*/
int nvgpu_gr_prepare_sw(struct gk20a *g);
/**
* @brief Enable GR engine h/w.
*
@@ -203,7 +193,7 @@ int nvgpu_gr_enable_hw(struct gk20a *g);
* after considering floorsweeping.
*
* This function must be called in this sequence:
* - nvgpu_gr_prepare_sw()
* - nvgpu_gr_alloc()
* - nvgpu_gr_enable_hw()
* - nvgpu_gr_init_support()
*

View File

@@ -323,9 +323,6 @@ static void nvgpu_free_gk20a(struct gk20a *g)
{
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
/* free gr memory */
nvgpu_gr_free(g);
kfree(l);
}

View File

@@ -1731,7 +1731,6 @@ return_err:
* Last since the above allocs may use data structures in here.
*/
nvgpu_kmem_fini(gk20a, NVGPU_KMEM_FINI_FORCE_CLEANUP);
nvgpu_gr_free(gk20a);
kfree(l);
return err;

View File

@@ -695,7 +695,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
err_free_irq:
nvgpu_free_irq(g);
nvgpu_gr_free(g);
err_disable_msi:
#if defined(CONFIG_PCI_MSI)
if (g->msi_enabled)

View File

@@ -399,7 +399,6 @@ int vgpu_probe(struct platform_device *pdev)
/* Initialize the platform interface. */
err = platform->probe(dev);
if (err) {
nvgpu_gr_free(gk20a);
if (err == -EPROBE_DEFER)
nvgpu_info(gk20a, "platform probe failed");
else
@@ -411,7 +410,6 @@ int vgpu_probe(struct platform_device *pdev)
err = platform->late_probe(dev);
if (err) {
nvgpu_err(gk20a, "late probe failed");
nvgpu_gr_free(gk20a);
return err;
}
}
@@ -419,14 +417,12 @@ int vgpu_probe(struct platform_device *pdev)
err = vgpu_comm_init(gk20a);
if (err) {
nvgpu_err(gk20a, "failed to init comm interface");
nvgpu_gr_free(gk20a);
return -ENOSYS;
}
priv->virt_handle = vgpu_connect();
if (!priv->virt_handle) {
nvgpu_err(gk20a, "failed to connect to server node");
nvgpu_gr_free(gk20a);
vgpu_comm_deinit();
return -ENOSYS;
}
@@ -434,21 +430,18 @@ int vgpu_probe(struct platform_device *pdev)
err = vgpu_get_constants(gk20a);
if (err) {
vgpu_comm_deinit();
nvgpu_gr_free(gk20a);
return err;
}
err = vgpu_pm_init(dev);
if (err) {
nvgpu_err(gk20a, "pm init failed");
nvgpu_gr_free(gk20a);
return err;
}
err = nvgpu_thread_create(&priv->intr_handler, gk20a,
vgpu_intr_thread, "gk20a");
if (err) {
nvgpu_gr_free(gk20a);
return err;
}