Skip to content

kpb: protect data staged for draining + minor changes - #2688

Merged
lgirdwood merged 10 commits into
thesofproject:masterfrom
mrajwa:kpb_dev
Apr 7, 2020
Merged

lgirdwood merged 10 commits into
thesofproject:masterfrom
mrajwa:kpb_dev

Conversation

@mrajwa

@mrajwa mrajwa commented Apr 1, 2020 •

Copy link
Copy Markdown
Contributor

This PR adds protection of history data so they won't get overwritten when pipeline_copy() task occurs during draining or init draining state.
Also, there is a change for the topology - minimal buffer size is raised so it enables safe draining for all formats.
Minor refactoring added too.

Signed-off-by: Marcin Rajwa marcin.rajwa@linux.intel.com

Comment thread src/audio/kpb.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you explain why in the commit message. I assume it's putting items closer together that are used together for faster access / better cache perf ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's it. The commit message has been updated.

mrajwa added 8 commits April 6, 2020 11:08
This patch changes the name of the "hb" struct to
more meaningfull "history_buffer". Therefore
code is more readable.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch changes the name of "dd" structure to
more meaningful "draining_data". Therefore code
is more readable.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch adds new struct called "history_data"
which contains all variables related to
history buffer namely, its size, amount of free and
available data as well as address of current write
buffer (history buffer is a collection of smaller
buffers)

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This additional variable says how much data can be
written to history buffer and won't cause overwrite
of data staged for draining. It is important to realize
the history buffer is circular and its data gets
overwrite all the time. So *free* in this case doesn't
mean "amount of bytes before buffer is full". History
buffer is *full* 99% of the time. However before the
draining starts we "freeze" history buffer data
so new samples can be written only if:

HISTORY_BUFFER_SIZE - HISTORY_DEPTH > 0

The result of above subtraction is what we call "free"

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch adds the condition that if we are
in draining or init draining state and
pipeline_copy() appeared before we actually
started the draining, plus the amount of new data
can overwrite the data staged for draining then
we should postpone buffering procedure for next
period. At that time we assume draining task will have
already drained some samples therefore making a space
for new ones.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch reworks the calculation of buffered data.
NOTE! We only keep record of buffered data up to
the size of history buffer as there is no usecase
beyond that.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch changes the error message caused by
no bytes to be buffered from "error" to warning
as this is not crirical error.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch moves the update of buffered data during
draining from buffering function to the caller
function.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
mrajwa added 2 commits April 6, 2020 11:36
This patch changes the order of members in comp_data
struct to improve memory access for related data.
So now data that are commonly used together like *state*
and *state_log* are put next to each other so fewer cache
reads are needed.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This updates the minimal host buffer size to the
minimum value which enables sefe draining for all
pcm parameters.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@lgirdwood

Copy link
Copy Markdown
Member

CI known issues on Jenkins.

@lgirdwood
lgirdwood merged commit 94b235c into thesofproject:master Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants