diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index a3b0be9b93e3..24c7f4774258 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -154,7 +154,7 @@ struct buffer_cb_free { /* pipeline buffer creation and destruction */ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t align); -struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc); +struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc); int buffer_set_size(struct comp_buffer *buffer, uint32_t size); void buffer_free(struct comp_buffer *buffer); void buffer_zero(struct comp_buffer *buffer); diff --git a/src/include/sof/common.h b/src/include/sof/common.h index dabeed102253..d8e7c0f340c4 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -119,10 +119,26 @@ #define PP_NARG(...) (sizeof((unsigned int[]){0, ##__VA_ARGS__}) \ / sizeof(unsigned int) - 1) -/* compile-time assertion */ +/* Compile-time assertion. + * + * The first, typedef-based solution silently succeeds with variables, + * for instance STATIC_ASSERT(n == 42, always_succeeds) when 'n' is a + * variable in a function. The second, array-based solution is not + * fooled by variables but it increases the .bss size at the -O0 + * optimization level (no difference with any real -O). As we're often + * short on space, use the typedef-based version by default. If you're + * afraid that some assertions are being fooled by variables then + * temporarily and locally switch to the second one. + */ +#if 1 #define STATIC_ASSERT(COND, MESSAGE) \ __attribute__((unused)) \ typedef char META_CONCAT(assertion_failed_, MESSAGE)[(COND) ? 1 : -1] +#else +#define STATIC_ASSERT(COND, MESSAGE) \ + __attribute__((unused)) \ + static char META_CONCAT(arr_assertion_failed_, MESSAGE)[(COND) ? 1 : -1] +#endif /* Allows checking preprocessor symbols in compile-time. * Returns true for config with value 1, false for undefined or any other value. diff --git a/src/include/sof/ipc/topology.h b/src/include/sof/ipc/topology.h index 12996d8a29da..938ec36db7e4 100644 --- a/src/include/sof/ipc/topology.h +++ b/src/include/sof/ipc/topology.h @@ -98,7 +98,7 @@ int ipc_comp_free(struct ipc *ipc, uint32_t comp_id); * @param buffer New IPC buffer descriptor. * @return 0 on success or negative error. */ -int ipc_buffer_new(struct ipc *ipc, struct sof_ipc_buffer *buffer); +int ipc_buffer_new(struct ipc *ipc, const struct sof_ipc_buffer *buffer); /** * \brief Free an IPC buffer. diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 54f330f5593b..0e2008129e84 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -599,7 +599,7 @@ int ipc_pipeline_complete(struct ipc *ipc, uint32_t comp_id) return ret; } -int ipc_buffer_new(struct ipc *ipc, struct sof_ipc_buffer *desc) +int ipc_buffer_new(struct ipc *ipc, const struct sof_ipc_buffer *desc) { struct ipc_comp_dev *ibd; struct comp_buffer *buffer; @@ -874,7 +874,7 @@ int ipc_comp_free(struct ipc *ipc, uint32_t comp_id) } /* create a new component in the pipeline */ -struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc) +struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc) { struct comp_buffer *buffer; diff --git a/src/lib/pm_runtime.c b/src/lib/pm_runtime.c index a69f94249a0a..1441d764b237 100644 --- a/src/lib/pm_runtime.c +++ b/src/lib/pm_runtime.c @@ -35,6 +35,21 @@ void pm_runtime_init(struct sof *sof) } +/* Warning: the terms in this API (enable, active,... ) apply sometimes + * to power _management_ and other times to _power_ which can be + * confusing. They are however consistent with + * https://www.kernel.org/doc/Documentation/power/runtime_pm.txt and the + * long tradition of double and triple negations in power management. + */ + +/** Increase the usage counter of some PM context. In general this + * blocks low power state but there are exception(s), for instance the + * context for the PM_RUNTIME_HOST_DMA_L1 is reversed: usage blocks high + * power state. + * + * Warning: some (all?) platforms don't really implement any counter, in + * other words the "counter" is silently maxed at 1. + */ void pm_runtime_get(enum pm_runtime_context context, uint32_t index) { tr_dbg(&pm_tr, "pm_runtime_get() context %d index %d", context, index); @@ -58,6 +73,8 @@ void pm_runtime_get_sync(enum pm_runtime_context context, uint32_t index) } } +/** Decreases the usage counter of some PM context, see pm_runtime_get() + */ void pm_runtime_put(enum pm_runtime_context context, uint32_t index) { tr_dbg(&pm_tr, "pm_runtime_put() context %d index %d", context, index); @@ -81,6 +98,7 @@ void pm_runtime_put_sync(enum pm_runtime_context context, uint32_t index) } } +/** Enables power _management_. The management, not the power. */ void pm_runtime_enable(enum pm_runtime_context context, uint32_t index) { tr_dbg(&pm_tr, "pm_runtime_enable() context %d index %d", context, @@ -93,6 +111,7 @@ void pm_runtime_enable(enum pm_runtime_context context, uint32_t index) } } +/** Disables power _management_. The management, not the power. */ void pm_runtime_disable(enum pm_runtime_context context, uint32_t index) { tr_dbg(&pm_tr, "pm_runtime_disable() context %d index %d", context, @@ -105,6 +124,7 @@ void pm_runtime_disable(enum pm_runtime_context context, uint32_t index) } } +/** Is the _power_ active. The power, not its management. */ bool pm_runtime_is_active(enum pm_runtime_context context, uint32_t index) { tr_dbg(&pm_tr, "pm_runtime_is_active() context %d index %d", context, diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index 9ab76b66f1b0..c51d23ecc9fe 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -537,6 +537,7 @@ int task_main_start(struct sof *sof) /* init pipeline position offsets */ pipeline_posn_init(sof); + /* Temporary fix for issue #4356 */ (void)notifier_register(NULL, scheduler_get_data(SOF_SCHEDULE_LL_TIMER), NOTIFIER_ID_LL_POST_RUN, ipc_send_queued_callback, 0);