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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Set state before bound callback. The callback may trigger
icmsg_send which requires CONNECTED state.
Signed-off-by: Erdem Simsek <erdem.simsek@nordicsemi.no>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>