Skip to content

arch/arm/am67: Add rptun IPC with the Linux A53 (remoteproc/rpmsg) - #20183

Open
gemstonedevteam wants to merge 4 commits into
apache:masterfrom
t3gemstone:am67-pr-08
Open

gemstonedevteam wants to merge 4 commits into
apache:masterfrom
t3gemstone:am67-pr-08

Conversation

@gemstonedevteam

@gemstonedevteam gemstonedevteam commented Sep 18, 2026

Copy link
Copy Markdown

Four commits: the drivers/rptun resource-table sizing change, the AM67 rptun
lowerhalf, the RAT sliding window, an nxstyle fix to a file this PR touches, and
documentation.

Summary

  • Adds the rptun lowerhalf connecting the R5F to Linux remoteproc over NAVSS
    mailbox0_cluster3 (R5F TX on FIFO 0 → Linux GIC SPI 109; Linux TX on
    FIFO 1 → VIM IRQ 116).
  • The mailbox ISR is a strict top half: drain the FIFO, W1C the status, EOI.
    OpenAMP delivery is deferred to HPWORK, because the rpmsg rx stack takes
    mutexes and allocates, neither of which is legal in interrupt context.
  • The resource table publishes two vdevs (rpmsg and virtio-net) with all vring
    device addresses FW_RSC_ADDR_ANY: Linux remoteproc allocates each vring
    from the R5F DMA pool and writes the chosen address back before releasing
    the core; fixed addresses outside the pool are rejected.
  • drivers/rptun: rptun_do_start() installed the resource table with a
    hardcoded sizeof(struct rptun_rsc_s), truncating extended tables that
    carry more than the single rpmsg vdev. An optional get_rsc_size() op is
    added with an RPTUN_GET_RSC_SIZE macro that falls back to the old value,
    so drivers using the standard table are unaffected.
  • The RAT sliding window addresses a 32-bit R5F against a 64-bit peer: J722S
    maps DDR beyond the first 2 GB at 0x8_8000_0000, outside the R5F's
    addressable space, while Linux freely posts virtio buffers there. Region 0
    is dedicated as a 16 MB window at 0xFE000000, re-aimed per access, with
    the window range MPU-mapped Non-cacheable.
  • MPU: two Non-cacheable regions cover the shared IPC memory. The R5F is not
    hardware-coherent with the A53; with cacheable mappings NuttX reads stale
    DRIVER_OK/vring state and the handshake hangs.

Impact

  • Is new feature added? YES — rptun/rpmsg IPC for AM67.
  • Impact on user? NO — the drivers/rptun change is an optional op with a
    fallback to the previous behaviour; existing rptun drivers are unaffected.
  • Impact on build? NO.
  • Impact on hardware? YES — arch/arm/am67 and board t3-gem-o1.
  • Impact on documentation? YES — provided in this PR.
  • Impact on security? NO.
  • Impact on compatibility? NORPTUN_GET_RSC_SIZE falls back to
    sizeof(struct rptun_rsc_s) when a driver does not implement it.
  • Anything else? Per rule 1.7.9, the drivers/rptun sizing change and the AM67
    lowerhalf are bundled deliberately: the lowerhalf's extended two-vdev table
    is truncated without it, so neither is functional alone. This is not a
    breaking change.

Testing

Build Host(s): Pardus GNU/Linux 25 (Debian 13 base), x86_64, host gcc 14
Toolchain:     arm-none-eabi-gcc 14.2.1 20241119 (15:14.2.rel1-1)
Target:        arm / TI AM67 (J722S) Cortex-R5F, board t3-gem-o1:nsh
nuttx-apps:    5a7ab4200
Loaded on the main-domain R5F by Linux remoteproc; console on UART-MAIN1.

Testing logs before change: no IPC support on this arch.

The version string in the logs is from the tested build; the commits were
GPG-signed afterwards, which rewrites hashes. The code is unchanged.

Testing logs after change:

make distclean && ./tools/configure.sh t3-gem-o1:nsh && make -j
  -> nuttx ELF 587972 bytes, 0 compiler warnings

Console:
nsh> ls /dev/rptun
/dev/rptun:
 r5f
nsh> 
nsh> ls /dev/rptun
/dev/rptun:
 r5f
nsh>

Test plan result:
console_alive            PASS  prompt responsive
version                  PASS  NuttX version 0.0.0 488ed91bec Sep 10 2026 13:49:52 t3-gem-o1:nsh
procfs                   PASS  procfs readable
tasks                    PASS  3 task lines
rptun_node               PASS  /dev/rptun:  r5f
linux_remoteproc         PASS  remoteproc3 running, fw=j722s-main-r5f0_0-fw, vdevs=virtio1,virtio2
linux_rpmsg_channels     PASS  2 channel(s): virtio1.rpmsg_ctrl.0.0 virtio1.rpmsg_ns.53.53

PASS=7
make distclean && ./tools/configure.sh t3-gem-o1:nsh && make -j
  -> nuttx ELF 587972 bytes, 0 compiler warnings

Console:
nsh> ls /dev/rptun
/dev/rptun:
 r5f
nsh> 
nsh> ls /dev/rptun
/dev/rptun:
 r5f
nsh>

Test plan result:
console_alive            PASS  prompt responsive
version                  PASS  NuttX version 0.0.0 488ed91bec Sep 10 2026 13:49:52 t3-gem-o1:nsh
procfs                   PASS  procfs readable
tasks                    PASS  3 task lines
rptun_node               PASS  /dev/rptun:  r5f
linux_remoteproc         PASS  remoteproc3 running, fw=j722s-main-r5f0_0-fw, vdevs=virtio1,virtio2
linux_rpmsg_channels     PASS  2 channel(s): virtio1.rpmsg_ctrl.0.0 virtio1.rpmsg_ns.53.53

PASS=7

PR verification Self-Check

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation.
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

acassis
acassis previously approved these changes Sep 18, 2026
Connects the R5F to Linux remoteproc over the NAVSS mailbox.

The mailbox ISR only drains the FIFO and acknowledges; OpenAMP delivery is
deferred to HPWORK, because the rpmsg rx path takes mutexes and allocates.

The resource table publishes two vdevs, rpmsg and virtio-net, leaving every
vring address FW_RSC_ADDR_ANY: Linux allocates them from the R5F DMA pool and
rejects fixed addresses outside it.

Shared IPC memory is mapped Non-cacheable, since the R5F is not coherent with
the A53 and cached mappings leave NuttX reading stale vring state.

Also drops the duplicate arm_mpu.c from CHIP_CSRCS.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
J722S maps DDR above the first 2 GB at 0x8_8000_0000, out of reach of the
32-bit R5F, while a 64-bit Linux peer posts virtio buffers there.

Dedicates RAT region 0 as a 16 MB window at 0xFE000000.  am67_rat_map() re-aims
it and returns a pointer plus the bytes left before the edge, so callers can
split copies that straddle it.

The window is Non-cacheable, since it retargets at runtime and cached lines
would alias across physical blocks.  A mapping is valid only until the next
call; the sole user, vhost-net, is serialised on the netdev work thread.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
Record the rptun/rpmsg link to the Linux A53 in the board's Peripheral
Support list.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
The mailbox handler drained the FIFO without checking the message body.
That caused shutdown messages to be lost, hence being unable to start/stop
the R5 cores from the Linux side.

The additions allow checking messages for control and virtqueue types.
Shutdown messages fall to the control branch, which ACKs the shutdown
request and parks the core in WFI.

Virtqueues still work as intended; the only difference is that control
messages are now handled correctly.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: arm Issues related to ARM (32-bit) architecture Size: L The size of the change in this PR is large Board: arm labels Sep 19, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@gemstonedevteam
gemstonedevteam marked this pull request as ready for review September 19, 2026 07:08
@acassis

acassis commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@gemstonedevteam please rebase

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

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Documentation Improvements or additions to documentation Board: arm Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants