Skip to content

Host-zephyr: limit copy bytes to one period for capture pipeline - #7145

Merged
ranj063 merged 1 commit into
thesofproject:mainfrom
btian1:copybytes
Mar 2, 2023
Merged

ranj063 merged 1 commit into
thesofproject:mainfrom
btian1:copybytes

Conversation

@btian1

@btian1 btian1 commented Feb 22, 2023 •

Copy link
Copy Markdown
Contributor

Limit copy bytes to period bytes for both playback and capture
to avoid high load spike.

@btian1 btian1 changed the title Host: limit bytes per copy to one period for the whole pipeline Host-zephyr: limit bytes per copy to one period for the whole pipeline Feb 23, 2023
@btian1 btian1 changed the title Host-zephyr: limit bytes per copy to one period for the whole pipeline Host-zephyr: limit copy bytes to one period for capture pipeline Feb 23, 2023

@aiChaoSONG aiChaoSONG left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the log is not correct, avail_bytes and free bytes are direction dependent.

Comment thread src/audio/host-zephyr.c Outdated
Comment on lines 497 to 498

@aiChaoSONG aiChaoSONG Feb 23, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for playback, avail_bytes is the bytes available in dma, free_bytes is the free bytes in downstream buffer; but for capture, avail_bytes is the bytes available in buffer, and free bytes is the free bytes in downstream DMA. so the log info here probably is wrong.

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.

it is just print some information help developer debug when there is a bug exists, to say wrong is not proper, afterall, deleoper always add/remove logs when debug, just print avail_bytes and free_bytes, developer have the sense to justify printed information.

@btian1

btian1 commented Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

@kv2019i , please review this PR

Comment thread src/audio/host-zephyr.c Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't understand how this can work... you are combining playback and capture direction avail and free bytes with MIN? so depending on direction isn't the other value like random? So it can be like always 0 or whatever the "balance" between free and avail happens to be... or I just don't understand how free_bytes and avail_bytes works.

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.

@juimonen, the real change is: change capture copy_bytes from:
copy_bytes = MIN(avail_bytes, free_bytes);
to:
copy_bytes = MIN(hd->period_bytes, MIN(avail_bytes, free_bytes));

Since both playback and capture have same limitation for copy_bytes, then I moved out for save code space.
Please check again.

@btian1
btian1 requested a review from juimonen February 28, 2023 05:30
Limit copy bytes to period bytes for both playback and capture
to avoid high load spike.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
@ranj063
ranj063 merged commit 5d210cc into thesofproject:main Mar 2, 2023
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