Skip to content

kpb: add new state - #2331

Merged
lgirdwood merged 2 commits into
thesofproject:masterfrom
mrajwa:ghw_dev
Feb 13, 2020
Merged

lgirdwood merged 2 commits into
thesofproject:masterfrom
mrajwa:ghw_dev

Conversation

@mrajwa

@mrajwa mrajwa commented Jan 28, 2020

Copy link
Copy Markdown
Contributor

This adds new state KPB_STATE_INIT_DRAINING
into KPB.

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

@lgirdwood lgirdwood left a comment

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.

@mrajwa can you add some more context in the commit message as to why this is needed. i.e. are we fixing an issue.
Btw, why do we not use the standard component states here ?

Comment thread src/audio/kpb.c Resolved
Comment thread src/audio/kpb.c Resolved
Comment thread src/include/sof/audio/kpb.h Resolved
@mrajwa

mrajwa commented Jan 29, 2020

Copy link
Copy Markdown
Contributor Author

@lgirdwood, @dbaluta this patch doesn't fix any issue, it just adds new state so we can have more detailed info in logs. Right now we will see a proper KPB state change like PREPARE -> RUN -> BUFFER -> INIT_DRAINING -> DRAINING -> ... -> RESET

Btw, why do we not use the standard component states here ?

Because these are private states of KPB and generic ones don't apply here.

@dbaluta

dbaluta commented Jan 29, 2020

Copy link
Copy Markdown
Collaborator

@lgirdwood, @dbaluta this patch doesn't fix any issue, it just adds new state so we can have more detailed info in logs. Right now we will see a proper KPB state change like PREPARE -> RUN -> BUFFER -> INIT_DRAINING -> DRAINING -> ... -> RESET

@mrajwa Oh, I see. Please add this information in the commit message.

@bkokoszx

Copy link
Copy Markdown
Collaborator

@mrajwa
Do we really need to come back to preserved_state? I think we should stay in KPB_STATE_INIT_DRAINING (and add support in kpb_copy()) or change to KPB_STATE_DRAINING, because after init_draining() we do not have to copy data to sink (selector) buffer. Can you take a look at #2343? I've added there handling KPB_STATE_INIT_DRAINING_STATE in kpb_copy().

@lgirdwood

Copy link
Copy Markdown
Member

@mrajwa @bkokoszx Please see my comments in #2343, it seems the same patch pushed to both PRs atm.

@mrajwa

mrajwa commented Jan 31, 2020

Copy link
Copy Markdown
Contributor Author

@mrajwa
Do we really need to come back to preserved_state? I think we should stay in KPB_STATE_INIT_DRAINING (and add support in kpb_copy()) or change to KPB_STATE_DRAINING, because after init_draining() we do not have to copy data to sink (selector) buffer. Can you take a look at #2343? I've added there handling KPB_STATE_INIT_DRAINING_STATE in kpb_copy().

I am against treating KPB_STATE_INIT_DRAINING and KPB_STATE_DRAINING as one state. This is unnatural and not true and will confuse people reading the code, logs etc. As for not switching back from KPB_STATE_INIT_DRAINING to preserved state - I think its sane to switch back as soon as init of draining is done since as I described above this state blocks all others (internal buffering being the most crucial one here)

@mrajwa
mrajwa force-pushed the ghw_dev branch 3 times, most recently from 701dd0e to 243ce18 Compare February 5, 2020 14:17

@lgirdwood lgirdwood left a comment

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.

@mrajwa is the state diagram pending for this PR ?

@mrajwa

mrajwa commented Feb 6, 2020

Copy link
Copy Markdown
Contributor Author

@mrajwa is the state diagram pending for this PR ?

kpb_state_diagram_v1

I have UML code for it also but the question is where should I commit it? Into sof-dosc? I see there is no parser for uml only picture source is linked.

@lgirdwood

Copy link
Copy Markdown
Member

@mrajwa looks good, I'm no UML parsing expert for docs, so better ask @mmaka1. Can you convert this to ASCII from UML to insert into the header (if we cant do this then a big comment is needed stating that any state changes must also be reflected in the UML diagram). i.e. I want to make it easy for anyone who changes code to alos update diagram.

@lgirdwood lgirdwood left a comment

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.

I think we are almost good, lets just make it easier to follow for other developers.

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.

Lets just state the assumption about state in a comment here.

Comment thread src/include/sof/audio/kpb.h 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.

and we can probably have a big fat comment here that any state changes must also be reflected in ASCII header diagram or UML diagram on sof-docs (with a link to said UML diagram).

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 very good idea, so let me first finish UML merging and once this is done I will come back here with the update.

@mrajwa

mrajwa commented Feb 9, 2020

Copy link
Copy Markdown
Contributor Author

@lgirdwood, I tried to convert it to ASCII using plantuml built in feature but it doesn't look good. So I would include it in the sof dosc in the form of plantuml code and/or actual rendered picture.

@keyonjie

Copy link
Copy Markdown
Contributor

@lgirdwood, I tried to convert it to ASCII using plantuml built in feature but it doesn't look good. So I would include it in the sof dosc in the form of plantuml code and/or actual rendered picture.

@mrajwa you could try asciiflow here: http://asciiflow.com/

@mrajwa

mrajwa commented Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

@keyonjie, this tool seems to be aimed to draw ASCII diagrams and it might work however, I don't see any option to save it as a code and no option to generate a picture for sof-dosc. Especially the former concerns me since it will make our diagrams hard to maintain - each time you would like to add new state you would have to redraw it yourself or tinker with ASCII in your own...nightmare. Plantuml is based on their code, so each and every time you modify something it all boils down to changing specific line in code. Not to mention it generates a nice picture right away.

@lgirdwood

Copy link
Copy Markdown
Member

@mrajwa ok, lets do it in sof-docs, as long as we have some comment that explains this with command line for using the tool to generate the output.

@mrajwa

mrajwa commented Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

I have added a PR into sof-docs thesofproject/sof-docs#183 and added comments you requested in the FW. Can we merge now? I would like to merge it fast as I want to open new, bigger PR for KWD aimed to make it even more secure in corner cases.

@mrajwa
mrajwa force-pushed the ghw_dev branch 2 times, most recently from 1119860 to d30b561 Compare February 11, 2020 11:40
This patch add a log message indicating wrong
state of KPB during buffering.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This adds new state KPB_STATE_INIT_DRAINING into
KPB internal states. This way we can see failed
init draining in logs. This new state is also
needed to change KPBs regular behavior in a
situation where we have initied draining task,
therefore calculated read position but the task
doesn't start before next pipeline_copy happens.
In this case, having this new state we can
recognize it and update read position
accordingly to new data.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
@lgirdwood
lgirdwood merged commit 36d4c9f into thesofproject:master Feb 13, 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.

6 participants