mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
Move interrupt specific data-members from common.mc to common.cic Some of these data members like sw_irq_stall_last_handled_cond need To be initialized much earlier during the OS specific init/probe stage. Also, some more members from struct nvgpu_interrupts(like stall_size, stall_lines[]), which will soon be moved to CIC will also need to be initialized early during the OS specific probe stage. However, the chip specific LUT can only be initialized after the hal_init stage where the HALs are all initialized. Split the CIC init to accommodate the above initialization requirements. JIRA NVGPU-6899 Change-Id: I9333db4cde59bb0aa8f6eb9f8472f00369817a5d Signed-off-by: Tejal Kudav <tkudav@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2552535 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
116 lines
2.8 KiB
C
116 lines
2.8 KiB
C
/*
|
|
* Copyright (c) 2021, 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/kmem.h>
|
|
#include <nvgpu/log.h>
|
|
#include <nvgpu/cic_rm.h>
|
|
|
|
#include "cic_rm_priv.h"
|
|
|
|
int nvgpu_cic_rm_setup(struct gk20a *g)
|
|
{
|
|
struct nvgpu_cic_rm *cic_rm;
|
|
int err = 0;
|
|
|
|
if (g->cic_rm != NULL) {
|
|
cic_dbg(g, "CIC_RM already initialized");
|
|
return 0;
|
|
}
|
|
|
|
cic_rm = nvgpu_kzalloc(g, sizeof(*cic_rm));
|
|
if (cic_rm == NULL) {
|
|
nvgpu_err(g, "Failed to allocate memory "
|
|
"for struct nvgpu_cic_rm");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
g->cic_rm = cic_rm;
|
|
cic_dbg(g, "CIC_RM unit initialization done.");
|
|
return err;
|
|
}
|
|
|
|
int nvgpu_cic_rm_init_vars(struct gk20a *g)
|
|
{
|
|
struct nvgpu_cic_rm *cic_rm;
|
|
int err = 0;
|
|
|
|
cic_rm = g->cic_rm;
|
|
if (cic_rm == NULL) {
|
|
nvgpu_err(g, "CIC_RM setup pending");
|
|
return -EINVAL;
|
|
}
|
|
|
|
err = nvgpu_cond_init(&cic_rm->sw_irq_stall_last_handled_cond);
|
|
if (err != 0) {
|
|
nvgpu_err(g, "sw irq stall cond init failed\n");
|
|
goto cleanup;
|
|
}
|
|
|
|
err = nvgpu_cond_init(&cic_rm->sw_irq_nonstall_last_handled_cond);
|
|
if (err != 0) {
|
|
nvgpu_err(g, "sw irq nonstall cond init failed\n");
|
|
goto cleanup_cond;
|
|
}
|
|
|
|
return 0;
|
|
|
|
cleanup_cond:
|
|
nvgpu_cond_destroy(&cic_rm->sw_irq_stall_last_handled_cond);
|
|
cleanup:
|
|
return err;
|
|
}
|
|
|
|
int nvgpu_cic_rm_deinit_vars(struct gk20a *g)
|
|
{
|
|
struct nvgpu_cic_rm *cic_rm;
|
|
|
|
cic_rm = g->cic_rm;
|
|
|
|
if (cic_rm == NULL) {
|
|
cic_dbg(g, "CIC_RM already removed");
|
|
return 0;
|
|
}
|
|
|
|
nvgpu_cond_destroy(&cic_rm->sw_irq_stall_last_handled_cond);
|
|
nvgpu_cond_destroy(&cic_rm->sw_irq_nonstall_last_handled_cond);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int nvgpu_cic_rm_remove(struct gk20a *g)
|
|
{
|
|
struct nvgpu_cic_rm *cic_rm;
|
|
|
|
cic_rm = g->cic_rm;
|
|
|
|
if (cic_rm == NULL) {
|
|
cic_dbg(g, "CIC_RM already removed");
|
|
return 0;
|
|
}
|
|
|
|
nvgpu_kfree(g, cic_rm);
|
|
g->cic_rm = NULL;
|
|
|
|
return 0;
|
|
}
|