Skip to content

audio: cadence: add optional API error reporting#10604

Open
ujfalusi wants to merge 1 commit intothesofproject:mainfrom
ujfalusi:peter/pr/cadence_silence_nonfatal
Open

audio: cadence: add optional API error reporting#10604
ujfalusi wants to merge 1 commit intothesofproject:mainfrom
ujfalusi:peter/pr/cadence_silence_nonfatal

Conversation

@ujfalusi
Copy link
Contributor

@ujfalusi ujfalusi commented Mar 6, 2026

Extend cadence_codec_process_data() with an optional output parameter for returning Cadence API error codes while preserving existing return behavior: non-fatal API errors still return 0 and fatal errors are returned.

Suppress non-fatal warning prints in this path and add lightweight overwrite tracing for repeated API error updates.

Update cadence IPC3 and IPC4 call sites to pass NULL for now.

Copilot AI review requested due to automatic review settings March 6, 2026 12:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Cadence codec processing path to optionally report the underlying Cadence API error code to callers, while keeping the existing behavior where non-fatal API errors do not fail processing.

Changes:

  • Extend cadence_codec_process_data() with an optional api_error_code output parameter.
  • Suppress non-fatal warning logs for selected Cadence API calls and add debug tracing when a stored API error code is overwritten.
  • Update IPC3 and IPC4 Cadence module call sites to pass NULL for the new optional parameter.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/include/sof/audio/module_adapter/module/cadence.h Updates the public function prototype to accept an optional API error output parameter.
src/audio/module_adapter/module/cadence.c Implements optional API error code storage and overwrite tracing; suppresses non-fatal warning prints on the updated path.
src/audio/module_adapter/module/cadence_ipc3.c Adapts the IPC3 processing call site to the new function signature by passing NULL.
src/audio/module_adapter/module/cadence_ipc4.c Adapts the IPC4 processing call site to the new function signature by passing NULL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (*api_error_code && *api_error_code != ret)
comp_dbg(dev, "overwriting api error code at %s: old %#x new %#x",
cmd_name, *api_error_code, ret);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

comp_dbg() uses %#x to print int values (ret and *api_error_code). In C this format expects an unsigned int, so this can trigger format warnings/UB for negative (high-bit-set) error codes. Consider casting to unsigned (or switching the stored type to an unsigned/UWORD32) when printing.

Suggested change
cmd_name, *api_error_code, ret);
cmd_name, (unsigned int)*api_error_code, (unsigned int)ret);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, the cadence codebase and defines are sloppy, this is what it is.
The error is described as bits (bit 31 - fatal, bit 11-14 class, etc), but defined as int.

uint32_t direction);
int cadence_codec_apply_params(struct processing_module *mod, int size, void *data);
int cadence_codec_process_data(struct processing_module *mod);
int cadence_codec_process_data(struct processing_module *mod, int *api_error_code);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The new output parameter uses int *api_error_code, but Cadence defines XA_ERRORCODE (see xa_type_def.h). Using XA_ERRORCODE * here would make the API intent explicit and avoid accidental type mismatches if Cadence ever changes the underlying type.

Suggested change
int cadence_codec_process_data(struct processing_module *mod, int *api_error_code);
int cadence_codec_process_data(struct processing_module *mod, XA_ERRORCODE *api_error_code);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, can be done, but the same 'int' is returned in case of error, again, it is not a purpose of the patch to correct the cadence module sloppy code.

Extend cadence_codec_process_data() with an optional output parameter
for returning Cadence API error codes while preserving existing return
behavior: non-fatal API errors still return 0 and fatal errors are
returned.

Suppress non-fatal warning prints in this path and add lightweight
overwrite tracing for repeated API error updates.

Update cadence IPC3 and IPC4 call sites to pass NULL for now.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi ujfalusi force-pushed the peter/pr/cadence_silence_nonfatal branch from c44f608 to d088eb0 Compare March 6, 2026 14:42
@ujfalusi
Copy link
Contributor Author

ujfalusi commented Mar 6, 2026

Changes since v1:

  • use XA_ERRORCODE as type for the new parameter to the cadence_codec_process_data()

@ujfalusi ujfalusi requested a review from singalsu March 6, 2026 14:43
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.

2 participants