From 5fb7f2a262d2e9e187d8bcc4fb2ceb945fec9f8d Mon Sep 17 00:00:00 2001 From: David Nieto Date: Thu, 26 Jan 2017 14:44:54 -0800 Subject: gpu: nvgpu: Propagate pmu initialization failures During testing it was detected that a failure in loading the firmware for the driver would not propagate, allowing some function pointers to be left unitialized. This would cause a kernel-crash later on. Bug 1866370 Change-Id: I66056a1d99229d10635293d4c1685f596f197255 Signed-off-by: David Nieto Reviewed-on: http://git-master/r/1295376 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Mahantesh Kumbar Reviewed-by: svccoveritychecker Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gp106/acr_gp106.c | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'drivers/gpu/nvgpu/gp106/acr_gp106.c') diff --git a/drivers/gpu/nvgpu/gp106/acr_gp106.c b/drivers/gpu/nvgpu/gp106/acr_gp106.c index 58c4e68a..308f1caf 100644 --- a/drivers/gpu/nvgpu/gp106/acr_gp106.c +++ b/drivers/gpu/nvgpu/gp106/acr_gp106.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -173,7 +173,8 @@ static int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img_v1 *p_img) err = gk20a_init_pmu(pmu); if (err) { - gp106_dbg_pmu("failed to set function pointers\n"); + gk20a_err(dev_from_gk20a(g), + "failed to set function pointers\n"); goto release_sig; } @@ -455,33 +456,34 @@ static int lsfm_discover_ucode_images(struct gk20a *g, /* Obtain the PMU ucode image and add it to the list if required*/ memset(&ucode_img, 0, sizeof(ucode_img)); status = pmu_ucode_details(g, &ucode_img); - if (status == 0) { - if (ucode_img.lsf_desc != NULL) { - /* The falon_id is formed by grabbing the static base - * falon_id from the image and adding the - * engine-designated falcon instance.*/ - pmu->pmu_mode |= PMU_SECURE_MODE; - falcon_id = ucode_img.lsf_desc->falcon_id + - ucode_img.flcn_inst; - - if (!lsfm_falcon_disabled(g, plsfm, falcon_id)) { - pmu->falcon_id = falcon_id; - if (lsfm_add_ucode_img(g, plsfm, &ucode_img, - pmu->falcon_id) == 0) - pmu->pmu_mode |= PMU_LSFM_MANAGED; - - plsfm->managed_flcn_cnt++; - } else { - gp106_dbg_pmu("id not managed %d\n", - ucode_img.lsf_desc->falcon_id); - } + if (status) + return status; + + if (ucode_img.lsf_desc != NULL) { + /* The falon_id is formed by grabbing the static base + * falon_id from the image and adding the + * engine-designated falcon instance.*/ + pmu->pmu_mode |= PMU_SECURE_MODE; + falcon_id = ucode_img.lsf_desc->falcon_id + + ucode_img.flcn_inst; + + if (!lsfm_falcon_disabled(g, plsfm, falcon_id)) { + pmu->falcon_id = falcon_id; + if (lsfm_add_ucode_img(g, plsfm, &ucode_img, + pmu->falcon_id) == 0) + pmu->pmu_mode |= PMU_LSFM_MANAGED; + + plsfm->managed_flcn_cnt++; + } else { + gp106_dbg_pmu("id not managed %d\n", + ucode_img.lsf_desc->falcon_id); } + } - /*Free any ucode image resources if not managing this falcon*/ - if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) { - gp106_dbg_pmu("pmu is not LSFM managed\n"); - lsfm_free_ucode_img_res(&ucode_img); - } + /*Free any ucode image resources if not managing this falcon*/ + if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) { + gp106_dbg_pmu("pmu is not LSFM managed\n"); + lsfm_free_ucode_img_res(&ucode_img); } /* Enumerate all constructed falcon objects, -- cgit v1.2.2