The host DMA has the different config method:
1. Get DMA channel based on stream tag.
2. Prepare DMA elem list based on local DMA trace buffer which make
sure that one trace record data can be transferred at least.
3. Need start DMA on firmware side before trigger start on kernel side.
4. Because no DMA callback in host DMA, add position update
calling at the end of trace_work().
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Get DMA channel based on stream tag when use host DMA.
Need also call different API in dma_copy_to_host_nowait().
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
At the end of the DMA, we need to set the channel status into
parapre, otherwise next dma start will fail.
This will fix APL pause resume issues.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
--
Test with:
Mininow max rt5651 and GP-MRB nocodec
SOF master: 728f1ff3e3
SOF-Tool master: 5b5bbe31e6https://github.com/plbossart/sound/tree/topic/sof-v4.14:
fe5e29155127a717ba5ae454b4bdde99afa67723
This patch fixes the bug with volume ramp down which causes volume
to underflow causing unspecified behaviour.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Clean up SSPSP bits to make SSP output follow ALSA ASoC definition
of all I2S/DSP_A/DSP_B/LEFT_J modes.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
The channel numbers of playback and capture are reversed on CNL.
The channel number of playback is 9.
The channel number of capture is 7.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Work queue cannot work rightly because it uses wrong timer setting.
Based on Keyon's comments, use SSP CLK intead of CPU CLK.
It is confirmed on my CNL platform.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
detected with sonarcloud: fix pointer test and avoid
redundant evaluation of lli as always true.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Detected with sonarcloud: test evaluates as always true.
Make sure both volume and switch are handled correctly
Fixes: 43e86cab60 ('volume: fix logic for volume mute/unmute')
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
missing assignment of 'ret' variable, fix
Detected with sonarcloud.
Fixes: 4252c49d53 ('pipeline: Add XRUN state and handler within pipeline')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The optimization assumes that sub-filters have length that is multiple
of four. The int24 Q1.23 format filter coefficients are replaced by
int32 Q1.31 format coefficients due to better match with Xtensa HiFi2
EP and and HiFi3 fractional types.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch moves generic common code to src.c/h from src_core.c/h and
places generic C optimized filter to src_generic.c. The HiFi EP
version is in src_hifi2ep.c and HiFi3 version is in src_hifi3.c. Use of
the Xtensa optimized versions require xt-xcc compiler.
The non-used SRC in/out rates query code is removed. The 24 bit
coefficients were replaced by 32 bit coefficients those are compatible
with Xtensa fractional integer types.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The src_width and dest_width are configured already in Bytes,
here fix it, otherwise 24/32 bit copying with hda-dma may have
problem.
Reported-by: Zhigang Wu <zhigang.wu@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
All other platforms use RZONE_SYS, not sure why CannonLake
should be any different.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The directions configured in sg_elem are actually dma transfer type,
not playback/capture direction, here correct them.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
rmalloc should also check the buffer heap if no capable memory can be
found in the runtime heap.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add memeory window for stream region. And position offset binding for
component. Replace IPC position update with memory window update.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Add stream region memory window into sof_ipc_window used for position
update.
For APL and CNL, we got a 1 page space for stream region.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Add sof_ipc_window for all platforms, and add IPC send after boot
compelted. Also remove the deprecated ready window.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Currently memory heap pools are statically defined in the allocator core
and don't define the capabilities of the memory in each pool.
This patch adds support for different memory capabilities so that users
can allocate memory that complies with any capability requirements for
requested memory.
The patch also moves the memory heap pool mappings to platform specific
code so that platforms can define their own mappings, support multiple
mappings and can move the mappings into different physical memory areas.
mappings
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a sanity check to make sure that data/rodata contains expected values
otherwise this can cause unpredictable behaviour that is difficult to
later diagnose.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Compiler cannot check the real type of "void*" pointer.
It is easy to cause pointer conversion error.
So use the pointer of element list of struct dma_sg_elem instead
of void* pointer.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Add total text size we used in memory mapping into module info to
help rimage build the right FW binary.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Liam's previous patch modify the structure variable from instance to
pointer. So it is unnecessary to use "&".
This parameter of parse_page_descriptors() is "void*", so complier
doesn't find this error.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Fix HSW handler so that it checks host_pending flag and aligns with
BYT IPC handler wrt trace messages.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Fill all available stack dump space with frames if available and update
any panic code to include passed value.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Initialise DMA trace prior to platform initialisation so that more users
may use trace as part of init.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
dma trace fix
Change the panic code is stack has been smashed. This allows platform
specific handlers to send new panic code to host if stack is smashed.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
On some platforms(e.g. APL, CNL), the external timer(wall clock)
uses the external interrupt bits, here change the common timer
logic to call interrupt APIs, which give a chance to handle for
different cases.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Improve the output from panic to include DSP registers and stack dump.
Export panic codes to UAPI for host driver logging.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This patch fixes the overlap between heap buffer and stack. The macro
for calculation missed the data size that caused heap to become too large.
Compilation of sof with xt-xcc triggers this issue in rimage and causes
image build fail.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Reduce the number of conditional build statements for gateway by moving
gateway code into fewer conditional build sections.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
We may have irq to modify buffer when are modifing the buffer.
Add the spin lock to make modify atomic.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
This patch fixes the volume mute/unmute logic in volume
to handle cases when volume is already muted/unmuted
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
For host with gateway, we need create extra dma_sg_elem *
period_count for hd->config.element_list, and free them
at host_reset() time, otherwise, the hd->local elements
may be broken if we use them for config.element_list.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
DW-DMA is more optimal using 32bit data size when transferring between
memories. Set configuration to always use 32 bit mode for non peripheral
copies from memory to memory.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
All GPDMA share the same irq on cannonlake, this is different with
appololake.The change is:probe GPDMA array when initilized, set the
array to the irq function; check the interrupt status of GPDMA array
in irq function, process the correct GPDMA that produces interrupt.
Signed-off-by: Rander Wang <rander.wang@intel.com>
Add a host and link DMA driver for Intel HDA DMA gateway.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Fix the dma not stop issue for using Hardware Link List mode.
Only enable it for APL/CNL at the moment.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Host GW DMA has no callback so host component has to manually notify
DMA driver when to copy each period.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Let clients know if they can expect a callback from DMA.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Allow clients to request a particular DMA channel if supported by the DMA
driver and it's available. If requested channel is not supported by DMAC
then return another channel. If requested channel is not free then we
return an error.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Some DMACs have an array of register elements to config and control
DMA channels. Provide a mapping here so that FW can easily calculate
the correct channel offset.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This API allows clients to manually inform the DMAC when they need more
data copied. The DMAC can then copy the desired amount of data.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
For dai component, it's frame_fmt may be different with host,
we usually configure it from topology, here fix it.
Contributor: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Due to misplaced parentheses the computation gives half of correct
result and omits rounding. Currently this macro is not used by code
in SOF git repository. Developers who may use format.h macros should
check their code.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
For hardware link list mode, we also need to configure address
and config registers for the first link list, here fix it.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
On Apollolake, the interrupt number for different channels of
the same controller are different, here add implementation of
it: register interrupt handler for each channel, and don't
need check channel in its specific handler anymore.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This patch provides library build support for host platform architecture.
It enables creating separate libraries for each SOF audio component.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add a support for a secondary boot loader than cant be used to bootstrap
multiple firmware modules.
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Apollolake has reset vector in ROM and some other changes that need
configured after reset.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Apollolake and Cannonlake have some register differences in DW-DMA HW.
Add macros to support those differences.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Allow interrupts to have a parent and child relationship in order to
support nested interrupts between different HW interrupt controllers.
This patch allows child handler to be registered for secondary interrupt
controllers and allow multiple child interrupt sources to share a single
interrupt pin.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Haswell and Broadwell have some differences with some DMA registers.
Add macros for these bits.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Coverity issue: 254842 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier
computations.
In parse_page_descriptors: Use of an uninitialized variable (CWE-457)
The elem.src variable is not initialized, but in
dma_trace_host_buffer() the code reads this initialized value.
Break
*e = *elem;
in
e->dest = elem->dest;
e->size = elem->size;
to only access relevant fields.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This patch updates the pointer cast in host/dai for library build
support for 64-bit arch
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Explicitly comment that the fall through in a switch case is not
a typo to make Coverity warnings go away.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
We don't need set host buffer size in each sg_elem, instead,
we can set it only one time, here set it in params().
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Make install/dist were missing some headers files and dirs. Add them and
make sure version generation works for building from the dist directory
where there is no git versioning information available.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Only compile dma-trace.c when BUILD_DMA_TRACE is true.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Acked-by: Yan Wang <yan.wang@linux.intel.com>
CONFIG_DMA_TRACE is selected by default. But we should
not do dma trace when CONFIG_DMA_TRACE is not selected
(--disable-dma-trace is added to configure command line),
here add this judgement to fix compiling issue for that
dma trace is not selected.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Acked-by: Yan Wang <yan.wang@linux.intel.com>
The DAI and host components states must be preserved during pause so that
when normal pipeline positions are used on resume. i.e. pause just looks
like a very long pipeline schedule.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The circular trace buffer can overflow if too much trace data is sent
before it can schedule a DMA copy to flush the data. This overflow
causes the avail bytes counter to be greater than the buffer size and
means the DMA copy is rescheduled until avail is 0 (repeating old data).
Fix this by resetting avail to 0 when we overflow.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The DAI and host components states must be preserved during pause so that
when normal pipeline positions are used on resume. i.e. pause just looks
like a very long pipeline schedule.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Fix so that dump stack does not overwrite any debug data and does not
read past the end of the stack.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Initialise the SA during platform init and then notify SA of idle in the
main audio loop.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a simple system monitoring agent that can detect when FW does not
execute correctly. The assumption is that FW will always idle from time
to time and this idling can be monitored by the SA. The FW wont idle if
it's thrashing, continually interrupted, continually running work or
continually rescheduling a task.
The SA will emit trace and panic if idle is not entered for a specific time
period.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Fix so that dump stack does not overwrite any debug data and does not
read past the end of the stack.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This patch changes the condition for limiting the smallest gain to
eliminate a never executed code part when VOL_MIN is defined as zero. The
variable v is unsigned integer so less than zero is not possible.
The functionality is not modified by this patch.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch changes the condition for limiting the smallest gain to
eliminate a never executed code part when VOL_MIN is defined as zero. The
variable v is unsigned integer so less than zero is not possible.
The functionality is not modified by this patch.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This variable is set by the return value of dma_copy_to_host_nowait().
Unsigned type will mislead error checking.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
This variable is set by the return value of dma_copy_to_host_nowait().
Unsigned type will mislead error checking.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Add a debug option that can detect deadlock and panic(). The deadlock
detection attempts to acquire a lock several times before giving up
and causing a panic() taht dumps the deadlock details.
Signed-off-by: Liam Girdwwod <liam.r.girdwood@linux.intel.com>
Add a debug option that can detect deadlock and panic(). The deadlock
detection attempts to acquire a lock several times before giving up
and causing a panic() taht dumps the deadlock details.
Signed-off-by: Liam Girdwwod <liam.r.girdwood@linux.intel.com>
Add message count and overflow detection to the trace position output
so that kernel and userspace can detect the trace buffer has overflowed.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Currently the trace initialisation must be performed after DMAC init
has completed. This means we miss the trace output from any platform
device initialisation.
Split the DMA trace initialisation into two parts so the trace buffer
is allocated early on and can accept messages meaning we dont miss any
device initialisation trace.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
For memory to memory copy(burst_elems initialized to be 0),
we set msize to default value 3, that is 2 ^ 3 = 8 items for
each burst transaction.
For DMA copying which related to peripheral device(source or
destination), we will use the configured burst_elems, which
usually means the number of data items, e.g. slot number for
SSP dai fifos.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
We should set burst_elems for dma peripheral dev copy, for
dai/ssp, it should be set to valid slot number, otherwise,
the dma may copy in wrong burst size and data will run with
wrong speed.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
We need configure different burst_elems for different dma copy, so
here introduce it to dma_sg_element struct.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
The timeout of work_reschedule_default() cannot be too short to finish
work queue rescheduling. Otherwise, the work will be rescheduled wrong
into the next timer loop.
Also change macro name of DMA trace time interval for reading easily.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
The volume component can change the sink data format depending on sink
component/pipeline topology configuration. This change is set locally,
but not to the host params that are passed downstream.
Fix this so that downstream components can check params match their
topology configuration.
Tested with test-passthrough-48k-vol-ssp2 and reef-byt-rt5651
topology files. Note that there are quite a few underflows likely added by
recent changes, more work needed to identify what goes on.
(first fix for prepare() from Liam, additional update for the params()
case by Pierre)
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Replace the r_ptr == w_ptr check as it was racy on the completion of the
host DMA preload. Better to check using the source component type.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Upstream pipeline topology is unknown to the DAI so we must check that the
DMA r_ptr != source pipeline w_ptr for all DAI sources.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Capture pipelines must wait for the DAI to fill one period of data
before they can be scheduled. This avoids underruning the pipeline.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The DMA linked list descriptors must be written back from cache so that
the DMA engine can read them.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
pipeline_copy down stream will return 0 instead of the component copy()
return value when an endpoint is reached. Make sure we return the
component value.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Host message queue is long sometimes. So when one new IPC message like
DMA trace host offset is pushed into, the previous same type IPC message may
haven't been sent.
For every type of IPC message, there are different comparison conditions.
So need a group of sub-finding functions to do and user also can extend them
easily based on new requirements in the future.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
We only need handle host page tables on platforms that we
program DMA host buffer(addr/size) inside firmware, for
other platforms, host driver will program these settings
and won't pass in page tables.
So here add frag CONFIG_HOST_PTABLE to configure this for
different platforms, on Baytrail, Cherrytrail, we need
CONFIG_HOST_PTABLE to be selected.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
For debug reason, e.g. DMA trace doesn't work or not implemented
yet, we can use --disable-dma-trace in configure command line,
which will unset CONFIG_DMA_TRACE flag, and it will fallback
to use traditional mailbox trace instead.
The flag is set by default, if we don't add '--disable-dma-trace'
to configure command.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
This patch prevents SRC to stall due to too demanding criteria of
function comp_buffer_can_copy_bytes. Since the input and output rate and
period length of SRC are different for source and sink both buffers do
not need to meet both criteria.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
When trace_error() is used to save error information into trace buffer,
the firmware may not in normal state and some spin lock be still locked.
So it may cause dead lock if trace_error() still uses non-atomic API
with spin lock.
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Cherrytrail SSP settings were the same as Baytrail but the SSP root
clock is different. To use 19.2MHz the Xtal source needs to be selected
Also add definition for SSP @ 25 MHz - even if it's unlikely to ever
be used
Tested on Up board and Cyan Chromebook.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
The purpose of checking half fullness is sending trace data as soon as
possible. It will avoid local DMA trace buffer full and unsent trace data
overwritten.
If DMA trace copying is running currently, it is unnecessary to checking
half fullness local DMA trace buffer.
The following is implementation details:
1. Add one flag in DMA trace data strcuture.
2. Set/unset this flag in trace_work() callback.
3. Add checking for this flag in dtrace_event().
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
This patch fixes a regression that caused SRC to try to initialize
for a mode that has been disabled from in/out rates matrix. The feature
exist to save tables RAM with modes those are not required. The bug
caused a divide by zero to happen in src_buffer_lengths() function.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Use comp_sample_bytes() to set DMA transfer size in DAI component and
comment why host always copies using word size transfers.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>