diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index db758f3a8ca3..c259b07d5fed 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -249,14 +249,18 @@ bool buffer_params_match(struct comp_buffer *buffer, static inline void buffer_stream_invalidate(struct comp_buffer *buffer, uint32_t bytes) { +#if CONFIG_INCOHERENT if (buffer->is_shared) audio_stream_invalidate(&buffer->stream, bytes); +#endif } static inline void buffer_stream_writeback(struct comp_buffer *buffer, uint32_t bytes) { +#if CONFIG_INCOHERENT if (buffer->is_shared) audio_stream_writeback(&buffer->stream, bytes); +#endif } diff --git a/src/include/sof/coherent.h b/src/include/sof/coherent.h index 445e8eae9b1c..8e13b661440c 100644 --- a/src/include/sof/coherent.h +++ b/src/include/sof/coherent.h @@ -17,7 +17,7 @@ #include #include -#define __coherent __aligned(DCACHE_LINE_SIZE) +#define __coherent __aligned(PLATFORM_DCACHE_ALIGN) /* * The coherent API allows optimized access to memory by multiple cores, using @@ -332,29 +332,17 @@ static inline void __coherent_shared_thread(struct coherent *c, const size_t siz __must_check static inline struct coherent __sparse_cache *coherent_acquire(struct coherent *c, const size_t size) { - if (c->shared) { - struct coherent __sparse_cache *cc = uncache_to_cache(c); - + if (c->shared) c->key = k_spin_lock(&c->lock); - /* invalidate local copy */ - dcache_invalidate_region(cc, size); - } - return (__sparse_force struct coherent __sparse_cache *)c; } static inline void coherent_release(struct coherent __sparse_cache *c, const size_t size) { - if (c->shared) { - struct coherent *uc = cache_to_uncache(c); - - /* wtb and inv local data to coherent object */ - dcache_writeback_invalidate_region(c, size); - - k_spin_unlock(&uc->lock, uc->key); - } + if (c->shared) + k_spin_unlock(&c->lock, c->key); } static inline void *__coherent_init(size_t offset, const size_t size) diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index 207645f1dd5b..43926002abe3 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -184,9 +184,12 @@ int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core, { /* check if it's a connection between cores */ if (buffer->core != comp_core) { +#if CONFIG_INCOHERENT /* buffer must be shared */ assert(buffer->is_shared); - +#else + buffer->is_shared = true; +#endif if (!comp->is_shared) comp_make_shared(comp); }