Skip to content

Backport 1bfb1978d ('dma: alloc separate buffers for DMAs') - #3712

Merged
brentlu merged 32 commits into
thesofproject:cml-008-patch-backport2from
brentlu:fix-3619
Oct 22, 2021
Merged

brentlu merged 32 commits into
thesofproject:cml-008-patch-backport2from
brentlu:fix-3619

Conversation

@brentlu

@brentlu brentlu commented Dec 23, 2020

Copy link
Copy Markdown
Contributor

Backport the commit 1bfb197 ('dma: alloc separate buffers for DMAs') and other related commits to fix the audio stop issue of CML Chromebooks.

commit 1bfb197
Author: Tomasz Lauda tomasz.lauda@linux.intel.com
Date: Fri Oct 18 13:08:44 2019 +0200

dma: alloc separate buffers for DMAs

Currently DMAs are using buffers on pipelines connected to either
host or dai components. This causes many problems in firmware logic
e.g. we need to preload playback pipelines with data or we need
to manually override buffer sizes, if the buffer isn't complaint
with specific DMA requirements. Also it requires from topology
creators to know some hardware specific things on each platform
like that for timer based scheduling on cAVS platforms we need
to have 3 periods in buffers connected to dai components.
This patch allocates separate buffers for DMAs, which are made
complaint by using different DMA attributes first. We no longer
need to preload playback streams, because we can start DMA
right away and just let it transfer zeroes before any valid
data will come.

Signed-off-by: Tomasz Lauda tomasz.lauda@linux.intel.com

@lgirdwood

Copy link
Copy Markdown
Member

@mwasko fyi - can you assign to cml production branch owner for review

tlauda and others added 17 commits January 19, 2021 08:41
Adds new NOTIFIER_ID_DMA_DOMAIN_CHANGE. This id will be used
by DMA single channel scheduling domain.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds DMA channel period value to dma_chan_data.
We can now easily retrieve the period value of
DMA channel transfers.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Some ll scheduling domains require to have interrupt cleared
right at the beginning of handler. Clear domain earlier to
fulfill that requirement.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds implementation of DMA single channel scheduling domain.
This domain allows to schedule all the tasks on all the cores
on single DMA channel interrupt. This way we have only one
interrupt source and we don't need to worry about handling
many interrupts. We always select the channel with the lowest
period. This domain cannot be used with the DMAs, which require
to manually reload the next data to be transferred e.g. DW-DMA
on BYT or HSW.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Switches from DMA multi channel domain to single channel
as the scheduling source for one of the low latency schedulers
for cAVS platforms.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Doesn't copy sink component, if it's not active.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
With new schedulers implementations we don't need to trigger
pipeline in atomic context anymore.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adjust memory sizes for heaps to provide
enough memory for alignment in buffer heap.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Fix alloc definitions for host build.
Function definitions were using defines in their body
which blocked usage of const values in said defines.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Add alignment option for memory requests.
Fix alloc definitions for UT.
Function definitions were using defines in their body
which blocked usage of const values in said defines.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Fixes tasks initialization for connected pipelines.
If we play on pipeline, which is not the owner of
the scheduling component, then the pipeline_prepare()
is not called on pipe owning that component and tasks
stay unitialized.

Fixes: de7d4c9 ("pipeline: allocate pipe_task only if needed")

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds new start_position field based on which we assess whether
we should throw an xrun. It fixes rare cases of xruns on release
with timer scheduled pipelines.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Returns an error, when there is no DAI component
connected to the DAI index specified by DAI config
IPC.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
In case of unsuccessful scheduler task init, the pipeline
task init should also fail.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Renames ipc_get_comp function to ipc_get_comp_by_id.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
When new pipeline is created we need to also verify whether
given pipeline id is already taken.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Merged hp buffer heap with normal buffer heap.
Since current buffer heap was actually using hp memory and it served
no purpose to have two heaps.
Removed extern capabilities and merged other capabiliteis to
buffer heap. Currently none of those buffer heaps supports extern.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
dabekjakub and others added 15 commits January 20, 2021 11:11
Add seeting of alignment for DMA buffer that is required by
Hardware configuration.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Unify function naming to fix DEBUG_HEAP build

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Adds and initializes id, pipeline_id and caps fields in buffer struct.
This is the only data needed after buffer creation. It allows us to
remove the whole sof_ipc_buffer struct from the buffers.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Extracts allocation part of buffer_new to separate function.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Adds new DMA attribute DMA_ATTR_BUFFER_PERIOD_COUNT and implements
it for every DMA. This attribute says how many periods should DMA
buffer consist of.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Implements simple buffer copy functions for 16 and 32 bit data.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Implements copy functions from/to DMA buffer. They take care
of cache operations and also can perform custom processing
during copy. By default it will be usual buffer copy, but in the future
it can be replaced with pcm conversions, so we don't need volume
into the pipelines just for that operation.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
DW-DMA has no specific alignments regarding buffer and copy sizes.
However setting it to 32 bytes breaks stream formats with period
sizes lower than 32 bytes, as linked list is being configured
incorrectly.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Currently DMAs are using buffers on pipelines connected to either
host or dai components. This causes many problems in firmware logic
e.g. we need to preload playback pipelines with data or we need
to manually override buffer sizes, if the buffer isn't complaint
with specific DMA requirements. Also it requires from topology
creators to know some hardware specific things on each platform
like that for timer based scheduling on cAVS platforms we need
to have 3 periods in buffers connected to dai components.
This patch allocates separate buffers for DMAs, which are made
complaint by using different DMA attributes first. We no longer
need to preload playback streams, because we can start DMA
right away and just let it transfer zeroes before any valid
data will come.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Removes buffer cache operations done based on the fact,
whether buffer is used by DMA or not. From now on DMAs have
their own dedicated buffers with dedicated copy functions,
so this code is no longer needed.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Change flow of components to not resize sink buffers.
We should just check the size of the allocated buffers
and let the topology define the maximum sizes.
Components can easily work with non aligned buffer sizes.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Removes code related to preload as with separate DMA
buffers we no longer need it.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
Changes flow of dai_copy to call dma_copy even if there is no data
available. This way we make sure that all DMA needed procedures are
executed, since buffers pointers won't be changed anyway.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
@brentlu

brentlu commented Jan 22, 2021

Copy link
Copy Markdown
Contributor Author

Following pull requests have been selected:

dma: alloc separate buffers for DMAs #1984
memory: Fix DEBUG_HEAP build. #1978
memory: removed hp buffer heap #1567
ipc: check whether pipeline id is already taken #1960
pipeline: check task init result #1956
ipc: return an error on dai not found #1951
dai: fix rare case of xrun on release #1945
pipeline: fix tasks initialization #1921
memory: added requesting alignment for buffer heap #1698
schedule: implement dma_single_chan_domain #1893

@lgirdwood

Copy link
Copy Markdown
Member

@mwasko @abonislawski @slawblauciak fyi - who owns the CML production branch ?

@mwasko

mwasko commented Jan 26, 2021 •

Copy link
Copy Markdown
Contributor

@bkokoszx can help with creating new CML release if necessary, but the backporting itself of PRs to older CML releases is not supported on our end.

@mwasko mwasko assigned mwasko and bkokoszx and unassigned mwasko Jan 26, 2021
@brentlu

brentlu commented Jan 27, 2021

Copy link
Copy Markdown
Contributor Author

The target branch, cml-008-patch-backport2, is a fresh one on HEAD of cml-008-patch-backport. Adrian helped us to create this branch. Does it work for you?

@mwasko

mwasko commented Jan 27, 2021

Copy link
Copy Markdown
Contributor

The target branch, cml-008-patch-backport2, is a fresh one on HEAD of cml-008-patch-backport. Adrian helped us to create this branch. Does it work for you?

Sorry @brentlu, currently we are on cml-011 so our recommendation is to switch to latest CML release branch.

@brentlu

brentlu commented Oct 22, 2021

Copy link
Copy Markdown
Contributor Author

FW has been deployed to CML Chromebooks since March without issue reported. Merge the code to the unused branch.

@brentlu
brentlu merged commit 99b7696 into thesofproject:cml-008-patch-backport2 Oct 22, 2021
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.

[BUG][CML] audio stops during aplay playback

7 participants