Skip to content

dai: host: copier: component: New pipeline latency calculation algorithm#5985

Merged
lgirdwood merged 11 commits intothesofproject:mainfrom
softwarecki:ppl-latency
Jul 12, 2022
Merged

dai: host: copier: component: New pipeline latency calculation algorithm#5985
lgirdwood merged 11 commits intothesofproject:mainfrom
softwarecki:ppl-latency

Conversation

@softwarecki
Copy link
Collaborator

The main goal of this PR is to update the algorithm of pipeline latency calculation. It is based on the number of buffered data blocks between the first and last component.

For this purpose, I have added a new function to the component's api that allows to read the total number of processed data by it. Then, I introduced total_data_processed counter in dai_data and host_data structure. The counters of processed data has been moved from a component device structure to the components private data. Finally I removed the position field from comp_dev structure which become unused. This field was ambiguous - it was not known whether it mean consumed or produced data. I added a similar processed data counters to the Copier module.

In the future, the stamping of start and stop of the pipe will be moved to MixIn component. I have some made preparations for this process in the Copier module. I added reading the dma index using the get_attribute function and reading the gateway position using the position method.

By the way, I cleaned the dai structure from unused fields: dai_pos, dai_pos_blks and start_position.

Changed a declaration of node_id in ipc4_copier_gateway_cfg to use a aproprietary type. This change makes easier to reference the node_id field. Thanks to it, you don't have to wonder what type the value should be casted. It make our work easier and minimize the risk of a mistake.

The ipc_get_ppl_comp function has been simplified by removing the duplicate loop. Now the component list is only reviewed once and both conditions are checked simultaneously.

Created new function comp_get_base_module_cfg for ipc4 which allows to get component's base configuration. This function is still access a component's private data in ugly way but it allows solve this issue easier in the future.

Removed unused dai_pos and dai_pos_blks fields from dai_data
structure. No pointer was assigned to dai_pos.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Removed from the dai_data structure the unused field start_position.
The assigned value was never used.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
I have added a new function to the component's api that allows
to read the total number of processed data by it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@softwarecki softwarecki force-pushed the ppl-latency branch 3 times, most recently from d61c165 to f9daf45 Compare July 5, 2022 13:45
@softwarecki softwarecki force-pushed the ppl-latency branch 2 times, most recently from 44b0618 to 5bedd4c Compare July 8, 2022 08:02
@softwarecki softwarecki requested a review from lgirdwood July 8, 2022 08:04
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Looks ready, juts need some more inline comments in some places. It wpould be good if we could check the need for 64bit values if we can use 32bit (given 32bit is much cheaper on xtensa).

Copy link
Member

Choose a reason for hiding this comment

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

Btw, since this is allowed to overflow why not use a cheaper 32bit value ? This would overflow at 6.5 hrs with 16bit 48kHz stereo. Could be a optimization if we dont require 64bit values on the host.

Fwiw, ALSA really just cares about the buffer position (and this is allowed to overflow back to 0), so it does not need 64bit values.

Please check for Windows though, no idea if Windows requires a 64bit value here.

The counting of processed data has been moved from a component
device structure to the components private data. Added a new
function for reading it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
The counting of processed data has been moved from a component
device structure to the components private data. Added a new
function for reading it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
The position field was ambiguous and is no longer used.
It has been deleted.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Added total processed data counters and function to read it.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Declare node_id in ipc4_copier_gateway_cfg structure as aproprietary type.
This change makes easier to reference the node_id field. Thanks to it,
you don't have to wonder what type the value should be casted. It make our
work easier and minimize the risk of a mistake.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@softwarecki softwarecki force-pushed the ppl-latency branch 2 times, most recently from 1353369 to 2f75dcf Compare July 11, 2022 12:47
The ipc_get_ppl_comp function has been simplified by removing
the duplicate loop. Now the component list is only reviewed once
and both conditions are checked simultaneously.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Created new function comp_get_base_module_cfg which allows
to get component's base configuration. This function is still
access a component's private data in ugly way but it allows
solve this issue easier in the future.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
New algorithm for calculating the pipeline latency based on
the number of buffered data blocks between the first and last
component.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@lgirdwood lgirdwood merged commit c4f4c97 into thesofproject:main Jul 12, 2022
@marc-hb
Copy link
Collaborator

marc-hb commented Jul 13, 2022

For the record the following regression was bisected to one commit in this PR:

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.

3 participants