The dma_suspend() implementation detected end-of-transfer based on
a software flag (stream->busy) rather than hardware status flags. This
is an issue because dma_suspend() is isr-ok and may thus be called while
IRQs are suspended; this prevents the DMA ISR from running and updating
software flags to reflect the actual hardware state.
This causes a deadlock if, while IRQs are suspended, a transfer on a
channel N completes then dma_suspend() is called to suspend channel N
while IRQs are still suspended. In this situation, the channel is idle
but stream->busy is still true because the DMA ISR could not execute.
Since suspending an idle channel has no effect, the SUSPF flag will
never become set and a deadlock occurs because both of the conditions
for exiting the loop in dma_suspend() will never be met.
Modify the function to rely exclusively on hardware flags to detect the
channel's current state, such that the loop will not deadlock even if
the DMA ISR cannot run because IRQs are suspended.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Factor the m2m software-trigger check into a helper using
FSL_FEATURE_EDMA_INSTANCE_HAS_CHANNEL_MUXn(base) for per-instance
detection, and gate all four m2m-software-only branches (SG -ENOTSUP,
burst-length override, manual start trigger, suspend -ENOSYS) on the
new dma_mcux_edma_m2m_software_only().
Fixes parallel display output on MCXN947 (FlexIO-triggered m2m
channels were treated as software-only and lost their per-minor-loop
pacing).
Fixes: efe48ea674Fixes: #108367
Signed-off-by: Qiang Zhang <qiang.zhang_6@nxp.com>
Add a bit of history about the driver (the information I would like to
forward to my future me). Try to explain why this driver has this design.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
By replacing "udma_table = cfg->chan_desc" by "chan_desc =
&cfg->chan_desc[channel]", we can simply many statements. So, all the
statements now fits on one line.
desc_src_addr and desc_dst_addr are in fact useless.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Scatter Gather transfers are not supported by siwx91x_udma_reload(). Detect
and reject them.
Also check the size of valid regarding the operation width.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Some fields names contained irrelevant information (eg. "addr" in
"sg_desc_addr_info" and in "sram_desc_addr", "dma" in "dma_desc_pool").
In other case, it lacked of consistency, (eg. "chan" vs "channel",
"config_zephyr" vs "dma_config" vs "config").
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
We try to prefix all the symbols in a file with the same prefix (so the
developer easily understand if a symbols is provided by Zephyr, the HAL or
is internal to the driver).
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Sanity checks were duplicated in siwx91x_udma_config_sg() and
siwx91x_udma_config_single(). Move them in the caller function.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
The UDMA drivers includes some functions to translate Zephyr values in
hardware values. However, these conversion are either trivial or not very
consistent. It is more readable to directly work with the native (Zephyr)
values. We just have to check the values requested by the caller are valid
before the processing.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Rather than using internal enum type to store the direction, store the
native (Zephyr) value. It will help to simplify the code in the next
changes.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
We try to prefix all the symbols in a file with the same prefix (so the
developer easily understand if a symbols is provided by Zephyr, the HAL or
is internal to the driver).
A few symbols in dma_silabs_siwx91x_gpdma.c did not follow this rule.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
The UDMA scatter-gather mode rejected any block whose size exceeded
DMA_MAX_TRANSFER_COUNT * burst_length bytes (1024 transfers). The was
caller responsible for splitting.
Apply the same fix as the GPDMA driver: when a dma_block_config block is
too large for a single scatter-gather descriptor, automatically split it
into as many chained descriptors as needed, advancing src/dst addresses
for each chunk (honoring DMA_ADDR_ADJ_INCREMENT / DMA_ADDR_ADJ_NO_CHANGE).
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
The GPDMA rejected any block whose size exceeded
GPDMA_DESC_MAX_TRANSFER_SIZE (4096 transfers). The was caller responsible
for splitting. There is no way for the caller to be aware of this
restriction.
This patch allow the GPDMA driver to automatically split the oversized
block and run the DMA with a linked descriptors.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
SiWx91x provide two DMA hardware block: GPDMA and UDMA, The GPDMA is
properly named: silabs,gpdma. However, the UDMA is named
"silabs,siwx91x-dma" without any reference to the hardware block it is
supposed to run.
Rename the UDMA driver to fix this inconsistency.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Update all drivers to use "flags" instead of "sense" when accessing
interrupt properties from device tree. This aligns with the updated
interrupt controller bindings that now consistently use "flags" as
the cell name for the IRQ type field.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
Add TDM DMA driver for AMD Audio Co-Processor 7.0. This includes:
- DMA driver (dma_acp_tdm.c) with support for memory-to-device and
device-to-memory transfers using ACP DMA engine
- Device tree bindings and node for ACP TDM DMA controller
- Kconfig and CMake build integration
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Co-authored-by: DineshKumar Kalva <DineshKumar.Kalva@amd.com>
Add sleep retention support for GDMA driver. When peripheral
power down is enabled for light sleep, register data is lost,
so REGDMA backup is needed to mantein peripheral operational.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
The LLI descriptor cache flush was unconditionally performed even
when a Cache Coherence Unit (CCU) is present. When CCU is enabled,
hardware guarantees a consistent data view between the DMA and
processor, making software cache maintenance redundant.
Signed-off-by: Hareem Sadiq <hareemx.sadiq@altera.com>
The max_channel is a compile time constant derived from device tree
and never modified at runtime.
Adding it to read only dev_cfg structure and using this variable from
dev_cfg structure
Signed-off-by: Hareem Sadiq <hareemx.sadiq@altera.com>
Abstract DT reset property check into a reset_supported macro,
update variable type to uint32_t, and remove channel < 0
check which is always false because of the uint32_t type
variable
Signed-off-by: Hareem Sadiq <hareemx.sadiq@altera.com>
The driver used a plain enum for channel state tracking which is
not safe on multi-core systems. A plain enum read-modify-write is
not guaranteed atomic on SMP a concurrent read on another core
could observe a torn or intermediate state value.
Replace ch_state with atomic_t and use atomic_set()/atomic_get()
for all channel state transitions. This ensures state visibility
across all cores without blocking, and preserves ISR callability
as required by the Zephyr DMA API
Signed-off-by: Hareem Sadiq <hareemx.sadiq@altera.com>
Previously, upstream left the AXI CTL fields at 0. Now adding the
AxCache and AxProt attributes macro and setting to the values
required for cache-coherent interconnect in Agilex5.
Signed-off-by: Hareem Sadiq <hareemx.sadiq@altera.com>
dma_init() performs a soft-reset to put the DMA into a known state, but
this reset is not repeated on subsequent stop/start cycles. If the DMA
stopped with error bits set, the next configure picks up the dirty state.
Add a needs_dma_soft_reset flag that is set by dma_stop() and checked at
the top of dma_configure(). When set, dma_configure() issues a soft-reset
via the RX channel DMACR (which resets both TX and RX), polls until the
reset bit clears, then continues with normal configuration.
Fixes DMA re-use after network interface down/up cycles.
Signed-off-by: Venkatesh Odela <venkatesh.odela@amd.com>
When a DMA channel is routed through the channel mux (dma_slot != 0), each
minor loop is paced by the peripheral request signal. In this case, the
caller-chosen burst length must be preserved to ensure correct operation.
Previously, the driver would collapse the minor loop into the whole block
for all memory-to-memory transfers without source chaining, but this logic
should only apply to genuine software-triggered transfers. Peripheral-
triggered transfers (e.g., FlexIO LCDIF) expect one minor loop per shifter
round, and collapsing the loop breaks this requirement.
Add a check for dma_slot == 0 to ensure burst length collapsing only occurs
for software-triggered transfers, not peripheral-triggered ones.
Signed-off-by: Kate Wang <yumeng.wang@nxp.com>
Replace direct esp_cache_msync() calls in the ESP32 GDMA and
SPI master drivers with the portable sys_cache_data_*() API.
Zephyr's API is a compile-time no-op when CACHE_MANAGEMENT is
disabled, so the same source compiles cleanly on every ESP32
SoC and stays cost-free where there is no writeback cache.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Adds support for no increment needed to support the LPSPI and other
peripherals with a FIFO buffer.
Furthermore we disable interrupts on each major loop on SG, instead
only do an interrupt on the final TCD.
Also a small optimization in dma_mcux_edma_reset_channel, where TCD
got zeroed twice.
Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
The GDMA_LL_AHB_TX_RX_SHARE_INTERRUPT macro used to gate the
shared rx/tx interrupt handler is no longer defined in the HAL,
so the guard always evaluates false and breaks the IRQ wiring
on ESP32-C2 and ESP32-C3.
Replace it with a check derived from devicetree that compares
the declared interrupt count against the channel pair count.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Add realtek ameba dma driver.
Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
drivers: dma: ameba: use IF_ENABLED instead of COND_CODE_1 with empty else
Replace COND_CODE_1(CONFIG_DMA_AMEBA_LLI, (...), ()) with the cleaner
IF_ENABLED(CONFIG_DMA_AMEBA_LLI, (...)) idiom in the DMA_AMEBA_INIT
macro. The two forms are semantically identical; IF_ENABLED avoids the
superfluous empty else argument.
Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
DMA_XILINX_AXI_DMA_DISABLE_CACHE_WHEN_ACCESSING_SG_DESCRIPTORS describes
a specific implementation strategy rather than the underlying intent:
manage cache coherency manually because the platform doesn't provide
hardware coherency for DMA accesses. Tying the symbol name to the
mechanism makes it harder to evolve the driver to a different coherency
strategy without breaking existing user configurations.
Introduce DMA_XILINX_AXI_DMA_MANUAL_CACHE_COHERENCY with the same
semantics and update the driver's #ifdef sites to use it. Keep the
original symbol around as an invisible alias that selects DEPRECATED
and the new symbol so existing out-of-tree configs continue to work
and produce a deprecation warning at build time instead of silently
losing the behaviour.
Signed-off-by: Abin Joseph <abin.joseph@amd.com>
The Xilinx PG021 spec requires the DMA to clear DMACR.RESET before any
further DMACR writes are honored. Use Zephyr's WAIT_FOR() helper from
<zephyr/sys/util.h> to spin on DMACR.RESET clearing after the soft-reset
write, with an XILINX_AXI_DMA_RESET_TIMEOUT_MS ceiling. On timeout, log
an error and return -EIO so the failure surfaces immediately instead of
being absorbed by silently dropped subsequent register writes.
Signed-off-by: Abin Joseph <abin.joseph@amd.com>
The IRQ lock/unlock helpers used bare 0x1 / 0x2 bit literals in the lock
key returned to the caller, and indexed the per-channel array with bare
0 and 1. Both required a "TX is 0, RX is 1" comment to read.
Replace the bit literals with named constants
XILINX_AXI_DMA_LOCK_KEY_TX_ENABLED / _RX_ENABLED, derived from the
existing channel index defines via BIT(), and replace the bare channel
indices with XILINX_AXI_DMA_TX_CHANNEL_NUM / _RX_CHANNEL_NUM. The
"TX/RX is N" / "TX/RX was enabled" comments become redundant and are
removed.
Signed-off-by: Abin Joseph <abin.joseph@amd.com>
Add DMA driver support for Realtek Bee series SoCs,
including RTL87x2G and RTL8752H.
This driver supports:
- Memory to Memory transfer
- Peripheral to Memory transfer
- Memory to Peripheral transfer
Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
Fix two issues in DMA driver:
1. ISR was invoking callback for all interrupts including suspend.
Add check to invoke callback only for transfer complete (TCMPL)
or transfer error (TERR) interrupts.
2. dma_get_status returned stale pending_length after config/reload
because write-back descriptor was not synced with base descriptor.
Sync write-back in dma_mchp_config and dmac_desc_reload_block.
Also improve type safety by changing void* to dmac_descriptor_registers_t*
in descriptor setup functions.
Signed-off-by: Arunprasath P <arunprasath.p@microchip.com>
Enable the optional clock described in devicetree during eDMA
driver initialization.
Keep RT7xx request-enable programming in board init so this
branch only moves the clock-control portion into the driver.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Add optional devicetree reset support to the MCUX eDMA
driver and deassert the reset line during initialization
when a reset specifier is provided.
Boards which do not describe a reset remain unchanged.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Introduces SYS_MEM_BLOCKS_DEFINE_TYPE() and
SYS_MEM_BLOCKS_DEFINE_STATIC_TYPE() helpers to allow the user to declare
mem blocks without having to manually ensure the alignment is correct,
which was very error-prone.
Matches the new K_MEM_SLAB_DEFINE_TYPE.
Signed-off-by: Egill Sigurdur <egill@egill.xyz>
Introduces K_MEM_SLAB_DEFINE_TYPE() and K_MEM_SLAB_DEFINE_STATIC_TYPE()
helpers to allow the user to declare slabs for types without having to
manually ensure the alignment is correct.
Manual slab alignment was very error-prone and this change fixes several
instances of misalignment that would be trapped by the undefined
behavior sanitizer when running on 64-bit targets.
Signed-off-by: Egill Sigurdur <egill@egill.xyz>
Don't clear DMA status flags when DMA controller is managed by the HAL.
The same logic was introduced in the dmav1/dmav2 driver by commit
110c61bfea.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
There is a typo in the DT_INST_IRQ_ macro. SDMA was used
until now only with HIFI4 DSP (xtensa) and for this arch
priority parameter is ignored.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Add DMA drivers for AMD ACP 7.0 audio DSP:
- Host DMA driver for memory transfers between system memory
and ACP audio processing units
- SoundWire DMA driver for audio streaming over SoundWire bus
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Rename BL61x GPIO and pinctrl drivers to bl61x_808 variants since
BL808 shares identical register layouts. Update compatible strings,
Kconfig, CMakeLists, and BL61x device tree accordingly. Extend the
DMA and IR receiver drivers' BL61x guards to also cover BL808.
Signed-off-by: William Markezana <william.markezana@gmail.com>
SF32LB DMA cleared its software busy bit on half-complete.
The QSPI NOR write path polled that bit while holding the flash lock.
Clear the DMA status bit only on completion or error.
Derive busy from the active state plus pending_length.
Poll pending_length until the flash DMA transfer reaches zero.
Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>