Skip to content

pipeline frame count and pcm range setting - #842

Merged
tlauda merged 4 commits into
thesofproject:masterfrom
juimonen:hwparams_to_frames
Aug 15, 2019
Merged

tlauda merged 4 commits into
thesofproject:masterfrom
juimonen:hwparams_to_frames

Conversation

@juimonen

Copy link
Copy Markdown

ok, this is a little bit monster, but the patches are more or less related. Idea is to set pipeline component frame count from stream samplerate and scheduling time. Because of stream sample rate range is also set in the topology, there's patches to set that on top level m4. Because frame count also affects buffer size, there's also patches related to buffer re-size inside firmware. 50kHz topology is the only "non-related", but it is also good for testing this thing.

@juimonen

Copy link
Copy Markdown
Author

Here's some documentation related to this pr, if someone has time to read:
https://github.com/orgs/thesofproject/teams/sof-developers/discussions/5

Comment thread src/audio/buffer.c Outdated
Comment thread src/audio/host.c Outdated
Comment thread src/audio/host.c Outdated
Comment thread tools/topology/sof-apl-da7219.m4 Outdated
Comment thread src/audio/pipeline.c Outdated
Comment thread tools/topology/m4/dai.m4 Outdated

@xiulipan xiulipan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@juimonen Finish the huge patches review, I have some question summary here:

  1. How the frame_rate is setting here. I see your example in discussion. But seems no related code here.
    Correct me if I missed something.
  2. The changes to topology is very huge. Any simple way?
    If there are any side effect if no src is pipeline?

others are small issues inline.

Comment thread src/audio/buffer.c Outdated
Comment thread src/audio/buffer.c Outdated
Comment thread src/audio/host.c Outdated
Comment thread tools/topology/m4/dai.m4 Outdated
Comment thread tools/topology/m4/dai.m4 Outdated
Comment thread tools/topology/sof-apl-src-50khz-pcm512x.m4 Outdated
Comment thread tools/topology/sof-apl-src-50khz-pcm512x.m4 Outdated
Comment thread src/audio/pipeline.c Outdated
Comment thread src/audio/src.c Outdated
Comment thread src/include/sof/audio/component.h Outdated
@juimonen
juimonen force-pushed the hwparams_to_frames branch 2 times, most recently from e97a5f9 to 5531d56 Compare January 16, 2019 14:44
@juimonen

Copy link
Copy Markdown
Author

@lgirdwood @xiulipan thanks for the review. I updated the PR. I tried to incorporate the suggestions, but there are still couple of comments I did not totally understand.

This PR should be really tested by QA with all possible platforms and topologies as I'm limited to up2...

@markyang

Copy link
Copy Markdown

The test results of PR842 are as follows:

DUT Device Codec Driver loaded PCM devices list HDMI/DP playback Analogy playback Analogy capture DMIC capture Volume Change Unload/reload (5 iterations) Unload/reload (100 iterations) Runtime PM S3/S0ix w/o playback (50 iterations) S3/S0ix w/ I2C playback (50 iterations) S3/S0ix w/ HDMI playback (50 iterations)
BYT Minnow Board rt5651 Passed Passed N/A Passed Passed N/A Passed Passed Passed N/A N/A N/A N/A
APL UP2 pcm512x Passed Passed Passed Passed N/A N/A Passed Passed Passed Passed Passed | 50 Passed | 50 Failed | 1 (#788) Known issue

Test env:
sof master: 03ababf (pr842 was applied)
kernel sof-dev: a5dd318 (latest)
tplg: sof-apl-pcm512x.tplg (pr842 was applied)
tplg: sof-byt-rt5651.tplg (pr842 was applied)
tplg: test-ssp0-mclk-0-I2S-volume-s16le-s16le-48k-24000k-codec.tplg (latest)

@lgirdwood

Copy link
Copy Markdown
Member

@markyang great results :)
@juimonen can you check CI build failure, you may need to restart build if results are older than 1 day.

@juimonen

Copy link
Copy Markdown
Author

@lgirdwood I'll rebase, however it goes to tomorrow, there was tomasz' patch for pipeline refactoring, which I have to resolve...

@lgirdwood

Copy link
Copy Markdown
Member

@juimonen @tlauda lets get Tomeks PR merged first then we can do this on top.

@juimonen

Copy link
Copy Markdown
Author

@lgirdwood, rebased and updated. The frame setting code now changed, because of re-factored pipeline code. I did test basic src topologies and they seem to work. I tried to test also 8-192khz range to 48kHz dai, but there's some problem. I think the kernel sof/pcm.c is currently tied to dai max rate, which is not going to work in the case mentioned before. I don't know however is it a problem for this pr now...

@juimonen

Copy link
Copy Markdown
Author

this PR is failing in cmocka test: test_audio_pipeline_complete_connect_downstream_full
which is testing frame setting from pipeline. Well this PR is removing setting frames from pipeline and instead using stream parameters to calculate it. So is the cmocka test invalid for this PR or I'm not understanding what is happening? @tlauda can you point me to right person writing the tests? I saw your name in the file...

Comment thread src/audio/pipeline.c Outdated
@lgirdwood

Copy link
Copy Markdown
Member

@juimonen just a minor comment and looks like a UT failure.

@juimonen
juimonen force-pushed the hwparams_to_frames branch 2 times, most recently from 6f67178 to 2494dbe Compare January 24, 2019 16:04
@juimonen

Copy link
Copy Markdown
Author

@lgirdwood I fixed the unit test, I hope the fix was ok. I'm still seeing strange build errors, some time outs and klockwork "indexing" errors...

@juimonen

Copy link
Copy Markdown
Author

don't merge this yet, as I need to test this better after pipeline refactoring!

@zrombel

zrombel commented Jan 25, 2019

Copy link
Copy Markdown

On QuickBuild in python regression test for this PR we are encountering DSP panic when sending ipc_stream_pcm_params to FW. This problem applies to APL, CNL and ICL builds.
PR_REGRESSION: https://quickbuild.igk.intel.com/build/3457197

IPC log (after creating topology when trying to create stream):

Creating stream (48000Hz, 2, 32b/32b).
Sending StreamPmcParams (60010000, 00000000)
Payload:
0000006C 60010000 00000000 00000000
00000000 00000000 00000054 0000001C
00000000 00000000 00000000 00000000
00000000 00000000 00000001 00000002
00000000 0000BB80 00020001 00040004
00003F00 00000000 00000000 00000000
00000000 00000000 00000000

Notification Ipc (8DEA0000, 00040800)
Payload:
0000006C 70000000 00000000 00000000
00000000 00000000 0000003C 00010001
00000000 00000000 00000000 00000000
00000000 00000000 66330000 00323733
03000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000

Full IPC log can be found on QuickBuild or I can provide it. All builds was made with xtensa-smp architecture. I will try to run test on APL with xtensa-up to see if problem is architecture dependent.

@juimonen
juimonen force-pushed the hwparams_to_frames branch from 503d5d4 to 5630a3c Compare July 4, 2019 07:44
@juimonen

juimonen commented Jul 4, 2019

Copy link
Copy Markdown
Author

@lgirdwood @mengdonglin I'd still like to have QA test round as this is very invasive... I can't test most platforms on my own.

@tlauda

tlauda commented Aug 10, 2019

Copy link
Copy Markdown
Contributor

@juimonen Can we get this rebased and maybe finally merged?

@juimonen
juimonen force-pushed the hwparams_to_frames branch from 5630a3c to 8e685e1 Compare August 12, 2019 10:55
@juimonen

Copy link
Copy Markdown
Author

@tlauda rebased. I think @mengdonglin is on vacation this week and I would like to have the extended testing for this... This is touching all topology files and I can't test them myself.

@tlauda

tlauda commented Aug 14, 2019

Copy link
Copy Markdown
Contributor

@lgirdwood @xiulipan Please rereview ASAP to avoid another rebase.

Comment thread tools/topology/CMakeLists.txt Outdated
@juimonen
juimonen force-pushed the hwparams_to_frames branch from 8e685e1 to 7983166 Compare August 14, 2019 11:21

@xiulipan xiulipan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some simple question about the pipeline rate setting.
It should be always need to be used for SRC involved pipeine right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we miss some setting to
W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST( ', SOF_TKN_SRC_RATE_OUT "PIPELINE_RATE"'))
in this file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, you are right. As this PR has been lingering for almost a year, topologies come an go...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dnl PIPELINE_PCM_ADD(pipeline,
dnl     pipe id, pcm, max channels, format,
dnl     period, priority, core,
dnl     pcm_min_rate, pcm_max_rate, pipeline_rate,
dnl     time_domain, sched_comp)```

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we also need to change the comments here?
PS: I think this commit should go after the topology: enable pcm range and pipeline rate and remove frame count

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok

Previously frame count was coming as topology pipeline parameter. As the
frame count might change because of some components have fixed
samplerate, we might as well calculate it from the stream parameters.
Component base struct will have new member output_rate, which the
component should set if it has fixed output rate (like SRC). Not setting
it or 0 means it can be whatever the pipeline decides. Components with 0
output_rate will have frames = (stream) sample_rate / (pipeline)
deadline. Components downstream to fixed output rate will obey the fixed
rate / period.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
@juimonen

Copy link
Copy Markdown
Author

@xiulipan it could/should be used with any/all pipelines. The old "frames" is going away, because we can calculate it automatically from samplerate&scheduletime. Of course difference on these new rates doesn't make much sense with pipeline without SRC.

Jaska Uimonen added 3 commits August 15, 2019 09:13
Enable setting pcm min and max rate from top level m4 pipeline macro.
This way it is possible to configure the whole pipeline to correct
samplerate range in 1 file. Previously you needed to modify the pipeline
macros where the rate was hardcoded. As the frame count is calculated
from pcm/dai rate and scheduling time the frame count is obsolete.

Introduce pipeline rate parameter to help configuring components with
fixed output rate. We can't deduce this from pcm range since for example
src might accept bigger max rate than the following dai. Even though the
parameter is named "pipeline rate" it essentially means the "final"
output rate to which this pipeline is connected to (dai or other
pipeline). In capture pipelines it means the originating fixed dai rate.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
cmocka pipeline connect unit test is checking the successful
connection from frames count set in components. However the frames
are not set in pipeline complete if we set the frames from stream
parameters. So check now that the pipeline pointer has been set
and matches the pipeline in high level test function.

Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
@juimonen
juimonen force-pushed the hwparams_to_frames branch from 7983166 to 86cae1a Compare August 15, 2019 06:22
@juimonen

Copy link
Copy Markdown
Author

@xiulipan pushed new version. I tried to address your comments.

@xiulipan xiulipan left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@juimonen LGTM! Some simple example comments is OK for us to make the change with your features here.

@tlauda

tlauda commented Aug 15, 2019

Copy link
Copy Markdown
Contributor

SOFCI TEST

@tlauda

tlauda commented Aug 15, 2019

Copy link
Copy Markdown
Contributor

@juimonen Do we need any additional testing or you think CI is enough? I would like to merge it as soon as possible and avoid another rebase.

@juimonen

Copy link
Copy Markdown
Author

@tlauda I'm not sure if all use cases with kwd and more exotic things work as intended... I'm not sure is anyone testing those. Anyway, it seems basic stuff is working and I'm fine with reverting or fixing if things arise.

@tlauda
tlauda dismissed lgirdwood’s stale review August 15, 2019 12:28

Requested changes done.

@tlauda

tlauda commented Aug 15, 2019

Copy link
Copy Markdown
Contributor

@juimonen CI passed (BYT machine with codec is currently down).

@tlauda
tlauda merged commit ebf406d into thesofproject:master Aug 15, 2019
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.

10 participants