Use riscv_plic_irq_set_pending() to trigger interrupts when
CONFIG_PLIC_SUPPORTS_SOFT_INTERRUPT is enabled.
Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
An ISO Synchronized Receiver stores PDUs received ahead of their event
in the lll->payload[][] sliding window until isr_rx_done() enqueues them
towards the Host. PDUs still held there when the BIG sync is terminated,
locally or by the remote, were never released: lll_sync_iso_flush() was
empty and ull_sync_iso_setup() clears the pointers on the next
synchronization. Each termination could leak ISO Rx buffers until too
few remained to receive, and reception was then skipped without
reporting lost SDUs.
Release the held PDUs in lll_sync_iso_flush(), which runs in LLL context
once the BIG sync event has been disabled, by enqueuing them marked as
NODE_RX_TYPE_RELEASE.
Tested with the BIS re-sync bsim test added in the next commit, which
fails without this change on nrf52_bsim and nrf5340bsim cpunet.
Tested on two nRF5340 Audio DKs, a broadcast sink following a source
that re-creates its BIG. Without this change both BISes lose most of
their SDUs after each re-sync. With it they are received at full rate.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
The USB backend copied each chunk into its single bounce buffer, then
blocked the tracing thread until the transfer completed. Nothing could
be drained from the tracing buffer while the bus was busy, so bursts
overflowed it.
Split the bounce buffer into two halves, keeping the same RAM, and let
the buffer pool provide the flow control: allocating blocks only while
both buffers are in flight, and each completion frees its buffer.
Disabling the endpoint completes any queued buffers with -ECONNABORTED,
which also frees them. The largest single transfer halves.
Streaming CTF over USB from an nRF52840 (measured on an NCS-based
tree), dropped events in a 60 s capture fell from 0.88% to 0.21%.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hayden Ball <hayden@playerdata.com>
Interrupt notifications are EP_INT_SIZE bytes long, but only the
type byte was appended with net_buf_add_u8() before buf->len was set
to the full size. Bytes 1-3 were never written: they only read as
zero because the buffer pool is static memory cleared at boot.
Setting buf->len directly also bypasses the net_buf tailroom check.
Append the notification with net_buf_add_le32(), which writes the
type into byte 0 and zeroes bytes 1-3, and check at build time that
this matches the interrupt endpoint size. The data sent to the host
is unchanged.
Signed-off-by: Firas Sammoura <fsammoura@google.com>
usbd_ep_buf_free() ends in udc_ep_buf_free(), which always returns 0,
so the error branch after freeing a completed OUT buffer is never
taken. Drop it and discard the return value explicitly. Do the same
for the other usbd_ep_buf_free() callers in this file, which already
ignore it, for consistency.
Signed-off-by: Firas Sammoura <fsammoura@google.com>
bulk_out_buf and the bulk_out_buf context field are never used: OUT
transfers are received directly into the handler's rx_ctx buffer.
Remove them, saving EP_BULK_SIZE bytes of RAM.
Signed-off-by: Firas Sammoura <fsammoura@google.com>
CONFIG_BT_CRYPTO, CONFIG_BT_GATT_CACHING and the Mesh crypto imply
CONFIG_MBEDTLS_AES_ROM_TABLES, but CONFIG_BT_HOST_CRYPTO, which
provides bt_encrypt_le(), does not. A Host without SMP has none of the
others, so its first AES operation generates the AES tables in RAM.
The generation also needs 512 bytes of stack in the calling thread.
Imply the ROM tables for the Host crypto as well when Mbed TLS is the
PSA Crypto provider, as the Mesh crypto does. For an image that uses
AES this trades 2096 bytes of flash for 8748 bytes of RAM on
qemu_cortex_m3. Images that do not use AES are unchanged.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
Explain that PSA Crypto functions taking keys should not be called
from within Secure Storage.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Change the wording from "potentially" to just plain insecure, and make
the Kconfig option `select NOT_SECURE`.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Previously, any entry that failed to be retrieved was allowed to
be overwritten.
Only allow to overwrite entries that are clearly corrupt in order to
better enforce PSA_STORAGE_FLAG_WRITE_ONCE.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
ZMS has an option to support 64-bit IDs.
It was previously assumed that ZMS IDs were always 32-bit.
Make the implementation work well with 64-bit ZMS IDs, only refusing
UIDs with caller ID bits set.
The checks are now always compiled in, not just debug asserts, and
they return an error.
The only backward-compatibility-breaking change is that now
CONFIG_ZMS_ID_64BIT gets enabled by default when 64-bit UIDs are in use.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
This adds the if block to enable support for Xtensa MPU inside
llext_copy_region() when userspace is enabled. This also
adds macro LLEXT_PAGE_SIZE to specify the MPU alignment.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
When sending an Echo Request failed, bt_l2cap_br_echo_req() kept its
identifier as the pending request, so every later Echo Request on that
connection returned -EBUSY. It also returned the buffer with the
signaling header, and possibly the L2CAP header, still pushed, although
the caller keeps the buffer on error. bt_l2cap_br_echo_rsp() had the
same buffer problem.
Clear the pending identifier and restore the buffer when sending fails,
and document that the caller gets the buffer back unchanged.
Tested with tests/bluetooth/host_l2cap_br_echo on native_sim.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Several Echo and connectionless callbacks can be registered, and all of
them receive the same buffer, so a callback that pulled data left the
ones after it with less or none. Restore the buffer after each
callback.
The next callback and the signaling loop then move the buffer's cursor
again, so the callback documentation now says the buffer is only valid
until the callback returns.
Tested with tests/bluetooth/host_l2cap_br_sig on native_sim.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
A signaling packet may carry several commands, but
l2cap_br_sig_handle() handed each command's handler the buffer up to
the end of the packet. Echo Request and Echo Response callbacks
therefore got any commands after the Echo as part of its data.
Limit the buffer to the command's own length while it is handled.
Tested with tests/bluetooth/host_l2cap_br_sig on native_sim.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
A recv() callback returning -EINPROGRESS takes over the reference to the
buffer and releases it with bt_l2cap_chan_recv_complete(). On basic mode
channels, and on retransmission, flow control and streaming mode
channels without alloc_buf(), bt_l2cap_br_recv() released that same
reference after the callback, so the buffer was freed while the
application still used it and released a second time on completion.
Give the receiver a reference of its own and drop it unless recv()
returns -EINPROGRESS, as RFCOMM does for its receivers.
Tested with tests/bluetooth/host_l2cap_br_recv on native_sim, with and
without CONFIG_BT_L2CAP_RET_FC.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
When a thread-specific data key is deleted via pthread_key_delete() while
threads that bound data to it are still alive, pthread_key_delete() drained
key_obj->key_data_l and called k_free(key_data) without removing
key_data->thread_data from the owning thread's key_list.
This left a dangling pointer in thread->key_list, causing:
1. Use-after-free on subsequent pthread_setspecific() calls by the thread.
2. Undefined destructor execution on thread exit, in violation of
POSIX IEEE 1003.1-2017 ("If pthread_key_delete() is called, no
destructor functions will be invoked by any subsequent thread exit
functions").
3. Linked-list corruption in sys_dlist_remove() on thread exit.
4. Kernel heap double-free in k_free() inside posix_thread_finalize().
Address this by:
- Storing a back-pointer to the owning struct posix_thread in
struct pthread_key_data.
- Populating key_data->thread in pthread_setspecific().
- In pthread_key_delete(), under pthread_key_lock, unlinking each
key_data->thread_data node from key_data->thread->key_list using
sys_slist_find_and_remove() before calling k_free().
- Updating posix_thread_finalize() to take entries off the thread's
key_list under pthread_key_lock and run destructors outside it, in up
to PTHREAD_DESTRUCTOR_ITERATIONS passes. Each pass visits the entries
present when it starts, so every key gets its destructor even when a
thread holds more keys than the iteration limit, and values set again
by a destructor are handled in the next pass.
- Adding regression tests for deleting a key bound to an active thread,
for a thread holding more keys than PTHREAD_DESTRUCTOR_ITERATIONS, and
for a destructor that keeps setting a value.
Fixes#120150
Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
Update comments in HID host implementation to reflect current behavior
after L2CAP signaling buffer allocation improvements.
Remove outdated comment explaining that `hid_close_handler()` runs on
the `bt_workq` to avoid deadlock when calling
`bt_l2cap_br_chan_disconnect()` from L2CAP callback. This workaround
is no longer necessary since L2CAP BR/EDR signaling now uses retry
mechanism instead of `K_FOREVER` for buffer allocation.
Clarify that `close_work` is used for:
- INTR channel connect timeout when CTRL is up but device never opens
INTR
- Closing the peer channel when one channel disconnects (normal
teardown path)
- Closing INTR channel when it establishes while CTRL is not connected
Update both the function comment in hid_host.c and the struct field
comment in hid_internal.h for consistency.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add a new Kconfig option `BT_L2CAP_SIG_TX_BUF_COUNT` to allow
independent configuration of L2CAP BR/EDR signaling channel TX buffer
pool size, separate from the connection count.
Previously, the signaling buffer pool size was fixed to
`CONFIG_BT_MAX_CONN`, which could lead to buffer exhaustion under
certain conditions. This change allows tuning the signaling buffer
pool independently to better handle memory pressure scenarios.
The new option defaults to `BT_L2CAP_TX_BUF_COUNT` and valid range
is 1 to 255 buffers.
Update `br_sig_pool` definition to use the new configuration option
instead of `CONFIG_BT_MAX_CONN`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Previously, a thread running on the `bt_workq` can deadlock while
waiting for a `br_sig_pool` buffer using `K_FOREVER`, because the
allocated buffer can only be released when it has been sent. For
instance, when `bt_l2cap_br_chan_del()` executes a channel's
`disconnected()` callback, `l2cap_br_disconn_req()` is already holding
the buffer for the `DISCONN_REQ` if the callback invokes
`bt_l2cap_br_chan_disconnect()` for another channel, the nested call
waits indefinitely for a buffer that cannot be released until the
outer call completes sending its response.
Add a retry mechanism to handle buffer allocation failures in L2CAP
BR/EDR signaling channel. When buffer allocation fails, the operation
is deferred and retried after a random interval to prevent unbounded
blocking of `bt_workq` and improve reliability.
Add `retry_work` delayed work to handle deferred operations. Implement
`l2cap_br_retry_handler()` to process pending operations.
Introduce `allocated_buf` to pre-allocate buffer for the response or
request.
Add flags to track pending retry operations, including `CONN_RSP`,
`CONFIG_REQ`, `CONFIG_REQ_RETRY`, `DISCONNECT_REQ`, `INFO_REQ`. Add
`BUILD_ASSERT` to verify L2CAP flags fit within available bitmap.
Modify signaling functions calling by the function
`l2cap_br_sig_handle()` to use pre-allocated buffer when the function
`l2cap_br_is_tx_buf_required` returns `true` value. Add `recv_pending`
buffer to handle incomplete L2CAP packets and schedule retries on
allocation failure in function `l2cap_br_recv()`.
Modify `l2cap_br_recv()` to queue incoming packets when a previous
packet is still being processed. Allocate from the memory slabs
`br_recv_pending_pool` and append to the pending queue.
Update `l2cap_br_retry_signaling_handler()` to process the current
pending buffer and automatically load the next queued buffer when
processing completes via `l2cap_br_recv_pending_done()`.
Add `l2cap_br_drop_recv_pending_bufs()` to properly clean up all
queued pending buffers. Ensure proper cleanup of allocated buffer,
free allocated memory slabs, and retry work on channel disconnect.
Also update the doxygen comments of the functions
`bt_l2cap_br_chan_connect()` and `bt_l2cap_br_chan_disconnect()`.
The changes are intended to shift the allocation strategy from a
blocking approach to a non-blocking one. When no buffer is available,
the request is deferred and retried later (e.g., after a short random
delay or when a buffer is returned to the pool). Consequently, a
return value of 0 from `bt_l2cap_br_chan_connect()` or
`bt_l2cap_br_chan_disconnect()` now indicates that the connection or
disconnection process has been initiated, rather than that the request
PDU has been sent. The trade-off-choosing between a deadlock and
dropping the request is intentional.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Directory block removal indexed i_block[] by logical block number, which
corrupts indirect directories. Root lookup leaves parent NULL, so renaming
the mount point crashed. Also reject out-of-range inode and group numbers,
cap inode bitmap walks to one block, and compute disk addresses in 64-bit
arithmetic.
Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
fs_mount() compared mp->fs_data against every mounted entry only after
"if (len != itr->mountp_len) continue;", so two mount points sharing one
private state struct were accepted whenever their mount point strings
differed in length, leaving two mount entries driving one file system
state. Move the comparison ahead of that short circuit, which is only a
precondition for the strncmp() below it, and skip it when the incoming
fs_data is NULL, since ext2 and other file systems that allocate their
state while mounting legitimately arrive here with NULL. Use a plain if
rather than CHECKIF so the guard survives CONFIG_NO_RUNTIME_CHECKS. Also
stop littlefs from clearing fs->backend on its mount failure path, which
corrupted the live instance owning it, and give each mount point in
test_multi_fs its own private data instead of sharing one instance.
Reject a NULL fs_data in littlefs_mount(); littlefs does not allocate that
instance itself.
Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
BT_DEV_INQUIRY stays set while remote names are being resolved, but the
controller has already reported Inquiry Complete by then, and the Host
is only told to issue Inquiry Cancel before that event (Core
Specification 6.3, Vol 4, Part E, Section 7.1.2). If the controller
fails the cancel then, bt_br_discovery_stop() returns that error with
the flag still set and the name resolution still running, and
bt_br_discovery_start() keeps returning -EALREADY until the last name
request completes.
Only send Inquiry Cancel when no remote name request is outstanding. A
name is requested from report_discovery_results(), which runs on the
Inquiry Complete event, so a result in RESOLVE_REMOTE_NAME_RESOLVING is
itself the record that the inquiry has finished.
The inquiry can also complete while the cancel is in flight. When that
completion starts no name request it clears the flag, and a failure
with the flag already clear is the stop that has just happened, not an
error to report. When it starts one the flag stays set until the last
name request completes, so the failure is returned and the caller can
stop again, which then skips the cancel and tears down.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
bt_rfcomm_dlc_connect() arms the RTX timer in rfcomm_dlc_init(), but its
failure path clears dlc->session without cancelling the timer. When
bt_l2cap_chan_connect() or rfcomm_dlc_start() fails, the timeout handler
therefore fires RFCOMM_CONN_TIMEOUT later on a DLC that was already torn
down, with no interleaving needed.
Cancel the timer on that path.
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
Assisted-by: Kiro:claude-opus-5
rfcomm_dlc_rtx_timeout() dereferences dlc->session, which is cleared in
rfcomm_dlc_destroy(). Destroy normally runs on bt_workq, where the cancel
there wins over the RTX work, but bt_rfcomm_dlc_disconnect() reaches
destroy from the caller's thread while the DLC is in INIT or
SECURITY_PENDING, and rfcomm.c takes no lock. The handler can therefore
still observe a torn down DLC and fault on the first dereference.
Return early in that case. This narrows the window rather than closing
it: a synchronous cancel would close it, but it is undefined here because
destroy is reachable from the handler itself.
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
Assisted-by: Kiro:claude-opus-5
conn_internal.h still declares functions whose definitions are gone,
and nothing in the tree refers to them. Remove the declarations, the
bt_conn_create_frag() macros and their comments.
bt_conn_disconnect_all() was removed by
commit 6eef6cd946 ("Bluetooth: host: Rethink how unpair all works"),
bt_conn_send_cb() and bt_conn_send_iso_cb() by
commit 28535fe2f2 ("Bluetooth: host: Change TX pattern (push -> pull)")
and bt_conn_create_frag_timeout() and its debug variant by
commit 1c8cae30a8 ("Bluetooth: host: Introduce "view" buffer concept").
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
When an attribute write failed during an Execute Write the server sent
an Error Response but kept walking the prepare queue. The next handle
was still written, and because the loop reassigns err, a later success
also produced an Execute Write Response, leaving two responses for one
request. Clear the queue and stop at the first failing handle, as Core
v6.3 Vol 3 Part F 3.4.6.3 requires.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
An Execute Write Request with the flags parameter set to 0x00 asks the
server to drop everything the client has queued. The server instead ran
the same reassembly as a real execute, so a queue whose offsets are not
contiguous, or whose reassembled value is too long, answered the cancel
with an Error Response. Core v6.3 Vol 3 Part F 3.4.6.3 requires the
values to be discarded and an Execute Write Response to be sent.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
The address otherwise gets the default netmask, so a peer assigned
address ending in .255 becomes the subnet broadcast address and every
TCP segment sent to it is dropped. A point-to-point link has no subnet,
so use /32. Outgoing interface selection by subnet match no longer picks
the link for peers in the former /24, such traffic follows the routing
table or the default interface instead.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The broadcast check ORs the inverted netmask into each interface
address. With a /32 netmask every address therefore matches itself and
with /31 the odd address of the pair does, so TCP segments to such
addresses are dropped as broadcast. These prefixes have no broadcast
address (RFC 3021), skip them.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
tcp_in() parsed the options of every received segment straight into
recv_options, and tcp_options_check() starts by clearing mss_found,
wnd_found and sack_perm_found. Any segment with options after the
handshake therefore dropped the negotiated MSS and conn_mss() fell back
to 536 bytes for the rest of the connection, shrinking the segment size,
the congestion window and the window thresholds derived from it. With
SACK enabled a peer sends ACKs with SACK blocks after the first loss, so
this hit every long-lived connection that saw a loss event.
Validate the option list of every segment as before, but store MSS,
window scale and SACK permitted only from segments with SYN set, which
are the only ones that may carry them.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
bt_id_delete() and bt_id_reset() are documented to disconnect any
connection created using the identity, but they only call bt_unpair(),
which disconnects the peers that have keys. A connection that never
paired stayed up with a handle that no longer refers to its identity.
Disconnect the established LE connections that use the handle after the
unpair step. As a bug fix of a stable API, this increments the bt_gap
API version to 1.1.2.
Two cases remain as before: a connection whose Connection Complete
event has been received but not processed yet is not found, and a
pairing in progress may still complete, and store keys for the handle,
before the link is down.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The `bt_conn_create_pdu_timeout()` function already prevents blocking
when called from `k_sys_work_q` thread by forcing the timeout to
`K_NO_WAIT`. However, it did not account for calls from `bt_workq`
thread, which will lead to a deadlock in the `bt_workq` thread if
the timeout is `K_FOREVER`, preventing the Bluetooth host stack from
functioning correctly. Consider a deadlock scenario:
In the function `l2cap_br_disconn_req()` runs on `bt_workq` and calls
`bt_l2cap_br_chan_del()`, which synchronously invokes
`ops->disconnected()`; if a profile initiates a l2cap channel connect
within this callback, `bt_l2cap_br_chan_connect()` is entered again
within the same `bt_workq` stack frame. At this point, if `br_sig_pool`
is exhausted, `bt_workq` becomes indefinitely blocked, causing all RX
processing to stall. In the worst-case scenario, it remains blocked
forever if there is only one net buffer in `br_sig_pool`.
Add `bt_is_work_thread()` helper function to check whether it is
executing in the `bt_workq` thread context.
Add the check to detect when running on `bt_workq` thread by
calling the helper `bt_is_work_thread()` while the timeout is set to
`K_FOREVER` in the function `bt_conn_create_pdu_timeout()` and force
`K_NO_WAIT` in that case as well.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
A service that supports HTTP/1 or HTTP/2 together with HTTP/3 opens two
listen sockets, a TCP one and a QUIC one, but the pollfd table reserved
only one slot per service. The extra listen sockets pushed the client
slots, and with few H3 stream slots the last client slot, past the end of
fds[].
Reserve two slots per service when HTTP/3 is enabled alongside HTTP/1 or
HTTP/2.
Fix the check for "All services failed" to behave again as it did before
HTTP/3 was introduced: Fail if not a single socket could be setup
successfully.
Extend the check at the end of http_server_init to cover both the HTTP/3
and the !HTTP/3 case to detect similar issues in the future. It now returns
-ENOMEM and closes all existing sockets for proper cleanup should the check
fail.
Fixes: d9c8ac48bf ("net: http: Add HTTP/3 support to the server")
Signed-off-by: Matthias Blankertz <matthias.blankertz@inovex.de>
pac_notify() returned 0 whatever pacs_gatt_notify() returned, so
notify_cb() cleared the changed flag after a failed notification. When
no ATT TX buffer is free, bt_gatt_notify_cb() fails with -ENOMEM and the
client never receives the changed PAC.
Return the error and retry on -ENOMEM, as HAS and VCP do, and on
-EAGAIN, which a change-unaware client gets, as MCS does. Retry a PAC
notification on -EBUSY too: pac_notify() returns it when a PAC read
holds the read buffer. Log any other error without a retry. Truncate a
value longer than the ATT MTU allows. Add a BabbleSim test.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Initialize struct net_sockaddr_storage to 0 before passing it to net_sad()
to avoid compiler warnings.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
The remote shell host formats cbprintf packages received from the
remote client without validation. Document that the host must trust
the remote client cores and describe the cases where print messages
access host memory.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
A system typically instantiates these backends more than once, for the
modem and for other UART peripherals, so a warning about a dropped
buffer or an aborted transmit does not say which UART it came from.
Prefix the warnings and errors in the three UART backends with the
device name, using the "%s: " form already used by modem_chat and
modem_stats. The name is read from backend->uart, as the modem_stats
buffer names in these files already do. The runtime PM messages in the
same files report the device name since commit 79861deac4 ("modem:
backends: Unify runtime PM log messages"), so this makes the rest of
them agree.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
The weak sys_trace_rtio_*_user() hooks have no prototypes, so an
out-of-tree implementation with the wrong signature links without any
diagnostic. Declare them next to the GPIO hooks, which are already
listed this way.
Assisted-by: claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
Updates callers of rtio_sqe_cancel to use the newer opaque handle
version which takes into account the generational allocation of SQEs.
The validation of cancel is now safe in that each SQE being cancelled
must belong to the pool in struct rtio the caller has access to and
knows about. It must also be the correct generation of the SQE so that
recycled or freed SQEs are not incorrectly dereferenced with undefined
behavior.
Adds a coccinelle semantic patch to update callers both in and outside
the tree.
A migration guide was updated to include information about the API
change and the usage of the spatch to help out of tree applications
update to the new call semantics. The spatch likely won't fix all
callers but could save some time.
Assisted-by: claude:claude-opus-5 coccinelle
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
Prior to this change it would be possible to incidentally cancel an
already completed SQE that then was recycled into a new operation simply
because no knowledge was kept if the SQE to be cancelled was the same
one we really wanted to cancel, only a pointer!
This is problematic for many reasons and could have easily lead to a
race or corrupted logic.
A bit field is kept to signal whether the SQE is currently free or
allocated alongside the generational count. Cancelling a free SQE is a
no-op. Cancelling a previous generation of SQE is a no-op.
A new I/O device API .cancel has been added which is used to signal
to the I/O device that some submission it may currently be working
or have queued should be best effort cancelled.
Several new tests verify the safety of the behavior
Assisted-by: claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
Move several members of the struct out to the containing struct
(iodev_sqe) such that the internal rtio_sqe can be viewed as const data.
In making the containing struct const a few usages of this needed
updating to access the receive buffer through the helper
(rtio_sqe_rx_buf) rather than directly through struct members.
Assisted-by: claude:claude-opus-5 coccinelle
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
socketpair.c and sockets_inet.c both define static
zsock_poll_prepare_ctx() and zsock_poll_update_ctx() with different
signatures, and sockets_service.c names its file scope state ctx, which
shadows every local ctx in the files compiled after it in a unity
build.
Rename the socketpair helpers to spair_poll_*() and the service state
to svc_ctx. The struct spair parameter of the two helpers becomes obj,
as a parameter named after its own tag violates rule 5.7 of the coding
guidelines. No functional change.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Several source files of the IP stack use the same names for their file
local objects and functions: six files have a mutex called lock,
ipv4_fragment.c and ipv6_fragment.c share the whole set of reassembly
helpers, and get_nbr(), iface_cb() and secret_key_id appear in more
than one file. This prevents compiling the stack as one translation
unit, as a unity build does.
Prefix the names with the file or the feature they belong to. No
functional change.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
iface_dynamic.h and net_shell_private.h have no include guard, so
compiling two shell source files as one translation unit redefines
struct net_shell_user_data and the interface completion helpers.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
net_private.h and 6lo_private.h have no include guard, so including
either of them twice in a translation unit redefines all of their
static inline functions. This happens as soon as several source files
of the IP stack are compiled as one translation unit.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Writing data directly into instruction memory with fs_read() may cause
an exception due to architectural limitations regarding instruction
memory access. Read the data into a temporary buffer first, then copy it
to instruction memory using arch_memcpy_to_instr().
Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
When a received frame's destination address has an FDB entry on the
port the frame arrived on, eth_bridge_fdb_forward_handler() cloned the
frame and queued it back out of that same port. The destination is on
the segment the frame came from, so the frame has already reached it;
sending it back duplicates it on that segment and can make the station
see its own traffic twice.
Keep counting the entry as a match, so that the frame is neither
flooded nor delivered elsewhere, but do not send it, as IEEE 802.1D
filtering requires. For a multicast address with entries on several
ports, the other ports still get the frame.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>