Files
linux-nv-oot/drivers/platform/tegra/dce/dce-init-deinit.c
anupamg 84e1c1d01f DCE-KMD: Decouple resources init and start logic
- In DCE_KMD, dce_fsm_start() schedules start of state machine
  functionality which involves the waiting for DCE-FW boot completion,
  IPC admin setup and communication etc.

- HVRTOS restricts certain functionalities like waiting on events,
  acquiring locks, etc in initialize phase.

- Also for HVRTOS we are executing worker queue work in same
  thread context directly from where it's called from.

- For above reasons, we need to decouple SW resource allocation and
  init logic and actual execution start logic which was part of
  dce_driver_init() earlier into 2 phases:
    - dce_driver_init()
        - This will do all resource allocation/init and will be called
          during resource initialization phase.
            - Module probe for Linux
            - Initialize() context for HVRTOS.
    - dce_driver_start()
        - This will start actual DCE logic execution after all
          resources are allocated and initialized and will be executed
          separately.
            - In Linux, both will be executed from the same probe
              while in HVRTOS, the former is in process initialize
              stage and dce_driver_start is run in the
              Thread initialize stage.

JIRA TDS-16052

Change-Id: I1176d748bc705106bb0c8ca7e647713abf2d4a00
Signed-off-by: anupamg <anupamg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3192613
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
2025-07-24 10:19:12 +00:00

120 lines
2.1 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <dce.h>
#include <os-utils.h>
/**
* dce_driver_start - Start executing DCE logic
*
* @d : Pointer to tegra_dce struct.
*
* Returns void
*/
void dce_driver_start(struct tegra_dce *d)
{
dce_fsm_start(d);
}
/**
* dce_driver_stop - Stop executing DCE logic
*
* @d : Pointer to tegra_dce struct.
*
* Returns void
*/
void dce_driver_stop(struct tegra_dce *d)
{
dce_fsm_stop(d);
}
/**
* dce_driver_init - Initializes the various sw components
* and few hw elements dce.
*
* @d : Pointer to tegra_dce struct.
*
* Return : 0 if successful.
*/
int dce_driver_init(struct tegra_dce *d)
{
int ret = 0;
/**
* Set dce boot satus to false
*/
dce_set_boot_complete(d, false);
ret = dce_boot_interface_init(d);
if (ret) {
dce_err(d, "dce boot interface init failed");
goto err_boot_interface_init;
}
ret = dce_admin_init(d);
if (ret) {
dce_err(d, "dce admin interface init failed");
goto err_admin_interface_init;
}
ret = dce_client_init(d);
if (ret) {
dce_err(d, "dce client workqueue init failed");
goto err_client_init;
}
ret = dce_work_cond_sw_resource_init(d);
if (ret) {
dce_err(d, "dce sw resource init failed");
goto err_sw_init;
}
ret = dce_fsm_init(d);
if (ret) {
dce_err(d, "dce FSM init failed");
goto err_fsm_init;
}
return ret;
err_fsm_init:
dce_work_cond_sw_resource_deinit(d);
err_sw_init:
dce_client_deinit(d);
err_client_init:
dce_admin_deinit(d);
err_admin_interface_init:
dce_boot_interface_deinit(d);
err_boot_interface_init:
d->boot_status |= DCE_STATUS_FAILED;
return ret;
}
/**
* dce_driver_deinit - Release various sw resources
* associated with dce.
*
* @d : Pointer to tegra_dce struct.
*
* Return : Void
*/
void dce_driver_deinit(struct tegra_dce *d)
{
/* TODO : Reset DCE ? */
dce_fsm_deinit(d);
dce_work_cond_sw_resource_deinit(d);
dce_client_deinit(d);
dce_admin_deinit(d);
dce_boot_interface_deinit(d);
dce_release_fw(d, d->fw_data);
}