From 6974f784e26b7d19d92fa282328bbeec28289b47 Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Tue, 24 Mar 2020 10:50:30 -0700 Subject: [PATCH] gpu: nvgpu: Update cbc_init_support() return error Currently, nvgpu_cbc_init_support() doesn't return error if cbc.alloc_comptags() fails. Modify nvgpu_cbc_init_support() to check error returned by cbc.alloc_comptags(). If alloc_comptags() fails, free allocated cbc memory and set cbc pointer to NULL. JIRA NVGPU-4666 Change-Id: Id7edaeebc81e7d7029d98bcdbffaf6506c8f0979 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2317822 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman Reviewed-by: Seema Khowala Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/cbc/cbc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/cbc/cbc.c b/drivers/gpu/nvgpu/common/cbc/cbc.c index 0470e6009..272c41f93 100644 --- a/drivers/gpu/nvgpu/common/cbc/cbc.c +++ b/drivers/gpu/nvgpu/common/cbc/cbc.c @@ -1,7 +1,7 @@ /* * CBC * - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-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"), @@ -51,6 +51,12 @@ void nvgpu_cbc_remove_support(struct gk20a *g) g->cbc = NULL; } +/* + * This function is triggered during finalize_poweron multiple times. + * This function should not return if cbc is not NULL. + * cbc.init(), which re-writes HW registers that are reset during suspend, + * should be allowed to execute each time. + */ int nvgpu_cbc_init_support(struct gk20a *g) { int err = 0; @@ -64,8 +70,15 @@ int nvgpu_cbc_init_support(struct gk20a *g) return -ENOMEM; } g->cbc = cbc; + if (g->ops.cbc.alloc_comptags != NULL) { err = g->ops.cbc.alloc_comptags(g, g->cbc); + if (err != 0) { + nvgpu_err(g, "Failed to allocate comptags"); + nvgpu_kfree(g, cbc); + g->cbc = NULL; + return err; + } } }