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
42 changes: 21 additions & 21 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int host_dma_set_config_and_copy(struct host_data *hd, struct comp_dev *d
local_elem->size = bytes;

/* reconfigure transfer */
ret = dma_config(hd->chan->dma->z_dev, hd->chan->index, &hd->z_config);
ret = sof_dma_config(hd->chan->dma, hd->chan->index, &hd->z_config);
if (ret < 0) {
comp_err(dev, "dma_config() failed, ret = %d",
ret);
Expand All @@ -95,7 +95,7 @@ static int host_dma_set_config_and_copy(struct host_data *hd, struct comp_dev *d

cb(dev, bytes);

ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, bytes);
ret = sof_dma_reload(hd->chan->dma, hd->chan->index, bytes);
if (ret < 0) {
comp_err(dev, "dma_copy() failed, ret = %d",
ret);
Expand Down Expand Up @@ -225,15 +225,15 @@ static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_c
hd->z_config.head_block->block_size = local_elem->size;

/* reconfigure transfer */
ret = dma_config(hd->chan->dma->z_dev, hd->chan->index, &hd->z_config);
ret = sof_dma_config(hd->chan->dma, hd->chan->index, &hd->z_config);
if (ret < 0) {
comp_err(dev, "dma_config() failed, ret = %u", ret);
return ret;
}

cb(dev, copy_bytes);

ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, copy_bytes);
ret = sof_dma_reload(hd->chan->dma, hd->chan->index, copy_bytes);
if (ret < 0)
comp_err(dev, "dma_copy() failed, ret = %u", ret);

Expand Down Expand Up @@ -367,7 +367,7 @@ static void host_dma_cb(struct comp_dev *dev, size_t bytes)
/* get status from dma and check for xrun */
static int host_get_status(struct comp_dev *dev, struct host_data *hd, struct dma_status *stat)
{
int ret = dma_get_status(hd->chan->dma->z_dev, hd->chan->index, stat);
int ret = sof_dma_get_status(hd->chan->dma, hd->chan->index, stat);
#if CONFIG_XRUN_NOTIFICATIONS_ENABLE
if (ret == -EPIPE && !hd->xrun_notification_sent) {
struct ipc_msg *notify = ipc_notification_pool_get(IPC4_RESOURCE_EVENT_SIZE);
Expand Down Expand Up @@ -562,8 +562,8 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal
if (!copy_bytes) {
if (hd->partial_size != 0) {
if (stream_sync(hd, dev)) {
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0,
hd->partial_size);
ret = sof_dma_reload(hd->chan->dma, hd->chan->index,
hd->partial_size);
if (ret < 0)
comp_err(dev, "dma_reload() failed, ret = %u", ret);

Expand All @@ -589,8 +589,8 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal
hd->dma_buffer_size - hd->partial_size <=
(2 + threshold) * hd->period_bytes) {
if (stream_sync(hd, dev)) {
ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0,
hd->partial_size);
ret = sof_dma_reload(hd->chan->dma, hd->chan->index,
hd->partial_size);
if (ret < 0)
comp_err(dev, "dma_reload() failed, ret = %u", ret);

Expand Down Expand Up @@ -665,14 +665,14 @@ int host_common_trigger(struct host_data *hd, struct comp_dev *dev, int cmd)
switch (cmd) {
case COMP_TRIGGER_START:
hd->partial_size = 0;
ret = dma_start(hd->chan->dma->z_dev, hd->chan->index);
ret = sof_dma_start(hd->chan->dma, hd->chan->index);
if (ret < 0)
comp_err(dev, "dma_start() failed, ret = %u",
ret);
break;
case COMP_TRIGGER_STOP:
case COMP_TRIGGER_XRUN:
ret = dma_stop(hd->chan->dma->z_dev, hd->chan->index);
ret = sof_dma_stop(hd->chan->dma, hd->chan->index);
if (ret < 0)
comp_err(dev, "dma stop failed: %d",
ret);
Expand Down Expand Up @@ -875,16 +875,16 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
hd->cont_update_posn = params->cont_update_posn;

/* retrieve DMA buffer address alignment */
err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
&addr_align);
err = sof_dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_ADDRESS_ALIGNMENT,
&addr_align);
if (err < 0) {
comp_err(dev, "could not get dma buffer address alignment, err = %d",
err);
return err;
}

/* retrieve DMA buffer size alignment */
err = dma_get_attribute(hd->dma->z_dev, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
err = sof_dma_get_attribute(hd->dma, DMA_ATTR_BUFFER_SIZE_ALIGNMENT, &align);
if (err < 0 || !align) {
comp_err(dev, "could not get valid dma buffer alignment, err = %d, align = %u",
err, align);
Expand Down Expand Up @@ -999,7 +999,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
/* get DMA channel from DMAC
* note: stream_tag is ignored by dw-dma
*/
channel = dma_request_channel(hd->dma->z_dev, &hda_chan);
channel = sof_dma_request_channel(hd->dma, hda_chan);
if (channel < 0) {
comp_err(dev, "requested channel %d is busy", hda_chan);
return -ENODEV;
Expand Down Expand Up @@ -1061,14 +1061,14 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
break;
}

err = dma_config(hd->chan->dma->z_dev, hd->chan->index, dma_cfg);
err = sof_dma_config(hd->chan->dma, hd->chan->index, dma_cfg);
if (err < 0) {
comp_err(dev, "dma_config() failed");
goto err_free_block_cfg;
}

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

if (err < 0) {
comp_err(dev, "dma_get_attribute() failed");
Expand All @@ -1091,7 +1091,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev,
dma_cfg->head_block = NULL;
rfree(dma_block_cfg);
err_release_channel:
dma_release_channel(hd->dma->z_dev, hd->chan->index);
sof_dma_release_channel(hd->dma, hd->chan->index);
hd->chan = NULL;

return err;
Expand Down Expand Up @@ -1151,8 +1151,8 @@ static int host_position(struct comp_dev *dev,
void host_common_reset(struct host_data *hd, uint16_t state)
{
if (hd->chan) {
dma_stop(hd->chan->dma->z_dev, hd->chan->index);
dma_release_channel(hd->dma->z_dev, hd->chan->index);
sof_dma_stop(hd->chan->dma, hd->chan->index);
sof_dma_release_channel(hd->dma, hd->chan->index);
hd->chan = NULL;
}

Expand Down
5 changes: 5 additions & 0 deletions src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ __cold int ipc_init(struct sof *sof)

tr_dbg(&ipc_tr, "entry");

#if CONFIG_SOF_BOOT_TEST_STANDALONE
LOG_INF("SOF_BOOT_TEST_STANDALONE, disabling IPC.");
return 0;
#endif

/* init ipc data */
sof->ipc = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, sizeof(*sof->ipc));
if (!sof->ipc) {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ DECLARE_TR_CTX(dma_tr, SOF_UUID(dma_uuid), LOG_LEVEL_INFO);
#if CONFIG_ZEPHYR_NATIVE_DRIVERS
static int dma_init(struct sof_dma *dma);

struct sof_dma *sof_dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
struct sof_dma *z_impl_sof_dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
{
const struct dma_info *info = dma_info_get();
int users, ret = 0;
Expand Down Expand Up @@ -129,7 +129,7 @@ struct sof_dma *sof_dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t f
return !ret ? dmin : NULL;
}

void sof_dma_put(struct sof_dma *dma)
void z_impl_sof_dma_put(struct sof_dma *dma)
{
k_spinlock_key_t key;

Expand Down Expand Up @@ -168,8 +168,8 @@ static int dma_init(struct sof_dma *dma)

return 0;
}
EXPORT_SYMBOL(sof_dma_get);
EXPORT_SYMBOL(sof_dma_put);
EXPORT_SYMBOL(z_impl_sof_dma_get);
EXPORT_SYMBOL(z_impl_sof_dma_put);
Comment on lines +171 to +172
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The remaining DMA API functions (sof_dma_config, sof_dma_start, sof_dma_stop, etc.) should also have EXPORT_SYMBOL declarations if they are intended to be used outside this module, to maintain consistency with the existing exports.

Copilot uses AI. Check for mistakes.
#else
struct dma *dma_get(uint32_t dir, uint32_t cap, uint32_t dev, uint32_t flags)
{
Expand Down
6 changes: 6 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ if(NOT DEFINED PLATFORM)
endif()
zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include)

zephyr_library_sources_ifdef(CONFIG_USERSPACE
Copy link
Member

Choose a reason for hiding this comment

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

I think we now have several config options around userspace, i.e. one for DP only and one for DP + infra.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood This is the canonical one defined in Zephyr and used all over Zephyr code when defining syscalls (in a way that still builds if user-space is not enabled in the build). I try to follow style and convetions of Zephyr even if these particular syscalls are on SOF side.

Copy link
Member

Choose a reason for hiding this comment

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

got you - so we cant drill down further for the syscalls today

syscall/sof_dma.c
)

zephyr_syscall_header(include/sof/lib/sof_dma.h)

# Mandatory Files used on all platforms.
# Commented files will be added/removed as integration dictates.
zephyr_library_sources(
Expand Down
15 changes: 15 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ config SOF_USERSPACE
processing mode as userspace code and data. This feature is WIP
and is not yet ready for production, for developers only.

config SOF_USERSPACE_INTERFACE_DMA
bool "Enable SOF DMA interface to userspace threads"
depends on USERSPACE
help
Allow user-space threads to use the SOF DMA interface.

config SOF_ZEPHYR_HEAP_CACHED
bool "Cached Zephyr heap for SOF memory non-shared zones"
default y if CAVS || ACE
Expand Down Expand Up @@ -178,6 +184,15 @@ config SOF_BOOT_TEST
initialized. After that SOF will continue running and be usable as
usual.

config SOF_BOOT_TEST_STANDALONE
bool "enable tests at boot time that are run instead of SOF main"
select SOF_BOOT_TEST
select ZTEST
help
Run extended set of tests at boot that can use IPC and interfere
with system state. Normal IPC handling of the SOF application
is disabled to allow more complex tests to run.

config SOF_ZEPHYR_NO_SOF_CLOCK
bool
help
Expand Down
19 changes: 4 additions & 15 deletions zephyr/include/sof/lib/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,11 @@ typedef int (*dma_process_func)(const struct audio_stream *source,
*/
int dmac_init(struct sof *sof);

/**
* \brief API to request a platform DMAC.
*
* Users can request DMAC based on dev type, copy direction, capabilities
* and access privilege.
* For exclusive access, ret DMAC with no channels draining.
* For shared access, ret DMAC with the least number of channels draining.
*/
struct sof_dma *sof_dma_get(uint32_t dir, uint32_t caps, uint32_t dev, uint32_t flags);

/**
* \brief API to release a platform DMAC.
*
* @param[in] dma DMAC to relese.
/*
* Need to use sof_dma.h to avoid "syscalls/dma.h" name conflict
* with Zephyr autogenerated headers for syscall support.
*/
void sof_dma_put(struct sof_dma *dma);
#include "sof_dma.h"

#ifndef CONFIG_ZEPHYR_NATIVE_DRIVERS
#include "dma-legacy.h"
Expand Down
Loading
Loading