Skip to content

Conversation

@ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Jul 3, 2025

The module_adapter_params() functions set the stream params based on the base config for each module which is available right after module init. So configure the params for IPC4 during module_new() and remove the call to ipc4_pipeline_params(). This should help with reducing the time to trigger pipelines during start.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 3, 2025

SOFCI TEST

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.

A nice improvement, although I'd elaborate what is happening and why more in the code comment. After all, the documentation for "params()" op is:

»        * Sets component audio stream parameters.                                                                                                                                           
»        * @param dev Component device.                                                                                                                                                      
»        * @param params Audio (PCM) stream parameters to be set. 

What module_adapter does here when built for IPC4, is quite a different thing.

#if CONFIG_IPC_MAJOR_4
struct sof_ipc_stream_params params = {{ 0 }};

/* set the stream params based on the module base cfg */
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is quite whacky looking code to pass a NULL params struct. I would add even more explanation to explain that in IPC3, params is used, but in IPC4 is not used, but instead it will be filled from basecfg.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kv2019i @ranj063 well, not sure if it's important or intentional, but it isn't the same as what is done now. Now these parameters are initialised to 0 only once for the entire pipeline. So when traversing the pipeline in ipc4_comp_params() if the first component sets some values in it, the next component will get those values. Let me "request changes" for this PR for now to make sure we think this through

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh I thought about this as well but even if it is initialized only once, we should be overwriting the params based on the current module's base_cfg. So in theory this should be do the same thing as before. But of course some of the alsabat tests as failing so I am not entirely sure if we're missing something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but looking more closely at module_adapter_params(), what I may be missing is the fact that the buffer parameters are updated in comp_verify_params() and this will not happen with my PR because the components may not be connected at this point. I'll look into it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh have a look at the updated PR now. I think Ive fixed the issue with missing comp_verify_params(). I've got almost all platforms passing except for LNL HDA(which doesnt seem like an issue with my PR)

Copy link
Collaborator Author

@ranj063 ranj063 Jul 7, 2025

Choose a reason for hiding this comment

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

of course the QB tests as failing. @lgirdwood who can help me with that? I cant even access the link

lyakh
lyakh previously requested changes Jul 7, 2025
#if CONFIG_IPC_MAJOR_4
struct sof_ipc_stream_params params = {{ 0 }};

/* set the stream params based on the module base cfg */
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kv2019i @ranj063 well, not sure if it's important or intentional, but it isn't the same as what is done now. Now these parameters are initialised to 0 only once for the entire pipeline. So when traversing the pipeline in ipc4_comp_params() if the first component sets some values in it, the next component will get those values. Let me "request changes" for this PR for now to make sure we think this through

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 7, 2025

SOFCI TEST

@ranj063 ranj063 force-pushed the main-070225 branch 2 times, most recently from ad23a94 to 90f94b7 Compare July 8, 2025 01:53
@lyakh lyakh dismissed their stale review July 8, 2025 07:13

question clarified

@ranj063 ranj063 requested review from fkwasowi and iganakov as code owners July 8, 2025 18:07
@ranj063 ranj063 force-pushed the main-070225 branch 11 times, most recently from e6e7b1e to a658cc1 Compare July 10, 2025 03:21
src/audio/kpb.c Outdated

kpb_set_params(dev, &params);

ret = kbp_verify_params(dev, &params);
Copy link
Collaborator

Choose a reason for hiding this comment

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

the naming of both of these functions isn't very... intuitive. AFAICS kpb_set_params() actually doesn't set parameters but rather gets them instead. I.e. it retrieves current KPB parameters into a user-provided structure. Then it isn't very clear why kbp_verify_params() is called - if you've just obtained parameters from a device, they should be valid, right? But also instead of just verifying parameters, which sounds like a read-only operation, kbp_verify_params() and the underlying comp_verify_params() can update parameters and also use them to configure audio buffers... Maybe we need at least some comments here and eventually also in the implementation.

struct sof_ipc_stream_params params;

/*
* set the stream params based on the module base cfg. There's no need to initialize
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think usually when we say, that a function "sets parameters," we mean, that we pass parameters to a function which are then used internally by that function for some configuration. While here as well as in kpb_set_params() above we retrieve parameters.

src/audio/kpb.c Outdated

ret = kbp_verify_params(dev, &params);
if (ret < 0) {
comp_err(dev, "kpb_prepare: pcm params verification failed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd propose not to use function names at least in new logging prints - even if they're otherwise used throughout the code. But in fact see comp_cl_err() call 6 lines down - it has no function name in it. Zephyr adds function names by itself. I'd also not use function names in added prints below - in module_adapter.c etc., even if so far they're used there.


comp_dbg(dev, "module_adapter_prepare() start");
#if CONFIG_IPC_MAJOR_4
/* verify params */
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think comments should add information, not obvious from the code, and a comment like this above a call to comp_verify_params() doesn't seem to add a lot of information. Instead maybe clarify that that function not only verifies parameters, but does more as discussed above

@lyakh
Copy link
Collaborator

lyakh commented Jul 14, 2025

@ranj063 also, if you update this PR - the subject "src: audio:..." confused me at first - I thought it was related to the SRC component :-) I think in SOF we don't quote the full path to the affected sources in the patch subject line, at least I don't think we usually put the "src" part there. Beginning with "audio:..." should be enough?

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 15, 2025

SOFCI TEST

@ranj063 ranj063 force-pushed the main-070225 branch 3 times, most recently from 1c604fa to 5715eff Compare July 15, 2025 21:39
@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 16, 2025

@lyakh Ive addressed your comments now. Let me know how it looks. I do not like the naming of the function comp_veryify_params() or kpb_verify_params. I am going to do a follow up PR to remove this function anyway to do the params update during binding.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 16, 2025

SOFCI TEST

@lyakh
Copy link
Collaborator

lyakh commented Jul 16, 2025

ouch - IPC timeout on PTL https://sof-ci.01.org/sofpr/PR10094/build13984/devicetest/index.html?model=PTLH_RVP_NOCODEC&testcase=multiple-pause-resume-50 - that isn't good. Now it isn't obvious that it's this PR that does that, we have observed "somewhat similar" problems recently #10116 but no IPC timeouts on PTL until now... So it might or might not be this PR. Let's put a DNM here for a bit.

@lgirdwood
Copy link
Member

ouch - IPC timeout on PTL https://sof-ci.01.org/sofpr/PR10094/build13984/devicetest/index.html?model=PTLH_RVP_NOCODEC&testcase=multiple-pause-resume-50 - that isn't good. Now it isn't obvious that it's this PR that does that, we have observed "somewhat similar" problems recently #10116 but no IPC timeouts on PTL until now... So it might or might not be this PR. Let's put a DNM here for a bit.

I think this is probably unrelated since this change will impact the initial stream start state transitions, but lets run another round of tests.

@lgirdwood
Copy link
Member

SOFCI TEST

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 16, 2025

I think this is probably unrelated since this change will impact the initial stream start state transitions, but lets run another round of tests.

Yeah, I doubt this PR can cause any impact on pause/release. Testing again now

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 16, 2025

SOFCI TEST

The module_adapter_params() functions set the stream params based on the
base config for each module which is available right after module init.
So configure the params for IPC4 during module_new() and remove the call
to ipc4_pipeline_params(). In order to update the buffer params, add a
call to comp_verify_params() during module_adapter_prepare in order to
update the intermediate buffers. This should help reduce the time to
trigger pipelines during start.

Add the params handling for the KPB and detect_test modules explicitly
because they don't use the module adapter.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 17, 2025

@wszypelt looks like the MTL drive was skipped in the QB tests. Would it be possible to trigger it again?

@lyakh
Copy link
Collaborator

lyakh commented Jul 17, 2025

@lgirdwood @ranj063 looks like since yesterday this PR ran through the CI up to 4 times: twice triggered by a git push and twice by the "magic keyword" comment. There are no multiple-pause-resume failures in the last round, but the one before the last again had IPC timeout on PTL in the same test.

We currently have failures in that test on multiple platforms #10116 but none of those had IPC timeouts. I also can easily reproduce those failures without IPC timeouts on a test MTL system. I'll try to dig some more into this today and possibly tomorrow, let's decide then.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 17, 2025

@lgirdwood @ranj063 looks like since yesterday this PR ran through the CI up to 4 times: twice triggered by a git push and twice by the "magic keyword" comment. There are no multiple-pause-resume failures in the last round, but the one before the last again had IPC timeout on PTL in the same test.

We currently have failures in that test on multiple platforms #10116 but none of those had IPC timeouts. I also can easily reproduce those failures without IPC timeouts on a test MTL system. I'll try to dig some more into this today and possibly tomorrow, let's decide then.
@lyakh I tried to trigger the test multiple times to see if the IPC timeout can be reproduced. But looks like the dmesg logs were missing in both the times they occured so it's hard to tell the sequence that caused it. But I have a suspicion on the xruns causing this. Do you know what is the sequence when an xrun occurs? Do we stop the pipeline and reset the pipeline within the FW or do we wait for the host to stop, reset and restart with a prepare?

@ranj063
Copy link
Collaborator Author

ranj063 commented Jul 17, 2025

SOFCI TEST

@lyakh
Copy link
Collaborator

lyakh commented Jul 18, 2025

We currently have failures in that test on multiple platforms #10116 but none of those had IPC timeouts. I also can easily reproduce those failures without IPC timeouts on a test MTL system. I'll try to dig some more into this today and possibly tomorrow, let's decide then.

update: I cannot really reproduce them, those were a different kind of failure

* retrieve the params from the basecfg, allocate stream_params and then update the
* sink/source buffer params.
*/
if (!mod->stream_params) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't seem possible any more? It's now allocated in .new()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it is possible when you restart a stream after a pipeline reset without freeing it

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ranj063 interesting. Could you explain a bit more just for my understanding - "restart" a stream - you don't mean stop -> start, just a reset, right? But when do such "resets" happen apart from when stopping streams?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh it never happens in our tests. But there's a QB test that does this sequence (it called randomDMAtest or something like that). I added this specifically to make that test pass:
set up pipelines -> start pipelines -> stop pipelines - >reset pipelines -> Put the DSP in D3 -> exit D3 -> prepare & restart pipelines -> stop pipelines -> reset pipelines -> free pipelines

@lyakh lyakh removed the DNM Do Not Merge tag label Jul 25, 2025
@kv2019i
Copy link
Collaborator

kv2019i commented Jul 28, 2025

@lyakh Are we good to go? Tests seems on par with other PRs now.

@kv2019i kv2019i merged commit 86cbc3b into thesofproject:main Jul 29, 2025
40 of 45 checks passed
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.

4 participants