-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: ipc4-topology: implement KCPS adjustment #4213
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
Conversation
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why __s32 and not just s32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it's an external parameter, a part of an ABI
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to add to the extension:
SOF_IPC4_MOD_EXT_MSG_SIZE(sizeof(adjust))
or you can also use the dedicated function to do a proper LARGE_CONFIG, see #4212.
Since you are always going to send a single u32, it might be justified to have it open coded, but in general I prefer to use the function which exists for the purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh... sof_ipc4_set_get_data() is a kind of a monster... In general - yes, I'd also rather use a proper abstraction, so... But well, I still think it's better to use the accessor. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is a monster, but it adds the benefit that we use common code and we can also dump the payload as hex in one place.
It is good to have these handled in one path to help debugging things.
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes and no, it is used to track the payload size in the mailbox, it is used in the IPC low level code to decide if we need to copy something to there or not.
Can you drop this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the msg.data_size, that's used for that in the IPC4 case, not the last parameter to sof_ipc_tx_message_no_reply(), but sure, I can drop it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, which is coming from this size parameter:
Line 57 in cff45ee
| msg->msg_size = msg_bytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stand corrected - I was looking at an older kernel version. Now it's used indeed!
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make the sof_ipc4_pipeline_send_kcps() handle the !kcps_adjust internally and then you can have this implemented in a more optimistic way:
if (!ret) {
ret = sof_ipc4_pipeline_send_kcps(sdev, swidget, kcps_adjust);
if (ret) {
dev_err(sdev->dev, "failed to increase KCPS: %d, continuing\n", ret);
ret = 0;
} else { /* the error case */ }
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was comparing the two options - where to put the check for 0 KCPS adjustment, and in the end I chose this option. It's a really small addition outside and makes it clear immediately at this level, whereas in the function - you'd be calling it just to return immediately. So, unless you feel strongly about this, I'd keep it as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about this, just it would make the caller sites cleaner, less number of if ().
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this is a dev_warn()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, dev_err() would be called by the CI, right? In fact I'm not even sure - should we make this a failure or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is an error, then we should treat it as an error, here we are ignoring it, so it is a warning, imho
No need for ABI version update (and it is not really defined for IPC4 anyways). The KCPS update is an existing FW feature, we just missed it. |
|
The SOF counterpart is thesofproject/sof#7160 |
ujfalusi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The open coded IPC message crafting is not correct (I would use the ops for it to do the right thing) and there is the wrong comment about the last parameter of sof_ipc_tx_message_no_reply()
sound/soc/sof/sof-audio.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a very ipc4 specific parameter, can we put it somewhere in one of the ipc4 structs instead of swidget?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved, thanks
plbossart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather lost of what this kpcs token means, and what exactly it changes.
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the first time I hear about a pipeline-level cycle count. We already have a module 'cpc' (cycle per chunk) and 'cps" *cycles per second", so it's not clear to me how those 3 tokens would be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need kcps ? In current 0004 branch, kcps is built from cpc and we already have cpc in module now. Why do we need to add kcps ?
int kcps = cd->cpc * 1000 / ppl_data->p->period;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 0004 branch, kcps is built from each module in pipeline with the above algorithm, why we need pipeline kcps ?
data.start = p->source_comp;
data.p = p;
walk_ctx.comp_func = add_pipeline_cps_consumption;
if(!clocks_handled)
ret = walk_ctx.comp_func(p->source_comp, NULL, &walk_ctx, PPL_DIR_DOWNSTREAM);
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does 'adjust' mean? is this to specify a kcycles value, or alter it from a baseline read in topology?
Completely unclear what this is about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can call it "delta" if that would help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or kcps_change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you call it 'delta' then the function should be not sof_ipc4_pipeline_send_kcps(), prehaps: sof_ipc4_send_kcps_update()?
sound/soc/sof/ipc4-topology.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see nothing that's pipeline-specific here, I really don't understand what 'adjust' means here. If the message destination is the base firmware module how would one change pipeline Y ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC it doesn't matter which specific pipeline requests the change in clock rate, we just add up all pipelines and configure the clock with the sum
sound/soc/sof/sof-audio.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int or s32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plbossart the value that's sent out has to be s32, because it can be negative for a negative adjustment, and it has to be 32 bits because it's a part of an ABI. But here we're storing a generic integer unsigned value, so I think unsigned int is appropriate here.
|
Base FW today supports a global per core DSP frequency manager to select the most power efficient clock based on DSP core loading. Today it uses the following rules
Rules 1, 2, & 3 are compatibility, rule 4 is extended feature improvement on Linux. Rule 3 is not implemented in driver today and has no tooling to capture per module cps or to regenerate signed FWs with new ext manifest cps data. Long term the DSP FW should be responsible to monitor the per core loading with hints from driver (manifest, topology) and adjust frequency as necessary. |
The SOF already supports the REGISTER_KCPS IPC, this patch also adds support for it to the driver. A new topology token is used for this, which specified the KCPS requirement for each pipeline. When a pipeline is created, that had a KCPS value specified for it in the topology, that value is sent to the firmware for clock adjustment. When such a pipeline is destroyed, the same negative value is sent to return the system clock rate to the original state. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
ujfalusi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still hide the delta_kcps check fro 0 in sof_ipc4_send_kcps(), but it is probably just a matter of taste.
|
I still don't get the relationship between pipeline and cores. We know that with the introduction of the DP domain the pipeline can be made of modules that are assigned on different cores. So how would the pipeline 'adjust' value be computed in this case? Lost in space, and it's Monday 9:45am. Oh well. |
|
I still don't know why we need kcps and how does fw support this. currently the FW algorithm is built based on module cpc. And I also found that cpc value in fw extended manifest was refined(mtl: add measured cps and cpc values). It seems that kernel driver should get cpc value from module extended config and send it to FW. |
@plbossart with this PR no KCPS calculations are done in the kernel. This PR does a very simple thing: takes values from the topology and sends them to the firmware. |
|
too many double-negatives in your answer @lyakh. The point is that if a component is assigned to a different core the entire logic looks wrong. Either we accept component-level core assignment or we don't. |
| offsetof(struct sof_ipc4_pipeline, use_chain_dma)}, | ||
| {SOF_TKN_SCHED_CORE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, | ||
| offsetof(struct sof_ipc4_pipeline, core_id)}, | ||
| {SOF_TKN_SCHED_PIPELINE_KCPS, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh, @ujfalusi and @jsarha I had a chat with @plbossart and can we modify this attribute to be per module i.e. needs to be in the base class of each module. This would then allow us to mix scheduling types in a pipeline and scale across cores.
Thinking further, can we also extend this to include format and be an array i.e.
{SOF_TKN_SCHED_MODULE_KCPS_S16LE, SND_SOC_TPLG_TUPLE_TYPE_ARRAY, get_token_u32_array,Where the array index would be the channel count + 1. i.e. when defined in topology
1000, 2000, 0, 4000, 0, 0, 0, 0This would then specify 1000 kcps for mono S16_LE, 2000kcps for stereo S16_LE, 3 channel S16_LE not known (can use platform max default), and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the CPC/CPS are kind of worst-case figures. They are not meant to be adjusted depending on channel count or input/output formats. We're probably looking at one broadbrush estimate for each module and correction factor to account for the known unknowns (cache, IPC, solar eclipses and neutrinos).
|
Clarification from FW is that kernel KCPS IPC should only sent in special cases to override the values on module config (defined in toml files). The implementation is not complete in SOF main but there is an early version available, see thesofproject/sof#7267 |
Not clear if the ask is to override the CPC/CPS values for a module (with the updated value impacting all pipelines with a module instance), for a module instance (with impact limited to the pipeline in which it is inserted), or for a pipeline containing a module instance (directly changing the total maintained at the pipeline level - if this makes sense). |
@plbossart as far as I understand we decided, that we don't want KCPS set from the topology and instead we want a user-activated trigger to increase the clock and maybe also some situations where this will be done automatically |
|
Yes, we will need some place to store the magical KCPS for a platform and send that with a kcontrol. |
Kcontrols are typically exposed in topology though... debugfs sounds like a better place for this kind of things. We should not use kcontrol IMHO. |
#4262 added the fallback platfomr KCPS support, we can use that number for the 'boost'
debugfs would be really simple for sure, but I think the issue is that this has to be exposed to user space and debugfs is not a good place for UCM to touch it for example. |
|
this PR is no longer aligned with our plans for MTL. We will first enable the parsing of CPC information from the manifest with #4338, and move all efforts to override the MCPS budget to a later point after revisiting the API for clock scaling with our firmware friends. Let's close this for now. |
The SOF already supports the REGISTER_KCPS IPC, this patch also adds support for it to the driver. A new topology token is used for this, which specified the KPCS requirement for each pipeline.
Do I need to bump up any ABI version numbers for this?