Skip to content

[FEATURE][Zephyr] replace mailbox.h with a IPC abstraction #9697

@kv2019i

Description

@kv2019i

Is your feature request related to a problem? Please describe.
Replace the SOF mailbox.h interface with a higher-level abstraction to send/receive IPCs from host, or some other higher level interface that can be moved to Zephyr.
Part of #5794

Currently each SOF platform needs to implement mailbox.h and memory.h. Mailbox.h implements following functions:

  • mailbox_sw_reg_write() and mailbox_sw_reg_write64()
  • mailbox_sw_reg_read() and mailbox_sw_reg_read64()
  • mailbox_sw_regs_write()

The common sof/lib/mailbox.h uses platform memory.h to additionally define:

  • mailbox_dspbox_*()
  • mailbox_hostbox_*()
  • mailbox_stream_*()

This is a hardware specific interface that needs to be implemented on SOF side. I.e. something we really want to move over to Zephyr, just like all other driver code.

Possible solutions / IPC driver abstraction
The mailbox.h interfaces are primarily used in SOF IPC code to send and receive messages to the host. Main users:

  • src/platform - platform files typically use this mailbox interfacea to send the initial FW_READY on boot
  • src/ipc3/handler.c - IPC3 implementation
  • src/ipc4/handler.c - IPC4 implementation
  • src/ipc/ipc-zephyr.c common IPC code
  • src/audio/copier - one specialized use (IPC4) to write position/delay data directly to a memory mapped register window
  • src/include/sof/debug/debug.h - one example (there are some more similar) of non-functional debug use (writing debug info to shared memory)
  • and a few other minor users

The primary user is still for IPC. So one option to remove this layer from SOF src/platform/ is to move everybody over to a common IPC driver interface. For Intel platforms, Zephyr now provides zephyr/soc/intel/intel_adsp/common/include/intel_adsp_ipc.h that essentially moves most of the platform functionality over to Zephyr. To make this more generally applicable, this interface would have to be extended to other vendors, and we'd need a solution how to tackle the extra memory-mapped I/O ops that are part of IPC4 (copier, telemetry, coredumps).

Early on Zephyr IPM (ipm.h) was considered for SOF IPC, but limitations were hit and IPM not used. Another look at the available interfaces is in order.

Possible solutions / Move mailbox abstraction to Zephyr

Details are open, but given simplicity of the interface, using available Zephyr tools (DT, sys_read/write() and perhaps device_mmio.h) to implement a c generic mailbox handler code should be doable.

References

See 2024 discussion in #9015 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ZephyrIssues only observed with Zephyr integratedenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions