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 <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2317822
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Vedashree Vidwans
2020-03-24 10:50:30 -07:00
committed by Alex Waterman
parent 0610a0b2d3
commit 6974f784e2

View File

@@ -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;
}
}
}