Skip to content

remoteproc: adi: replace MDMA memcpy with memcpy_toio for LDR load#3268

Open
vasbimpikasadi wants to merge 112 commits into
analogdevicesinc:adsp-6.18.31-yfrom
vasbimpikasadi:LNXDSP-1348/remoteproc-replace-mdma-with-memcpy
Open

remoteproc: adi: replace MDMA memcpy with memcpy_toio for LDR load#3268
vasbimpikasadi wants to merge 112 commits into
analogdevicesinc:adsp-6.18.31-yfrom
vasbimpikasadi:LNXDSP-1348/remoteproc-replace-mdma-with-memcpy

Conversation

@vasbimpikasadi
Copy link
Copy Markdown

MDMA writes to SHARC L2 memory (0x200xxxxx) are silently rejected at the bus fabric level on ADSP-SC573 and ADSP-SC589. The MDMA engine stalls waiting for a write ACK that never comes (DMA_STAT.RUN=4, IRQERR=0), and the remoteproc driver times out.

Use memcpy_toio/memset_io with the L1 and L2 virtual mappings already established in probe (L1_shared_base, L2_shared_base) instead of the MDMA engine. This follows the same pattern as rproc_elf_load_segments() in remoteproc_elf_loader.c which uses memcpy_toio when the target region is IOMEM.

Remove the now-unused MDMA infrastructure: dmaengine_get/put, dma_alloc_coherent bounce buffer, SPU permission setup for MDMA channels, and the completion callback.

Tested on ADSP-SC589-MINI with a synthetic 128 KB L2 stress LDR image.

PR Description

  • Please replace this comment with a summary of your changes, and add any context
    necessary to understand them. List any dependencies required for this change.
  • To check the checkboxes below, insert a 'x' between square brackets (without
    any space), or simply check them after publishing the PR.
  • If you changes include a breaking change, please specify dependent PRs in the
    description and try to push all related PRs simultaneously.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

pamolloy and others added 30 commits November 4, 2025 13:53
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Only supports the ADZS-SC589-MINI

Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Signed-off-by: UtsavAgarwalADI <utsav.agarwal@analog.com>
Signed-off-by: Philip Molloy <philip.molloy@analog.com>
Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com>
Co-developed-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Co-developed-by: Greg Malysa <greg.malysa@timesys.com>
Signed-off-by: Greg Malysa <greg.malysa@timesys.com>
Signed-off-by: Utsav Agarwal <Utsav.Agarwal@analog.com>
Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com>
Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com>
Adding SoC audio support for the following modes:

- ASoC (linux only audio)
- SHARC ALSA (Hybrid Audio)
- SHARC

Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
CalebEthridgeADI and others added 22 commits February 12, 2026 08:36
The output for the gige-reset line was not changed
when the polarity of the gpio was changed, resulting in the
gige-reset line being active all the time and preventing
the probe of the ethernet.

Fixes: 7eaf7e4 (ARM: dts: adi: fix polarity of GPIO signals)
Signed-off-by: Caleb Ethridge <caleb.ethridge@analog.com>
Reconfiguring the partitions in the SPI and OSPI to remove
the DTB partition and give the extra space to the rootfs
partition.

Signed-off-by: Caleb Ethridge <caleb.ethridge@analog.com>
GCC 15 changed the default C standard version to C23, which should not
have impacted the kernel because it requests the gnu11 standard via
'-std=' in the main Makefile. However, the x86 compressed boot Makefile
uses its own set of KBUILD_CFLAGS without a '-std=' value (i.e., using
the default), resulting in errors from the kernel's definitions of bool,
true, and false in stddef.h, which are reserved keywords under C23.

  ./include/linux/stddef.h:11:9: error: expected identifier before ‘false’
     11 |         false   = 0,
  ./include/linux/types.h:35:33: error: two or more data types in declaration specifiers
     35 | typedef _Bool                   bool;

Set '-std=gnu11' in the x86 compressed boot Makefile to resolve the
error and consistently use the same C standard version for the entire
kernel.

Closes: https://lore.kernel.org/4OAhbllK7x4QJGpZjkYjtBYNLd_2whHx9oFiuZcGwtVR4hIzvduultkgfAIRZI3vQpZylu7Gl929HaYFRGeMEalWCpeMzCIIhLxxRhq4U-Y=@protonmail.com/
Closes: https://lore.kernel.org/Z4467umXR2PZ0M1H@tucnak/
Reported-by: Kostadin Shishmanov <kostadinshishmanov@protonmail.com>
Reported-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/20250121-x86-use-std-consistently-gcc-15-v1-1-8ab0acf645cb%40kernel.org
(cherry picked from commit ee2ab46)
Signed-off-by: Caleb Ethridge <caleb.ethridge@analog.com>
Remove unused button-led device tree nodes from sc573-ezlite,
and sc594-som boards.

Signed-off-by: Ozan Durgut <ozndrgt@gmail.com>
Removing these hardcoded bootargs since they are
not needed, bootargs are passed from U-boot for
ADSP platforms.

Signed-off-by: Caleb Ethridge <caleb.ethridge@analog.com>
Update the labels of SPI/OSPI partitions to
maintain consistency across repos.

Fixes: c400f44 (ARM: dts: adi: Update SPI and OSPI partitions in device tree)
Signed-off-by: Caleb Ethridge <caleb.ethridge@analog.com>
Always fetch from the official public ADI org, even when forked

Signed-off-by: Philip Molloy <philip.molloy@analog.com>
In adi_uart4_serial_dma_tx(), the driver updates uart->port.icount.tx
manually and then calls uart_xmit_advance(&uart->port, uart->tx_count).

However, uart_xmit_advance() already advances the xmit_fifo TX queue and
accounts transmitted bytes into icount.tx, so the function counts each
completed DMA transfer twice.

This does not affect data transmission, but it makes TX accounting
incorrect. Kernel serial diagnostics that report icount.tx will
show inflated TX byte counts, which could make it harder to
debug UART related bugs/issues in the future.

An example of this is /proc/tty/driver/adi-uart4 which directly shows
you various pieces of information such as the TX and RX counts associated
with the driver:

	root@adsp-sc598-som-ezkit:~# cat /proc/tty/driver/adi-uart4
	serinfo:1.0 driver revision:
	0: uart:ADI-UART4 irq:0 tx:19594 rx:25

To reproduce and view changes to the TX and RX counts you can boot
up Linux on an ADSP-SC589 or ADSP-SC594. Then in a separate
terminal SSH into the board. Then in the SSH session view the
above. Then in the serial console type a single character, move
back to the SSH session and view the data again, it should
have increased now.

I did this exact experiment, so this is the count beforehand:

	root@adsp-sc598-som-ezkit:~# cat /proc/tty/driver/adi-uart4
	serinfo:1.0 driver revision:
	0: uart:ADI-UART4 irq:0 tx:19594 rx:25

Then type a character in the serial console (i pressed 'a' once)
and view the counters again in the SSH session:

	root@adsp-sc598-som-ezkit:~# cat /proc/tty/driver/adi-uart4
	serinfo:1.0 driver revision:
	0: uart:ADI-UART4 irq:0 tx:19596 rx:26

As you can see the TX counter has gone to 19596 (should be 19595)
which illustrates the double increment once from
"uart->port.icount.tx += uart->tx_count;" and another time from
the uart_xmit_advance() call.

Fix this by dropping the explicit icount.tx update and relying on
uart_xmit_advance() for TX accounting.

Fixes: eab94da ("serial: Add UART driver for SC5xx SoCs")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
adi_uart4_serial_remove() frees "uart" before checking and releasing
the DMA channels stored in the same structure.

Move the DMA channel release before "kfree(uart)" so the remove path
does not dereference freed memory.

Fixes: eab94da ("serial: Add UART driver for SC5xx SoCs")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
Add COMPILE_TEST to SERIAL_ADI_UART4 so CI build jobs can build the driver.

Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
Add the missing MODULE_LICENSE() declaration so CI jobs can build the driver.

Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
Remove the explicit .owner assignment from adi_uart4_serial_driver
to address the coccicheck warning:
"No need to set .owner here. The core will do it."

Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
…llback

During the DMA TX completion callback adi_uart4_serial_dma_tx(), the
driver checks whether to call uart_write_wakeup() before advancing the
xmit_fifo TX queue with uart_xmit_advance().

uart_write_wakeup() notifies the tty layer that the driver can accept
more output and wakes tasks blocked in the tty write path. For ttySC0,
that allows a blocked writer to resume and eventually queue more bytes
into the TX buffer (xmit_fifo).

Because this check is done before xmit_fifo is advanced, the wakeup
decision uses stale xmit_fifo state. This becomes problematic when a
completed DMA transfer reduces the pending TX queue below
WAKEUP_CHARS, because blocked writers can miss their wakeup and remain
stalled. This includes the case where the DMA completion drains the
queue completely.

Missing this wakeup can stop further output from being queued and make
the serial console appear to hang or freeze.

I was able to reproduce the issue on both the ADSP-SC594 and ADSP-SC598
by running 'top' on the serial console and repeatedly refreshing the
display. When the issue triggers, the userspace writer ('top') ends up
blocked in the tty write path, for example:

    wait_woken
    n_tty_write
    file_tty_write
    tty_write
    vfs_write
    ksys_write

To fix this issue, the driver should first advance xmit_fifo via
uart_xmit_advance() and only then evaluate whether uart_write_wakeup()
is needed based on the post completion FIFO state. Furthermore
drop the "if (!kfifo_is_empty(&tport->xmit_fifo)" check, since an empty
xmit_fifo after uart_xmit_advance() means the pending TX queue
has dropped to 0, which is still below WAKEUP_CHARS and is a
valid case for uart_write_wakeup().

Tested-by: Arturs Artamonovs <arturs.artamonovs@analog.com>
Fixes: eab94da ("serial: Add UART driver for SC5xx SoCs")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
The SC598-SOM-EZLITE device tree source and defconfig exist in
the tree, but the device tree blob was never built because it
was missing from the Makefile. This resulted in the EZLITE board
being unusable despite having support in place.

Add the sc598-som-ezlite.dtb build target to fix the missing
compilation step and enable proper EZLITE board support.

Fixes: a5d4be9 ("arm64: dts: adi: sc598: add device tree")
Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
of_iomap() returns NULL on failure, not an error pointer. Replace the
IS_ERR() checks with NULL checks in sc57x_clock_probe().

Fixes: df2ba6d ("clk: adi: Add clock driver for ADSP-SC573")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
of_iomap() returns NULL on failure, not an error pointer. Replace the
IS_ERR() checks with NULL checks in sc58x_clock_probe().

Fixes: b288b42 ("clk: adi: Add clock driver for ADSP-SC589")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
of_iomap() returns NULL on failure, not an error pointer. Replace the
IS_ERR() checks with NULL checks in sc594_clock_probe().

Fixes: 9cf6b0c ("clk: adi: Add clock driver for ADSP-SC594")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
of_iomap() returns NULL on failure, not an error pointer. Replace the
IS_ERR() checks with NULL checks in sc598_clock_probe().

Fixes: 71b82fe ("clock: Add driver for ADSP-SC5xx")
Signed-off-by: Qasim Ijaz <qasim.ijaz@analog.com>
Enable early console support for ADI UART4. Currently it
is included in the kernel command line arguments for
ADSP Linux but not enabled via Kconfig.

This makes it so the ADI UART4 driver selects and enables
earlycon support by default and will be available as an
early console option during boot.

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
When a channel gets unbound, rpmsg_dev_remove() destroys the endpoint
and frees the IDR slot, but forgets to reset rpdev->src back to
RPMSG_ADDR_ANY. So the next time the channel gets bound,
rpmsg_dev_probe() passes the old stale address as a specific IDR
request. If another channel snached that address in the meantime,
idr_alloc() fails with -ENOSPC (-28) and probe blows up with:

  rpmsg_chrdev: idr_alloc failed: -28
  rpmsg_chrdev: failed to create endpoint
  rpmsg_chrdev: probe with driver rpmsg_chrdev failed with error -12

This makes the sucess of bind/unbind sequences order-dependent when
it really shouldn't be.

Fix: reset rpdev->src to RPMSG_ADDR_ANY after tearing down the endpoint,
but only for channels with dynamically-assigned addresses (!rpdev->announce).
Channels with a predefined local address need to keep their src so they
re-announce the same address on rebind.

Fixes: bbd1880 ("rpmsg: Support drivers without primary endpoint")
Signed-off-by: Vasileios Bimpikas <Vasileios.Bimpikas@analog.com>
Add device tree support for SC598 HTOL SBC based on the
reference board designs.

Signed-off-by: Ozan Durgut <ozan.durgut@analog.com>
MDMA writes to SHARC L2 memory (0x200xxxxx) are silently rejected at
the bus fabric level on ADSP-SC573 and ADSP-SC589. The MDMA engine
stalls waiting for a write ACK that never comes (DMA_STAT.RUN=4,
IRQERR=0), and the remoteproc driver times out.

Use memcpy_toio/memset_io with the L1 and L2 virtual mappings already
established in probe (L1_shared_base, L2_shared_base) instead of the
MDMA engine. This follows the same pattern as rproc_elf_load_segments()
in remoteproc_elf_loader.c which uses memcpy_toio when the target
region is IOMEM.

Remove the now-unused MDMA infrastructure: dmaengine_get/put,
dma_alloc_coherent bounce buffer, SPU permission setup for MDMA
channels, and the completion callback.

Tested on ADSP-SC589-MINI with a synthetic 128 KB L2 stress LDR image.

Signed-off-by: Vasileios Bimpikas <vasileios.bimpikas@analog.com>

if (!tx) {
dev_err(rproc_data->dev, "Failed to allocate dma transaction\n");
if (addr >= rproc_data->l1_da_range[0] &&
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

where this ranges comes from L2 only for vring's or L3. Firmware is loaded to L3

return -EINVAL;
}

void set_spu_securep_msec(u16 n, bool msec);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In comment section
'''
MDMA writes to SHARC L2 memory (0x200xxxxx) are silently rejected at the bus fabric level on ADSP-SC573 and ADSP-SC589. The MDMA engine stalls waiting for a write ACK that never comes (DMA_STAT.RUN=4, IRQERR=0), and the remoteproc driver times out.
''' does it means that SPU is enabled , when transaction is running and actually that error because SPU is enabled by other cores? And isn't this just suppressing error rather fixing underlying issue?

@pamolloy pamolloy added this to ADSP May 15, 2026
@pamolloy pamolloy changed the base branch from adsp-6.12.0-y to adsp-6.18.31-y May 21, 2026 12:46
@pamolloy
Copy link
Copy Markdown
Collaborator

@vasbimpikasadi Please rebase this on top of adsp-6.18.31-y 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

10 participants