Skip to content
Open
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 app/boards/intel_adsp_ace15_mtpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IDLE_CLOCK_GATING=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace20_lnl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IDLE_CLOCK_GATING=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace30_ptl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_XTENSA_MMU_NUM_L2_TABLES=128
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace30_wcl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288
CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace40_nvl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ CONFIG_DMA_INTEL_ADSP_GPDMA=n
CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace40_nvls.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ CONFIG_DMA_INTEL_ADSP_GPDMA=n
CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_MM_DRV_INTEL_VIRTUAL_REGION_COUNT=2
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
CONFIG_ACE_V1X_RTC_COUNTER=n

# Zephyr / power settings
CONFIG_ADSP_IMR_CONTEXT_SAVE=y
Expand Down
14 changes: 2 additions & 12 deletions src/include/sof/lib/fast-get.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@

struct k_heap;

#if defined(__ZEPHYR__) && defined(CONFIG_SOF_FULL_ZEPHYR_APPLICATION)
#include <zephyr/toolchain.h>

__syscall const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size);
__syscall void fast_put(struct k_heap *heap, const void *sram_ptr);
#include <zephyr/syscalls/fast-get.h>
#else
const void *z_impl_fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size);
void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr);
#define fast_get z_impl_fast_get
#define fast_put z_impl_fast_put
#endif /* __ZEPHYR__ */
const void *fast_get(struct k_heap *heap, const void * const dram_ptr, size_t size);
void fast_put(struct k_heap *heap, const void *sram_ptr);

#endif /* __SOF_LIB_FAST_GET_H__ */
53 changes: 18 additions & 35 deletions zephyr/lib/fast-get.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
#include <rtos/symbol.h>
#include <ipc/topology.h>

#ifdef __ZEPHYR__
#include <zephyr/logging/log.h>
#else
#define LOG_DBG(...) do {} while (0)
#define LOG_INF(...) do {} while (0)
#define LOG_WRN(...) do {} while (0)
#define LOG_ERR(...) do {} while (0)
Comment on lines +22 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I understand, these are Zephyr macros. I suspect they might be used in other places soon. Do we want to move this else into a separate file that is included when Zephyr is not present?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh Also wondering why do we need to ifdef Zephyr, this is zephyr/lib/fast-get.c after all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#endif

struct sof_fast_get_entry {
const void *dram_ptr;
void *sram_ptr;
Expand Down Expand Up @@ -81,7 +90,7 @@ static struct sof_fast_get_entry *fast_get_find_entry(struct sof_fast_get_data *
return NULL;
}

const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
const void *fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
{
struct sof_fast_get_data *data = &fast_get_data;
struct sof_fast_get_entry *entry;
Expand All @@ -101,7 +110,7 @@ const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t si

if (entry->sram_ptr) {
if (entry->size != size || entry->dram_ptr != dram_ptr) {
tr_err(fast_get, "size %u != %u or ptr %p != %p mismatch",
LOG_ERR("size %u != %u or ptr %p != %p mismatch",
entry->size, size, entry->dram_ptr, dram_ptr);
ret = NULL;
goto out;
Expand All @@ -128,12 +137,11 @@ const void *z_impl_fast_get(struct k_heap *heap, const void *dram_ptr, size_t si
entry->refcount = 1;
out:
k_spin_unlock(&data->lock, key);
tr_dbg(fast_get, "get %p, %p, size %u, refcnt %u", dram_ptr, ret, size,
entry ? entry->refcount : 0);
LOG_DBG("get %p, %p, size %u, refcnt %u", dram_ptr, ret, size, entry ? entry->refcount : 0);

return ret;
}
EXPORT_SYMBOL(z_impl_fast_get);
EXPORT_SYMBOL(fast_get);

static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *data,
const void *sram_ptr)
Expand All @@ -148,7 +156,7 @@ static struct sof_fast_get_entry *fast_put_find_entry(struct sof_fast_get_data *
return NULL;
}

void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr)
void fast_put(struct k_heap *heap, const void *sram_ptr)
{
struct sof_fast_get_data *data = &fast_get_data;
struct sof_fast_get_entry *entry;
Expand All @@ -157,7 +165,7 @@ void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr)
key = k_spin_lock(&fast_get_data.lock);
entry = fast_put_find_entry(data, sram_ptr);
if (!entry) {
tr_err(fast_get, "Put called to unknown address %p", sram_ptr);
LOG_ERR("Put called to unknown address %p", sram_ptr);
goto out;
}
entry->refcount--;
Expand All @@ -166,33 +174,8 @@ void z_impl_fast_put(struct k_heap *heap, const void *sram_ptr)
memset(entry, 0, sizeof(*entry));
}
out:
tr_dbg(fast_get, "put %p, DRAM %p size %u refcnt %u", sram_ptr, entry ? entry->dram_ptr : 0,
entry ? entry->size : 0, entry ? entry->refcount : 0);
LOG_DBG("put %p, DRAM %p size %u refcnt %u", sram_ptr, entry ? entry->dram_ptr : 0,
entry ? entry->size : 0, entry ? entry->refcount : 0);
k_spin_unlock(&data->lock, key);
}
EXPORT_SYMBOL(z_impl_fast_put);

#ifdef CONFIG_USERSPACE
#include <zephyr/internal/syscall_handler.h>
void z_vrfy_fast_put(struct k_heap *heap, const void *sram_ptr)
{
K_OOPS(K_SYSCALL_MEMORY_WRITE(heap, sizeof(*heap)));
/*
* FIXME: we don't know how much SRAM has been allocated, so cannot
* check. Should fast_put() be changed to pass a size argument?
*/

z_impl_fast_put(heap, sram_ptr);
}
#include <zephyr/syscalls/fast_put_mrsh.c>

const void *z_vrfy_fast_get(struct k_heap *heap, const void *dram_ptr, size_t size)
{
K_OOPS(K_SYSCALL_MEMORY_WRITE(heap, sizeof(*heap)));
/* We cannot (easily) verify the actual heapp memory */
K_OOPS(K_SYSCALL_MEMORY_READ(dram_ptr, size));

return z_impl_fast_get(heap, dram_ptr, size);
}
#include <zephyr/syscalls/fast_get_mrsh.c>
#endif
EXPORT_SYMBOL(fast_put);