Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ static int dai_reset(struct comp_dev *dev)
dai_dma_release(dev);

dma_sg_free(&config->elem_array);
rfree(dd->z_config->head_block);
rfree(dd->z_config);

if (dd->dma_buffer) {
Expand Down
14 changes: 9 additions & 5 deletions src/lib/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,29 @@ struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
if (ret < 0) {
tr_err(&dma_tr, "dma_get(): dma-probe failed id = %d, ret = %d",
dmin->plat_data.id, ret);
goto out;
}
}
if (!ret)
dmin->sref++;

dmin->sref++;

tr_info(&dma_tr, "dma_get() ID %d sref = %d busy channels %ld",
dmin->plat_data.id, dmin->sref,
atomic_read(&dmin->num_channels_busy));

out:
k_spin_unlock(&dmin->lock, key);
return dmin;
return !ret ? dmin : NULL;
}

void dma_put(struct dma *dma)
{
k_spinlock_key_t key;

key = k_spin_lock(&dma->lock);
--dma->sref;
if (--dma->sref == 0) {
rfree(dma->chan);
dma->chan = NULL;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Without this, we lose one "dma->chan = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED" worth of memory whenever sref goes to 1->0 and back.


tr_info(&dma_tr, "dma_put(), dma = %p, sref = %d",
dma, dma->sref);
Expand Down