Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: host-zephyr: Allocate DMA block configuration on heap #8867

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

LaurentiuM1234
Copy link
Contributor

@LaurentiuM1234 LaurentiuM1234 commented Feb 15, 2024

Currently, the DMA block configuration (struct dma_block_config) is placed on the stack during host_common_params(). Later on, host_copy_one_shot() tries to re-configure the DMAC driver using the same block configuration that's located in a stack frame that's no longer valid. As such, allocate a DMA block configuration on the heap during host_common_params() which can be used later on (e.g: during host_copy_one_shot()) to reconfigure the DMAC.

Cherry-picked from #8859

@dbaluta
Copy link
Collaborator

dbaluta commented Feb 15, 2024

@marc-hb @lgirdwood I think I'm out of the loop here, what is the status of fixing zephyr builds? Are we waiting for some change to be merged into zephyr right?

@marc-hb
Copy link
Collaborator

marc-hb commented Feb 15, 2024

what is the status of fixing zephyr builds? Are we waiting for some change to be merged into zephyr right?

This is tracked in #8818

break;
}

err = dma_config(hd->chan->dma->z_dev, hd->chan->index, dma_cfg);
if (err < 0) {
comp_err(dev, "host_params(): dma_config() failed");
dma_release_channel(hd->dma->z_dev, hd->chan->index);
rfree(dma_block_cfg);
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we also want to reset dma_cfg->head_block to NULL before freeing? Might be worth making an error handling label at the bottom of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, should be ok now

Currently, the DMA block configuration (struct dma_block_config)
is placed on the stack during host_common_params(). Later on,
host_copy_one_shot() tries to re-configure the DMAC driver
using the same block configuration that's located in a stack
frame that's no longer valid. As such, allocate a DMA
block configuration on the heap during host_common_params()
which can be used later on (e.g: during host_copy_one_shot())
to reconfigure the DMAC.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
}

err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_COPY_ALIGNMENT,
&hd->dma_copy_align);

if (err < 0) {
comp_err(dev, "host_params(): dma_get_attribute()");
return err;
goto err_free_block_cfg;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this actually seems to be a bug-fix...

@dbaluta dbaluta merged commit 3681e09 into thesofproject:main Feb 20, 2024
34 of 44 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.

8 participants