Skip to content
Draft
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
6 changes: 6 additions & 0 deletions posix/include/rtos/panic.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ void __panic(uint32_t p, const char *filename, uint32_t linenum) SOF_NORETURN;
#define assert(cond) (void)((cond) || (sof_panic(SOF_IPC_PANIC_ASSERT), 0))
#endif

/*
* The Zephyr assert macros. On Zephyr, rtos/panic.h provides them through
* <zephyr/kernel.h>.
*/
#include <zephyr/sys/__assert.h>

#endif /* __POSIX_RTOS_PANIC_H__ */
4 changes: 2 additions & 2 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void src_copy_s16(struct processing_module *mod,
n_copy = (n < n_wrap_src) ? n : n_wrap_src;
s_copy = n_copy * sizeof(int16_t);
ret = memcpy_s(buf, s_copy, src, s_copy);
assert(!ret);
__ASSERT_NO_MSG(!ret);

/* Update and check both source and destination for wrap */
n -= n_copy;
Expand Down Expand Up @@ -172,7 +172,7 @@ static void src_copy_s16(struct processing_module *mod,
n_copy = (n < n_wrap_snk) ? n : n_wrap_snk;
s_copy = n_copy * sizeof(int16_t);
ret = memcpy_s(snk, s_copy, buf, s_copy);
assert(!ret);
__ASSERT_NO_MSG(!ret);

/* Update and check both source and destination for wrap */
n -= n_copy;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/buffers/audio_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void audio_buffer_init(struct sof_audio_buffer *buffer, uint32_t buffer_type, bo
CORE_CHECK_STRUCT_INIT(buffer, is_shared);
buffer->buffer_type = buffer_type;
buffer->ops = audio_buffer_ops;
assert(audio_buffer_ops->free);
__ASSERT_NO_MSG(audio_buffer_ops->free);
buffer->audio_stream_params = audio_stream_params;
buffer->is_shared = is_shared;

Expand Down
12 changes: 6 additions & 6 deletions src/audio/buffers/comp_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)

struct mod_alloc_ctx *alloc = buffer->audio_buffer.alloc;

assert(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);

if (alloc)
sof_ctx_free(alloc, buffer->stream.addr);
Expand Down Expand Up @@ -292,7 +292,7 @@ struct comp_buffer *buffer_alloc(struct mod_alloc_ctx *alloc, size_t size, uint3
return NULL;
}

assert(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);

if (alloc)
stream_addr = sof_ctx_alloc(alloc, flags, size, align);
Expand Down Expand Up @@ -340,7 +340,7 @@ struct comp_buffer *buffer_alloc_range(struct mod_alloc_ctx *alloc, size_t prefe
if (preferred_size % minimum_size)
preferred_size += minimum_size - preferred_size % minimum_size;

assert(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);

for (size = preferred_size; size >= minimum_size; size -= minimum_size) {
if (alloc)
Expand Down Expand Up @@ -403,7 +403,7 @@ int buffer_set_size(struct comp_buffer *buffer, uint32_t size, uint32_t alignmen
if (size == audio_stream_get_size(&buffer->stream))
return 0;

assert(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);

if (alloc)
new_ptr = sof_ctx_alloc(alloc, buffer->flags, size, alignment);
Expand Down Expand Up @@ -458,7 +458,7 @@ int buffer_set_size_range(struct comp_buffer *buffer, size_t preferred_size, siz
if (preferred_size == actual_size)
return 0;

assert(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_SOF_USERSPACE_LL) || alloc);

for (new_size = preferred_size; new_size >= minimum_size;
new_size -= minimum_size) {
Expand Down Expand Up @@ -530,7 +530,7 @@ EXPORT_SYMBOL(buffer_set_params);
bool buffer_params_match(struct comp_buffer *buffer,
struct sof_ipc_stream_params *params, uint32_t flag)
{
assert(params);
__ASSERT_NO_MSG(params);
CORE_CHECK_STRUCT(&buffer->audio_buffer);

if ((flag & BUFF_PARAMS_FRAME_FMT) &&
Expand Down
2 changes: 1 addition & 1 deletion src/audio/buffers/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ uint8_t __sparse_cache *ring_buffer_get_pointer(struct ring_buffer *ring_buffer,
static inline
size_t ring_buffer_inc_offset(struct ring_buffer *ring_buffer, size_t offset, size_t inc)
{
assert(inc <= ring_buffer->data_buffer_size);
__ASSERT_NO_MSG(inc <= ring_buffer->data_buffer_size);
offset += inc;
/* wrap around ? 2*size because of "double area" */
if (offset >= 2 * ring_buffer->data_buffer_size)
Expand Down
4 changes: 2 additions & 2 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static APP_SYSUSER_BSS struct comp_driver_list cd;
#ifdef CONFIG_SOF_USERSPACE_LL
struct comp_driver_list *comp_drivers_get(void)
{
assert(!ll_sch_is_current());
__ASSERT_NO_MSG(!ll_sch_is_current());
return &cd;
}
#endif
Expand Down Expand Up @@ -586,7 +586,7 @@ int comp_copy(struct comp_dev *dev)
{
int ret = 0;

assert(dev->drv->ops.copy);
__ASSERT_NO_MSG(dev->drv->ops.copy);

/* copy only if we are the owner of component OR this is DP component
*
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/copier_dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void copier_dai_adjust_params(const struct copier_data *cd,
int dma_buf_container_bits, dma_buf_valid_bits;

/* Call this func only for DAI gateway with already setup DMA buffer */
assert(cd->dd[0] && cd->dd[0]->dma_buffer);
__ASSERT_NO_MSG(cd->dd[0] && cd->dd[0]->dma_buffer);
dma_buf = cd->dd[0]->dma_buffer;

/* Unfortunately, configuring the gateway DMA buffer format is somewhat confusing.
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static bool is_remapping_chmap(uint32_t chmap, size_t out_channel_count)
{
size_t i;

assert(out_channel_count <= 8);
__ASSERT_NO_MSG(out_channel_count <= 8);

for (i = 0; i < out_channel_count; i++) {
if ((chmap & 0xf) != i)
Expand Down
4 changes: 2 additions & 2 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ static int crossover_init_coef_lr4(struct processing_module *mod,
/* coefficients of the first biquad */
ret = memcpy_s(lr4->coef, sizeof(struct sof_eq_iir_biquad),
coef, sizeof(struct sof_eq_iir_biquad));
assert(!ret);
__ASSERT_NO_MSG(!ret);

/* coefficients of the second biquad */
ret = memcpy_s(lr4->coef + SOF_EQ_IIR_NBIQUAD,
sizeof(struct sof_eq_iir_biquad),
coef, sizeof(struct sof_eq_iir_biquad));
assert(!ret);
__ASSERT_NO_MSG(!ret);

/* LR4 filters are two 2nd order filters, so only need 4 delay slots
* delay[0..1] -> state for first biquad
Expand Down
6 changes: 3 additions & 3 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ dai_dma_multi_endpoint_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t fr
if (dev->direction == SOF_IPC_STREAM_CAPTURE)
audio_stream_invalidate(&dd->dma_buffer->stream, bytes);

assert(dd->channel_copy);
__ASSERT_NO_MSG(dd->channel_copy);

/* copy all channels one by one */
for (i = 0; i < audio_stream_get_channels(&dd->dma_buffer->stream); i++) {
Expand Down Expand Up @@ -1948,8 +1948,8 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
}
}

assert(audio_stream_get_channels(&dd->dma_buffer->stream));
assert(audio_stream_get_channels(&dd->local_buffer->stream));
__ASSERT_NO_MSG(audio_stream_get_channels(&dd->dma_buffer->stream));
__ASSERT_NO_MSG(audio_stream_get_channels(&dd->local_buffer->stream));

/* calculate minimum size to copy */
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
Expand Down
20 changes: 10 additions & 10 deletions src/audio/data_blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct comp_data_blob_handler {

static void comp_free_data_blob(struct comp_data_blob_handler *blob_handler)
{
assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

/* data_new may hold a partially received blob even when no blob has
* been committed to data yet, so the two must be released independently.
Expand All @@ -59,7 +59,7 @@ void comp_data_blob_set_validator(struct comp_data_blob_handler *blob_handler,
int (*validator)(struct comp_dev *dev, void *new_data,
uint32_t new_data_size))
{
assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

blob_handler->validator = validator;
}
Expand All @@ -68,7 +68,7 @@ EXPORT_SYMBOL(comp_data_blob_set_validator);
void *comp_get_data_blob(struct comp_data_blob_handler *blob_handler,
size_t *size, uint32_t *crc)
{
assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

comp_dbg(blob_handler->dev, "comp_get_data_blob()");

Expand Down Expand Up @@ -113,7 +113,7 @@ EXPORT_SYMBOL(comp_get_data_blob);
bool comp_is_new_data_blob_available(struct comp_data_blob_handler
*blob_handler)
{
assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

comp_dbg(blob_handler->dev, "entry");

Expand Down Expand Up @@ -142,7 +142,7 @@ __cold int comp_init_data_blob(struct comp_data_blob_handler *blob_handler,

assert_can_be_cold();

assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

comp_free_data_blob(blob_handler);

Expand All @@ -161,7 +161,7 @@ __cold int comp_init_data_blob(struct comp_data_blob_handler *blob_handler,
*/
if (init_data) {
ret = memcpy_s(blob_handler->data, size, init_data, size);
assert(!ret);
__ASSERT_NO_MSG(!ret);
} else {
bzero(blob_handler->data, size);
}
Expand Down Expand Up @@ -335,7 +335,7 @@ __cold int ipc4_comp_data_blob_set(struct comp_data_blob_handler *blob_handler,

assert_can_be_cold();

assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

comp_dbg(blob_handler->dev,
"data_offset = %d",
Expand Down Expand Up @@ -477,7 +477,7 @@ __cold int comp_data_blob_set_cmd(struct comp_data_blob_handler *blob_handler,

assert_can_be_cold();

assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

comp_dbg(blob_handler->dev, "msg_index = %d, num_elems = %d, remaining = %d ",
cdata->msg_index, cdata->num_elems,
Expand Down Expand Up @@ -622,7 +622,7 @@ __cold int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler,

assert_can_be_cold();

assert(blob_handler);
__ASSERT_NO_MSG(blob_handler);

if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(blob_handler->dev, "comp_data_blob_set_cmd(), illegal control command");
Expand Down Expand Up @@ -667,7 +667,7 @@ __cold int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler,
ret = memcpy_s(cdata->data->data, size,
(char *)blob_handler->data + blob_handler->data_pos,
cdata->num_elems);
assert(!ret);
__ASSERT_NO_MSG(!ret);

cdata->data->abi = SOF_ABI_VERSION;
cdata->data->size = blob_handler->data_size;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/dsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void dsrc_set_rate(struct dsrc *dsrc, uint32_t in_rate, uint32_t out_rate)
if (out_rate > in_rate)
max_phase = ((uint64_t)in_rate << 32) / (out_rate - in_rate);
else
assert(out_rate == in_rate);
__ASSERT_NO_MSG(out_rate == in_rate);

if (max_phase == dsrc->max_phase)
return;
Expand All @@ -30,7 +30,7 @@ void dsrc_set_rate(struct dsrc *dsrc, uint32_t in_rate, uint32_t out_rate)
uint32_t new_32 = max_phase >> 32;

/* Used below as divisors, non-zero as long as out_rate <= 2 * in_rate */
assert(old_32 && new_32);
__ASSERT_NO_MSG(old_32 && new_32);

/* Keep the same fractional delay, and phase_acc below the new max_phase */
dsrc->phase_acc = ((dsrc->phase_acc >> 32) * new_32 / old_32) << 32;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void eq_iir_pass(struct processing_module *mod, const struct cir_buf_source *sou
}

ret = memcpy_s(dst, dst_contiguous, src, copy);
assert(!ret);
__ASSERT_NO_MSG(!ret);
bytes -= copy;
src = source_cir_buf_wrap(src + copy, source->buf_start, source->buf_end);
dst = cir_buf_wrap(dst + copy, sink->buf_start, sink->buf_end);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static ALWAYS_INLINE void source_to_float(struct sof_source *src, float **dst_bu
dst[i] = &dst_bufs[i][frame0];

err = source_get_data(src, bytes, (void *)&buf, (void *)&bufstart, &bufsz);
assert(err == 0);
__ASSERT_NO_MSG(err == 0);
bufend = &bufstart[bufsz];

while (frames) {
Expand Down Expand Up @@ -195,7 +195,7 @@ static ALWAYS_INLINE void float_to_sink(struct sof_sink *dst, float **src_bufs,
src[i] = &src_bufs[i][0];

err = sink_get_buffer(dst, bytes, (void *)&buf, (void *)&bufstart, &bufsz);
assert(err == 0);
__ASSERT_NO_MSG(err == 0);
bufend = &bufstart[bufsz];

while (frames) {
Expand Down
20 changes: 10 additions & 10 deletions src/audio/intel_uaol.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const struct device *const uaol_devs[] = {
const struct device *get_uaol_zdevice(int uaol_link_id)
{
/* uaol_link_id is just an index for the device tree device */
assert(uaol_link_id < ARRAY_SIZE(uaol_devs));
__ASSERT_NO_MSG(uaol_link_id < ARRAY_SIZE(uaol_devs));
return uaol_devs[uaol_link_id];
}

Expand Down Expand Up @@ -58,7 +58,7 @@ int dai_get_uaol_stream_id(struct dai *dai, int *uaol_link_id, int *uaol_stream_
*/
void process_uaol_feedback(struct comp_dev *dev, struct dai_data *dd)
{
assert(dd && dd->uaol.fb_chan_idx >= 0 && dd->uaol.fb_dma_buf);
__ASSERT_NO_MSG(dd && dd->uaol.fb_chan_idx >= 0 && dd->uaol.fb_dma_buf);

struct dma_status stat = {0};
int ret = sof_dma_get_status(dd->uaol.fb_dma, dd->uaol.fb_chan_idx, &stat);
Expand All @@ -71,11 +71,11 @@ void process_uaol_feedback(struct comp_dev *dev, struct dai_data *dd)
if (stat.pending_length < 4)
return; /* No feedback is normal as it might be sent rarely. */

assert(is_uncached(dd->uaol.fb_dma_buf)); /* Use uncached pointer to read DMA buffer */
assert(dd->uaol.fb_dma_buf_size >= 4);
__ASSERT_NO_MSG(is_uncached(dd->uaol.fb_dma_buf)); /* DMA buffer is read uncached */
__ASSERT_NO_MSG(dd->uaol.fb_dma_buf_size >= 4);

/* NOTE: Not all DMA drivers populate stat.write_position. Intel ACE HDA does. */
assert((stat.write_position & 3) == 0); /* 4-byte alignment check. */
__ASSERT_NO_MSG((stat.write_position & 3) == 0); /* 4-byte alignment check. */
/* Read the last received 4 bytes (ignore older ones if any). */
int last_4_bytes_pos = stat.write_position >= 4 ? (stat.write_position - 4) :
(dd->uaol.fb_dma_buf_size - 4);
Expand Down Expand Up @@ -145,7 +145,7 @@ int uaol_dma_buffer_copy_to(struct dai_data *dd, size_t dma_bytes)
{
int ret = 0;

assert(dd->uaol.feedback_drift != 0);
__ASSERT_NO_MSG(dd->uaol.feedback_drift != 0);

if (dd->uaol.feedback_drift > 0) {
size_t frames = dma_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
Expand All @@ -155,7 +155,7 @@ int uaol_dma_buffer_copy_to(struct dai_data *dd, size_t dma_bytes)

struct cir_buf_ptr in = { dd->local_buffer->stream.addr,
dd->local_buffer->stream.end_addr, dd->local_buffer->stream.r_ptr };
assert(dd->uaol.dsrc_buf);
__ASSERT_NO_MSG(dd->uaol.dsrc_buf);
struct cir_buf_ptr out = { dd->uaol.dsrc_buf->stream.addr,
dd->uaol.dsrc_buf->stream.end_addr, dd->uaol.dsrc_buf->stream.w_ptr };

Expand All @@ -179,7 +179,7 @@ int uaol_dma_buffer_copy_to(struct dai_data *dd, size_t dma_bytes)
} else if (dd->uaol.feedback_drift < 0) {
/* It is expected this func is called every 1 ms */
dd->uaol.ms_since_last_adjustment++;
assert(dd->uaol.feedback_drift < 0 && dd->uaol.feedback_drift >= -1000);
__ASSERT_NO_MSG(dd->uaol.feedback_drift < 0 && dd->uaol.feedback_drift >= -1000);
if (dd->uaol.ms_since_last_adjustment >= -1000 / dd->uaol.feedback_drift) {
dd->uaol.ms_since_last_adjustment = 0;
adjust_uaol_rate(dd, false);
Expand Down Expand Up @@ -213,7 +213,7 @@ int setup_uaol_feedback_dma(struct dai_data *dd, struct comp_dev *dev)
return 0;

/* UAOL feedback is an optional 2nd DMA link (1st is audio DMA link) */
assert(GTW_DMA_DEVICE_MAX_COUNT >= 2);
__ASSERT_NO_MSG(GTW_DMA_DEVICE_MAX_COUNT >= 2);
if (!dai->host_dma_config[1] || !dai->host_dma_config[1]->pre_allocated_by_host) {
comp_info(dev, "No UAOL feedback DMA link supplied by host.");
return 0;
Expand Down Expand Up @@ -306,7 +306,7 @@ int setup_uaol_feedback_dma(struct dai_data *dd, struct comp_dev *dev)
dma_cfg->head_block->next_block = dma_cfg->head_block;

/* dai_common_params() must have created the DMA buffer already */
assert(dd->dma_buffer);
__ASSERT_NO_MSG(dd->dma_buffer);
/* dai_common_copy() keeps one free DMA frame for the DSRC-inserted one, so a copy
* never exceeds the DMA buffer size in frames
*/
Expand Down
2 changes: 1 addition & 1 deletion src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ static void adjust_drain_interval(struct comp_data *kpb, struct draining_data *d

drained = dd->drained - dd->prev_adjustment_drained;
elapsed = now - dd->prev_adjustment_time;
assert(elapsed);
__ASSERT_NO_MSG(elapsed);
/* average drained bytes per second */
actual_pace = (size_t)k_ms_to_cyc_ceil64(1000) / elapsed * drained;

Expand Down
Loading
Loading