Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipeline 2.0 - introduce abstract audio_buffer api #9260

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

marcinszkudlinski
Copy link
Contributor

@marcinszkudlinski marcinszkudlinski commented Jun 26, 2024

This PR introduces an abstract struct sof_audio_buffer which should become a base abstract class for all buffer types in pipeline 2.0
PR should be neutral for all functionality

On the generic pipeline code there MUST NOT be any other usage of buffers but:

  • sof_audio_buffer for maintenance operations
  • sof_sink
  • sof_source

(with obvious exception for buffer creation - see concept of "buffer factory)

this PR change usage of DP_queue (renamed to ring_buffer) to match the above request

*/
struct ring_buffer *ring_buffer_source; /**< source API shadow, an additional ring_buffer
* at data out
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure these two renames make sense, or at least they might deserve a separate commit. It's one thing to rename an API, but it doesn't necessarily mean, that all users have to be renamed too. If these members are only used by DP components, maybe we can keep their names? Or if you want to use these members for other cases too, then this should rather be a separate commit, but then maybe you also need to move them out of the #if?

@@ -0,0 +1,306 @@
// SPDX-License-Identifier: BSD-3-Clause
Copy link
Collaborator

Choose a reason for hiding this comment

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

this rename-and-modify unfortunately confused git enough to not recognise this as a rename any more. Maybe we can split this into two commits: first rename without modifying contents, then change the API itself? Or the other way round - doesn't matter. As it stands the only way to review this would be to download both files and to diff them manually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed to 2 commits - one for rename + move, second for internal structures changes

zephyr/CMakeLists.txt Show resolved Hide resolved
*/
struct sof_audio_buffer *shadow_buffer_source; /**< source API shadow, an additional buffer
* at data output
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

oookeeey, not sure why it's "shadow" but at least - yes, to reinforce my previous comment, I'd keep the "dp-buffer" name until here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed "shadow" to "secondary", but keeping dp_queue here is not a good idea - double buffering it is not limited to ring_buffer a.k.a. dp_queue now

src/audio/buffer.c Outdated Show resolved Hide resolved
src/audio/buffers/ring_buffer.c Outdated Show resolved Hide resolved
src/include/sof/audio/audio_buffer.h Outdated Show resolved Hide resolved
src/include/sof/audio/audio_buffer.h Outdated Show resolved Hide resolved
src/include/sof/audio/audio_buffer.h Outdated Show resolved Hide resolved
src/ipc/ipc4/helper.c Outdated Show resolved Hide resolved
@marcinszkudlinski marcinszkudlinski force-pushed the pipeline2_0_001 branch 2 times, most recently from 6cdf717 to d060b70 Compare July 3, 2024 16:12
@marcinszkudlinski marcinszkudlinski changed the title [WIP] pipeline 2.0 - introduce abstract audio_buffer api pipeline 2.0 - introduce abstract audio_buffer api Jul 4, 2024
@marcinszkudlinski marcinszkudlinski marked this pull request as ready for review July 4, 2024 07:24
@marcinszkudlinski
Copy link
Contributor Author

marcinszkudlinski commented Jul 4, 2024

Development is of course still in progress, but this PR looks like a good subset. Please proceed with review.

@@ -272,8 +272,8 @@ void buffer_free(struct comp_buffer *buffer)
/* In case some listeners didn't unregister from buffer's callbacks */
notifier_unregister_all(NULL, buffer);
#if CONFIG_ZEPHYR_DP_SCHEDULER
ring_buffer_free(buffer->stream.dp_queue_sink);
ring_buffer_free(buffer->stream.dp_queue_source);
ring_buffer_free_legacy(buffer->stream.dp_queue_sink);
Copy link
Contributor Author

@marcinszkudlinski marcinszkudlinski Jul 4, 2024

Choose a reason for hiding this comment

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

this "legacy" is introduced ONLY to make this commit compile (and probably work) - there was a function name collision.
The function is removed in the very next commit

@lgirdwood
Copy link
Member

@marcinszkudlinski good stuff - CI looking good too, just a minor conflict.

@marcinszkudlinski
Copy link
Contributor Author

as to codestyle check failure:

WARNING: please write a help paragraph that fully describes the config symbol

I did, the symbol is fully described, but checkpatch is blind to this.

dp_queue was created as a buffer to handle
special needs for DP modules.
However, in pipeline2.0 there will be more usecases
for it - as in fact it is a lockless cross-core
cached ring buffer.
This commit does rename dp_queue to more adequate name
It also moves the file to "buffers" directory, a place
for all implementations of buffers in pipeline 2.0

The commit, however, does not change names of structures
because git/github does not handle complex changes like
rename and modification correctly

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
as a follow-up of a prev commit, internal structures
should also be changed accordingly

The commit, however, does not change names of variables
in the code that use struct ring_buffer.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
in pipeline2.0 there's more than one buffer type
to be used for passing audio data from one module
to another. However, each single buffer must provide
same API.
This commit introduces a common API for buffers and
at the same time connects it to ring_buffer.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
This commit removes all direct calls to ring_buffer (formerly dp_queue)
from the code, replacing with a generic sof_audio_buffer API

Only direct call that stays is creation of ring_buffer, yet it will
soon be replaced also by a buffer factory

Legacy API from ring buffer is also removed, as it should not be used
anymore

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
This flag enables changes to new pipeline structure,
known as pipeline2_0
It is required for certain new features, like DP_SCHEDULER.
The changes are incremental and at the moment pipeline 2.0
is fully backward compatible with legacy platforms, however
it generates some overhead in data and code, so it is useful to
turn if off if not needed

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
@marcinszkudlinski
Copy link
Contributor Author

rebased

@marcinszkudlinski
Copy link
Contributor Author

I missed one commit during rebase

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Looks god to me and cleans up the code. I was wondering whether this is really dependent on IPC4 (dp scheduling is, but also the ringbuffer/dpqueue)? Anyways, not a blockign item. Tests seem good. LNL hard to tell as this seems to hit thesofproject/linux#5098 .

@marc-hb
Copy link
Collaborator

marc-hb commented Jul 9, 2024

This compilation failure seems relevant:
https://github.com/thesofproject/sof/actions/runs/9852402212/job/27200883856?pr=9260

return IPC4_FAILURE;
}
if (!cpu_is_me(sink->ipc_config.core))
if (ll_wait_finished_on_core(sink) < 0) {
ll_unblock(cross_core_unbind);
ll_unblock(cross_core_unbind, flags);
return IPC4_FAILURE;
}
#else
Copy link
Collaborator

Choose a reason for hiding this comment

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

@marcinszkudlinski Can you check the CI build fail? I think you missed a few spots in helper.c wheere CONFIG_CROSS_CORE_STREAM is ifdeffed out and there's call to ll_block/ll_unblock.

Explicit usage of a local variable in a macro is not a
good practice.
Macros changed to use a variable as an argument

+ fix a warning "'flags' may be used uninitialized"

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
@kv2019i
Copy link
Collaborator

kv2019i commented Jul 10, 2024

One case of #9191 in https://sof-ci.01.org/sofpr/PR9260/build6422/devicetest/index.html , rest looks clean. Merging.

@kv2019i kv2019i merged commit 2a9b40f into thesofproject:main Jul 10, 2024
44 of 47 checks passed
@marcinszkudlinski marcinszkudlinski deleted the pipeline2_0_001 branch August 7, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants