Repository navigation
zephyr: wrapper: Abort failing ll thread and release held resources - #11502
Draft
adityaganeshintel2k wants to merge 4 commits into
Draft
adityaganeshintel2k wants to merge 4 commits into
adityaganeshintel2k wants to merge 4 commits into
Conversation
DEBUG ONLY - not for upstream. Add COMP_GAIN_FAULT_INJECT (default y), COMP_GAIN_FAULT_INJECT_CORE (default 1) and COMP_GAIN_FAULT_INJECT_PERIODS (default 1000). When enabled, the GAIN module uses gain_process(), a wrapper around volume_process(). On gain instances whose IPC4 core_id equals COMP_GAIN_FAULT_INJECT_CORE, after COMP_GAIN_FAULT_INJECT_PERIODS process() calls (about 1 s at a 1 ms LL period) it logs a "FAULT INJECT" error and executes "ill", raising an Xtensa IllegalInstruction exception (EXCCAUSE 0) from the LL thread of that core. The core is taken from dev->ipc_config.core instead of being read from the CPU, so the check is valid in user-space LL threads. __builtin_trap() is not used because Xtensa GCC emits "break 1, 15" (a debug exception) for it. The PEAKVOL module keeps calling volume_process() directly and is not affected. The per-instance counter lives in struct vol_data, which is zero-allocated, so no shared global is touched from user space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er() k_sys_fatal_error_handler() calls xtensa_exception_is_user() on Xtensa builds with CONFIG_USERSPACE, but the declaration lives in Zephyr's arch-internal header xtensa_internal.h, which was not included. This breaks the build with -Werror=implicit-function-declaration. Include the header under the same CONFIG_XTENSA && CONFIG_USERSPACE guard as the caller. zephyr/arch/xtensa/include is already on the include path. This restores the include added by 1e8d83b on ag-userspace-handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Xtensa userspace builds, a CPU exception or a kernel oops raised by a user thread is the fault of that thread: return from k_sys_fatal_error_handler() so that z_fatal_error() aborts only the faulting thread instead of halting the whole DSP. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
In user-space LL builds zephyr_ll_run() keeps the per-core LL scheduler mutex locked while running the tasks. When a module faults in the LL thread, k_sys_fatal_error_handler() returns and z_fatal_error() aborts only that thread, but Zephyr does not release mutexes of aborted threads. The lock stays owned by the dead thread and the next user_ll_lock_sched() on that core pends forever. E.g. the IPC user thread triggering a pipeline stop blocks, and all further IPCs for that core time out with -EAGAIN in ipc_user_forward_cmd(). Add zephyr_ll_release_locks_of_current(), called from the fatal error handler while _current is still the faulting thread and owner of the lock. It looks the locks up in the kernel-only zephyr_ll_klocks[] copy, resets the shadow owner tracking and unlocks every recursion level, handing the lock over to the first waiter. Rescheduling is deferred until the exception returns. This only unblocks the waiters. The scheduler state is not repaired: the tasks run in the interrupted tick stay on the dead thread's temporary list and no further LL ticks happen on that core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ganesh, Aditya <aditya.ganesh@intel.com>
Collaborator
|
Can one of the admins verify this patch?
|
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.
This injects a exception in the process function of gain module when running on core 1. When the exception is raised it would kill the low latency thread that is running the process function every ms and would also release the shared resources between low latency thread and the ipc user thread attached to the same core