[BACKPORT] wqueue: support custom user queues and harden queue lifecycle - #415
Open
13022591351 wants to merge 5 commits into
Open
13022591351 wants to merge 5 commits into
13022591351 wants to merge 5 commits into
Conversation
…heap. up_allocate_heap() calculates the available user heap from SRAM_END but previously placed the aligned region relative to SRAM123_END. That mixes the selected primary SRAM with a fixed D2 SRAM boundary and leaves SRAM123_END undefined for dual-core M7 and M4 configurations. Place the user heap relative to SRAM_END so its size, MPU alignment, and location all refer to the SRAM region selected by the chip configuration. Tested by building and booting a Protected image on an STM32H7 PX4 FMUv6C. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com> (cherry picked from commit b1a4d85)
The generic ARMv7-M user SRAM helper marks memory shareable. STM32H7 Protected user data and heaps can reside in cacheable AXI or D2 SRAM, where userspace synchronization needs LDREX/STREX to use the CPU-local exclusive monitor. Map protected user SRAM as Normal, cacheable, and non-shareable. Dual-core RPTUN SRAM remains unaffected because it is mapped separately with explicit shareable attributes. Tested by booting a Protected image and running user and kernel work-queue stress tests on an STM32H7 PX4 FMUv6C. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com> (cherry picked from commit 519c9a4)
Prevent work_queue_free() from destroying predefined queues or freeing a custom queue from one of its own callbacks. Mark teardown under the queue lock, reject new submissions, return pending work to its owner, and wait for every worker before releasing queue resources. Clean up partially created worker pools, reject invalid delays, safely replace pending periodic work, and make synchronous cancellation wait for every concurrent callback using the same work structure. Tested on an STM32H7 PX4 FMUv6C with the matching ostest suite in Flat and Protected kernel builds. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com> (cherry picked from commit d2e01b9)
Factor the common queueing logic used by work_queue_wq() and work_queue_next_wq() into a private helper. Preserve existing timing semantics: regular work calculates its absolute expiration before taking the queue lock, while periodic work advances the previous expiration under the lock. This is a code deduplication change with no public API or behavior changes. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com> (cherry picked from commit 7e5d05f)
Implement the handle-based create, queue, priority, cancellation, and teardown APIs for CONFIG_LIBC_USRWORK. Custom queues use configurable pthread worker pools while the predefined USRWORK queue remains available. Match scheduler-backend delay, replacement, cancellation, and lifecycle semantics. Restrict the libc backend to task context because it uses blocking synchronization. Tested on an STM32H7 PX4 FMUv6C with ostest wqueue in Protected user space. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com> (cherry picked from commit ae5997e)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport five commits merged in Apache NuttX to
px4_firmware_nuttx-12.12.0+, providing the NuttX support needed for aseparate PX4 work-queue migration.
The upstream changes are from
apache/nuttx#19982 and
apache/nuttx#19983:
Each backport records the official merged Apache commit in its
cherry picked fromtrailer and preserves the original author and sign-off.Impact
cancellation, and teardown in
sched/wqueue.pools under
CONFIG_LIBC_USRWORK. The predefined ProtectedUSRWORKremains usable with pthread support disabled.
for user-space synchronization. The separately mapped shared RPTUN SRAM
is unaffected.
used from ISR context; libc user queue operations remain task-context only.
No PX4 application, board configuration, or nuttx-apps changes are included.
The PX4 adapter is a separate change; this backport does not introduce a
PX4-specific duplicate-submission policy into NuttX.
Backport notes
stack_addrimplementation. The later upstream static HPWORK/LPWORK stack support is
not present in this branch and is not pulled in as a dependency.
refactors. The functional commits already use
nxsem_wait()/-EINTRretry loops, so no downstream cancellation-code changes are needed.
source commits. For the lifecycle commit, the actual added and removed
source lines also match upstream;
git range-diffshows differences onlyin the existing stack-handling context described above.
Testing
Backport preparation checks:
git diff --check: passed.tools/checkpatch.shover all five commits: passed.The upstream series was tested on an STM32H7 PX4 FMUv6C with the ostest
work-queue suite in Flat, Protected kernel/user, and Protected without pthread
support; the upstream PRs contain the test records. Those results describe
the upstream validation, not a new hardware run of this backport. No
additional on-board test was performed while preparing this PR.