Skip to content

Commit 1ef6f66

Browse files
marcinszkudlinskilgirdwood
authored andcommitted
buf: add cache invalidation on unbind
unbind hook in buffer is guaranteed to be called on the core that was using the API. Free, however, may be called on other core Add cache invalidation, that must be called on core that was producing data (user of sink API) in unbind hook. Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent a57700a commit 1ef6f66

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/audio/buffers/ring_buffer.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,21 @@ static int ring_buffer_release_data(struct sof_source *source, size_t free_size)
239239
return 0;
240240
}
241241

242+
int ring_buffer_module_unbind(struct sof_sink *sink)
243+
{
244+
struct ring_buffer *ring_buffer = ring_buffer_from_sink(sink);
245+
246+
CORE_CHECK_STRUCT(&ring_buffer->audio_buffer);
247+
248+
/* in case of disconnection, invalidate all cache. This method is guaranteed be called on
249+
* core that have been using sink API
250+
*/
251+
ring_buffer_invalidate_shared(ring_buffer, ring_buffer->_data_buffer,
252+
ring_buffer->data_buffer_size);
253+
254+
return 0;
255+
}
256+
242257
static struct source_ops ring_buffer_source_ops = {
243258
.get_data_available = ring_buffer_get_data_available,
244259
.get_data = ring_buffer_get_data,
@@ -249,6 +264,7 @@ static struct sink_ops ring_buffer_sink_ops = {
249264
.get_free_size = ring_buffer_get_free_size,
250265
.get_buffer = ring_buffer_get_buffer,
251266
.commit_buffer = ring_buffer_commit_buffer,
267+
.on_unbind = ring_buffer_module_unbind,
252268
};
253269

254270
static const struct audio_buffer_ops audio_buffer_ops = {

0 commit comments

Comments
 (0)