platform: dce: FSM incremental fixes

This patch addresses design review comments for FSM
 - Add comment to update design doc on FSM update
 - Create wrapper function to check bootcmd complete status
 - move bootstrapping functions to dce_bootstrap.c file
 - Fix sw resource init/deinit function name

Bug 3583331

Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Change-Id: I77f05135f7ec1882922907f8acef50def639d26d
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2758902
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Mahesh Kumar
2022-08-10 14:09:58 +05:30
committed by Laxman Dewangan
parent 5aa80075ad
commit 8ef1f2db87
7 changed files with 105 additions and 83 deletions

View File

@@ -309,10 +309,10 @@ int dce_admin_handle_ipc_requested_event(struct tegra_dce *d, void *params)
(struct dce_admin_send_msg_params *)params;
/*
* Do not handle admin IPC if bootstrap is not completed
* Do not handle admin IPC if boot commands are not completed
*/
if ((d->boot_status & DCE_FW_BOOTSTRAP_DONE) == 0) {
dce_err(d, "Bootstrap not yet completed\n");
if (!dce_is_bootcmds_done(d)) {
dce_err(d, "Boot commands are not yet completed\n");
ret = -EINVAL;
goto out;
}

View File

@@ -144,6 +144,76 @@ int dce_handle_boot_complete_received_event(struct tegra_dce *d, void *params)
return 0;
}
/*
* dce_start_boot_flow : Start dce bootstrap flow
*
* @d : Pointer to tegra_dce struct.
*
* Return : 0 if successful else error code
*/
static int
dce_start_boot_flow(struct tegra_dce *d)
{
int ret = 0;
ret = dce_start_bootstrap_flow(d);
if (ret) {
dce_err(d, "DCE_BOOT_FAILED: Bootstrap flow didn't complete");
goto exit;
}
dce_admin_ivc_channel_reset(d);
ret = dce_start_admin_seq(d);
if (ret) {
dce_err(d, "DCE_BOOT_FAILED: Admin flow didn't complete");
} else {
d->boot_status |= DCE_FW_BOOT_DONE;
dce_info(d, "DCE_BOOT_DONE");
}
exit:
if (ret)
d->boot_status |= DCE_STATUS_FAILED;
return ret;
}
/**
* dce_bootstrap_work_fn : execute fsm start and bootstrap flow
*
* @d : Pointer to tegra_dce struct.
*
* Return : void
*/
void dce_bootstrap_work_fn(struct tegra_dce *d)
{
int ret = 0;
if (d == NULL) {
dce_err(d, "tegra_dce struct is NULL");
return;
}
ret = dce_fsm_post_event(d, EVENT_ID_DCE_FSM_START, NULL);
if (ret) {
dce_err(d, "FSM start failed\n");
return;
}
ret = dce_fsm_post_event(d, EVENT_ID_DCE_BOOT_COMPLETE_REQUESTED, NULL);
if (ret) {
dce_err(d, "Error while posting DCE_BOOT_COMPLETE_REQUESTED event");
return;
}
ret = dce_start_boot_flow(d);
if (ret) {
dce_err(d, "DCE bootstrapping failed\n");
return;
}
}
/**
* dce_handle_irq_status - Handles irq status from DCE
*

View File

@@ -19,6 +19,9 @@ struct dce_event_process_struct {
int (*fsm_event_handle)(struct tegra_dce *d, void *params);
};
/*
* Please update FSM design Document, whenever updating below event table
*/
static struct dce_event_process_struct event_process_table[] = {
{
.event = EVENT_ID_DCE_FSM_START,
@@ -120,6 +123,8 @@ int dce_handle_event_stub(struct tegra_dce *d, void *params)
* @event : Event for which FSM state need to be set
*
* Return : void
*
* Please update FSM design Document, whenever updating below event states
*/
static void
dce_fsm_set_state(struct tegra_dce *d,
@@ -211,6 +216,8 @@ dce_fsm_set_state(struct tegra_dce *d,
* @event : Posted FSM event
*
* @return : ESUCCESS if event valid else error code
*
* Please update FSM design Document, whenever updating below event validation
*/
static int
dce_fsm_validate_event(struct tegra_dce *d,

View File

@@ -44,7 +44,7 @@ int dce_driver_init(struct tegra_dce *d)
goto err_client_init;
}
ret = dce_sw_resource_init(d);
ret = dce_work_cond_sw_resource_init(d);
if (ret) {
dce_err(d, "dce sw resource init failed");
goto err_sw_init;
@@ -61,7 +61,7 @@ int dce_driver_init(struct tegra_dce *d)
return ret;
err_fsm_init:
dce_sw_resource_deinit(d);
dce_work_cond_sw_resource_deinit(d);
err_sw_init:
dce_client_deinit(d);
err_client_init:
@@ -89,7 +89,7 @@ void dce_driver_deinit(struct tegra_dce *d)
dce_fsm_deinit(d);
dce_sw_resource_deinit(d);
dce_work_cond_sw_resource_deinit(d);
dce_client_deinit(d);

View File

@@ -72,84 +72,14 @@ void dce_wakeup_interruptible(struct tegra_dce *d, u32 msg_id)
dce_cond_signal_interruptible(&wait->cond_wait);
}
/*
* dce_start_boot_flow : Start dce bootstrap flow
/**
* dce_work_cond_sw_resource_init : Init dce workqueues related resources
*
* @d : Pointer to tegra_dce struct.
*
* Return : 0 if successful else error code
*/
static int
dce_start_boot_flow(struct tegra_dce *d)
{
int ret = 0;
ret = dce_start_bootstrap_flow(d);
if (ret) {
dce_warn(d, "DCE_BOOT_FAILED: Bootstrap flow didn't complete");
goto exit;
}
dce_admin_ivc_channel_reset(d);
ret = dce_start_admin_seq(d);
if (ret) {
dce_warn(d, "DCE_BOOT_FAILED: Admin flow didn't complete");
} else {
d->boot_status |= DCE_FW_BOOT_DONE;
dce_info(d, "DCE_BOOT_DONE");
}
exit:
if (ret)
d->boot_status |= DCE_STATUS_FAILED;
return ret;
}
/**
* dce_bootstrap_work_fn : execute fsm start and bootstrap flow
*
* @d : Pointer to tegra_dce struct.
*
* Return : void
*/
void dce_bootstrap_work_fn(struct tegra_dce *d)
{
int ret = 0;
if (d == NULL) {
dce_err(d, "tegra_dce struct is NULL");
return;
}
ret = dce_fsm_post_event(d, EVENT_ID_DCE_FSM_START, NULL);
if (ret) {
dce_err(d, "FSM start failed\n");
return;
}
ret = dce_fsm_post_event(d, EVENT_ID_DCE_BOOT_COMPLETE_REQUESTED, NULL);
if (ret) {
dce_err(d, "Error while posting DCE_BOOT_COMPLETE_REQUESTED event");
return;
}
ret = dce_start_boot_flow(d);
if (ret) {
dce_err(d, "DCE bootstrapping failed\n");
return;
}
}
/**
* dce_sw_resource_init : Init dce workques related resources
*
* @d : Pointer to tegra_dce struct.
*
* Return : 0 if successful else error code
*/
int dce_sw_resource_init(struct tegra_dce *d)
int dce_work_cond_sw_resource_init(struct tegra_dce *d)
{
int ret = 0;
int i;
@@ -185,13 +115,13 @@ exit:
}
/**
* dce_sw_resource_deinit : de-init dce workques related resources
* dce_work_cond_sw_resource_deinit : de-init dce workqueues related resources
*
* @d : Pointer to tegra_dce struct.
*
* Return : void
*/
void dce_sw_resource_deinit(struct tegra_dce *d)
void dce_work_cond_sw_resource_deinit(struct tegra_dce *d)
{
int i;

View File

@@ -32,8 +32,8 @@ struct dce_wait_cond {
struct dce_cond cond_wait;
};
int dce_sw_resource_init(struct tegra_dce *d);
void dce_sw_resource_deinit(struct tegra_dce *d);
int dce_work_cond_sw_resource_init(struct tegra_dce *d);
void dce_work_cond_sw_resource_deinit(struct tegra_dce *d);
void dce_schedule_boot_complete_wait_worker(struct tegra_dce *d);
int dce_wait_interruptible(struct tegra_dce *d, u32 msg_id);
void dce_wakeup_interruptible(struct tegra_dce *d, u32 msg_id);

View File

@@ -290,6 +290,20 @@ static inline void dce_set_boot_complete(struct tegra_dce *d, bool val)
d->boot_complete = val;
}
/**
* dce_is_bootcmds_done - Checks if dce bootstrap bootcmds done.
*
* Chekc if all the mailbox boot commands are completed
*
* @d - Pointer to tegra_dce struct.
*
* Return : True if bootcmds are completed
*/
static inline bool dce_is_bootcmds_done(struct tegra_dce *d)
{
return (d->boot_status & DCE_FW_BOOTSTRAP_DONE) ? true : false;
}
/**
* dce_is_bootstrap_done - check if dce bootstrap is done.
*
@@ -358,6 +372,7 @@ const char *dce_get_fw_name(struct tegra_dce *d);
int dce_driver_init(struct tegra_dce *d);
void dce_driver_deinit(struct tegra_dce *d);
void dce_bootstrap_work_fn(struct tegra_dce *d);
int dce_start_bootstrap_flow(struct tegra_dce *d);
int dce_boot_interface_init(struct tegra_dce *d);
void dce_boot_interface_deinit(struct tegra_dce *d);