Commit graph zephyr/subsys/ipc
Author SHA1 Message Date
Krzysztof Chruściński
f2c81bd2ea ipc: ipc_service: icbmsg: Fix potential maybe-uninitialized warning
off variable is always set in K_SPINLOCK block but still strict compiler
may complain about potential use of uninitilized variable.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-08-31 06:59:32 -04:00
Bjarki Arge Andreasen
5d4a6698f0 ipc: icbmsg: define stats_name if CONFIG_STATS
The stats_name used by CONFIG_STATS must be defined if stats are
registered. CONFIG_STATS_NAMES covers individual stats, not the stats
group, which must have a name.

Letting stats_name be initializing to NULL, the stats module will hit
a NULL dereference if either stats_group_find or stats_register is
called after icbmsg has registered itself.

The issue was not found since icbmsg is the only stats module
registering itself, thus stats_register() did not need to access the
stats_name to validate no duplicates are registered on the next
call to stats_register().

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-08-27 12:16:03 +01:00
Krzysztof Chruściński
c4b4a0e090 ipc: ipc_service: icbmsg: Fix case for nameless endpoint
If endpoint did not have any name then 0 was used for hash
which is the default value. Because of that service was
assuming that endpoints are bounded. Use value different
than 0.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-08-18 17:28:32 -04:00
Krzysztof Chruściński
edcaf73893 ipc: ipc_service: icbmsg: Rework backend
Major rework of the ICBMSG ipc service backend:

 1. User callback is called from the mbox interrupt context.
 Since RX holding functionality is supported it is possible to
 postpone data processing to the thread context and limit the
 time spent in the interrupt context to a minimum.

 2.Extracted buffer allocation into separate file (heap)
 Buffer can now be allocated from interrupt context as well.

 3.Changed control path.
 Instead of sending messages using icmsg, lightweight queue is used.
 Each direction has producer and consumer queue. Each queue has n
 (typically 16) byte slots. Producer is writing an index of the buffer
 where new message can be found into the next free slot. Receiver is
 reading from the producer queue and when buffer is processed then its
 index is written to the next free slot in the consumer queue.
 TX side, after each sending, is performing a garbage collection by
 reading slots from the consumer queue and freeing the buffer. With this
 approach producer queue is written only by the TX side and read by RX
 side and consumer queue is written by the RX side and read by the
 TX side. Additionally, queue supports 2 priority levels. Consumer is
 first reading high priority messages.

 Rework significantly reduces code size (2,5-4kB) and increases
 performance. It also allows to send messages from any context and
 reduced round trip time since receiver can respond directly from the
 receive callback.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Assisted-by: Cursor:auto
2026-08-08 16:31:53 -04:00
Krzysztof Chruściński
dc78cbe292 ipc: ipc_service: backends: icbmsg: Align to the API return values
Return values as states in the API contract:
- ipc_service_send_nocopy shall return number of bytes that were sent
- ipc_service_drop_tx_buffer returns -EALREADY if buffer is not
allocated.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-23 16:08:37 +02:00
Fangwei Que
d9b78cda6b ipc: rpmsg: make shmem reset init priority configurable
The RPMsg static vrings backend currently hard-codes the
shared memory reset SYS_INIT priority to 1.

Some platforms need this reset to run later within PRE_KERNEL_1
because the shared memory region depends on earlier platform
initialization. Add a dedicated Kconfig option so platforms can
override the priority without modifying the backend code.

The default value remains 1, so existing behavior is preserved.

Signed-off-by: Fangwei Que <15259288389@163.com>
2026-07-15 15:26:10 +02:00
Tomas Galbicka
b6fe144fb9 ipc: service: backends: add RPMSG-Lite backend
Add a new IPC service backend based on the RPMsg-Lite library.
The backend implements the ipc_service_backend ops (open, close,
register/deregister endpoint, send, send_nocopy, get/drop TX buffer,
hold/release RX buffer) on top of the RPMsg-Lite virtio transport.

A new DT binding (nxp,ipc-rpmsg-lite) is introduced to describe
each RPMsg-Lite link instance: shared memory region, role (host/remote),
link-id, MBOX channels, and per-instance buffer/priority tunables.
Multiple links share a single MBOX channel pair via the
notification-parent property; platform_notify() dispatches the
encoded vector_id to the correct link.

Signed-off-by: Tomas Galbicka <tomas.galbicka@nxp.com>
2026-07-01 05:20:27 -04:00
Michael Zimmermann
e10af22991 tree-wide: replace usages of k_work_q thread with thread_id
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-29 22:17:45 -04:00
Krzysztof Chruściński
04accb118e ipc: ipc_service: Remove new line from logs
Remove redundant new lines from logs in the ipc_service API file.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-06-24 07:39:22 -04:00
Anas Nashif
8104af619e typos: fix various typos under subsys/
Fix various typos.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Mike J. Chen
a09d9756e0 ipc: ipc_service: icbmsg: add close op
Implement the close operation for ipc_icbmsg

Signed-off-by: Mike J. Chen <mjchen@google.com>
Co-Authored-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2026-06-09 08:42:14 +02:00
Andre Heinemans
23e0f466c6 ipc: open-amp: Kconfig: move item closer to parent
Move OPENAMP_VENDOR_RSC_TABLE_FILE just below OPEN_AMP_VENDOR_RSC_TABLE
who it depends on. This improves identation in menuconfig for other
config items.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-06-01 12:05:54 +02:00
Andre Heinemans
276f587af4 ipc: open-amp: Kconfig: refactor dependencies
The menu items that are depending on OPENAMP_RSC_TABLE are bundled
within an if-statement. The 'depends on' fields are therefore not
required anymore.
OPENAMP_VRING_ALIGNMENT mistakenly did not have the 'depends on' and is
added to the if-statement as well. This fixes identation in the menu.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-06-01 12:05:54 +02:00
Nicholas Lowell
9369f96a6c ipc: open-amp: make vring alignment configurable
allow for configurable vring alignment for better system
flexibility instead of hard-coded 16 byte alignment
which could be unacceptable for cache-managed systems of different
cache-line sizes

Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
2026-04-14 22:28:37 -04:00
Krzysztof Chruściński
99336e5d24 ipc: ipc_service: icbmsg: Return error on too early open
If open is called before the backend is initilize then bounding
will stuck as works scheduled to the workqueue in the open function
are never executed. Return error if open is called too early, before
device initialization.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-03-20 20:43:13 +09:00
Ayush Singh
5e2e40f64c boards: beagleboard: pocketbeagle_2: m4: Add rpmsg uart
- Add rpmsg uart in dt.
- Not enabling it by default yet.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-03-16 18:58:35 -05:00
Ayush Singh
4979d81f75 ipc: rpmsg_service: Add openamp resource table support
Use resource table when CONFIG_OPENAMP_RSC_TABLE is enabled.

Tested with PocketBeagle 2 (M4 core running Zephyr)

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-03-16 18:58:35 -05:00
Erdem Simsek
a71a9fd9d1 ipc_service: icmsg: Update state information before bound request
Set state before bound callback. The callback may trigger
icmsg_send which requires CONNECTED state.

Signed-off-by: Erdem Simsek <erdem.simsek@nordicsemi.no>
2026-03-16 10:08:08 -04:00
Pete Johanson
dbe1e63d36 ipc: Move to barrier_sync_synchronize()
Move the IPC subsystem to the new barrier_sync_synchronize()
wrapper API.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-02-25 18:47:53 +01:00
Chaitanya Tata
7f6d361473 nrf_wifi: Remove nRF71 support
The driver and module now supports nRF70 only, nRF71 support will be
added in the future using a new driver.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2026-02-09 11:59:17 -06:00
Jamie McCrae
13bcf52b29 soc: arm: mps2: Fix SoC Kconfig naming
Fixes the Kconfig name of this so that it matches the value from
soc.yml, this has not been deprecated because this SoC is a virtual
SoC used only with the boards in zephyr meaning it should not cause
any breakage of out-of-tree boards

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 13:20:45 +00:00
Jamie McCrae
bf5460b661 soc: arm: musca: Fix SoC Kconfig naming
Fixes the Kconfig name of this so that it matches the value from
soc.yml, this has not been deprecated because this SoC is a virtual
SoC used only with the 2 boards in zephyr meaning it should not
cause any breakage of out-of-tree boards

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 13:20:45 +00:00
Gaetan Perrot
bb214df802 ipc: ipc_service: ipc_static_vrings: make vq_teardown void
vq_teardown() never reports errors and always returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-16 11:39:51 +00:00
Tomasz Leman
5fae86c69c intel_adsp: document host IPC backend data model and send hook
This patch refreshes the documentation in the Intel Audio DSP host IPC
service backend to match the current data model and backend API
contracts.

The updated comments clarify that ipc_ept_cfg::priv must point to
intel_adsp_ipc_ept_priv_data so that the backend can carry state between
the ISR and the application callbacks. They also describe that both the
send and receive paths operate on a fixed two-word uint32_t IPC payload
(header and extended payload) rather than a generic byte buffer, and
that len must always be sizeof(uint32_t) * 2.

The documentation for intel_adsp_ipc_send() is rewritten to explain the
expected payload format, the length and NULL checks performed by the
backend, and how the function programs the IPC registers while relying
on ipc_send_message() for BUSY and TX acknowledgment handling. The
parameter semantics and error returns are aligned with the generic
ipc_service send() hook contract to make the backend behaviour easier to
understand and reuse.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2026-01-09 14:21:41 -06:00
Tomasz Leman
15fa6a374e ipc: intel_adsp: simplify host IPC service backend
Rework the Intel Audio DSP host IPC service backend to use the generic
ipc_service data/len conventions and the new critical send and buffer
management APIs.

Replace the backend-specific intel_adsp_ipc_msg and related enums with a
simple two-word payload passed through the standard ipc_service_send()
and ipc_service_send_critical() interfaces, and adapt the ISR and
receive callback to operate on this representation.

Use ipc_service_get_tx_buffer_size() as a readiness check for the host
channel and provide hold_rx_buffer() / release_rx_buffer()
implementations so ipc_service_release_rx_buffer() can be used to signal
when the channel becomes available again.

Wire the emergency send path through send_critical() to route urgent
messages via the backend's emergency fast path while keeping the normal
IPC flow unchanged.

Move the synchronous IPC wait logic out of the Intel Audio DSP host IPC
backend and into the common intel_adsp_ipc helper used by tests.

Update intel_adsp_ipc_send_message_sync() to both send the IPC message
through ipc_service_send() and wait on the backend semaphore, and remove
the now redundant ipc_send_message_sync() helper from the host IPC
backend.

Document that intel_adsp_ipc_send_message_sync() is a test-only helper,
not used by SOF firmware, and that it is a candidate for future removal
or for replacement by an explicit synchronous send primitive in the
generic IPC service API or in application code.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2026-01-09 14:21:41 -06:00
Tomasz Leman
4cf753bfb2 ipc_service: Add ipc_service_send_critical function
Add ipc_service_send_critical() as a dedicated API for sending critical
high-priority messages over an IPC endpoint.

Introduce an optional send_critical() callback in struct
ipc_service_backend so backends can implement a special fast path that
bypasses normal state and busy checks for critical notifications such as
crash reports or fatal errors.

The ipc_service_send_critical() wrapper mirrors ipc_service_send() on
the service side and delegates the actual behavior to the
backend-specific send_critical() implementation.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2026-01-09 14:21:41 -06:00
Dmitrii Sharshakov
8f4f1fa5fa ipc: icmsg: fix unbound for POSIX
Make sure unbound works on nrf5340bsim.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-12-08 15:02:29 -05:00
Tomasz Leman
45bfe066c7 ipc: intel_adsp_host_ipc: clear tx_ack_pending on PM resume
Fix IPC driver becoming non-operational after power management resume
due to stale tx_ack_pending state from before suspend.

After the IPC service backend refactor (commit cf7e2e63c1), the
intel_adsp_ipc_data structure contains function pointers for
suspend/resume handlers. This prevents using `memset` to clear the
entire structure during initialization, which was previously done in
intel_adsp_ipc_init.

Without clearing tx_ack_pending on resume, if the device enters D3 state
while still waiting for an IPC acknowledgment (e.g., from a previous
test iteration), the driver remains stuck in the waiting state after
resume. This prevents sending any new IPC messages, including the
FW_READY notification after D3 exit.

The fix explicitly clears tx_ack_pending during PM_DEVICE_ACTION_RESUME
to ensure the driver starts in a clean operational state after resume,
regardless of the state before suspend.

Fixes regression introduced in commit cf7e2e63c1

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2025-10-29 20:18:41 +02:00
Chaitanya Tata
05899583fd ipc: icmsg: Increase default stack size
For nRF71 Wi-Fi a higher stack size is needed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-10-29 13:48:33 +02:00
Daniel Leung
cf7e2e63c1 soc: intel_adsp: rework host IPC using IPC service
This reworks the Intel audio DSP host IPC driver as a backend of
the IPC service. This is the first step to rework IPC in SOF
(Sound Open Firmware) into using a more generic IPC API instead
of a SoC specific one.

For now, it keeps the old interface to maintain usability
as it is going to be a multiple process to rework IPC
over there.

Also, the structure of the new IPC backend resembles
the SoC specific driver to make it easier to compare
between them at this first iteration. Future optimizations
will probably be needed once we start modifying the SOF
side to utilize the IPC interface.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-09-29 12:42:00 -04:00
Iuliana Prodan
a795046143 ipc: move Open AMP from lib/ to subsys/ipc/
Moved the Open AMP code from lib/ to subsys/ipc/ to better
organize IPC-related components.

Updated build and config files to reflect the new location.

Adjusted path in MAINTAINERS.yml.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2025-09-26 13:22:55 +02:00
Gaetan Perrot
dd180c2789 ipc_service: ipc_icbmsg: fix unchecked error in icmsg_open()
Coverity (CID 516253) reported that the return value of
initialize_tx_with_sid_disabled() was set but not used, leading to
potential silent failures.

Check if the return value is negative and propagate the error through the
existing cleanup path.

Fixes: CID 516253

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-11 13:15:04 -10:00
Pisit Sawangvonganan
0ec49fa570 kconfig: fix typo in (soc, subsys)
Utilize a code spell-checking tool to scan for and correct spelling errors
in `Kconfig` files within the `soc` and `subsys` directory.
Additionally, incorporates a fix recommended by the reviewer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-07-01 10:58:54 -10:00
Adam Kondraciuk
31689690c9 ipc: ipc_service: Parametrize workqueue stack size
Add `IPC_SERVICE_BACKEND_ICBMSG_EP_BOUND_WORK_Q_STACK_SIZE` config
and parametrize its value depending on the optimization level.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2025-06-11 10:09:02 -07:00
Adrien Ricciardi
2f17465421 ipc: icbmsg: Add a workqueue name
This allows to easily identify the workqueue thread when using the kernel
shell commands.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2025-06-04 16:59:04 +02:00
Radosław Koppel
26e3e82e60 ipc_service: ipc_icbmsg: Update backend API return values
Update release_rx_buffer return value to match API documentation.
Cleanup register_ept workflow - remove unused variable.

Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
2025-03-28 12:21:30 +01:00
Dominik Kilian
84a215aff8 ipc_service: icmsg: Add "unbound" functionality
In some cases, CPUs that may need to reset or
temporary stop communication. This commit adds "unbound"
functionality that provides a callback to IPC service user
when connection was interrupted for some reason, e.g.
expected or unexpected CPU reset, closing the
endpoint. The "unbound" callback is optional to implement
by endpoints. This commit implements it in the ICMsg
backend.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2025-02-14 13:34:49 +01:00
Timothy Keys
614f55f8be ipc: ipc_service: Null terminate RPMsg endpoint names
This fixes the compiler warning -Wstringop-truncation in
version 13 of gcc.

Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
2025-01-22 10:40:27 +01:00
Daniel Mangum
2ca82ea6c4 ipc: pbuf: fix idx_occupied comment
Fix typos in the comment on the idx_occupied function.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2025-01-16 22:38:26 +01:00
Dominik Kilian
81bb231fd0 ipc: icbmsg: Reduce block alignment to 32-bits
The ICBMsg backend divides its memory into
blocks. Each block is aligned to data cache
alignment. Is it not required, since adjacent
blocks has the same data flow direction (either
read-only or write-only). This commit changes
it to 32-bits making wasted memory significantly
reduced.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2024-11-22 08:26:22 -05:00
Alberto Escolar Piedras
a5e3a33b39 ipc: icmsg & icbmsg: Fix alloc_tx_buffer() doxygen description
The return values were not correct, and the parameters descriptions
were not too easy to understand.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-10-24 13:15:35 +01:00
Dominik Kilian
cbaafe209c boards: nordic: ipc: added dcache alignement
The nRF54 and nRF92 chips has data cache, which means
the ICMsg and ICBMsg must be configured to follow required
cache alignment of the shared memory.
The `dcache-alignement` needs to be defined for that.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2024-10-24 03:45:35 +01:00
Piotr Koziar
51e0130a74 ipc: icmsg: increase stack size of RX work queue thread
Increases default size of stack used by work queue RX thread
from 1024 to 1280 to avoid memory issues.

After adding the buffer with the default size of 128
that is allocated on the thread's stack (see #77552),
there is too little stack left during heavy stress.

Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
2024-10-22 20:40:57 +02:00
Dominik Kilian
131229b2c4 icbmsg: Allow deregistration of the endpoints
This is implementation of ICBMsg endpoint deregistration.
The underlying ICMsg instance and blocks are not affected by
deregistration, so it is possible to reuse the same address
during the re-registration of the same endpoint.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2024-10-21 18:43:22 -05:00
Alberto Escolar Piedras
ca26820ac1 ipc: icmsg: Check return error of pbuf_rx_init()
When pbuf_rx_init() was added, this caller did not check for a possibly
returned error to not have more overhead than before using this
function.
Although unlikely let's check for a possible error (not configured Rx
pbuf cfg).

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-10-02 10:09:18 +02:00
Andrew Davis
df64d076d8 ipc: ipc_service: Inline libmetal_{setup,teardown}() for correct ordering
Currently metal_init() is called as part of libmetal_setup() which is
called after libmetal has already started being used (metal_io_init
called before). Same for metal_finish() but in reverse (metal_io_finish
called after). To fix this inline the content of libmetal_{setup,teardown}
into their one call-sites and move the init/finish calls to the correct
spot before/after all uses of the lib.

Signed-off-by: Andrew Davis <afd@ti.com>
2024-10-02 10:04:59 +02:00
Andrew Davis
be4a4ee324 ipc: ipc_service: Remove intermediate metal generic device
A libmetal "generic" device is created, then opened and used for its IO
regions. Since we are adding these IO regions in the first place there
is no reason for this layer of indirection.

Signed-off-by: Andrew Davis <afd@ti.com>
2024-10-02 10:04:59 +02:00
Andrew Davis
d58542fcc4 ipc: rpmsg_service: Remove virtual shared memory device
A virtual metal_device is created, next the needed IO regions are created
and added to this device. Immediately we extract these regions back out
and make use of them. There is no reason to create the metal_device and
add the IO regions to it, instead simply use the IO regions directly.

This is similar to what was already done to the openamp_rsc_table sample.

Signed-off-by: Andrew Davis <afd@ti.com>
2024-10-02 10:04:59 +02:00
Alberto Escolar Piedras
b5b91b3edb ipc: icmsg & icbmsg: Add support for POSIX arch targets
Add support in this IPC backends for POSIX arch targets in general,
and ensure the nrf5340bsim defines the buffer which will be used.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-26 03:34:26 -04:00
Alberto Escolar Piedras
5dc810e261 ipc: pbuf: Provide function for Rx side initialization
Provide a new function for initializing the Rx side,
so users do not need to initialize the pointers by hand
if they did not use PBUF_DEFINE().

Let's also rename pbuf_init() to pbuf_tx_init() to clearly
signify the previous function was only meant to be used
by the Tx side.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-26 03:34:26 -04:00