Skip to content

framework/csimanager: fix/improve error handling and resource management#7174

Merged
vibhor-m merged 1 commit intoSamsung:masterfrom
rajat-samsung:fix/csifw_error_handling_and_resourse_management
Apr 27, 2026
Merged

framework/csimanager: fix/improve error handling and resource management#7174
vibhor-m merged 1 commit intoSamsung:masterfrom
rajat-samsung:fix/csifw_error_handling_and_resourse_management

Conversation

@rajat-samsung
Copy link
Copy Markdown
Contributor

@rajat-samsung rajat-samsung commented Feb 27, 2026

This commit enhances the Channel State Information (CSI) framework with improved error handling, resource management, and robustness:

  • Renamed CSIFW_INVALID_RAWDATA to CSIFW_ERROR_DATA_NOT_AVAILABLE for clearer error reporting
  • Implemented timeout handling in message queue operations to prevent indefinite blocking
  • Enhanced error reporting with more descriptive messages and callback notifications
  • Added consecutive failure detection mechanism to prevent system lockups
  • Fixed preprocessor directive logic for custom device path configuration
  • Fixed logic error in add_service function for proper buffer management
  • Improved resource management with proper pthread attribute cleanup
  • Added configurable timeout option for CSI data collection
  • Removed invalid csi config enable after wifi reconnect
  • Added task_manager stop and unregister

@rajat-samsung rajat-samsung force-pushed the fix/csifw_error_handling_and_resourse_management branch 2 times, most recently from e80da5b to e2241df Compare March 9, 2026 07:46
@rajat-samsung rajat-samsung force-pushed the fix/csifw_error_handling_and_resourse_management branch 3 times, most recently from 4e1c5a3 to 9e96c9f Compare April 20, 2026 08:16
return;
}

if (info->status == TM_APP_STATE_RUNNING) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition does not ensure, that stop will be called only when task_func is running. Hence running check can be removed.

csi_data_len = msg.data_len;
len = readCSIData(fd, get_data_buffptr, csi_data_len);
last_data_read_timestamp_us = get_monotonic_time_us();
CSIFW_LOGD("last_data_read_timestamp_us after readCSIData:%llu",last_data_read_timestamp_us);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSIFW_LOGD("CSI Data read complete %llu", get_monotonic_time_us());

return CSIFW_OK;
}

static unsigned long long get_monotonic_time_us(void)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function will be called lot of times.

this function should be inline
OR
This function can be a pre-processer

consecutive_failures++;
if (consecutive_failures >= MAX_CONSECUTIVE_FAILURES) {
CSIFW_LOGE("CRITICAL: %d consecutive Message received size error", consecutive_failures);
consecutive_failures = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consecutive_failures & timeout_count are in success path and will be set to 0 always. This may be a redundant operation performed in default path

@rajat-samsung rajat-samsung force-pushed the fix/csifw_error_handling_and_resourse_management branch 7 times, most recently from 129f3e7 to ceade1c Compare April 27, 2026 05:30
}
if (len != csi_data_len - CSIFW_CSI_HEADER_LEN) {
csi_data_len = len + CSIFW_CSI_HEADER_LEN;
if (consecutive_failures > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition can be improvised as per timeout_count variable

if (consecutive_failures >= MAX_CONSECUTIVE_FAILURES) {
CSIFW_LOGE("CRITICAL: %d consecutive failures detected", consecutive_failures);
consecutive_failures = 0;
p_csifw_ctx->CSI_DataCallback(CSIFW_INTERNAL_ERROR, 0, NULL, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a todo to stop CSI FW when this error happens

- Renamed CSIFW_INVALID_RAWDATA to CSIFW_ERROR_DATA_NOT_AVAILABLE for clearer error reporting
- Implemented timeout handling in message queue operations to prevent indefinite blocking
- Enhanced error reporting with more descriptive messages and callback notifications
- Fixed preprocessor directive logic for custom device path configuration
- Fixed logic error in add_service function for proper buffer management
- Added consecutive failure detection mechanism to prevent system lockups
- Improved resource management with proper pthread attribute cleanup
- Added configurable timeout option for CSI data collection
- Removed invalid csi config enable after wifi reconnect
- CSI data length correction using board info
- Added task_manager stop and unregister
@rajat-samsung rajat-samsung force-pushed the fix/csifw_error_handling_and_resourse_management branch from ceade1c to c7a2639 Compare April 27, 2026 05:50
Copy link
Copy Markdown

@sh44-lee sh44-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@vibhor-m vibhor-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are fine.

@vibhor-m vibhor-m merged commit 4548c36 into Samsung:master Apr 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants