Skip to content

audio: chain_dma: Fix error handling in chain_init()#10744

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

audio: chain_dma: Fix error handling in chain_init()#10744
ujfalusi wants to merge 1 commit intothesofproject:mainfrom
ujfalusi:peter/pr/chain_panic_fix

Conversation

@ujfalusi
Copy link
Copy Markdown
Contributor

@ujfalusi ujfalusi commented May 6, 2026

If the dma_request_channel() for the link fails we print the error, jump to error_host to release the channel and return with success. This can lead to firmware crash later on when the ChainDMA is started.

Correct the error handling by setting the err correctly in this case and also update the prints to print unique strings and information to help debugging.

If the dma_request_channel() for the link fails we print the error, jump
to error_host to release the channel and return with success.
This can lead to firmware crash later on when the ChainDMA  is started.

Correct the error handling by setting the err correctly in this case and
also update the prints to print unique strings and information to help
debugging.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Copy link
Copy Markdown
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 fixes a bug in chain_init() error handling where failure to allocate the link DMA channel could still return success, potentially leading to a later firmware crash when ChainDMA starts.

Changes:

  • Return the actual negative error code when host dma_request_channel() fails (instead of -EINVAL).
  • Ensure link dma_request_channel() failures propagate an error via err before jumping to cleanup.
  • Make host/link DMA error logs distinguishable by adding “host” vs “link” context.

Comment thread src/audio/chain_dma.c
Comment on lines +461 to +462
comp_err(dev, "host dma_request_channel() failed for %u",
cd->host_connector_node_id.f.v_index);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the error code is irrelevant, it is -EINVAL always.

Comment thread src/audio/chain_dma.c
err = dma_config(cd->dma_host->z_dev, cd->chan_host->index, dma_cfg_host);
if (err < 0) {
comp_err(dev, "dma_config() failed");
comp_err(dev, "host dma_config() failed for %d", channel);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

printing the 'channel' intentionally here, probably the error code can help, but I expect the underlying code to print on failure points

Comment thread src/audio/chain_dma.c
Comment on lines +478 to +479
comp_err(dev, "link dma_request_channel() failed for %u",
cd->link_connector_node_id.f.v_index);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as for the first suggestion.

Comment thread src/audio/chain_dma.c
err = dma_config(cd->dma_link->z_dev, cd->chan_link->index, dma_cfg_link);
if (err < 0) {
comp_err(dev, "dma_config() failed");
comp_err(dev, "link dma_config() failed for %d", channel);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

again, as intended

Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks @ujfalusi !

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.

4 participants